| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594 |
- function kee(t,e){for(var n=0;n<e.length;n++){const i=e[n];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in t)){const a=Object.getOwnPropertyDescriptor(i,r);a&&Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();var ly=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var KE={exports:{}},hg={};var l4;function Lee(){if(l4)return hg;l4=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(i,r,a){var s=null;if(a!==void 0&&(s=""+a),r.key!==void 0&&(s=""+r.key),"key"in r){a={};for(var o in r)o!=="key"&&(a[o]=r[o])}else a=r;return r=a.ref,{$$typeof:t,type:i,key:s,ref:r!==void 0?r:null,props:a}}return hg.Fragment=e,hg.jsx=n,hg.jsxs=n,hg}var c4;function Iee(){return c4||(c4=1,KE.exports=Lee()),KE.exports}var g=Iee(),YE={exports:{}},qt={};var u4;function Uee(){if(u4)return qt;u4=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),p=Symbol.iterator;function m(H){return H===null||typeof H!="object"?null:(H=p&&H[p]||H["@@iterator"],typeof H=="function"?H:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,v={};function x(H,Y,se){this.props=H,this.context=Y,this.refs=v,this.updater=se||_}x.prototype.isReactComponent={},x.prototype.setState=function(H,Y){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,Y,"setState")},x.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function M(){}M.prototype=x.prototype;function w(H,Y,se){this.props=H,this.context=Y,this.refs=v,this.updater=se||_}var E=w.prototype=new M;E.constructor=w,b(E,x.prototype),E.isPureReactComponent=!0;var T=Array.isArray;function P(){}var N={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function R(H,Y,se){var ue=se.ref;return{$$typeof:t,type:H,key:Y,ref:ue!==void 0?ue:null,props:se}}function O(H,Y){return R(H.type,Y,H.props)}function z(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function I(H){var Y={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(se){return Y[se]})}var G=/\/+/g;function L(H,Y){return typeof H=="object"&&H!==null&&H.key!=null?I(""+H.key):Y.toString(36)}function B(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(P,P):(H.status="pending",H.then(function(Y){H.status==="pending"&&(H.status="fulfilled",H.value=Y)},function(Y){H.status==="pending"&&(H.status="rejected",H.reason=Y)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function q(H,Y,se,ue,xe){var re=typeof H;(re==="undefined"||re==="boolean")&&(H=null);var ve=!1;if(H===null)ve=!0;else switch(re){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(H.$$typeof){case t:case e:ve=!0;break;case d:return ve=H._init,q(ve(H._payload),Y,se,ue,xe)}}if(ve)return xe=xe(H),ve=ue===""?"."+L(H,0):ue,T(xe)?(se="",ve!=null&&(se=ve.replace(G,"$&/")+"/"),q(xe,Y,se,"",function(we){return we})):xe!=null&&(z(xe)&&(xe=O(xe,se+(xe.key==null||H&&H.key===xe.key?"":(""+xe.key).replace(G,"$&/")+"/")+ve)),Y.push(xe)),1;ve=0;var Pe=ue===""?".":ue+":";if(T(H))for(var pe=0;pe<H.length;pe++)ue=H[pe],re=Pe+L(ue,pe),ve+=q(ue,Y,se,re,xe);else if(pe=m(H),typeof pe=="function")for(H=pe.call(H),pe=0;!(ue=H.next()).done;)ue=ue.value,re=Pe+L(ue,pe++),ve+=q(ue,Y,se,re,xe);else if(re==="object"){if(typeof H.then=="function")return q(B(H),Y,se,ue,xe);throw Y=String(H),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ve}function W(H,Y,se){if(H==null)return H;var ue=[],xe=0;return q(H,ue,"","",function(re){return Y.call(se,re,xe++)}),ue}function X(H){if(H._status===-1){var Y=H._result;Y=Y(),Y.then(function(se){(H._status===0||H._status===-1)&&(H._status=1,H._result=se)},function(se){(H._status===0||H._status===-1)&&(H._status=2,H._result=se)}),H._status===-1&&(H._status=0,H._result=Y)}if(H._status===1)return H._result.default;throw H._result}var Q=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},ie={map:W,forEach:function(H,Y,se){W(H,function(){Y.apply(this,arguments)},se)},count:function(H){var Y=0;return W(H,function(){Y++}),Y},toArray:function(H){return W(H,function(Y){return Y})||[]},only:function(H){if(!z(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return qt.Activity=f,qt.Children=ie,qt.Component=x,qt.Fragment=n,qt.Profiler=r,qt.PureComponent=w,qt.StrictMode=i,qt.Suspense=l,qt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,qt.__COMPILER_RUNTIME={__proto__:null,c:function(H){return N.H.useMemoCache(H)}},qt.cache=function(H){return function(){return H.apply(null,arguments)}},qt.cacheSignal=function(){return null},qt.cloneElement=function(H,Y,se){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ue=b({},H.props),xe=H.key;if(Y!=null)for(re in Y.key!==void 0&&(xe=""+Y.key),Y)!U.call(Y,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&Y.ref===void 0||(ue[re]=Y[re]);var re=arguments.length-2;if(re===1)ue.children=se;else if(1<re){for(var ve=Array(re),Pe=0;Pe<re;Pe++)ve[Pe]=arguments[Pe+2];ue.children=ve}return R(H.type,xe,ue)},qt.createContext=function(H){return H={$$typeof:s,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:a,_context:H},H},qt.createElement=function(H,Y,se){var ue,xe={},re=null;if(Y!=null)for(ue in Y.key!==void 0&&(re=""+Y.key),Y)U.call(Y,ue)&&ue!=="key"&&ue!=="__self"&&ue!=="__source"&&(xe[ue]=Y[ue]);var ve=arguments.length-2;if(ve===1)xe.children=se;else if(1<ve){for(var Pe=Array(ve),pe=0;pe<ve;pe++)Pe[pe]=arguments[pe+2];xe.children=Pe}if(H&&H.defaultProps)for(ue in ve=H.defaultProps,ve)xe[ue]===void 0&&(xe[ue]=ve[ue]);return R(H,re,xe)},qt.createRef=function(){return{current:null}},qt.forwardRef=function(H){return{$$typeof:o,render:H}},qt.isValidElement=z,qt.lazy=function(H){return{$$typeof:d,_payload:{_status:-1,_result:H},_init:X}},qt.memo=function(H,Y){return{$$typeof:c,type:H,compare:Y===void 0?null:Y}},qt.startTransition=function(H){var Y=N.T,se={};N.T=se;try{var ue=H(),xe=N.S;xe!==null&&xe(se,ue),typeof ue=="object"&&ue!==null&&typeof ue.then=="function"&&ue.then(P,Q)}catch(re){Q(re)}finally{Y!==null&&se.types!==null&&(Y.types=se.types),N.T=Y}},qt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},qt.use=function(H){return N.H.use(H)},qt.useActionState=function(H,Y,se){return N.H.useActionState(H,Y,se)},qt.useCallback=function(H,Y){return N.H.useCallback(H,Y)},qt.useContext=function(H){return N.H.useContext(H)},qt.useDebugValue=function(){},qt.useDeferredValue=function(H,Y){return N.H.useDeferredValue(H,Y)},qt.useEffect=function(H,Y){return N.H.useEffect(H,Y)},qt.useEffectEvent=function(H){return N.H.useEffectEvent(H)},qt.useId=function(){return N.H.useId()},qt.useImperativeHandle=function(H,Y,se){return N.H.useImperativeHandle(H,Y,se)},qt.useInsertionEffect=function(H,Y){return N.H.useInsertionEffect(H,Y)},qt.useLayoutEffect=function(H,Y){return N.H.useLayoutEffect(H,Y)},qt.useMemo=function(H,Y){return N.H.useMemo(H,Y)},qt.useOptimistic=function(H,Y){return N.H.useOptimistic(H,Y)},qt.useReducer=function(H,Y,se){return N.H.useReducer(H,Y,se)},qt.useRef=function(H){return N.H.useRef(H)},qt.useState=function(H){return N.H.useState(H)},qt.useSyncExternalStore=function(H,Y,se){return N.H.useSyncExternalStore(H,Y,se)},qt.useTransition=function(){return N.H.useTransition()},qt.version="19.2.0",qt}var d4;function tm(){return d4||(d4=1,YE.exports=Uee()),YE.exports}var A=tm();const li=qs(A),jee=kee({__proto__:null,default:li},[A]);var ZE={exports:{}},pg={},QE={exports:{}},JE={};var f4;function Fee(){return f4||(f4=1,(function(t){function e(q,W){var X=q.length;q.push(W);e:for(;0<X;){var Q=X-1>>>1,ie=q[Q];if(0<r(ie,W))q[Q]=W,q[X]=ie,X=Q;else break e}}function n(q){return q.length===0?null:q[0]}function i(q){if(q.length===0)return null;var W=q[0],X=q.pop();if(X!==W){q[0]=X;e:for(var Q=0,ie=q.length,H=ie>>>1;Q<H;){var Y=2*(Q+1)-1,se=q[Y],ue=Y+1,xe=q[ue];if(0>r(se,X))ue<ie&&0>r(xe,se)?(q[Q]=xe,q[ue]=X,Q=ue):(q[Q]=se,q[Y]=X,Q=Y);else if(ue<ie&&0>r(xe,X))q[Q]=xe,q[ue]=X,Q=ue;else break e}}return W}function r(q,W){var X=q.sortIndex-W.sortIndex;return X!==0?X:q.id-W.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var s=Date,o=s.now();t.unstable_now=function(){return s.now()-o}}var l=[],c=[],d=1,f=null,p=3,m=!1,_=!1,b=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function E(q){for(var W=n(c);W!==null;){if(W.callback===null)i(c);else if(W.startTime<=q)i(c),W.sortIndex=W.expirationTime,e(l,W);else break;W=n(c)}}function T(q){if(b=!1,E(q),!_)if(n(l)!==null)_=!0,P||(P=!0,I());else{var W=n(c);W!==null&&B(T,W.startTime-q)}}var P=!1,N=-1,U=5,R=-1;function O(){return v?!0:!(t.unstable_now()-R<U)}function z(){if(v=!1,P){var q=t.unstable_now();R=q;var W=!0;try{e:{_=!1,b&&(b=!1,M(N),N=-1),m=!0;var X=p;try{t:{for(E(q),f=n(l);f!==null&&!(f.expirationTime>q&&O());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,p=f.priorityLevel;var ie=Q(f.expirationTime<=q);if(q=t.unstable_now(),typeof ie=="function"){f.callback=ie,E(q),W=!0;break t}f===n(l)&&i(l),E(q)}else i(l);f=n(l)}if(f!==null)W=!0;else{var H=n(c);H!==null&&B(T,H.startTime-q),W=!1}}break e}finally{f=null,p=X,m=!1}W=void 0}}finally{W?I():P=!1}}}var I;if(typeof w=="function")I=function(){w(z)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,L=G.port2;G.port1.onmessage=z,I=function(){L.postMessage(null)}}else I=function(){x(z,0)};function B(q,W){N=x(function(){q(t.unstable_now())},W)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<q?Math.floor(1e3/q):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(q){switch(p){case 1:case 2:case 3:var W=3;break;default:W=p}var X=p;p=W;try{return q()}finally{p=X}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(q,W){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var X=p;p=q;try{return W()}finally{p=X}},t.unstable_scheduleCallback=function(q,W,X){var Q=t.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?Q+X:Q):X=Q,q){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=X+ie,q={id:d++,callback:W,priorityLevel:q,startTime:X,expirationTime:ie,sortIndex:-1},X>Q?(q.sortIndex=X,e(c,q),n(l)===null&&q===n(c)&&(b?(M(N),N=-1):b=!0,B(T,X-Q))):(q.sortIndex=ie,e(l,q),_||m||(_=!0,P||(P=!0,I()))),q},t.unstable_shouldYield=O,t.unstable_wrapCallback=function(q){var W=p;return function(){var X=p;p=W;try{return q.apply(this,arguments)}finally{p=X}}}})(JE)),JE}var h4;function zee(){return h4||(h4=1,QE.exports=Fee()),QE.exports}var eA={exports:{}},Gr={};var p4;function Bee(){if(p4)return Gr;p4=1;var t=tm();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+l+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var i={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");function a(l,c,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:f==null?null:""+f,children:l,containerInfo:c,implementation:d}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(l,c){if(l==="font")return"";if(typeof c=="string")return c==="use-credentials"?c:""}return Gr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Gr.createPortal=function(l,c){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)throw Error(e(299));return a(l,c,null,d)},Gr.flushSync=function(l){var c=s.T,d=i.p;try{if(s.T=null,i.p=2,l)return l()}finally{s.T=c,i.p=d,i.d.f()}},Gr.preconnect=function(l,c){typeof l=="string"&&(c?(c=c.crossOrigin,c=typeof c=="string"?c==="use-credentials"?c:"":void 0):c=null,i.d.C(l,c))},Gr.prefetchDNS=function(l){typeof l=="string"&&i.d.D(l)},Gr.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var d=c.as,f=o(d,c.crossOrigin),p=typeof c.integrity=="string"?c.integrity:void 0,m=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;d==="style"?i.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:f,integrity:p,fetchPriority:m}):d==="script"&&i.d.X(l,{crossOrigin:f,integrity:p,fetchPriority:m,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},Gr.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var d=o(c.as,c.crossOrigin);i.d.M(l,{crossOrigin:d,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0})}}else c==null&&i.d.M(l)},Gr.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var d=c.as,f=o(d,c.crossOrigin);i.d.L(l,d,{crossOrigin:f,integrity:typeof c.integrity=="string"?c.integrity:void 0,nonce:typeof c.nonce=="string"?c.nonce:void 0,type:typeof c.type=="string"?c.type:void 0,fetchPriority:typeof c.fetchPriority=="string"?c.fetchPriority:void 0,referrerPolicy:typeof c.referrerPolicy=="string"?c.referrerPolicy:void 0,imageSrcSet:typeof c.imageSrcSet=="string"?c.imageSrcSet:void 0,imageSizes:typeof c.imageSizes=="string"?c.imageSizes:void 0,media:typeof c.media=="string"?c.media:void 0})}},Gr.preloadModule=function(l,c){if(typeof l=="string")if(c){var d=o(c.as,c.crossOrigin);i.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:d,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else i.d.m(l)},Gr.requestFormReset=function(l){i.d.r(l)},Gr.unstable_batchedUpdates=function(l,c){return l(c)},Gr.useFormState=function(l,c,d){return s.H.useFormState(l,c,d)},Gr.useFormStatus=function(){return s.H.useHostTransitionStatus()},Gr.version="19.2.0",Gr}var m4;function r$(){if(m4)return eA.exports;m4=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),eA.exports=Bee(),eA.exports}var g4;function Hee(){if(g4)return pg;g4=1;var t=zee(),e=tm(),n=r$();function i(u){var h="https://react.dev/errors/"+u;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)h+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+u+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(u){return!(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)}function a(u){var h=u,y=u;if(u.alternate)for(;h.return;)h=h.return;else{u=h;do h=u,(h.flags&4098)!==0&&(y=h.return),u=h.return;while(u)}return h.tag===3?y:null}function s(u){if(u.tag===13){var h=u.memoizedState;if(h===null&&(u=u.alternate,u!==null&&(h=u.memoizedState)),h!==null)return h.dehydrated}return null}function o(u){if(u.tag===31){var h=u.memoizedState;if(h===null&&(u=u.alternate,u!==null&&(h=u.memoizedState)),h!==null)return h.dehydrated}return null}function l(u){if(a(u)!==u)throw Error(i(188))}function c(u){var h=u.alternate;if(!h){if(h=a(u),h===null)throw Error(i(188));return h!==u?null:u}for(var y=u,S=h;;){var C=y.return;if(C===null)break;var D=C.alternate;if(D===null){if(S=C.return,S!==null){y=S;continue}break}if(C.child===D.child){for(D=C.child;D;){if(D===y)return l(C),u;if(D===S)return l(C),h;D=D.sibling}throw Error(i(188))}if(y.return!==S.return)y=C,S=D;else{for(var V=!1,ne=C.child;ne;){if(ne===y){V=!0,y=C,S=D;break}if(ne===S){V=!0,S=C,y=D;break}ne=ne.sibling}if(!V){for(ne=D.child;ne;){if(ne===y){V=!0,y=D,S=C;break}if(ne===S){V=!0,S=D,y=C;break}ne=ne.sibling}if(!V)throw Error(i(189))}}if(y.alternate!==S)throw Error(i(190))}if(y.tag!==3)throw Error(i(188));return y.stateNode.current===y?u:h}function d(u){var h=u.tag;if(h===5||h===26||h===27||h===6)return u;for(u=u.child;u!==null;){if(h=d(u),h!==null)return h;u=u.sibling}return null}var f=Object.assign,p=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),w=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),O=Symbol.for("react.memo_cache_sentinel"),z=Symbol.iterator;function I(u){return u===null||typeof u!="object"?null:(u=z&&u[z]||u["@@iterator"],typeof u=="function"?u:null)}var G=Symbol.for("react.client.reference");function L(u){if(u==null)return null;if(typeof u=="function")return u.$$typeof===G?null:u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case b:return"Fragment";case x:return"Profiler";case v:return"StrictMode";case T:return"Suspense";case P:return"SuspenseList";case R:return"Activity"}if(typeof u=="object")switch(u.$$typeof){case _:return"Portal";case w:return u.displayName||"Context";case M:return(u._context.displayName||"Context")+".Consumer";case E:var h=u.render;return u=u.displayName,u||(u=h.displayName||h.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case N:return h=u.displayName||null,h!==null?h:L(u.type)||"Memo";case U:h=u._payload,u=u._init;try{return L(u(h))}catch{}}return null}var B=Array.isArray,q=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},Q=[],ie=-1;function H(u){return{current:u}}function Y(u){0>ie||(u.current=Q[ie],Q[ie]=null,ie--)}function se(u,h){ie++,Q[ie]=u.current,u.current=h}var ue=H(null),xe=H(null),re=H(null),ve=H(null);function Pe(u,h){switch(se(re,h),se(xe,u),se(ue,null),h.nodeType){case 9:case 11:u=(u=h.documentElement)&&(u=u.namespaceURI)?PU(u):0;break;default:if(u=h.tagName,h=h.namespaceURI)h=PU(h),u=DU(h,u);else switch(u){case"svg":u=1;break;case"math":u=2;break;default:u=0}}Y(ue),se(ue,u)}function pe(){Y(ue),Y(xe),Y(re)}function we(u){u.memoizedState!==null&&se(ve,u);var h=ue.current,y=DU(h,u.type);h!==y&&(se(xe,u),se(ue,y))}function ze(u){xe.current===u&&(Y(ue),Y(xe)),ve.current===u&&(Y(ve),cg._currentValue=X)}var ce,ft;function F(u){if(ce===void 0)try{throw Error()}catch(y){var h=y.stack.trim().match(/\n( *(at )?)/);ce=h&&h[1]||"",ft=-1<y.stack.indexOf(`
- at`)?" (<anonymous>)":-1<y.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ce+u+ft}var $=!1;function ae(u,h){if(!u||$)return"";$=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(h){var st=function(){throw Error()};if(Object.defineProperty(st.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(st,[])}catch(Ke){var Ve=Ke}Reflect.construct(u,[],st)}else{try{st.call()}catch(Ke){Ve=Ke}u.call(st.prototype)}}else{try{throw Error()}catch(Ke){Ve=Ke}(st=u())&&typeof st.catch=="function"&&st.catch(function(){})}}catch(Ke){if(Ke&&Ve&&typeof Ke.stack=="string")return[Ke.stack,Ve.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var C=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");C&&C.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var D=S.DetermineComponentFrameRoot(),V=D[0],ne=D[1];if(V&&ne){var _e=V.split(`
- `),Fe=ne.split(`
- `);for(C=S=0;S<_e.length&&!_e[S].includes("DetermineComponentFrameRoot");)S++;for(;C<Fe.length&&!Fe[C].includes("DetermineComponentFrameRoot");)C++;if(S===_e.length||C===Fe.length)for(S=_e.length-1,C=Fe.length-1;1<=S&&0<=C&&_e[S]!==Fe[C];)C--;for(;1<=S&&0<=C;S--,C--)if(_e[S]!==Fe[C]){if(S!==1||C!==1)do if(S--,C--,0>C||_e[S]!==Fe[C]){var Je=`
- `+_e[S].replace(" at new "," at ");return u.displayName&&Je.includes("<anonymous>")&&(Je=Je.replace("<anonymous>",u.displayName)),Je}while(1<=S&&0<=C);break}}}finally{$=!1,Error.prepareStackTrace=y}return(y=u?u.displayName||u.name:"")?F(y):""}function J(u,h){switch(u.tag){case 26:case 27:case 5:return F(u.type);case 16:return F("Lazy");case 13:return u.child!==h&&h!==null?F("Suspense Fallback"):F("Suspense");case 19:return F("SuspenseList");case 0:case 15:return ae(u.type,!1);case 11:return ae(u.type.render,!1);case 1:return ae(u.type,!0);case 31:return F("Activity");default:return""}}function ee(u){try{var h="",y=null;do h+=J(u,y),y=u,u=u.return;while(u);return h}catch(S){return`
- Error generating stack: `+S.message+`
- `+S.stack}}var oe=Object.prototype.hasOwnProperty,De=t.unstable_scheduleCallback,Ne=t.unstable_cancelCallback,te=t.unstable_shouldYield,j=t.unstable_requestPaint,k=t.unstable_now,K=t.unstable_getCurrentPriorityLevel,me=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,he=t.unstable_NormalPriority,Ye=t.unstable_LowPriority,Le=t.unstable_IdlePriority,qe=t.log,rt=t.unstable_setDisableYieldValue,Ie=null,Re=null;function ht(u){if(typeof qe=="function"&&rt(u),Re&&typeof Re.setStrictMode=="function")try{Re.setStrictMode(Ie,u)}catch{}}var tt=Math.clz32?Math.clz32:de,et=Math.log,ct=Math.LN2;function de(u){return u>>>=0,u===0?32:31-(et(u)/ct|0)|0}var nt=256,fe=262144,ke=4194304;function Me(u){var h=u&42;if(h!==0)return h;switch(u&-u){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return u&261888;case 262144:case 524288:case 1048576:case 2097152:return u&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return u&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return u}}function ge(u,h,y){var S=u.pendingLanes;if(S===0)return 0;var C=0,D=u.suspendedLanes,V=u.pingedLanes;u=u.warmLanes;var ne=S&134217727;return ne!==0?(S=ne&~D,S!==0?C=Me(S):(V&=ne,V!==0?C=Me(V):y||(y=ne&~u,y!==0&&(C=Me(y))))):(ne=S&~D,ne!==0?C=Me(ne):V!==0?C=Me(V):y||(y=S&~u,y!==0&&(C=Me(y)))),C===0?0:h!==0&&h!==C&&(h&D)===0&&(D=C&-C,y=h&-h,D>=y||D===32&&(y&4194048)!==0)?h:C}function Be(u,h){return(u.pendingLanes&~(u.suspendedLanes&~u.pingedLanes)&h)===0}function lt(u,h){switch(u){case 1:case 2:case 4:case 8:case 64:return h+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return h+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function bt(){var u=ke;return ke<<=1,(ke&62914560)===0&&(ke=4194304),u}function Nt(u){for(var h=[],y=0;31>y;y++)h.push(u);return h}function an(u,h){u.pendingLanes|=h,h!==268435456&&(u.suspendedLanes=0,u.pingedLanes=0,u.warmLanes=0)}function Dt(u,h,y,S,C,D){var V=u.pendingLanes;u.pendingLanes=y,u.suspendedLanes=0,u.pingedLanes=0,u.warmLanes=0,u.expiredLanes&=y,u.entangledLanes&=y,u.errorRecoveryDisabledLanes&=y,u.shellSuspendCounter=0;var ne=u.entanglements,_e=u.expirationTimes,Fe=u.hiddenUpdates;for(y=V&~y;0<y;){var Je=31-tt(y),st=1<<Je;ne[Je]=0,_e[Je]=-1;var Ve=Fe[Je];if(Ve!==null)for(Fe[Je]=null,Je=0;Je<Ve.length;Je++){var Ke=Ve[Je];Ke!==null&&(Ke.lane&=-536870913)}y&=~st}S!==0&&Nn(u,S,0),D!==0&&C===0&&u.tag!==0&&(u.suspendedLanes|=D&~(V&~h))}function Nn(u,h,y){u.pendingLanes|=h,u.suspendedLanes&=~h;var S=31-tt(h);u.entangledLanes|=h,u.entanglements[S]=u.entanglements[S]|1073741824|y&261930}function Gn(u,h){var y=u.entangledLanes|=h;for(u=u.entanglements;y;){var S=31-tt(y),C=1<<S;C&h|u[S]&h&&(u[S]|=h),y&=~C}}function fr(u,h){var y=h&-h;return y=(y&42)!==0?1:Ki(y),(y&(u.suspendedLanes|h))!==0?0:y}function Ki(u){switch(u){case 2:u=1;break;case 8:u=4;break;case 32:u=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:u=128;break;case 268435456:u=134217728;break;default:u=0}return u}function hr(u){return u&=-u,2<u?8<u?(u&134217727)!==0?32:268435456:8:2}function Cr(){var u=W.p;return u!==0?u:(u=window.event,u===void 0?32:t4(u.type))}function $r(u,h){var y=W.p;try{return W.p=u,h()}finally{W.p=y}}var Oi=Math.random().toString(36).slice(2),fi="__reactFiber$"+Oi,Ei="__reactProps$"+Oi,Ks="__reactContainer$"+Oi,Ac="__reactEvents$"+Oi,le="__reactListeners$"+Oi,Ue="__reactHandles$"+Oi,We="__reactResources$"+Oi,Xe="__reactMarker$"+Oi;function Ge(u){delete u[fi],delete u[Ei],delete u[Ac],delete u[le],delete u[Ue]}function _t(u){var h=u[fi];if(h)return h;for(var y=u.parentNode;y;){if(h=y[Ks]||y[fi]){if(y=h.alternate,h.child!==null||y!==null&&y.child!==null)for(u=FU(u);u!==null;){if(y=u[fi])return y;u=FU(u)}return h}u=y,y=u.parentNode}return null}function Z(u){if(u=u[fi]||u[Ks]){var h=u.tag;if(h===5||h===6||h===13||h===31||h===26||h===27||h===3)return u}return null}function be(u){var h=u.tag;if(h===5||h===26||h===27||h===6)return u.stateNode;throw Error(i(33))}function Ce(u){var h=u[We];return h||(h=u[We]={hoistableStyles:new Map,hoistableScripts:new Map}),h}function Te(u){u[Xe]=!0}var Se=new Set,Qe={};function ut(u,h){vt(u,h),vt(u+"Capture",h)}function vt(u,h){for(Qe[u]=h,u=0;u<h.length;u++)Se.add(h[u])}var xt=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Rt={},wt={};function pt(u){return oe.call(wt,u)?!0:oe.call(Rt,u)?!1:xt.test(u)?wt[u]=!0:(Rt[u]=!0,!1)}function Vt(u,h,y){if(pt(h))if(y===null)u.removeAttribute(h);else{switch(typeof y){case"undefined":case"function":case"symbol":u.removeAttribute(h);return;case"boolean":var S=h.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){u.removeAttribute(h);return}}u.setAttribute(h,""+y)}}function kt(u,h,y){if(y===null)u.removeAttribute(h);else{switch(typeof y){case"undefined":case"function":case"symbol":case"boolean":u.removeAttribute(h);return}u.setAttribute(h,""+y)}}function Qt(u,h,y,S){if(S===null)u.removeAttribute(y);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":u.removeAttribute(y);return}u.setAttributeNS(h,y,""+S)}}function on(u){switch(typeof u){case"bigint":case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function hn(u){var h=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(h==="checkbox"||h==="radio")}function Ot(u,h,y){var S=Object.getOwnPropertyDescriptor(u.constructor.prototype,h);if(!u.hasOwnProperty(h)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var C=S.get,D=S.set;return Object.defineProperty(u,h,{configurable:!0,get:function(){return C.call(this)},set:function(V){y=""+V,D.call(this,V)}}),Object.defineProperty(u,h,{enumerable:S.enumerable}),{getValue:function(){return y},setValue:function(V){y=""+V},stopTracking:function(){u._valueTracker=null,delete u[h]}}}}function Wt(u){if(!u._valueTracker){var h=hn(u)?"checked":"value";u._valueTracker=Ot(u,h,""+u[h])}}function Xt(u){if(!u)return!1;var h=u._valueTracker;if(!h)return!0;var y=h.getValue(),S="";return u&&(S=hn(u)?u.checked?"true":"false":u.value),u=S,u!==y?(h.setValue(u),!0):!1}function vi(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}var Ai=/[\n"\\]/g;function Tn(u){return u.replace(Ai,function(h){return"\\"+h.charCodeAt(0).toString(16)+" "})}function Ys(u,h,y,S,C,D,V,ne){u.name="",V!=null&&typeof V!="function"&&typeof V!="symbol"&&typeof V!="boolean"?u.type=V:u.removeAttribute("type"),h!=null?V==="number"?(h===0&&u.value===""||u.value!=h)&&(u.value=""+on(h)):u.value!==""+on(h)&&(u.value=""+on(h)):V!=="submit"&&V!=="reset"||u.removeAttribute("value"),h!=null?pr(u,V,on(h)):y!=null?pr(u,V,on(y)):S!=null&&u.removeAttribute("value"),C==null&&D!=null&&(u.defaultChecked=!!D),C!=null&&(u.checked=C&&typeof C!="function"&&typeof C!="symbol"),ne!=null&&typeof ne!="function"&&typeof ne!="symbol"&&typeof ne!="boolean"?u.name=""+on(ne):u.removeAttribute("name")}function Rn(u,h,y,S,C,D,V,ne){if(D!=null&&typeof D!="function"&&typeof D!="symbol"&&typeof D!="boolean"&&(u.type=D),h!=null||y!=null){if(!(D!=="submit"&&D!=="reset"||h!=null)){Wt(u);return}y=y!=null?""+on(y):"",h=h!=null?""+on(h):y,ne||h===u.value||(u.value=h),u.defaultValue=h}S=S??C,S=typeof S!="function"&&typeof S!="symbol"&&!!S,u.checked=ne?u.checked:!!S,u.defaultChecked=!!S,V!=null&&typeof V!="function"&&typeof V!="symbol"&&typeof V!="boolean"&&(u.name=V),Wt(u)}function pr(u,h,y){h==="number"&&vi(u.ownerDocument)===u||u.defaultValue===""+y||(u.defaultValue=""+y)}function Yi(u,h,y,S){if(u=u.options,h){h={};for(var C=0;C<y.length;C++)h["$"+y[C]]=!0;for(y=0;y<u.length;y++)C=h.hasOwnProperty("$"+u[y].value),u[y].selected!==C&&(u[y].selected=C),C&&S&&(u[y].defaultSelected=!0)}else{for(y=""+on(y),h=null,C=0;C<u.length;C++){if(u[C].value===y){u[C].selected=!0,S&&(u[C].defaultSelected=!0);return}h!==null||u[C].disabled||(h=u[C])}h!==null&&(h.selected=!0)}}function mr(u,h,y){if(h!=null&&(h=""+on(h),h!==u.value&&(u.value=h),y==null)){u.defaultValue!==h&&(u.defaultValue=h);return}u.defaultValue=y!=null?""+on(y):""}function Nr(u,h,y,S){if(h==null){if(S!=null){if(y!=null)throw Error(i(92));if(B(S)){if(1<S.length)throw Error(i(93));S=S[0]}y=S}y==null&&(y=""),h=y}y=on(h),u.defaultValue=y,S=u.textContent,S===y&&S!==""&&S!==null&&(u.value=S),Wt(u)}function Mo(u,h){if(h){var y=u.firstChild;if(y&&y===u.lastChild&&y.nodeType===3){y.nodeValue=h;return}}u.textContent=h}var nl=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ck(u,h,y){var S=h.indexOf("--")===0;y==null||typeof y=="boolean"||y===""?S?u.setProperty(h,""):h==="float"?u.cssFloat="":u[h]="":S?u.setProperty(h,y):typeof y!="number"||y===0||nl.has(h)?h==="float"?u.cssFloat=y:u[h]=(""+y).trim():u[h]=y+"px"}function Nk(u,h,y){if(h!=null&&typeof h!="object")throw Error(i(62));if(u=u.style,y!=null){for(var S in y)!y.hasOwnProperty(S)||h!=null&&h.hasOwnProperty(S)||(S.indexOf("--")===0?u.setProperty(S,""):S==="float"?u.cssFloat="":u[S]="");for(var C in h)S=h[C],h.hasOwnProperty(C)&&y[C]!==S&&Ck(u,C,S)}else for(var D in h)h.hasOwnProperty(D)&&Ck(u,D,h[D])}function Gw(u){if(u.indexOf("-")===-1)return!1;switch(u){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var RQ=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),PQ=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Jx(u){return PQ.test(""+u)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":u}function il(){}var Ww=null;function qw(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var Hf=null,Vf=null;function Rk(u){var h=Z(u);if(h&&(u=h.stateNode)){var y=u[Ei]||null;e:switch(u=h.stateNode,h.type){case"input":if(Ys(u,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name),h=y.name,y.type==="radio"&&h!=null){for(y=u;y.parentNode;)y=y.parentNode;for(y=y.querySelectorAll('input[name="'+Tn(""+h)+'"][type="radio"]'),h=0;h<y.length;h++){var S=y[h];if(S!==u&&S.form===u.form){var C=S[Ei]||null;if(!C)throw Error(i(90));Ys(S,C.value,C.defaultValue,C.defaultValue,C.checked,C.defaultChecked,C.type,C.name)}}for(h=0;h<y.length;h++)S=y[h],S.form===u.form&&Xt(S)}break e;case"textarea":mr(u,y.value,y.defaultValue);break e;case"select":h=y.value,h!=null&&Yi(u,!!y.multiple,h,!1)}}}var Xw=!1;function Pk(u,h,y){if(Xw)return u(h,y);Xw=!0;try{var S=u(h);return S}finally{if(Xw=!1,(Hf!==null||Vf!==null)&&(zv(),Hf&&(h=Hf,u=Vf,Vf=Hf=null,Rk(h),u)))for(h=0;h<u.length;h++)Rk(u[h])}}function Am(u,h){var y=u.stateNode;if(y===null)return null;var S=y[Ei]||null;if(S===null)return null;y=S[h];e:switch(h){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(S=!S.disabled)||(u=u.type,S=!(u==="button"||u==="input"||u==="select"||u==="textarea")),u=!S;break e;default:u=!1}if(u)return null;if(y&&typeof y!="function")throw Error(i(231,h,typeof y));return y}var rl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kw=!1;if(rl)try{var Tm={};Object.defineProperty(Tm,"passive",{get:function(){Kw=!0}}),window.addEventListener("test",Tm,Tm),window.removeEventListener("test",Tm,Tm)}catch{Kw=!1}var Tc=null,Yw=null,ev=null;function Dk(){if(ev)return ev;var u,h=Yw,y=h.length,S,C="value"in Tc?Tc.value:Tc.textContent,D=C.length;for(u=0;u<y&&h[u]===C[u];u++);var V=y-u;for(S=1;S<=V&&h[y-S]===C[D-S];S++);return ev=C.slice(u,1<S?1-S:void 0)}function tv(u){var h=u.keyCode;return"charCode"in u?(u=u.charCode,u===0&&h===13&&(u=13)):u=h,u===10&&(u=13),32<=u||u===13?u:0}function nv(){return!0}function Ok(){return!1}function _a(u){function h(y,S,C,D,V){this._reactName=y,this._targetInst=C,this.type=S,this.nativeEvent=D,this.target=V,this.currentTarget=null;for(var ne in u)u.hasOwnProperty(ne)&&(y=u[ne],this[ne]=y?y(D):D[ne]);return this.isDefaultPrevented=(D.defaultPrevented!=null?D.defaultPrevented:D.returnValue===!1)?nv:Ok,this.isPropagationStopped=Ok,this}return f(h.prototype,{preventDefault:function(){this.defaultPrevented=!0;var y=this.nativeEvent;y&&(y.preventDefault?y.preventDefault():typeof y.returnValue!="unknown"&&(y.returnValue=!1),this.isDefaultPrevented=nv)},stopPropagation:function(){var y=this.nativeEvent;y&&(y.stopPropagation?y.stopPropagation():typeof y.cancelBubble!="unknown"&&(y.cancelBubble=!0),this.isPropagationStopped=nv)},persist:function(){},isPersistent:nv}),h}var ld={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(u){return u.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},iv=_a(ld),Cm=f({},ld,{view:0,detail:0}),DQ=_a(Cm),Zw,Qw,Nm,rv=f({},Cm,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:eM,button:0,buttons:0,relatedTarget:function(u){return u.relatedTarget===void 0?u.fromElement===u.srcElement?u.toElement:u.fromElement:u.relatedTarget},movementX:function(u){return"movementX"in u?u.movementX:(u!==Nm&&(Nm&&u.type==="mousemove"?(Zw=u.screenX-Nm.screenX,Qw=u.screenY-Nm.screenY):Qw=Zw=0,Nm=u),Zw)},movementY:function(u){return"movementY"in u?u.movementY:Qw}}),kk=_a(rv),OQ=f({},rv,{dataTransfer:0}),kQ=_a(OQ),LQ=f({},Cm,{relatedTarget:0}),Jw=_a(LQ),IQ=f({},ld,{animationName:0,elapsedTime:0,pseudoElement:0}),UQ=_a(IQ),jQ=f({},ld,{clipboardData:function(u){return"clipboardData"in u?u.clipboardData:window.clipboardData}}),FQ=_a(jQ),zQ=f({},ld,{data:0}),Lk=_a(zQ),BQ={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},HQ={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},VQ={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $Q(u){var h=this.nativeEvent;return h.getModifierState?h.getModifierState(u):(u=VQ[u])?!!h[u]:!1}function eM(){return $Q}var GQ=f({},Cm,{key:function(u){if(u.key){var h=BQ[u.key]||u.key;if(h!=="Unidentified")return h}return u.type==="keypress"?(u=tv(u),u===13?"Enter":String.fromCharCode(u)):u.type==="keydown"||u.type==="keyup"?HQ[u.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:eM,charCode:function(u){return u.type==="keypress"?tv(u):0},keyCode:function(u){return u.type==="keydown"||u.type==="keyup"?u.keyCode:0},which:function(u){return u.type==="keypress"?tv(u):u.type==="keydown"||u.type==="keyup"?u.keyCode:0}}),WQ=_a(GQ),qQ=f({},rv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ik=_a(qQ),XQ=f({},Cm,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:eM}),KQ=_a(XQ),YQ=f({},ld,{propertyName:0,elapsedTime:0,pseudoElement:0}),ZQ=_a(YQ),QQ=f({},rv,{deltaX:function(u){return"deltaX"in u?u.deltaX:"wheelDeltaX"in u?-u.wheelDeltaX:0},deltaY:function(u){return"deltaY"in u?u.deltaY:"wheelDeltaY"in u?-u.wheelDeltaY:"wheelDelta"in u?-u.wheelDelta:0},deltaZ:0,deltaMode:0}),JQ=_a(QQ),eJ=f({},ld,{newState:0,oldState:0}),tJ=_a(eJ),nJ=[9,13,27,32],tM=rl&&"CompositionEvent"in window,Rm=null;rl&&"documentMode"in document&&(Rm=document.documentMode);var iJ=rl&&"TextEvent"in window&&!Rm,Uk=rl&&(!tM||Rm&&8<Rm&&11>=Rm),jk=" ",Fk=!1;function zk(u,h){switch(u){case"keyup":return nJ.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bk(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var $f=!1;function rJ(u,h){switch(u){case"compositionend":return Bk(h);case"keypress":return h.which!==32?null:(Fk=!0,jk);case"textInput":return u=h.data,u===jk&&Fk?null:u;default:return null}}function aJ(u,h){if($f)return u==="compositionend"||!tM&&zk(u,h)?(u=Dk(),ev=Yw=Tc=null,$f=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1<h.char.length)return h.char;if(h.which)return String.fromCharCode(h.which)}return null;case"compositionend":return Uk&&h.locale!=="ko"?null:h.data;default:return null}}var sJ={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hk(u){var h=u&&u.nodeName&&u.nodeName.toLowerCase();return h==="input"?!!sJ[u.type]:h==="textarea"}function Vk(u,h,y,S){Hf?Vf?Vf.push(S):Vf=[S]:Hf=S,h=qv(h,"onChange"),0<h.length&&(y=new iv("onChange","change",null,y,S),u.push({event:y,listeners:h}))}var Pm=null,Dm=null;function oJ(u){EU(u,0)}function av(u){var h=be(u);if(Xt(h))return u}function $k(u,h){if(u==="change")return h}var Gk=!1;if(rl){var nM;if(rl){var iM="oninput"in document;if(!iM){var Wk=document.createElement("div");Wk.setAttribute("oninput","return;"),iM=typeof Wk.oninput=="function"}nM=iM}else nM=!1;Gk=nM&&(!document.documentMode||9<document.documentMode)}function qk(){Pm&&(Pm.detachEvent("onpropertychange",Xk),Dm=Pm=null)}function Xk(u){if(u.propertyName==="value"&&av(Dm)){var h=[];Vk(h,Dm,u,qw(u)),Pk(oJ,h)}}function lJ(u,h,y){u==="focusin"?(qk(),Pm=h,Dm=y,Pm.attachEvent("onpropertychange",Xk)):u==="focusout"&&qk()}function cJ(u){if(u==="selectionchange"||u==="keyup"||u==="keydown")return av(Dm)}function uJ(u,h){if(u==="click")return av(h)}function dJ(u,h){if(u==="input"||u==="change")return av(h)}function fJ(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var Ha=typeof Object.is=="function"?Object.is:fJ;function Om(u,h){if(Ha(u,h))return!0;if(typeof u!="object"||u===null||typeof h!="object"||h===null)return!1;var y=Object.keys(u),S=Object.keys(h);if(y.length!==S.length)return!1;for(S=0;S<y.length;S++){var C=y[S];if(!oe.call(h,C)||!Ha(u[C],h[C]))return!1}return!0}function Kk(u){for(;u&&u.firstChild;)u=u.firstChild;return u}function Yk(u,h){var y=Kk(u);u=0;for(var S;y;){if(y.nodeType===3){if(S=u+y.textContent.length,u<=h&&S>=h)return{node:y,offset:h-u};u=S}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=Kk(y)}}function Zk(u,h){return u&&h?u===h?!0:u&&u.nodeType===3?!1:h&&h.nodeType===3?Zk(u,h.parentNode):"contains"in u?u.contains(h):u.compareDocumentPosition?!!(u.compareDocumentPosition(h)&16):!1:!1}function Qk(u){u=u!=null&&u.ownerDocument!=null&&u.ownerDocument.defaultView!=null?u.ownerDocument.defaultView:window;for(var h=vi(u.document);h instanceof u.HTMLIFrameElement;){try{var y=typeof h.contentWindow.location.href=="string"}catch{y=!1}if(y)u=h.contentWindow;else break;h=vi(u.document)}return h}function rM(u){var h=u&&u.nodeName&&u.nodeName.toLowerCase();return h&&(h==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||h==="textarea"||u.contentEditable==="true")}var hJ=rl&&"documentMode"in document&&11>=document.documentMode,Gf=null,aM=null,km=null,sM=!1;function Jk(u,h,y){var S=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;sM||Gf==null||Gf!==vi(S)||(S=Gf,"selectionStart"in S&&rM(S)?S={start:S.selectionStart,end:S.selectionEnd}:(S=(S.ownerDocument&&S.ownerDocument.defaultView||window).getSelection(),S={anchorNode:S.anchorNode,anchorOffset:S.anchorOffset,focusNode:S.focusNode,focusOffset:S.focusOffset}),km&&Om(km,S)||(km=S,S=qv(aM,"onSelect"),0<S.length&&(h=new iv("onSelect","select",null,h,y),u.push({event:h,listeners:S}),h.target=Gf)))}function cd(u,h){var y={};return y[u.toLowerCase()]=h.toLowerCase(),y["Webkit"+u]="webkit"+h,y["Moz"+u]="moz"+h,y}var Wf={animationend:cd("Animation","AnimationEnd"),animationiteration:cd("Animation","AnimationIteration"),animationstart:cd("Animation","AnimationStart"),transitionrun:cd("Transition","TransitionRun"),transitionstart:cd("Transition","TransitionStart"),transitioncancel:cd("Transition","TransitionCancel"),transitionend:cd("Transition","TransitionEnd")},oM={},eL={};rl&&(eL=document.createElement("div").style,"AnimationEvent"in window||(delete Wf.animationend.animation,delete Wf.animationiteration.animation,delete Wf.animationstart.animation),"TransitionEvent"in window||delete Wf.transitionend.transition);function ud(u){if(oM[u])return oM[u];if(!Wf[u])return u;var h=Wf[u],y;for(y in h)if(h.hasOwnProperty(y)&&y in eL)return oM[u]=h[y];return u}var tL=ud("animationend"),nL=ud("animationiteration"),iL=ud("animationstart"),pJ=ud("transitionrun"),mJ=ud("transitionstart"),gJ=ud("transitioncancel"),rL=ud("transitionend"),aL=new Map,lM="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");lM.push("scrollEnd");function Zs(u,h){aL.set(u,h),ut(h,[u])}var sv=typeof reportError=="function"?reportError:function(u){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var h=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof u=="object"&&u!==null&&typeof u.message=="string"?String(u.message):String(u),error:u});if(!window.dispatchEvent(h))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",u);return}console.error(u)},hs=[],qf=0,cM=0;function ov(){for(var u=qf,h=cM=qf=0;h<u;){var y=hs[h];hs[h++]=null;var S=hs[h];hs[h++]=null;var C=hs[h];hs[h++]=null;var D=hs[h];if(hs[h++]=null,S!==null&&C!==null){var V=S.pending;V===null?C.next=C:(C.next=V.next,V.next=C),S.pending=C}D!==0&&sL(y,C,D)}}function lv(u,h,y,S){hs[qf++]=u,hs[qf++]=h,hs[qf++]=y,hs[qf++]=S,cM|=S,u.lanes|=S,u=u.alternate,u!==null&&(u.lanes|=S)}function uM(u,h,y,S){return lv(u,h,y,S),cv(u)}function dd(u,h){return lv(u,null,null,h),cv(u)}function sL(u,h,y){u.lanes|=y;var S=u.alternate;S!==null&&(S.lanes|=y);for(var C=!1,D=u.return;D!==null;)D.childLanes|=y,S=D.alternate,S!==null&&(S.childLanes|=y),D.tag===22&&(u=D.stateNode,u===null||u._visibility&1||(C=!0)),u=D,D=D.return;return u.tag===3?(D=u.stateNode,C&&h!==null&&(C=31-tt(y),u=D.hiddenUpdates,S=u[C],S===null?u[C]=[h]:S.push(h),h.lane=y|536870912),D):null}function cv(u){if(50<ng)throw ng=0,yE=null,Error(i(185));for(var h=u.return;h!==null;)u=h,h=u.return;return u.tag===3?u.stateNode:null}var Xf={};function xJ(u,h,y,S){this.tag=u,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=h,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Va(u,h,y,S){return new xJ(u,h,y,S)}function dM(u){return u=u.prototype,!(!u||!u.isReactComponent)}function al(u,h){var y=u.alternate;return y===null?(y=Va(u.tag,h,u.key,u.mode),y.elementType=u.elementType,y.type=u.type,y.stateNode=u.stateNode,y.alternate=u,u.alternate=y):(y.pendingProps=h,y.type=u.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=u.flags&65011712,y.childLanes=u.childLanes,y.lanes=u.lanes,y.child=u.child,y.memoizedProps=u.memoizedProps,y.memoizedState=u.memoizedState,y.updateQueue=u.updateQueue,h=u.dependencies,y.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext},y.sibling=u.sibling,y.index=u.index,y.ref=u.ref,y.refCleanup=u.refCleanup,y}function oL(u,h){u.flags&=65011714;var y=u.alternate;return y===null?(u.childLanes=0,u.lanes=h,u.child=null,u.subtreeFlags=0,u.memoizedProps=null,u.memoizedState=null,u.updateQueue=null,u.dependencies=null,u.stateNode=null):(u.childLanes=y.childLanes,u.lanes=y.lanes,u.child=y.child,u.subtreeFlags=0,u.deletions=null,u.memoizedProps=y.memoizedProps,u.memoizedState=y.memoizedState,u.updateQueue=y.updateQueue,u.type=y.type,h=y.dependencies,u.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext}),u}function uv(u,h,y,S,C,D){var V=0;if(S=u,typeof u=="function")dM(u)&&(V=1);else if(typeof u=="string")V=See(u,y,ue.current)?26:u==="html"||u==="head"||u==="body"?27:5;else e:switch(u){case R:return u=Va(31,y,h,C),u.elementType=R,u.lanes=D,u;case b:return fd(y.children,C,D,h);case v:V=8,C|=24;break;case x:return u=Va(12,y,h,C|2),u.elementType=x,u.lanes=D,u;case T:return u=Va(13,y,h,C),u.elementType=T,u.lanes=D,u;case P:return u=Va(19,y,h,C),u.elementType=P,u.lanes=D,u;default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case w:V=10;break e;case M:V=9;break e;case E:V=11;break e;case N:V=14;break e;case U:V=16,S=null;break e}V=29,y=Error(i(130,u===null?"null":typeof u,"")),S=null}return h=Va(V,y,h,C),h.elementType=u,h.type=S,h.lanes=D,h}function fd(u,h,y,S){return u=Va(7,u,S,h),u.lanes=y,u}function fM(u,h,y){return u=Va(6,u,null,h),u.lanes=y,u}function lL(u){var h=Va(18,null,null,0);return h.stateNode=u,h}function hM(u,h,y){return h=Va(4,u.children!==null?u.children:[],u.key,h),h.lanes=y,h.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},h}var cL=new WeakMap;function ps(u,h){if(typeof u=="object"&&u!==null){var y=cL.get(u);return y!==void 0?y:(h={value:u,source:h,stack:ee(h)},cL.set(u,h),h)}return{value:u,source:h,stack:ee(h)}}var Kf=[],Yf=0,dv=null,Lm=0,ms=[],gs=0,Cc=null,Eo=1,Ao="";function sl(u,h){Kf[Yf++]=Lm,Kf[Yf++]=dv,dv=u,Lm=h}function uL(u,h,y){ms[gs++]=Eo,ms[gs++]=Ao,ms[gs++]=Cc,Cc=u;var S=Eo;u=Ao;var C=32-tt(S)-1;S&=~(1<<C),y+=1;var D=32-tt(h)+C;if(30<D){var V=C-C%5;D=(S&(1<<V)-1).toString(32),S>>=V,C-=V,Eo=1<<32-tt(h)+C|y<<C|S,Ao=D+u}else Eo=1<<D|y<<C|S,Ao=u}function pM(u){u.return!==null&&(sl(u,1),uL(u,1,0))}function mM(u){for(;u===dv;)dv=Kf[--Yf],Kf[Yf]=null,Lm=Kf[--Yf],Kf[Yf]=null;for(;u===Cc;)Cc=ms[--gs],ms[gs]=null,Ao=ms[--gs],ms[gs]=null,Eo=ms[--gs],ms[gs]=null}function dL(u,h){ms[gs++]=Eo,ms[gs++]=Ao,ms[gs++]=Cc,Eo=h.id,Ao=h.overflow,Cc=u}var Rr=null,Jn=null,vn=!1,Nc=null,xs=!1,gM=Error(i(519));function Rc(u){var h=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Im(ps(h,u)),gM}function fL(u){var h=u.stateNode,y=u.type,S=u.memoizedProps;switch(h[fi]=u,h[Ei]=S,y){case"dialog":dn("cancel",h),dn("close",h);break;case"iframe":case"object":case"embed":dn("load",h);break;case"video":case"audio":for(y=0;y<rg.length;y++)dn(rg[y],h);break;case"source":dn("error",h);break;case"img":case"image":case"link":dn("error",h),dn("load",h);break;case"details":dn("toggle",h);break;case"input":dn("invalid",h),Rn(h,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":dn("invalid",h);break;case"textarea":dn("invalid",h),Nr(h,S.value,S.defaultValue,S.children)}y=S.children,typeof y!="string"&&typeof y!="number"&&typeof y!="bigint"||h.textContent===""+y||S.suppressHydrationWarning===!0||NU(h.textContent,y)?(S.popover!=null&&(dn("beforetoggle",h),dn("toggle",h)),S.onScroll!=null&&dn("scroll",h),S.onScrollEnd!=null&&dn("scrollend",h),S.onClick!=null&&(h.onclick=il),h=!0):h=!1,h||Rc(u,!0)}function hL(u){for(Rr=u.return;Rr;)switch(Rr.tag){case 5:case 31:case 13:xs=!1;return;case 27:case 3:xs=!0;return;default:Rr=Rr.return}}function Zf(u){if(u!==Rr)return!1;if(!vn)return hL(u),vn=!0,!1;var h=u.tag,y;if((y=h!==3&&h!==27)&&((y=h===5)&&(y=u.type,y=!(y!=="form"&&y!=="button")||kE(u.type,u.memoizedProps)),y=!y),y&&Jn&&Rc(u),hL(u),h===13){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(i(317));Jn=jU(u)}else if(h===31){if(u=u.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(i(317));Jn=jU(u)}else h===27?(h=Jn,$c(u.type)?(u=FE,FE=null,Jn=u):Jn=h):Jn=Rr?ys(u.stateNode.nextSibling):null;return!0}function hd(){Jn=Rr=null,vn=!1}function xM(){var u=Nc;return u!==null&&(Ea===null?Ea=u:Ea.push.apply(Ea,u),Nc=null),u}function Im(u){Nc===null?Nc=[u]:Nc.push(u)}var vM=H(null),pd=null,ol=null;function Pc(u,h,y){se(vM,h._currentValue),h._currentValue=y}function ll(u){u._currentValue=vM.current,Y(vM)}function yM(u,h,y){for(;u!==null;){var S=u.alternate;if((u.childLanes&h)!==h?(u.childLanes|=h,S!==null&&(S.childLanes|=h)):S!==null&&(S.childLanes&h)!==h&&(S.childLanes|=h),u===y)break;u=u.return}}function bM(u,h,y,S){var C=u.child;for(C!==null&&(C.return=u);C!==null;){var D=C.dependencies;if(D!==null){var V=C.child;D=D.firstContext;e:for(;D!==null;){var ne=D;D=C;for(var _e=0;_e<h.length;_e++)if(ne.context===h[_e]){D.lanes|=y,ne=D.alternate,ne!==null&&(ne.lanes|=y),yM(D.return,y,u),S||(V=null);break e}D=ne.next}}else if(C.tag===18){if(V=C.return,V===null)throw Error(i(341));V.lanes|=y,D=V.alternate,D!==null&&(D.lanes|=y),yM(V,y,u),V=null}else V=C.child;if(V!==null)V.return=C;else for(V=C;V!==null;){if(V===u){V=null;break}if(C=V.sibling,C!==null){C.return=V.return,V=C;break}V=V.return}C=V}}function Qf(u,h,y,S){u=null;for(var C=h,D=!1;C!==null;){if(!D){if((C.flags&524288)!==0)D=!0;else if((C.flags&262144)!==0)break}if(C.tag===10){var V=C.alternate;if(V===null)throw Error(i(387));if(V=V.memoizedProps,V!==null){var ne=C.type;Ha(C.pendingProps.value,V.value)||(u!==null?u.push(ne):u=[ne])}}else if(C===ve.current){if(V=C.alternate,V===null)throw Error(i(387));V.memoizedState.memoizedState!==C.memoizedState.memoizedState&&(u!==null?u.push(cg):u=[cg])}C=C.return}u!==null&&bM(h,u,y,S),h.flags|=262144}function fv(u){for(u=u.firstContext;u!==null;){if(!Ha(u.context._currentValue,u.memoizedValue))return!0;u=u.next}return!1}function md(u){pd=u,ol=null,u=u.dependencies,u!==null&&(u.firstContext=null)}function Pr(u){return pL(pd,u)}function hv(u,h){return pd===null&&md(u),pL(u,h)}function pL(u,h){var y=h._currentValue;if(h={context:h,memoizedValue:y,next:null},ol===null){if(u===null)throw Error(i(308));ol=h,u.dependencies={lanes:0,firstContext:h},u.flags|=524288}else ol=ol.next=h;return y}var vJ=typeof AbortController<"u"?AbortController:function(){var u=[],h=this.signal={aborted:!1,addEventListener:function(y,S){u.push(S)}};this.abort=function(){h.aborted=!0,u.forEach(function(y){return y()})}},yJ=t.unstable_scheduleCallback,bJ=t.unstable_NormalPriority,ki={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _M(){return{controller:new vJ,data:new Map,refCount:0}}function Um(u){u.refCount--,u.refCount===0&&yJ(bJ,function(){u.controller.abort()})}var jm=null,SM=0,Jf=0,eh=null;function _J(u,h){if(jm===null){var y=jm=[];SM=0,Jf=EE(),eh={status:"pending",value:void 0,then:function(S){y.push(S)}}}return SM++,h.then(mL,mL),h}function mL(){if(--SM===0&&jm!==null){eh!==null&&(eh.status="fulfilled");var u=jm;jm=null,Jf=0,eh=null;for(var h=0;h<u.length;h++)(0,u[h])()}}function SJ(u,h){var y=[],S={status:"pending",value:null,reason:null,then:function(C){y.push(C)}};return u.then(function(){S.status="fulfilled",S.value=h;for(var C=0;C<y.length;C++)(0,y[C])(h)},function(C){for(S.status="rejected",S.reason=C,C=0;C<y.length;C++)(0,y[C])(void 0)}),S}var gL=q.S;q.S=function(u,h){JI=k(),typeof h=="object"&&h!==null&&typeof h.then=="function"&&_J(u,h),gL!==null&&gL(u,h)};var gd=H(null);function wM(){var u=gd.current;return u!==null?u:Wn.pooledCache}function pv(u,h){h===null?se(gd,gd.current):se(gd,h.pool)}function xL(){var u=wM();return u===null?null:{parent:ki._currentValue,pool:u}}var th=Error(i(460)),MM=Error(i(474)),mv=Error(i(542)),gv={then:function(){}};function vL(u){return u=u.status,u==="fulfilled"||u==="rejected"}function yL(u,h,y){switch(y=u[y],y===void 0?u.push(h):y!==h&&(h.then(il,il),h=y),h.status){case"fulfilled":return h.value;case"rejected":throw u=h.reason,_L(u),u;default:if(typeof h.status=="string")h.then(il,il);else{if(u=Wn,u!==null&&100<u.shellSuspendCounter)throw Error(i(482));u=h,u.status="pending",u.then(function(S){if(h.status==="pending"){var C=h;C.status="fulfilled",C.value=S}},function(S){if(h.status==="pending"){var C=h;C.status="rejected",C.reason=S}})}switch(h.status){case"fulfilled":return h.value;case"rejected":throw u=h.reason,_L(u),u}throw vd=h,th}}function xd(u){try{var h=u._init;return h(u._payload)}catch(y){throw y!==null&&typeof y=="object"&&typeof y.then=="function"?(vd=y,th):y}}var vd=null;function bL(){if(vd===null)throw Error(i(459));var u=vd;return vd=null,u}function _L(u){if(u===th||u===mv)throw Error(i(483))}var nh=null,Fm=0;function xv(u){var h=Fm;return Fm+=1,nh===null&&(nh=[]),yL(nh,u,h)}function zm(u,h){h=h.props.ref,u.ref=h!==void 0?h:null}function vv(u,h){throw h.$$typeof===p?Error(i(525)):(u=Object.prototype.toString.call(h),Error(i(31,u==="[object Object]"?"object with keys {"+Object.keys(h).join(", ")+"}":u)))}function SL(u){function h(Oe,Ee){if(u){var je=Oe.deletions;je===null?(Oe.deletions=[Ee],Oe.flags|=16):je.push(Ee)}}function y(Oe,Ee){if(!u)return null;for(;Ee!==null;)h(Oe,Ee),Ee=Ee.sibling;return null}function S(Oe){for(var Ee=new Map;Oe!==null;)Oe.key!==null?Ee.set(Oe.key,Oe):Ee.set(Oe.index,Oe),Oe=Oe.sibling;return Ee}function C(Oe,Ee){return Oe=al(Oe,Ee),Oe.index=0,Oe.sibling=null,Oe}function D(Oe,Ee,je){return Oe.index=je,u?(je=Oe.alternate,je!==null?(je=je.index,je<Ee?(Oe.flags|=67108866,Ee):je):(Oe.flags|=67108866,Ee)):(Oe.flags|=1048576,Ee)}function V(Oe){return u&&Oe.alternate===null&&(Oe.flags|=67108866),Oe}function ne(Oe,Ee,je,it){return Ee===null||Ee.tag!==6?(Ee=fM(je,Oe.mode,it),Ee.return=Oe,Ee):(Ee=C(Ee,je),Ee.return=Oe,Ee)}function _e(Oe,Ee,je,it){var Lt=je.type;return Lt===b?Je(Oe,Ee,je.props.children,it,je.key):Ee!==null&&(Ee.elementType===Lt||typeof Lt=="object"&&Lt!==null&&Lt.$$typeof===U&&xd(Lt)===Ee.type)?(Ee=C(Ee,je.props),zm(Ee,je),Ee.return=Oe,Ee):(Ee=uv(je.type,je.key,je.props,null,Oe.mode,it),zm(Ee,je),Ee.return=Oe,Ee)}function Fe(Oe,Ee,je,it){return Ee===null||Ee.tag!==4||Ee.stateNode.containerInfo!==je.containerInfo||Ee.stateNode.implementation!==je.implementation?(Ee=hM(je,Oe.mode,it),Ee.return=Oe,Ee):(Ee=C(Ee,je.children||[]),Ee.return=Oe,Ee)}function Je(Oe,Ee,je,it,Lt){return Ee===null||Ee.tag!==7?(Ee=fd(je,Oe.mode,it,Lt),Ee.return=Oe,Ee):(Ee=C(Ee,je),Ee.return=Oe,Ee)}function st(Oe,Ee,je){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number"||typeof Ee=="bigint")return Ee=fM(""+Ee,Oe.mode,je),Ee.return=Oe,Ee;if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case m:return je=uv(Ee.type,Ee.key,Ee.props,null,Oe.mode,je),zm(je,Ee),je.return=Oe,je;case _:return Ee=hM(Ee,Oe.mode,je),Ee.return=Oe,Ee;case U:return Ee=xd(Ee),st(Oe,Ee,je)}if(B(Ee)||I(Ee))return Ee=fd(Ee,Oe.mode,je,null),Ee.return=Oe,Ee;if(typeof Ee.then=="function")return st(Oe,xv(Ee),je);if(Ee.$$typeof===w)return st(Oe,hv(Oe,Ee),je);vv(Oe,Ee)}return null}function Ve(Oe,Ee,je,it){var Lt=Ee!==null?Ee.key:null;if(typeof je=="string"&&je!==""||typeof je=="number"||typeof je=="bigint")return Lt!==null?null:ne(Oe,Ee,""+je,it);if(typeof je=="object"&&je!==null){switch(je.$$typeof){case m:return je.key===Lt?_e(Oe,Ee,je,it):null;case _:return je.key===Lt?Fe(Oe,Ee,je,it):null;case U:return je=xd(je),Ve(Oe,Ee,je,it)}if(B(je)||I(je))return Lt!==null?null:Je(Oe,Ee,je,it,null);if(typeof je.then=="function")return Ve(Oe,Ee,xv(je),it);if(je.$$typeof===w)return Ve(Oe,Ee,hv(Oe,je),it);vv(Oe,je)}return null}function Ke(Oe,Ee,je,it,Lt){if(typeof it=="string"&&it!==""||typeof it=="number"||typeof it=="bigint")return Oe=Oe.get(je)||null,ne(Ee,Oe,""+it,Lt);if(typeof it=="object"&&it!==null){switch(it.$$typeof){case m:return Oe=Oe.get(it.key===null?je:it.key)||null,_e(Ee,Oe,it,Lt);case _:return Oe=Oe.get(it.key===null?je:it.key)||null,Fe(Ee,Oe,it,Lt);case U:return it=xd(it),Ke(Oe,Ee,je,it,Lt)}if(B(it)||I(it))return Oe=Oe.get(je)||null,Je(Ee,Oe,it,Lt,null);if(typeof it.then=="function")return Ke(Oe,Ee,je,xv(it),Lt);if(it.$$typeof===w)return Ke(Oe,Ee,je,hv(Ee,it),Lt);vv(Ee,it)}return null}function Ct(Oe,Ee,je,it){for(var Lt=null,_n=null,Pt=Ee,Zt=Ee=0,mn=null;Pt!==null&&Zt<je.length;Zt++){Pt.index>Zt?(mn=Pt,Pt=null):mn=Pt.sibling;var Sn=Ve(Oe,Pt,je[Zt],it);if(Sn===null){Pt===null&&(Pt=mn);break}u&&Pt&&Sn.alternate===null&&h(Oe,Pt),Ee=D(Sn,Ee,Zt),_n===null?Lt=Sn:_n.sibling=Sn,_n=Sn,Pt=mn}if(Zt===je.length)return y(Oe,Pt),vn&&sl(Oe,Zt),Lt;if(Pt===null){for(;Zt<je.length;Zt++)Pt=st(Oe,je[Zt],it),Pt!==null&&(Ee=D(Pt,Ee,Zt),_n===null?Lt=Pt:_n.sibling=Pt,_n=Pt);return vn&&sl(Oe,Zt),Lt}for(Pt=S(Pt);Zt<je.length;Zt++)mn=Ke(Pt,Oe,Zt,je[Zt],it),mn!==null&&(u&&mn.alternate!==null&&Pt.delete(mn.key===null?Zt:mn.key),Ee=D(mn,Ee,Zt),_n===null?Lt=mn:_n.sibling=mn,_n=mn);return u&&Pt.forEach(function(Kc){return h(Oe,Kc)}),vn&&sl(Oe,Zt),Lt}function zt(Oe,Ee,je,it){if(je==null)throw Error(i(151));for(var Lt=null,_n=null,Pt=Ee,Zt=Ee=0,mn=null,Sn=je.next();Pt!==null&&!Sn.done;Zt++,Sn=je.next()){Pt.index>Zt?(mn=Pt,Pt=null):mn=Pt.sibling;var Kc=Ve(Oe,Pt,Sn.value,it);if(Kc===null){Pt===null&&(Pt=mn);break}u&&Pt&&Kc.alternate===null&&h(Oe,Pt),Ee=D(Kc,Ee,Zt),_n===null?Lt=Kc:_n.sibling=Kc,_n=Kc,Pt=mn}if(Sn.done)return y(Oe,Pt),vn&&sl(Oe,Zt),Lt;if(Pt===null){for(;!Sn.done;Zt++,Sn=je.next())Sn=st(Oe,Sn.value,it),Sn!==null&&(Ee=D(Sn,Ee,Zt),_n===null?Lt=Sn:_n.sibling=Sn,_n=Sn);return vn&&sl(Oe,Zt),Lt}for(Pt=S(Pt);!Sn.done;Zt++,Sn=je.next())Sn=Ke(Pt,Oe,Zt,Sn.value,it),Sn!==null&&(u&&Sn.alternate!==null&&Pt.delete(Sn.key===null?Zt:Sn.key),Ee=D(Sn,Ee,Zt),_n===null?Lt=Sn:_n.sibling=Sn,_n=Sn);return u&&Pt.forEach(function(Oee){return h(Oe,Oee)}),vn&&sl(Oe,Zt),Lt}function Un(Oe,Ee,je,it){if(typeof je=="object"&&je!==null&&je.type===b&&je.key===null&&(je=je.props.children),typeof je=="object"&&je!==null){switch(je.$$typeof){case m:e:{for(var Lt=je.key;Ee!==null;){if(Ee.key===Lt){if(Lt=je.type,Lt===b){if(Ee.tag===7){y(Oe,Ee.sibling),it=C(Ee,je.props.children),it.return=Oe,Oe=it;break e}}else if(Ee.elementType===Lt||typeof Lt=="object"&&Lt!==null&&Lt.$$typeof===U&&xd(Lt)===Ee.type){y(Oe,Ee.sibling),it=C(Ee,je.props),zm(it,je),it.return=Oe,Oe=it;break e}y(Oe,Ee);break}else h(Oe,Ee);Ee=Ee.sibling}je.type===b?(it=fd(je.props.children,Oe.mode,it,je.key),it.return=Oe,Oe=it):(it=uv(je.type,je.key,je.props,null,Oe.mode,it),zm(it,je),it.return=Oe,Oe=it)}return V(Oe);case _:e:{for(Lt=je.key;Ee!==null;){if(Ee.key===Lt)if(Ee.tag===4&&Ee.stateNode.containerInfo===je.containerInfo&&Ee.stateNode.implementation===je.implementation){y(Oe,Ee.sibling),it=C(Ee,je.children||[]),it.return=Oe,Oe=it;break e}else{y(Oe,Ee);break}else h(Oe,Ee);Ee=Ee.sibling}it=hM(je,Oe.mode,it),it.return=Oe,Oe=it}return V(Oe);case U:return je=xd(je),Un(Oe,Ee,je,it)}if(B(je))return Ct(Oe,Ee,je,it);if(I(je)){if(Lt=I(je),typeof Lt!="function")throw Error(i(150));return je=Lt.call(je),zt(Oe,Ee,je,it)}if(typeof je.then=="function")return Un(Oe,Ee,xv(je),it);if(je.$$typeof===w)return Un(Oe,Ee,hv(Oe,je),it);vv(Oe,je)}return typeof je=="string"&&je!==""||typeof je=="number"||typeof je=="bigint"?(je=""+je,Ee!==null&&Ee.tag===6?(y(Oe,Ee.sibling),it=C(Ee,je),it.return=Oe,Oe=it):(y(Oe,Ee),it=fM(je,Oe.mode,it),it.return=Oe,Oe=it),V(Oe)):y(Oe,Ee)}return function(Oe,Ee,je,it){try{Fm=0;var Lt=Un(Oe,Ee,je,it);return nh=null,Lt}catch(Pt){if(Pt===th||Pt===mv)throw Pt;var _n=Va(29,Pt,null,Oe.mode);return _n.lanes=it,_n.return=Oe,_n}finally{}}}var yd=SL(!0),wL=SL(!1),Dc=!1;function EM(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function AM(u,h){u=u.updateQueue,h.updateQueue===u&&(h.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,callbacks:null})}function Oc(u){return{lane:u,tag:0,payload:null,callback:null,next:null}}function kc(u,h,y){var S=u.updateQueue;if(S===null)return null;if(S=S.shared,(An&2)!==0){var C=S.pending;return C===null?h.next=h:(h.next=C.next,C.next=h),S.pending=h,h=cv(u),sL(u,null,y),h}return lv(u,S,h,y),cv(u)}function Bm(u,h,y){if(h=h.updateQueue,h!==null&&(h=h.shared,(y&4194048)!==0)){var S=h.lanes;S&=u.pendingLanes,y|=S,h.lanes=y,Gn(u,y)}}function TM(u,h){var y=u.updateQueue,S=u.alternate;if(S!==null&&(S=S.updateQueue,y===S)){var C=null,D=null;if(y=y.firstBaseUpdate,y!==null){do{var V={lane:y.lane,tag:y.tag,payload:y.payload,callback:null,next:null};D===null?C=D=V:D=D.next=V,y=y.next}while(y!==null);D===null?C=D=h:D=D.next=h}else C=D=h;y={baseState:S.baseState,firstBaseUpdate:C,lastBaseUpdate:D,shared:S.shared,callbacks:S.callbacks},u.updateQueue=y;return}u=y.lastBaseUpdate,u===null?y.firstBaseUpdate=h:u.next=h,y.lastBaseUpdate=h}var CM=!1;function Hm(){if(CM){var u=eh;if(u!==null)throw u}}function Vm(u,h,y,S){CM=!1;var C=u.updateQueue;Dc=!1;var D=C.firstBaseUpdate,V=C.lastBaseUpdate,ne=C.shared.pending;if(ne!==null){C.shared.pending=null;var _e=ne,Fe=_e.next;_e.next=null,V===null?D=Fe:V.next=Fe,V=_e;var Je=u.alternate;Je!==null&&(Je=Je.updateQueue,ne=Je.lastBaseUpdate,ne!==V&&(ne===null?Je.firstBaseUpdate=Fe:ne.next=Fe,Je.lastBaseUpdate=_e))}if(D!==null){var st=C.baseState;V=0,Je=Fe=_e=null,ne=D;do{var Ve=ne.lane&-536870913,Ke=Ve!==ne.lane;if(Ke?(pn&Ve)===Ve:(S&Ve)===Ve){Ve!==0&&Ve===Jf&&(CM=!0),Je!==null&&(Je=Je.next={lane:0,tag:ne.tag,payload:ne.payload,callback:null,next:null});e:{var Ct=u,zt=ne;Ve=h;var Un=y;switch(zt.tag){case 1:if(Ct=zt.payload,typeof Ct=="function"){st=Ct.call(Un,st,Ve);break e}st=Ct;break e;case 3:Ct.flags=Ct.flags&-65537|128;case 0:if(Ct=zt.payload,Ve=typeof Ct=="function"?Ct.call(Un,st,Ve):Ct,Ve==null)break e;st=f({},st,Ve);break e;case 2:Dc=!0}}Ve=ne.callback,Ve!==null&&(u.flags|=64,Ke&&(u.flags|=8192),Ke=C.callbacks,Ke===null?C.callbacks=[Ve]:Ke.push(Ve))}else Ke={lane:Ve,tag:ne.tag,payload:ne.payload,callback:ne.callback,next:null},Je===null?(Fe=Je=Ke,_e=st):Je=Je.next=Ke,V|=Ve;if(ne=ne.next,ne===null){if(ne=C.shared.pending,ne===null)break;Ke=ne,ne=Ke.next,Ke.next=null,C.lastBaseUpdate=Ke,C.shared.pending=null}}while(!0);Je===null&&(_e=st),C.baseState=_e,C.firstBaseUpdate=Fe,C.lastBaseUpdate=Je,D===null&&(C.shared.lanes=0),Fc|=V,u.lanes=V,u.memoizedState=st}}function ML(u,h){if(typeof u!="function")throw Error(i(191,u));u.call(h)}function EL(u,h){var y=u.callbacks;if(y!==null)for(u.callbacks=null,u=0;u<y.length;u++)ML(y[u],h)}var ih=H(null),yv=H(0);function AL(u,h){u=xl,se(yv,u),se(ih,h),xl=u|h.baseLanes}function NM(){se(yv,xl),se(ih,ih.current)}function RM(){xl=yv.current,Y(ih),Y(yv)}var $a=H(null),vs=null;function Lc(u){var h=u.alternate;se(Ti,Ti.current&1),se($a,u),vs===null&&(h===null||ih.current!==null||h.memoizedState!==null)&&(vs=u)}function PM(u){se(Ti,Ti.current),se($a,u),vs===null&&(vs=u)}function TL(u){u.tag===22?(se(Ti,Ti.current),se($a,u),vs===null&&(vs=u)):Ic()}function Ic(){se(Ti,Ti.current),se($a,$a.current)}function Ga(u){Y($a),vs===u&&(vs=null),Y(Ti)}var Ti=H(0);function bv(u){for(var h=u;h!==null;){if(h.tag===13){var y=h.memoizedState;if(y!==null&&(y=y.dehydrated,y===null||UE(y)||jE(y)))return h}else if(h.tag===19&&(h.memoizedProps.revealOrder==="forwards"||h.memoizedProps.revealOrder==="backwards"||h.memoizedProps.revealOrder==="unstable_legacy-backwards"||h.memoizedProps.revealOrder==="together")){if((h.flags&128)!==0)return h}else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===u)break;for(;h.sibling===null;){if(h.return===null||h.return===u)return null;h=h.return}h.sibling.return=h.return,h=h.sibling}return null}var cl=0,Kt=null,Ln=null,Li=null,_v=!1,rh=!1,bd=!1,Sv=0,$m=0,ah=null,wJ=0;function yi(){throw Error(i(321))}function DM(u,h){if(h===null)return!1;for(var y=0;y<h.length&&y<u.length;y++)if(!Ha(u[y],h[y]))return!1;return!0}function OM(u,h,y,S,C,D){return cl=D,Kt=h,h.memoizedState=null,h.updateQueue=null,h.lanes=0,q.H=u===null||u.memoizedState===null?uI:XM,bd=!1,D=y(S,C),bd=!1,rh&&(D=NL(h,y,S,C)),CL(u),D}function CL(u){q.H=qm;var h=Ln!==null&&Ln.next!==null;if(cl=0,Li=Ln=Kt=null,_v=!1,$m=0,ah=null,h)throw Error(i(300));u===null||Ii||(u=u.dependencies,u!==null&&fv(u)&&(Ii=!0))}function NL(u,h,y,S){Kt=u;var C=0;do{if(rh&&(ah=null),$m=0,rh=!1,25<=C)throw Error(i(301));if(C+=1,Li=Ln=null,u.updateQueue!=null){var D=u.updateQueue;D.lastEffect=null,D.events=null,D.stores=null,D.memoCache!=null&&(D.memoCache.index=0)}q.H=dI,D=h(y,S)}while(rh);return D}function MJ(){var u=q.H,h=u.useState()[0];return h=typeof h.then=="function"?Gm(h):h,u=u.useState()[0],(Ln!==null?Ln.memoizedState:null)!==u&&(Kt.flags|=1024),h}function kM(){var u=Sv!==0;return Sv=0,u}function LM(u,h,y){h.updateQueue=u.updateQueue,h.flags&=-2053,u.lanes&=~y}function IM(u){if(_v){for(u=u.memoizedState;u!==null;){var h=u.queue;h!==null&&(h.pending=null),u=u.next}_v=!1}cl=0,Li=Ln=Kt=null,rh=!1,$m=Sv=0,ah=null}function sa(){var u={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Li===null?Kt.memoizedState=Li=u:Li=Li.next=u,Li}function Ci(){if(Ln===null){var u=Kt.alternate;u=u!==null?u.memoizedState:null}else u=Ln.next;var h=Li===null?Kt.memoizedState:Li.next;if(h!==null)Li=h,Ln=u;else{if(u===null)throw Kt.alternate===null?Error(i(467)):Error(i(310));Ln=u,u={memoizedState:Ln.memoizedState,baseState:Ln.baseState,baseQueue:Ln.baseQueue,queue:Ln.queue,next:null},Li===null?Kt.memoizedState=Li=u:Li=Li.next=u}return Li}function wv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Gm(u){var h=$m;return $m+=1,ah===null&&(ah=[]),u=yL(ah,u,h),h=Kt,(Li===null?h.memoizedState:Li.next)===null&&(h=h.alternate,q.H=h===null||h.memoizedState===null?uI:XM),u}function Mv(u){if(u!==null&&typeof u=="object"){if(typeof u.then=="function")return Gm(u);if(u.$$typeof===w)return Pr(u)}throw Error(i(438,String(u)))}function UM(u){var h=null,y=Kt.updateQueue;if(y!==null&&(h=y.memoCache),h==null){var S=Kt.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(h={data:S.data.map(function(C){return C.slice()}),index:0})))}if(h==null&&(h={data:[],index:0}),y===null&&(y=wv(),Kt.updateQueue=y),y.memoCache=h,y=h.data[h.index],y===void 0)for(y=h.data[h.index]=Array(u),S=0;S<u;S++)y[S]=O;return h.index++,y}function ul(u,h){return typeof h=="function"?h(u):h}function Ev(u){var h=Ci();return jM(h,Ln,u)}function jM(u,h,y){var S=u.queue;if(S===null)throw Error(i(311));S.lastRenderedReducer=y;var C=u.baseQueue,D=S.pending;if(D!==null){if(C!==null){var V=C.next;C.next=D.next,D.next=V}h.baseQueue=C=D,S.pending=null}if(D=u.baseState,C===null)u.memoizedState=D;else{h=C.next;var ne=V=null,_e=null,Fe=h,Je=!1;do{var st=Fe.lane&-536870913;if(st!==Fe.lane?(pn&st)===st:(cl&st)===st){var Ve=Fe.revertLane;if(Ve===0)_e!==null&&(_e=_e.next={lane:0,revertLane:0,gesture:null,action:Fe.action,hasEagerState:Fe.hasEagerState,eagerState:Fe.eagerState,next:null}),st===Jf&&(Je=!0);else if((cl&Ve)===Ve){Fe=Fe.next,Ve===Jf&&(Je=!0);continue}else st={lane:0,revertLane:Fe.revertLane,gesture:null,action:Fe.action,hasEagerState:Fe.hasEagerState,eagerState:Fe.eagerState,next:null},_e===null?(ne=_e=st,V=D):_e=_e.next=st,Kt.lanes|=Ve,Fc|=Ve;st=Fe.action,bd&&y(D,st),D=Fe.hasEagerState?Fe.eagerState:y(D,st)}else Ve={lane:st,revertLane:Fe.revertLane,gesture:Fe.gesture,action:Fe.action,hasEagerState:Fe.hasEagerState,eagerState:Fe.eagerState,next:null},_e===null?(ne=_e=Ve,V=D):_e=_e.next=Ve,Kt.lanes|=st,Fc|=st;Fe=Fe.next}while(Fe!==null&&Fe!==h);if(_e===null?V=D:_e.next=ne,!Ha(D,u.memoizedState)&&(Ii=!0,Je&&(y=eh,y!==null)))throw y;u.memoizedState=D,u.baseState=V,u.baseQueue=_e,S.lastRenderedState=D}return C===null&&(S.lanes=0),[u.memoizedState,S.dispatch]}function FM(u){var h=Ci(),y=h.queue;if(y===null)throw Error(i(311));y.lastRenderedReducer=u;var S=y.dispatch,C=y.pending,D=h.memoizedState;if(C!==null){y.pending=null;var V=C=C.next;do D=u(D,V.action),V=V.next;while(V!==C);Ha(D,h.memoizedState)||(Ii=!0),h.memoizedState=D,h.baseQueue===null&&(h.baseState=D),y.lastRenderedState=D}return[D,S]}function RL(u,h,y){var S=Kt,C=Ci(),D=vn;if(D){if(y===void 0)throw Error(i(407));y=y()}else y=h();var V=!Ha((Ln||C).memoizedState,y);if(V&&(C.memoizedState=y,Ii=!0),C=C.queue,HM(OL.bind(null,S,C,u),[u]),C.getSnapshot!==h||V||Li!==null&&Li.memoizedState.tag&1){if(S.flags|=2048,sh(9,{destroy:void 0},DL.bind(null,S,C,y,h),null),Wn===null)throw Error(i(349));D||(cl&127)!==0||PL(S,h,y)}return y}function PL(u,h,y){u.flags|=16384,u={getSnapshot:h,value:y},h=Kt.updateQueue,h===null?(h=wv(),Kt.updateQueue=h,h.stores=[u]):(y=h.stores,y===null?h.stores=[u]:y.push(u))}function DL(u,h,y,S){h.value=y,h.getSnapshot=S,kL(h)&&LL(u)}function OL(u,h,y){return y(function(){kL(h)&&LL(u)})}function kL(u){var h=u.getSnapshot;u=u.value;try{var y=h();return!Ha(u,y)}catch{return!0}}function LL(u){var h=dd(u,2);h!==null&&Aa(h,u,2)}function zM(u){var h=sa();if(typeof u=="function"){var y=u;if(u=y(),bd){ht(!0);try{y()}finally{ht(!1)}}}return h.memoizedState=h.baseState=u,h.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ul,lastRenderedState:u},h}function IL(u,h,y,S){return u.baseState=y,jM(u,Ln,typeof S=="function"?S:ul)}function EJ(u,h,y,S,C){if(Cv(u))throw Error(i(485));if(u=h.action,u!==null){var D={payload:C,action:u,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(V){D.listeners.push(V)}};q.T!==null?y(!0):D.isTransition=!1,S(D),y=h.pending,y===null?(D.next=h.pending=D,UL(h,D)):(D.next=y.next,h.pending=y.next=D)}}function UL(u,h){var y=h.action,S=h.payload,C=u.state;if(h.isTransition){var D=q.T,V={};q.T=V;try{var ne=y(C,S),_e=q.S;_e!==null&&_e(V,ne),jL(u,h,ne)}catch(Fe){BM(u,h,Fe)}finally{D!==null&&V.types!==null&&(D.types=V.types),q.T=D}}else try{D=y(C,S),jL(u,h,D)}catch(Fe){BM(u,h,Fe)}}function jL(u,h,y){y!==null&&typeof y=="object"&&typeof y.then=="function"?y.then(function(S){FL(u,h,S)},function(S){return BM(u,h,S)}):FL(u,h,y)}function FL(u,h,y){h.status="fulfilled",h.value=y,zL(h),u.state=y,h=u.pending,h!==null&&(y=h.next,y===h?u.pending=null:(y=y.next,h.next=y,UL(u,y)))}function BM(u,h,y){var S=u.pending;if(u.pending=null,S!==null){S=S.next;do h.status="rejected",h.reason=y,zL(h),h=h.next;while(h!==S)}u.action=null}function zL(u){u=u.listeners;for(var h=0;h<u.length;h++)(0,u[h])()}function BL(u,h){return h}function HL(u,h){if(vn){var y=Wn.formState;if(y!==null){e:{var S=Kt;if(vn){if(Jn){t:{for(var C=Jn,D=xs;C.nodeType!==8;){if(!D){C=null;break t}if(C=ys(C.nextSibling),C===null){C=null;break t}}D=C.data,C=D==="F!"||D==="F"?C:null}if(C){Jn=ys(C.nextSibling),S=C.data==="F!";break e}}Rc(S)}S=!1}S&&(h=y[0])}}return y=sa(),y.memoizedState=y.baseState=h,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:BL,lastRenderedState:h},y.queue=S,y=oI.bind(null,Kt,S),S.dispatch=y,S=zM(!1),D=qM.bind(null,Kt,!1,S.queue),S=sa(),C={state:h,dispatch:null,action:u,pending:null},S.queue=C,y=EJ.bind(null,Kt,C,D,y),C.dispatch=y,S.memoizedState=u,[h,y,!1]}function VL(u){var h=Ci();return $L(h,Ln,u)}function $L(u,h,y){if(h=jM(u,h,BL)[0],u=Ev(ul)[0],typeof h=="object"&&h!==null&&typeof h.then=="function")try{var S=Gm(h)}catch(V){throw V===th?mv:V}else S=h;h=Ci();var C=h.queue,D=C.dispatch;return y!==h.memoizedState&&(Kt.flags|=2048,sh(9,{destroy:void 0},AJ.bind(null,C,y),null)),[S,D,u]}function AJ(u,h){u.action=h}function GL(u){var h=Ci(),y=Ln;if(y!==null)return $L(h,y,u);Ci(),h=h.memoizedState,y=Ci();var S=y.queue.dispatch;return y.memoizedState=u,[h,S,!1]}function sh(u,h,y,S){return u={tag:u,create:y,deps:S,inst:h,next:null},h=Kt.updateQueue,h===null&&(h=wv(),Kt.updateQueue=h),y=h.lastEffect,y===null?h.lastEffect=u.next=u:(S=y.next,y.next=u,u.next=S,h.lastEffect=u),u}function WL(){return Ci().memoizedState}function Av(u,h,y,S){var C=sa();Kt.flags|=u,C.memoizedState=sh(1|h,{destroy:void 0},y,S===void 0?null:S)}function Tv(u,h,y,S){var C=Ci();S=S===void 0?null:S;var D=C.memoizedState.inst;Ln!==null&&S!==null&&DM(S,Ln.memoizedState.deps)?C.memoizedState=sh(h,D,y,S):(Kt.flags|=u,C.memoizedState=sh(1|h,D,y,S))}function qL(u,h){Av(8390656,8,u,h)}function HM(u,h){Tv(2048,8,u,h)}function TJ(u){Kt.flags|=4;var h=Kt.updateQueue;if(h===null)h=wv(),Kt.updateQueue=h,h.events=[u];else{var y=h.events;y===null?h.events=[u]:y.push(u)}}function XL(u){var h=Ci().memoizedState;return TJ({ref:h,nextImpl:u}),function(){if((An&2)!==0)throw Error(i(440));return h.impl.apply(void 0,arguments)}}function KL(u,h){return Tv(4,2,u,h)}function YL(u,h){return Tv(4,4,u,h)}function ZL(u,h){if(typeof h=="function"){u=u();var y=h(u);return function(){typeof y=="function"?y():h(null)}}if(h!=null)return u=u(),h.current=u,function(){h.current=null}}function QL(u,h,y){y=y!=null?y.concat([u]):null,Tv(4,4,ZL.bind(null,h,u),y)}function VM(){}function JL(u,h){var y=Ci();h=h===void 0?null:h;var S=y.memoizedState;return h!==null&&DM(h,S[1])?S[0]:(y.memoizedState=[u,h],u)}function eI(u,h){var y=Ci();h=h===void 0?null:h;var S=y.memoizedState;if(h!==null&&DM(h,S[1]))return S[0];if(S=u(),bd){ht(!0);try{u()}finally{ht(!1)}}return y.memoizedState=[S,h],S}function $M(u,h,y){return y===void 0||(cl&1073741824)!==0&&(pn&261930)===0?u.memoizedState=h:(u.memoizedState=y,u=tU(),Kt.lanes|=u,Fc|=u,y)}function tI(u,h,y,S){return Ha(y,h)?y:ih.current!==null?(u=$M(u,y,S),Ha(u,h)||(Ii=!0),u):(cl&42)===0||(cl&1073741824)!==0&&(pn&261930)===0?(Ii=!0,u.memoizedState=y):(u=tU(),Kt.lanes|=u,Fc|=u,h)}function nI(u,h,y,S,C){var D=W.p;W.p=D!==0&&8>D?D:8;var V=q.T,ne={};q.T=ne,qM(u,!1,h,y);try{var _e=C(),Fe=q.S;if(Fe!==null&&Fe(ne,_e),_e!==null&&typeof _e=="object"&&typeof _e.then=="function"){var Je=SJ(_e,S);Wm(u,h,Je,Xa(u))}else Wm(u,h,S,Xa(u))}catch(st){Wm(u,h,{then:function(){},status:"rejected",reason:st},Xa())}finally{W.p=D,V!==null&&ne.types!==null&&(V.types=ne.types),q.T=V}}function CJ(){}function GM(u,h,y,S){if(u.tag!==5)throw Error(i(476));var C=iI(u).queue;nI(u,C,h,X,y===null?CJ:function(){return rI(u),y(S)})}function iI(u){var h=u.memoizedState;if(h!==null)return h;h={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ul,lastRenderedState:X},next:null};var y={};return h.next={memoizedState:y,baseState:y,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ul,lastRenderedState:y},next:null},u.memoizedState=h,u=u.alternate,u!==null&&(u.memoizedState=h),h}function rI(u){var h=iI(u);h.next===null&&(h=u.alternate.memoizedState),Wm(u,h.next.queue,{},Xa())}function WM(){return Pr(cg)}function aI(){return Ci().memoizedState}function sI(){return Ci().memoizedState}function NJ(u){for(var h=u.return;h!==null;){switch(h.tag){case 24:case 3:var y=Xa();u=Oc(y);var S=kc(h,u,y);S!==null&&(Aa(S,h,y),Bm(S,h,y)),h={cache:_M()},u.payload=h;return}h=h.return}}function RJ(u,h,y){var S=Xa();y={lane:S,revertLane:0,gesture:null,action:y,hasEagerState:!1,eagerState:null,next:null},Cv(u)?lI(h,y):(y=uM(u,h,y,S),y!==null&&(Aa(y,u,S),cI(y,h,S)))}function oI(u,h,y){var S=Xa();Wm(u,h,y,S)}function Wm(u,h,y,S){var C={lane:S,revertLane:0,gesture:null,action:y,hasEagerState:!1,eagerState:null,next:null};if(Cv(u))lI(h,C);else{var D=u.alternate;if(u.lanes===0&&(D===null||D.lanes===0)&&(D=h.lastRenderedReducer,D!==null))try{var V=h.lastRenderedState,ne=D(V,y);if(C.hasEagerState=!0,C.eagerState=ne,Ha(ne,V))return lv(u,h,C,0),Wn===null&&ov(),!1}catch{}finally{}if(y=uM(u,h,C,S),y!==null)return Aa(y,u,S),cI(y,h,S),!0}return!1}function qM(u,h,y,S){if(S={lane:2,revertLane:EE(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Cv(u)){if(h)throw Error(i(479))}else h=uM(u,y,S,2),h!==null&&Aa(h,u,2)}function Cv(u){var h=u.alternate;return u===Kt||h!==null&&h===Kt}function lI(u,h){rh=_v=!0;var y=u.pending;y===null?h.next=h:(h.next=y.next,y.next=h),u.pending=h}function cI(u,h,y){if((y&4194048)!==0){var S=h.lanes;S&=u.pendingLanes,y|=S,h.lanes=y,Gn(u,y)}}var qm={readContext:Pr,use:Mv,useCallback:yi,useContext:yi,useEffect:yi,useImperativeHandle:yi,useLayoutEffect:yi,useInsertionEffect:yi,useMemo:yi,useReducer:yi,useRef:yi,useState:yi,useDebugValue:yi,useDeferredValue:yi,useTransition:yi,useSyncExternalStore:yi,useId:yi,useHostTransitionStatus:yi,useFormState:yi,useActionState:yi,useOptimistic:yi,useMemoCache:yi,useCacheRefresh:yi};qm.useEffectEvent=yi;var uI={readContext:Pr,use:Mv,useCallback:function(u,h){return sa().memoizedState=[u,h===void 0?null:h],u},useContext:Pr,useEffect:qL,useImperativeHandle:function(u,h,y){y=y!=null?y.concat([u]):null,Av(4194308,4,ZL.bind(null,h,u),y)},useLayoutEffect:function(u,h){return Av(4194308,4,u,h)},useInsertionEffect:function(u,h){Av(4,2,u,h)},useMemo:function(u,h){var y=sa();h=h===void 0?null:h;var S=u();if(bd){ht(!0);try{u()}finally{ht(!1)}}return y.memoizedState=[S,h],S},useReducer:function(u,h,y){var S=sa();if(y!==void 0){var C=y(h);if(bd){ht(!0);try{y(h)}finally{ht(!1)}}}else C=h;return S.memoizedState=S.baseState=C,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:C},S.queue=u,u=u.dispatch=RJ.bind(null,Kt,u),[S.memoizedState,u]},useRef:function(u){var h=sa();return u={current:u},h.memoizedState=u},useState:function(u){u=zM(u);var h=u.queue,y=oI.bind(null,Kt,h);return h.dispatch=y,[u.memoizedState,y]},useDebugValue:VM,useDeferredValue:function(u,h){var y=sa();return $M(y,u,h)},useTransition:function(){var u=zM(!1);return u=nI.bind(null,Kt,u.queue,!0,!1),sa().memoizedState=u,[!1,u]},useSyncExternalStore:function(u,h,y){var S=Kt,C=sa();if(vn){if(y===void 0)throw Error(i(407));y=y()}else{if(y=h(),Wn===null)throw Error(i(349));(pn&127)!==0||PL(S,h,y)}C.memoizedState=y;var D={value:y,getSnapshot:h};return C.queue=D,qL(OL.bind(null,S,D,u),[u]),S.flags|=2048,sh(9,{destroy:void 0},DL.bind(null,S,D,y,h),null),y},useId:function(){var u=sa(),h=Wn.identifierPrefix;if(vn){var y=Ao,S=Eo;y=(S&~(1<<32-tt(S)-1)).toString(32)+y,h="_"+h+"R_"+y,y=Sv++,0<y&&(h+="H"+y.toString(32)),h+="_"}else y=wJ++,h="_"+h+"r_"+y.toString(32)+"_";return u.memoizedState=h},useHostTransitionStatus:WM,useFormState:HL,useActionState:HL,useOptimistic:function(u){var h=sa();h.memoizedState=h.baseState=u;var y={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return h.queue=y,h=qM.bind(null,Kt,!0,y),y.dispatch=h,[u,h]},useMemoCache:UM,useCacheRefresh:function(){return sa().memoizedState=NJ.bind(null,Kt)},useEffectEvent:function(u){var h=sa(),y={impl:u};return h.memoizedState=y,function(){if((An&2)!==0)throw Error(i(440));return y.impl.apply(void 0,arguments)}}},XM={readContext:Pr,use:Mv,useCallback:JL,useContext:Pr,useEffect:HM,useImperativeHandle:QL,useInsertionEffect:KL,useLayoutEffect:YL,useMemo:eI,useReducer:Ev,useRef:WL,useState:function(){return Ev(ul)},useDebugValue:VM,useDeferredValue:function(u,h){var y=Ci();return tI(y,Ln.memoizedState,u,h)},useTransition:function(){var u=Ev(ul)[0],h=Ci().memoizedState;return[typeof u=="boolean"?u:Gm(u),h]},useSyncExternalStore:RL,useId:aI,useHostTransitionStatus:WM,useFormState:VL,useActionState:VL,useOptimistic:function(u,h){var y=Ci();return IL(y,Ln,u,h)},useMemoCache:UM,useCacheRefresh:sI};XM.useEffectEvent=XL;var dI={readContext:Pr,use:Mv,useCallback:JL,useContext:Pr,useEffect:HM,useImperativeHandle:QL,useInsertionEffect:KL,useLayoutEffect:YL,useMemo:eI,useReducer:FM,useRef:WL,useState:function(){return FM(ul)},useDebugValue:VM,useDeferredValue:function(u,h){var y=Ci();return Ln===null?$M(y,u,h):tI(y,Ln.memoizedState,u,h)},useTransition:function(){var u=FM(ul)[0],h=Ci().memoizedState;return[typeof u=="boolean"?u:Gm(u),h]},useSyncExternalStore:RL,useId:aI,useHostTransitionStatus:WM,useFormState:GL,useActionState:GL,useOptimistic:function(u,h){var y=Ci();return Ln!==null?IL(y,Ln,u,h):(y.baseState=u,[u,y.queue.dispatch])},useMemoCache:UM,useCacheRefresh:sI};dI.useEffectEvent=XL;function KM(u,h,y,S){h=u.memoizedState,y=y(S,h),y=y==null?h:f({},h,y),u.memoizedState=y,u.lanes===0&&(u.updateQueue.baseState=y)}var YM={enqueueSetState:function(u,h,y){u=u._reactInternals;var S=Xa(),C=Oc(S);C.payload=h,y!=null&&(C.callback=y),h=kc(u,C,S),h!==null&&(Aa(h,u,S),Bm(h,u,S))},enqueueReplaceState:function(u,h,y){u=u._reactInternals;var S=Xa(),C=Oc(S);C.tag=1,C.payload=h,y!=null&&(C.callback=y),h=kc(u,C,S),h!==null&&(Aa(h,u,S),Bm(h,u,S))},enqueueForceUpdate:function(u,h){u=u._reactInternals;var y=Xa(),S=Oc(y);S.tag=2,h!=null&&(S.callback=h),h=kc(u,S,y),h!==null&&(Aa(h,u,y),Bm(h,u,y))}};function fI(u,h,y,S,C,D,V){return u=u.stateNode,typeof u.shouldComponentUpdate=="function"?u.shouldComponentUpdate(S,D,V):h.prototype&&h.prototype.isPureReactComponent?!Om(y,S)||!Om(C,D):!0}function hI(u,h,y,S){u=h.state,typeof h.componentWillReceiveProps=="function"&&h.componentWillReceiveProps(y,S),typeof h.UNSAFE_componentWillReceiveProps=="function"&&h.UNSAFE_componentWillReceiveProps(y,S),h.state!==u&&YM.enqueueReplaceState(h,h.state,null)}function _d(u,h){var y=h;if("ref"in h){y={};for(var S in h)S!=="ref"&&(y[S]=h[S])}if(u=u.defaultProps){y===h&&(y=f({},y));for(var C in u)y[C]===void 0&&(y[C]=u[C])}return y}function pI(u){sv(u)}function mI(u){console.error(u)}function gI(u){sv(u)}function Nv(u,h){try{var y=u.onUncaughtError;y(h.value,{componentStack:h.stack})}catch(S){setTimeout(function(){throw S})}}function xI(u,h,y){try{var S=u.onCaughtError;S(y.value,{componentStack:y.stack,errorBoundary:h.tag===1?h.stateNode:null})}catch(C){setTimeout(function(){throw C})}}function ZM(u,h,y){return y=Oc(y),y.tag=3,y.payload={element:null},y.callback=function(){Nv(u,h)},y}function vI(u){return u=Oc(u),u.tag=3,u}function yI(u,h,y,S){var C=y.type.getDerivedStateFromError;if(typeof C=="function"){var D=S.value;u.payload=function(){return C(D)},u.callback=function(){xI(h,y,S)}}var V=y.stateNode;V!==null&&typeof V.componentDidCatch=="function"&&(u.callback=function(){xI(h,y,S),typeof C!="function"&&(zc===null?zc=new Set([this]):zc.add(this));var ne=S.stack;this.componentDidCatch(S.value,{componentStack:ne!==null?ne:""})})}function PJ(u,h,y,S,C){if(y.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(h=y.alternate,h!==null&&Qf(h,y,C,!0),y=$a.current,y!==null){switch(y.tag){case 31:case 13:return vs===null?Bv():y.alternate===null&&bi===0&&(bi=3),y.flags&=-257,y.flags|=65536,y.lanes=C,S===gv?y.flags|=16384:(h=y.updateQueue,h===null?y.updateQueue=new Set([S]):h.add(S),SE(u,S,C)),!1;case 22:return y.flags|=65536,S===gv?y.flags|=16384:(h=y.updateQueue,h===null?(h={transitions:null,markerInstances:null,retryQueue:new Set([S])},y.updateQueue=h):(y=h.retryQueue,y===null?h.retryQueue=new Set([S]):y.add(S)),SE(u,S,C)),!1}throw Error(i(435,y.tag))}return SE(u,S,C),Bv(),!1}if(vn)return h=$a.current,h!==null?((h.flags&65536)===0&&(h.flags|=256),h.flags|=65536,h.lanes=C,S!==gM&&(u=Error(i(422),{cause:S}),Im(ps(u,y)))):(S!==gM&&(h=Error(i(423),{cause:S}),Im(ps(h,y))),u=u.current.alternate,u.flags|=65536,C&=-C,u.lanes|=C,S=ps(S,y),C=ZM(u.stateNode,S,C),TM(u,C),bi!==4&&(bi=2)),!1;var D=Error(i(520),{cause:S});if(D=ps(D,y),tg===null?tg=[D]:tg.push(D),bi!==4&&(bi=2),h===null)return!0;S=ps(S,y),y=h;do{switch(y.tag){case 3:return y.flags|=65536,u=C&-C,y.lanes|=u,u=ZM(y.stateNode,S,u),TM(y,u),!1;case 1:if(h=y.type,D=y.stateNode,(y.flags&128)===0&&(typeof h.getDerivedStateFromError=="function"||D!==null&&typeof D.componentDidCatch=="function"&&(zc===null||!zc.has(D))))return y.flags|=65536,C&=-C,y.lanes|=C,C=vI(C),yI(C,u,y,S),TM(y,C),!1}y=y.return}while(y!==null);return!1}var QM=Error(i(461)),Ii=!1;function Dr(u,h,y,S){h.child=u===null?wL(h,null,y,S):yd(h,u.child,y,S)}function bI(u,h,y,S,C){y=y.render;var D=h.ref;if("ref"in S){var V={};for(var ne in S)ne!=="ref"&&(V[ne]=S[ne])}else V=S;return md(h),S=OM(u,h,y,V,D,C),ne=kM(),u!==null&&!Ii?(LM(u,h,C),dl(u,h,C)):(vn&&ne&&pM(h),h.flags|=1,Dr(u,h,S,C),h.child)}function _I(u,h,y,S,C){if(u===null){var D=y.type;return typeof D=="function"&&!dM(D)&&D.defaultProps===void 0&&y.compare===null?(h.tag=15,h.type=D,SI(u,h,D,S,C)):(u=uv(y.type,null,S,h,h.mode,C),u.ref=h.ref,u.return=h,h.child=u)}if(D=u.child,!sE(u,C)){var V=D.memoizedProps;if(y=y.compare,y=y!==null?y:Om,y(V,S)&&u.ref===h.ref)return dl(u,h,C)}return h.flags|=1,u=al(D,S),u.ref=h.ref,u.return=h,h.child=u}function SI(u,h,y,S,C){if(u!==null){var D=u.memoizedProps;if(Om(D,S)&&u.ref===h.ref)if(Ii=!1,h.pendingProps=S=D,sE(u,C))(u.flags&131072)!==0&&(Ii=!0);else return h.lanes=u.lanes,dl(u,h,C)}return JM(u,h,y,S,C)}function wI(u,h,y,S){var C=S.children,D=u!==null?u.memoizedState:null;if(u===null&&h.stateNode===null&&(h.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((h.flags&128)!==0){if(D=D!==null?D.baseLanes|y:y,u!==null){for(S=h.child=u.child,C=0;S!==null;)C=C|S.lanes|S.childLanes,S=S.sibling;S=C&~D}else S=0,h.child=null;return MI(u,h,D,y,S)}if((y&536870912)!==0)h.memoizedState={baseLanes:0,cachePool:null},u!==null&&pv(h,D!==null?D.cachePool:null),D!==null?AL(h,D):NM(),TL(h);else return S=h.lanes=536870912,MI(u,h,D!==null?D.baseLanes|y:y,y,S)}else D!==null?(pv(h,D.cachePool),AL(h,D),Ic(),h.memoizedState=null):(u!==null&&pv(h,null),NM(),Ic());return Dr(u,h,C,y),h.child}function Xm(u,h){return u!==null&&u.tag===22||h.stateNode!==null||(h.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),h.sibling}function MI(u,h,y,S,C){var D=wM();return D=D===null?null:{parent:ki._currentValue,pool:D},h.memoizedState={baseLanes:y,cachePool:D},u!==null&&pv(h,null),NM(),TL(h),u!==null&&Qf(u,h,S,!0),h.childLanes=C,null}function Rv(u,h){return h=Dv({mode:h.mode,children:h.children},u.mode),h.ref=u.ref,u.child=h,h.return=u,h}function EI(u,h,y){return yd(h,u.child,null,y),u=Rv(h,h.pendingProps),u.flags|=2,Ga(h),h.memoizedState=null,u}function DJ(u,h,y){var S=h.pendingProps,C=(h.flags&128)!==0;if(h.flags&=-129,u===null){if(vn){if(S.mode==="hidden")return u=Rv(h,S),h.lanes=536870912,Xm(null,u);if(PM(h),(u=Jn)?(u=UU(u,xs),u=u!==null&&u.data==="&"?u:null,u!==null&&(h.memoizedState={dehydrated:u,treeContext:Cc!==null?{id:Eo,overflow:Ao}:null,retryLane:536870912,hydrationErrors:null},y=lL(u),y.return=h,h.child=y,Rr=h,Jn=null)):u=null,u===null)throw Rc(h);return h.lanes=536870912,null}return Rv(h,S)}var D=u.memoizedState;if(D!==null){var V=D.dehydrated;if(PM(h),C)if(h.flags&256)h.flags&=-257,h=EI(u,h,y);else if(h.memoizedState!==null)h.child=u.child,h.flags|=128,h=null;else throw Error(i(558));else if(Ii||Qf(u,h,y,!1),C=(y&u.childLanes)!==0,Ii||C){if(S=Wn,S!==null&&(V=fr(S,y),V!==0&&V!==D.retryLane))throw D.retryLane=V,dd(u,V),Aa(S,u,V),QM;Bv(),h=EI(u,h,y)}else u=D.treeContext,Jn=ys(V.nextSibling),Rr=h,vn=!0,Nc=null,xs=!1,u!==null&&dL(h,u),h=Rv(h,S),h.flags|=4096;return h}return u=al(u.child,{mode:S.mode,children:S.children}),u.ref=h.ref,h.child=u,u.return=h,u}function Pv(u,h){var y=h.ref;if(y===null)u!==null&&u.ref!==null&&(h.flags|=4194816);else{if(typeof y!="function"&&typeof y!="object")throw Error(i(284));(u===null||u.ref!==y)&&(h.flags|=4194816)}}function JM(u,h,y,S,C){return md(h),y=OM(u,h,y,S,void 0,C),S=kM(),u!==null&&!Ii?(LM(u,h,C),dl(u,h,C)):(vn&&S&&pM(h),h.flags|=1,Dr(u,h,y,C),h.child)}function AI(u,h,y,S,C,D){return md(h),h.updateQueue=null,y=NL(h,S,y,C),CL(u),S=kM(),u!==null&&!Ii?(LM(u,h,D),dl(u,h,D)):(vn&&S&&pM(h),h.flags|=1,Dr(u,h,y,D),h.child)}function TI(u,h,y,S,C){if(md(h),h.stateNode===null){var D=Xf,V=y.contextType;typeof V=="object"&&V!==null&&(D=Pr(V)),D=new y(S,D),h.memoizedState=D.state!==null&&D.state!==void 0?D.state:null,D.updater=YM,h.stateNode=D,D._reactInternals=h,D=h.stateNode,D.props=S,D.state=h.memoizedState,D.refs={},EM(h),V=y.contextType,D.context=typeof V=="object"&&V!==null?Pr(V):Xf,D.state=h.memoizedState,V=y.getDerivedStateFromProps,typeof V=="function"&&(KM(h,y,V,S),D.state=h.memoizedState),typeof y.getDerivedStateFromProps=="function"||typeof D.getSnapshotBeforeUpdate=="function"||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(V=D.state,typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount(),V!==D.state&&YM.enqueueReplaceState(D,D.state,null),Vm(h,S,D,C),Hm(),D.state=h.memoizedState),typeof D.componentDidMount=="function"&&(h.flags|=4194308),S=!0}else if(u===null){D=h.stateNode;var ne=h.memoizedProps,_e=_d(y,ne);D.props=_e;var Fe=D.context,Je=y.contextType;V=Xf,typeof Je=="object"&&Je!==null&&(V=Pr(Je));var st=y.getDerivedStateFromProps;Je=typeof st=="function"||typeof D.getSnapshotBeforeUpdate=="function",ne=h.pendingProps!==ne,Je||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(ne||Fe!==V)&&hI(h,D,S,V),Dc=!1;var Ve=h.memoizedState;D.state=Ve,Vm(h,S,D,C),Hm(),Fe=h.memoizedState,ne||Ve!==Fe||Dc?(typeof st=="function"&&(KM(h,y,st,S),Fe=h.memoizedState),(_e=Dc||fI(h,y,_e,S,Ve,Fe,V))?(Je||typeof D.UNSAFE_componentWillMount!="function"&&typeof D.componentWillMount!="function"||(typeof D.componentWillMount=="function"&&D.componentWillMount(),typeof D.UNSAFE_componentWillMount=="function"&&D.UNSAFE_componentWillMount()),typeof D.componentDidMount=="function"&&(h.flags|=4194308)):(typeof D.componentDidMount=="function"&&(h.flags|=4194308),h.memoizedProps=S,h.memoizedState=Fe),D.props=S,D.state=Fe,D.context=V,S=_e):(typeof D.componentDidMount=="function"&&(h.flags|=4194308),S=!1)}else{D=h.stateNode,AM(u,h),V=h.memoizedProps,Je=_d(y,V),D.props=Je,st=h.pendingProps,Ve=D.context,Fe=y.contextType,_e=Xf,typeof Fe=="object"&&Fe!==null&&(_e=Pr(Fe)),ne=y.getDerivedStateFromProps,(Fe=typeof ne=="function"||typeof D.getSnapshotBeforeUpdate=="function")||typeof D.UNSAFE_componentWillReceiveProps!="function"&&typeof D.componentWillReceiveProps!="function"||(V!==st||Ve!==_e)&&hI(h,D,S,_e),Dc=!1,Ve=h.memoizedState,D.state=Ve,Vm(h,S,D,C),Hm();var Ke=h.memoizedState;V!==st||Ve!==Ke||Dc||u!==null&&u.dependencies!==null&&fv(u.dependencies)?(typeof ne=="function"&&(KM(h,y,ne,S),Ke=h.memoizedState),(Je=Dc||fI(h,y,Je,S,Ve,Ke,_e)||u!==null&&u.dependencies!==null&&fv(u.dependencies))?(Fe||typeof D.UNSAFE_componentWillUpdate!="function"&&typeof D.componentWillUpdate!="function"||(typeof D.componentWillUpdate=="function"&&D.componentWillUpdate(S,Ke,_e),typeof D.UNSAFE_componentWillUpdate=="function"&&D.UNSAFE_componentWillUpdate(S,Ke,_e)),typeof D.componentDidUpdate=="function"&&(h.flags|=4),typeof D.getSnapshotBeforeUpdate=="function"&&(h.flags|=1024)):(typeof D.componentDidUpdate!="function"||V===u.memoizedProps&&Ve===u.memoizedState||(h.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||V===u.memoizedProps&&Ve===u.memoizedState||(h.flags|=1024),h.memoizedProps=S,h.memoizedState=Ke),D.props=S,D.state=Ke,D.context=_e,S=Je):(typeof D.componentDidUpdate!="function"||V===u.memoizedProps&&Ve===u.memoizedState||(h.flags|=4),typeof D.getSnapshotBeforeUpdate!="function"||V===u.memoizedProps&&Ve===u.memoizedState||(h.flags|=1024),S=!1)}return D=S,Pv(u,h),S=(h.flags&128)!==0,D||S?(D=h.stateNode,y=S&&typeof y.getDerivedStateFromError!="function"?null:D.render(),h.flags|=1,u!==null&&S?(h.child=yd(h,u.child,null,C),h.child=yd(h,null,y,C)):Dr(u,h,y,C),h.memoizedState=D.state,u=h.child):u=dl(u,h,C),u}function CI(u,h,y,S){return hd(),h.flags|=256,Dr(u,h,y,S),h.child}var eE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function tE(u){return{baseLanes:u,cachePool:xL()}}function nE(u,h,y){return u=u!==null?u.childLanes&~y:0,h&&(u|=qa),u}function NI(u,h,y){var S=h.pendingProps,C=!1,D=(h.flags&128)!==0,V;if((V=D)||(V=u!==null&&u.memoizedState===null?!1:(Ti.current&2)!==0),V&&(C=!0,h.flags&=-129),V=(h.flags&32)!==0,h.flags&=-33,u===null){if(vn){if(C?Lc(h):Ic(),(u=Jn)?(u=UU(u,xs),u=u!==null&&u.data!=="&"?u:null,u!==null&&(h.memoizedState={dehydrated:u,treeContext:Cc!==null?{id:Eo,overflow:Ao}:null,retryLane:536870912,hydrationErrors:null},y=lL(u),y.return=h,h.child=y,Rr=h,Jn=null)):u=null,u===null)throw Rc(h);return jE(u)?h.lanes=32:h.lanes=536870912,null}var ne=S.children;return S=S.fallback,C?(Ic(),C=h.mode,ne=Dv({mode:"hidden",children:ne},C),S=fd(S,C,y,null),ne.return=h,S.return=h,ne.sibling=S,h.child=ne,S=h.child,S.memoizedState=tE(y),S.childLanes=nE(u,V,y),h.memoizedState=eE,Xm(null,S)):(Lc(h),iE(h,ne))}var _e=u.memoizedState;if(_e!==null&&(ne=_e.dehydrated,ne!==null)){if(D)h.flags&256?(Lc(h),h.flags&=-257,h=rE(u,h,y)):h.memoizedState!==null?(Ic(),h.child=u.child,h.flags|=128,h=null):(Ic(),ne=S.fallback,C=h.mode,S=Dv({mode:"visible",children:S.children},C),ne=fd(ne,C,y,null),ne.flags|=2,S.return=h,ne.return=h,S.sibling=ne,h.child=S,yd(h,u.child,null,y),S=h.child,S.memoizedState=tE(y),S.childLanes=nE(u,V,y),h.memoizedState=eE,h=Xm(null,S));else if(Lc(h),jE(ne)){if(V=ne.nextSibling&&ne.nextSibling.dataset,V)var Fe=V.dgst;V=Fe,S=Error(i(419)),S.stack="",S.digest=V,Im({value:S,source:null,stack:null}),h=rE(u,h,y)}else if(Ii||Qf(u,h,y,!1),V=(y&u.childLanes)!==0,Ii||V){if(V=Wn,V!==null&&(S=fr(V,y),S!==0&&S!==_e.retryLane))throw _e.retryLane=S,dd(u,S),Aa(V,u,S),QM;UE(ne)||Bv(),h=rE(u,h,y)}else UE(ne)?(h.flags|=192,h.child=u.child,h=null):(u=_e.treeContext,Jn=ys(ne.nextSibling),Rr=h,vn=!0,Nc=null,xs=!1,u!==null&&dL(h,u),h=iE(h,S.children),h.flags|=4096);return h}return C?(Ic(),ne=S.fallback,C=h.mode,_e=u.child,Fe=_e.sibling,S=al(_e,{mode:"hidden",children:S.children}),S.subtreeFlags=_e.subtreeFlags&65011712,Fe!==null?ne=al(Fe,ne):(ne=fd(ne,C,y,null),ne.flags|=2),ne.return=h,S.return=h,S.sibling=ne,h.child=S,Xm(null,S),S=h.child,ne=u.child.memoizedState,ne===null?ne=tE(y):(C=ne.cachePool,C!==null?(_e=ki._currentValue,C=C.parent!==_e?{parent:_e,pool:_e}:C):C=xL(),ne={baseLanes:ne.baseLanes|y,cachePool:C}),S.memoizedState=ne,S.childLanes=nE(u,V,y),h.memoizedState=eE,Xm(u.child,S)):(Lc(h),y=u.child,u=y.sibling,y=al(y,{mode:"visible",children:S.children}),y.return=h,y.sibling=null,u!==null&&(V=h.deletions,V===null?(h.deletions=[u],h.flags|=16):V.push(u)),h.child=y,h.memoizedState=null,y)}function iE(u,h){return h=Dv({mode:"visible",children:h},u.mode),h.return=u,u.child=h}function Dv(u,h){return u=Va(22,u,null,h),u.lanes=0,u}function rE(u,h,y){return yd(h,u.child,null,y),u=iE(h,h.pendingProps.children),u.flags|=2,h.memoizedState=null,u}function RI(u,h,y){u.lanes|=h;var S=u.alternate;S!==null&&(S.lanes|=h),yM(u.return,h,y)}function aE(u,h,y,S,C,D){var V=u.memoizedState;V===null?u.memoizedState={isBackwards:h,rendering:null,renderingStartTime:0,last:S,tail:y,tailMode:C,treeForkCount:D}:(V.isBackwards=h,V.rendering=null,V.renderingStartTime=0,V.last=S,V.tail=y,V.tailMode=C,V.treeForkCount=D)}function PI(u,h,y){var S=h.pendingProps,C=S.revealOrder,D=S.tail;S=S.children;var V=Ti.current,ne=(V&2)!==0;if(ne?(V=V&1|2,h.flags|=128):V&=1,se(Ti,V),Dr(u,h,S,y),S=vn?Lm:0,!ne&&u!==null&&(u.flags&128)!==0)e:for(u=h.child;u!==null;){if(u.tag===13)u.memoizedState!==null&&RI(u,y,h);else if(u.tag===19)RI(u,y,h);else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===h)break e;for(;u.sibling===null;){if(u.return===null||u.return===h)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}switch(C){case"forwards":for(y=h.child,C=null;y!==null;)u=y.alternate,u!==null&&bv(u)===null&&(C=y),y=y.sibling;y=C,y===null?(C=h.child,h.child=null):(C=y.sibling,y.sibling=null),aE(h,!1,C,y,D,S);break;case"backwards":case"unstable_legacy-backwards":for(y=null,C=h.child,h.child=null;C!==null;){if(u=C.alternate,u!==null&&bv(u)===null){h.child=C;break}u=C.sibling,C.sibling=y,y=C,C=u}aE(h,!0,y,null,D,S);break;case"together":aE(h,!1,null,null,void 0,S);break;default:h.memoizedState=null}return h.child}function dl(u,h,y){if(u!==null&&(h.dependencies=u.dependencies),Fc|=h.lanes,(y&h.childLanes)===0)if(u!==null){if(Qf(u,h,y,!1),(y&h.childLanes)===0)return null}else return null;if(u!==null&&h.child!==u.child)throw Error(i(153));if(h.child!==null){for(u=h.child,y=al(u,u.pendingProps),h.child=y,y.return=h;u.sibling!==null;)u=u.sibling,y=y.sibling=al(u,u.pendingProps),y.return=h;y.sibling=null}return h.child}function sE(u,h){return(u.lanes&h)!==0?!0:(u=u.dependencies,!!(u!==null&&fv(u)))}function OJ(u,h,y){switch(h.tag){case 3:Pe(h,h.stateNode.containerInfo),Pc(h,ki,u.memoizedState.cache),hd();break;case 27:case 5:we(h);break;case 4:Pe(h,h.stateNode.containerInfo);break;case 10:Pc(h,h.type,h.memoizedProps.value);break;case 31:if(h.memoizedState!==null)return h.flags|=128,PM(h),null;break;case 13:var S=h.memoizedState;if(S!==null)return S.dehydrated!==null?(Lc(h),h.flags|=128,null):(y&h.child.childLanes)!==0?NI(u,h,y):(Lc(h),u=dl(u,h,y),u!==null?u.sibling:null);Lc(h);break;case 19:var C=(u.flags&128)!==0;if(S=(y&h.childLanes)!==0,S||(Qf(u,h,y,!1),S=(y&h.childLanes)!==0),C){if(S)return PI(u,h,y);h.flags|=128}if(C=h.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),se(Ti,Ti.current),S)break;return null;case 22:return h.lanes=0,wI(u,h,y,h.pendingProps);case 24:Pc(h,ki,u.memoizedState.cache)}return dl(u,h,y)}function DI(u,h,y){if(u!==null)if(u.memoizedProps!==h.pendingProps)Ii=!0;else{if(!sE(u,y)&&(h.flags&128)===0)return Ii=!1,OJ(u,h,y);Ii=(u.flags&131072)!==0}else Ii=!1,vn&&(h.flags&1048576)!==0&&uL(h,Lm,h.index);switch(h.lanes=0,h.tag){case 16:e:{var S=h.pendingProps;if(u=xd(h.elementType),h.type=u,typeof u=="function")dM(u)?(S=_d(u,S),h.tag=1,h=TI(null,h,u,S,y)):(h.tag=0,h=JM(null,h,u,S,y));else{if(u!=null){var C=u.$$typeof;if(C===E){h.tag=11,h=bI(null,h,u,S,y);break e}else if(C===N){h.tag=14,h=_I(null,h,u,S,y);break e}}throw h=L(u)||u,Error(i(306,h,""))}}return h;case 0:return JM(u,h,h.type,h.pendingProps,y);case 1:return S=h.type,C=_d(S,h.pendingProps),TI(u,h,S,C,y);case 3:e:{if(Pe(h,h.stateNode.containerInfo),u===null)throw Error(i(387));S=h.pendingProps;var D=h.memoizedState;C=D.element,AM(u,h),Vm(h,S,null,y);var V=h.memoizedState;if(S=V.cache,Pc(h,ki,S),S!==D.cache&&bM(h,[ki],y,!0),Hm(),S=V.element,D.isDehydrated)if(D={element:S,isDehydrated:!1,cache:V.cache},h.updateQueue.baseState=D,h.memoizedState=D,h.flags&256){h=CI(u,h,S,y);break e}else if(S!==C){C=ps(Error(i(424)),h),Im(C),h=CI(u,h,S,y);break e}else{switch(u=h.stateNode.containerInfo,u.nodeType){case 9:u=u.body;break;default:u=u.nodeName==="HTML"?u.ownerDocument.body:u}for(Jn=ys(u.firstChild),Rr=h,vn=!0,Nc=null,xs=!0,y=wL(h,null,S,y),h.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling}else{if(hd(),S===C){h=dl(u,h,y);break e}Dr(u,h,S,y)}h=h.child}return h;case 26:return Pv(u,h),u===null?(y=VU(h.type,null,h.pendingProps,null))?h.memoizedState=y:vn||(y=h.type,u=h.pendingProps,S=Xv(re.current).createElement(y),S[fi]=h,S[Ei]=u,Or(S,y,u),Te(S),h.stateNode=S):h.memoizedState=VU(h.type,u.memoizedProps,h.pendingProps,u.memoizedState),null;case 27:return we(h),u===null&&vn&&(S=h.stateNode=zU(h.type,h.pendingProps,re.current),Rr=h,xs=!0,C=Jn,$c(h.type)?(FE=C,Jn=ys(S.firstChild)):Jn=C),Dr(u,h,h.pendingProps.children,y),Pv(u,h),u===null&&(h.flags|=4194304),h.child;case 5:return u===null&&vn&&((C=S=Jn)&&(S=cee(S,h.type,h.pendingProps,xs),S!==null?(h.stateNode=S,Rr=h,Jn=ys(S.firstChild),xs=!1,C=!0):C=!1),C||Rc(h)),we(h),C=h.type,D=h.pendingProps,V=u!==null?u.memoizedProps:null,S=D.children,kE(C,D)?S=null:V!==null&&kE(C,V)&&(h.flags|=32),h.memoizedState!==null&&(C=OM(u,h,MJ,null,null,y),cg._currentValue=C),Pv(u,h),Dr(u,h,S,y),h.child;case 6:return u===null&&vn&&((u=y=Jn)&&(y=uee(y,h.pendingProps,xs),y!==null?(h.stateNode=y,Rr=h,Jn=null,u=!0):u=!1),u||Rc(h)),null;case 13:return NI(u,h,y);case 4:return Pe(h,h.stateNode.containerInfo),S=h.pendingProps,u===null?h.child=yd(h,null,S,y):Dr(u,h,S,y),h.child;case 11:return bI(u,h,h.type,h.pendingProps,y);case 7:return Dr(u,h,h.pendingProps,y),h.child;case 8:return Dr(u,h,h.pendingProps.children,y),h.child;case 12:return Dr(u,h,h.pendingProps.children,y),h.child;case 10:return S=h.pendingProps,Pc(h,h.type,S.value),Dr(u,h,S.children,y),h.child;case 9:return C=h.type._context,S=h.pendingProps.children,md(h),C=Pr(C),S=S(C),h.flags|=1,Dr(u,h,S,y),h.child;case 14:return _I(u,h,h.type,h.pendingProps,y);case 15:return SI(u,h,h.type,h.pendingProps,y);case 19:return PI(u,h,y);case 31:return DJ(u,h,y);case 22:return wI(u,h,y,h.pendingProps);case 24:return md(h),S=Pr(ki),u===null?(C=wM(),C===null&&(C=Wn,D=_M(),C.pooledCache=D,D.refCount++,D!==null&&(C.pooledCacheLanes|=y),C=D),h.memoizedState={parent:S,cache:C},EM(h),Pc(h,ki,C)):((u.lanes&y)!==0&&(AM(u,h),Vm(h,null,null,y),Hm()),C=u.memoizedState,D=h.memoizedState,C.parent!==S?(C={parent:S,cache:S},h.memoizedState=C,h.lanes===0&&(h.memoizedState=h.updateQueue.baseState=C),Pc(h,ki,S)):(S=D.cache,Pc(h,ki,S),S!==C.cache&&bM(h,[ki],y,!0))),Dr(u,h,h.pendingProps.children,y),h.child;case 29:throw h.pendingProps}throw Error(i(156,h.tag))}function fl(u){u.flags|=4}function oE(u,h,y,S,C){if((h=(u.mode&32)!==0)&&(h=!1),h){if(u.flags|=16777216,(C&335544128)===C)if(u.stateNode.complete)u.flags|=8192;else if(aU())u.flags|=8192;else throw vd=gv,MM}else u.flags&=-16777217}function OI(u,h){if(h.type!=="stylesheet"||(h.state.loading&4)!==0)u.flags&=-16777217;else if(u.flags|=16777216,!XU(h))if(aU())u.flags|=8192;else throw vd=gv,MM}function Ov(u,h){h!==null&&(u.flags|=4),u.flags&16384&&(h=u.tag!==22?bt():536870912,u.lanes|=h,uh|=h)}function Km(u,h){if(!vn)switch(u.tailMode){case"hidden":h=u.tail;for(var y=null;h!==null;)h.alternate!==null&&(y=h),h=h.sibling;y===null?u.tail=null:y.sibling=null;break;case"collapsed":y=u.tail;for(var S=null;y!==null;)y.alternate!==null&&(S=y),y=y.sibling;S===null?h||u.tail===null?u.tail=null:u.tail.sibling=null:S.sibling=null}}function ei(u){var h=u.alternate!==null&&u.alternate.child===u.child,y=0,S=0;if(h)for(var C=u.child;C!==null;)y|=C.lanes|C.childLanes,S|=C.subtreeFlags&65011712,S|=C.flags&65011712,C.return=u,C=C.sibling;else for(C=u.child;C!==null;)y|=C.lanes|C.childLanes,S|=C.subtreeFlags,S|=C.flags,C.return=u,C=C.sibling;return u.subtreeFlags|=S,u.childLanes=y,h}function kJ(u,h,y){var S=h.pendingProps;switch(mM(h),h.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ei(h),null;case 1:return ei(h),null;case 3:return y=h.stateNode,S=null,u!==null&&(S=u.memoizedState.cache),h.memoizedState.cache!==S&&(h.flags|=2048),ll(ki),pe(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(u===null||u.child===null)&&(Zf(h)?fl(h):u===null||u.memoizedState.isDehydrated&&(h.flags&256)===0||(h.flags|=1024,xM())),ei(h),null;case 26:var C=h.type,D=h.memoizedState;return u===null?(fl(h),D!==null?(ei(h),OI(h,D)):(ei(h),oE(h,C,null,S,y))):D?D!==u.memoizedState?(fl(h),ei(h),OI(h,D)):(ei(h),h.flags&=-16777217):(u=u.memoizedProps,u!==S&&fl(h),ei(h),oE(h,C,u,S,y)),null;case 27:if(ze(h),y=re.current,C=h.type,u!==null&&h.stateNode!=null)u.memoizedProps!==S&&fl(h);else{if(!S){if(h.stateNode===null)throw Error(i(166));return ei(h),null}u=ue.current,Zf(h)?fL(h):(u=zU(C,S,y),h.stateNode=u,fl(h))}return ei(h),null;case 5:if(ze(h),C=h.type,u!==null&&h.stateNode!=null)u.memoizedProps!==S&&fl(h);else{if(!S){if(h.stateNode===null)throw Error(i(166));return ei(h),null}if(D=ue.current,Zf(h))fL(h);else{var V=Xv(re.current);switch(D){case 1:D=V.createElementNS("http://www.w3.org/2000/svg",C);break;case 2:D=V.createElementNS("http://www.w3.org/1998/Math/MathML",C);break;default:switch(C){case"svg":D=V.createElementNS("http://www.w3.org/2000/svg",C);break;case"math":D=V.createElementNS("http://www.w3.org/1998/Math/MathML",C);break;case"script":D=V.createElement("div"),D.innerHTML="<script><\/script>",D=D.removeChild(D.firstChild);break;case"select":D=typeof S.is=="string"?V.createElement("select",{is:S.is}):V.createElement("select"),S.multiple?D.multiple=!0:S.size&&(D.size=S.size);break;default:D=typeof S.is=="string"?V.createElement(C,{is:S.is}):V.createElement(C)}}D[fi]=h,D[Ei]=S;e:for(V=h.child;V!==null;){if(V.tag===5||V.tag===6)D.appendChild(V.stateNode);else if(V.tag!==4&&V.tag!==27&&V.child!==null){V.child.return=V,V=V.child;continue}if(V===h)break e;for(;V.sibling===null;){if(V.return===null||V.return===h)break e;V=V.return}V.sibling.return=V.return,V=V.sibling}h.stateNode=D;e:switch(Or(D,C,S),C){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&fl(h)}}return ei(h),oE(h,h.type,u===null?null:u.memoizedProps,h.pendingProps,y),null;case 6:if(u&&h.stateNode!=null)u.memoizedProps!==S&&fl(h);else{if(typeof S!="string"&&h.stateNode===null)throw Error(i(166));if(u=re.current,Zf(h)){if(u=h.stateNode,y=h.memoizedProps,S=null,C=Rr,C!==null)switch(C.tag){case 27:case 5:S=C.memoizedProps}u[fi]=h,u=!!(u.nodeValue===y||S!==null&&S.suppressHydrationWarning===!0||NU(u.nodeValue,y)),u||Rc(h,!0)}else u=Xv(u).createTextNode(S),u[fi]=h,h.stateNode=u}return ei(h),null;case 31:if(y=h.memoizedState,u===null||u.memoizedState!==null){if(S=Zf(h),y!==null){if(u===null){if(!S)throw Error(i(318));if(u=h.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(i(557));u[fi]=h}else hd(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;ei(h),u=!1}else y=xM(),u!==null&&u.memoizedState!==null&&(u.memoizedState.hydrationErrors=y),u=!0;if(!u)return h.flags&256?(Ga(h),h):(Ga(h),null);if((h.flags&128)!==0)throw Error(i(558))}return ei(h),null;case 13:if(S=h.memoizedState,u===null||u.memoizedState!==null&&u.memoizedState.dehydrated!==null){if(C=Zf(h),S!==null&&S.dehydrated!==null){if(u===null){if(!C)throw Error(i(318));if(C=h.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(i(317));C[fi]=h}else hd(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;ei(h),C=!1}else C=xM(),u!==null&&u.memoizedState!==null&&(u.memoizedState.hydrationErrors=C),C=!0;if(!C)return h.flags&256?(Ga(h),h):(Ga(h),null)}return Ga(h),(h.flags&128)!==0?(h.lanes=y,h):(y=S!==null,u=u!==null&&u.memoizedState!==null,y&&(S=h.child,C=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(C=S.alternate.memoizedState.cachePool.pool),D=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(D=S.memoizedState.cachePool.pool),D!==C&&(S.flags|=2048)),y!==u&&y&&(h.child.flags|=8192),Ov(h,h.updateQueue),ei(h),null);case 4:return pe(),u===null&&NE(h.stateNode.containerInfo),ei(h),null;case 10:return ll(h.type),ei(h),null;case 19:if(Y(Ti),S=h.memoizedState,S===null)return ei(h),null;if(C=(h.flags&128)!==0,D=S.rendering,D===null)if(C)Km(S,!1);else{if(bi!==0||u!==null&&(u.flags&128)!==0)for(u=h.child;u!==null;){if(D=bv(u),D!==null){for(h.flags|=128,Km(S,!1),u=D.updateQueue,h.updateQueue=u,Ov(h,u),h.subtreeFlags=0,u=y,y=h.child;y!==null;)oL(y,u),y=y.sibling;return se(Ti,Ti.current&1|2),vn&&sl(h,S.treeForkCount),h.child}u=u.sibling}S.tail!==null&&k()>jv&&(h.flags|=128,C=!0,Km(S,!1),h.lanes=4194304)}else{if(!C)if(u=bv(D),u!==null){if(h.flags|=128,C=!0,u=u.updateQueue,h.updateQueue=u,Ov(h,u),Km(S,!0),S.tail===null&&S.tailMode==="hidden"&&!D.alternate&&!vn)return ei(h),null}else 2*k()-S.renderingStartTime>jv&&y!==536870912&&(h.flags|=128,C=!0,Km(S,!1),h.lanes=4194304);S.isBackwards?(D.sibling=h.child,h.child=D):(u=S.last,u!==null?u.sibling=D:h.child=D,S.last=D)}return S.tail!==null?(u=S.tail,S.rendering=u,S.tail=u.sibling,S.renderingStartTime=k(),u.sibling=null,y=Ti.current,se(Ti,C?y&1|2:y&1),vn&&sl(h,S.treeForkCount),u):(ei(h),null);case 22:case 23:return Ga(h),RM(),S=h.memoizedState!==null,u!==null?u.memoizedState!==null!==S&&(h.flags|=8192):S&&(h.flags|=8192),S?(y&536870912)!==0&&(h.flags&128)===0&&(ei(h),h.subtreeFlags&6&&(h.flags|=8192)):ei(h),y=h.updateQueue,y!==null&&Ov(h,y.retryQueue),y=null,u!==null&&u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(y=u.memoizedState.cachePool.pool),S=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(S=h.memoizedState.cachePool.pool),S!==y&&(h.flags|=2048),u!==null&&Y(gd),null;case 24:return y=null,u!==null&&(y=u.memoizedState.cache),h.memoizedState.cache!==y&&(h.flags|=2048),ll(ki),ei(h),null;case 25:return null;case 30:return null}throw Error(i(156,h.tag))}function LJ(u,h){switch(mM(h),h.tag){case 1:return u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 3:return ll(ki),pe(),u=h.flags,(u&65536)!==0&&(u&128)===0?(h.flags=u&-65537|128,h):null;case 26:case 27:case 5:return ze(h),null;case 31:if(h.memoizedState!==null){if(Ga(h),h.alternate===null)throw Error(i(340));hd()}return u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 13:if(Ga(h),u=h.memoizedState,u!==null&&u.dehydrated!==null){if(h.alternate===null)throw Error(i(340));hd()}return u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 19:return Y(Ti),null;case 4:return pe(),null;case 10:return ll(h.type),null;case 22:case 23:return Ga(h),RM(),u!==null&&Y(gd),u=h.flags,u&65536?(h.flags=u&-65537|128,h):null;case 24:return ll(ki),null;case 25:return null;default:return null}}function kI(u,h){switch(mM(h),h.tag){case 3:ll(ki),pe();break;case 26:case 27:case 5:ze(h);break;case 4:pe();break;case 31:h.memoizedState!==null&&Ga(h);break;case 13:Ga(h);break;case 19:Y(Ti);break;case 10:ll(h.type);break;case 22:case 23:Ga(h),RM(),u!==null&&Y(gd);break;case 24:ll(ki)}}function Ym(u,h){try{var y=h.updateQueue,S=y!==null?y.lastEffect:null;if(S!==null){var C=S.next;y=C;do{if((y.tag&u)===u){S=void 0;var D=y.create,V=y.inst;S=D(),V.destroy=S}y=y.next}while(y!==C)}}catch(ne){Dn(h,h.return,ne)}}function Uc(u,h,y){try{var S=h.updateQueue,C=S!==null?S.lastEffect:null;if(C!==null){var D=C.next;S=D;do{if((S.tag&u)===u){var V=S.inst,ne=V.destroy;if(ne!==void 0){V.destroy=void 0,C=h;var _e=y,Fe=ne;try{Fe()}catch(Je){Dn(C,_e,Je)}}}S=S.next}while(S!==D)}}catch(Je){Dn(h,h.return,Je)}}function LI(u){var h=u.updateQueue;if(h!==null){var y=u.stateNode;try{EL(h,y)}catch(S){Dn(u,u.return,S)}}}function II(u,h,y){y.props=_d(u.type,u.memoizedProps),y.state=u.memoizedState;try{y.componentWillUnmount()}catch(S){Dn(u,h,S)}}function Zm(u,h){try{var y=u.ref;if(y!==null){switch(u.tag){case 26:case 27:case 5:var S=u.stateNode;break;case 30:S=u.stateNode;break;default:S=u.stateNode}typeof y=="function"?u.refCleanup=y(S):y.current=S}}catch(C){Dn(u,h,C)}}function To(u,h){var y=u.ref,S=u.refCleanup;if(y!==null)if(typeof S=="function")try{S()}catch(C){Dn(u,h,C)}finally{u.refCleanup=null,u=u.alternate,u!=null&&(u.refCleanup=null)}else if(typeof y=="function")try{y(null)}catch(C){Dn(u,h,C)}else y.current=null}function UI(u){var h=u.type,y=u.memoizedProps,S=u.stateNode;try{e:switch(h){case"button":case"input":case"select":case"textarea":y.autoFocus&&S.focus();break e;case"img":y.src?S.src=y.src:y.srcSet&&(S.srcset=y.srcSet)}}catch(C){Dn(u,u.return,C)}}function lE(u,h,y){try{var S=u.stateNode;iee(S,u.type,y,h),S[Ei]=h}catch(C){Dn(u,u.return,C)}}function jI(u){return u.tag===5||u.tag===3||u.tag===26||u.tag===27&&$c(u.type)||u.tag===4}function cE(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||jI(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.tag===27&&$c(u.type)||u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function uE(u,h,y){var S=u.tag;if(S===5||S===6)u=u.stateNode,h?(y.nodeType===9?y.body:y.nodeName==="HTML"?y.ownerDocument.body:y).insertBefore(u,h):(h=y.nodeType===9?y.body:y.nodeName==="HTML"?y.ownerDocument.body:y,h.appendChild(u),y=y._reactRootContainer,y!=null||h.onclick!==null||(h.onclick=il));else if(S!==4&&(S===27&&$c(u.type)&&(y=u.stateNode,h=null),u=u.child,u!==null))for(uE(u,h,y),u=u.sibling;u!==null;)uE(u,h,y),u=u.sibling}function kv(u,h,y){var S=u.tag;if(S===5||S===6)u=u.stateNode,h?y.insertBefore(u,h):y.appendChild(u);else if(S!==4&&(S===27&&$c(u.type)&&(y=u.stateNode),u=u.child,u!==null))for(kv(u,h,y),u=u.sibling;u!==null;)kv(u,h,y),u=u.sibling}function FI(u){var h=u.stateNode,y=u.memoizedProps;try{for(var S=u.type,C=h.attributes;C.length;)h.removeAttributeNode(C[0]);Or(h,S,y),h[fi]=u,h[Ei]=y}catch(D){Dn(u,u.return,D)}}var hl=!1,Ui=!1,dE=!1,zI=typeof WeakSet=="function"?WeakSet:Set,gr=null;function IJ(u,h){if(u=u.containerInfo,DE=ty,u=Qk(u),rM(u)){if("selectionStart"in u)var y={start:u.selectionStart,end:u.selectionEnd};else e:{y=(y=u.ownerDocument)&&y.defaultView||window;var S=y.getSelection&&y.getSelection();if(S&&S.rangeCount!==0){y=S.anchorNode;var C=S.anchorOffset,D=S.focusNode;S=S.focusOffset;try{y.nodeType,D.nodeType}catch{y=null;break e}var V=0,ne=-1,_e=-1,Fe=0,Je=0,st=u,Ve=null;t:for(;;){for(var Ke;st!==y||C!==0&&st.nodeType!==3||(ne=V+C),st!==D||S!==0&&st.nodeType!==3||(_e=V+S),st.nodeType===3&&(V+=st.nodeValue.length),(Ke=st.firstChild)!==null;)Ve=st,st=Ke;for(;;){if(st===u)break t;if(Ve===y&&++Fe===C&&(ne=V),Ve===D&&++Je===S&&(_e=V),(Ke=st.nextSibling)!==null)break;st=Ve,Ve=st.parentNode}st=Ke}y=ne===-1||_e===-1?null:{start:ne,end:_e}}else y=null}y=y||{start:0,end:0}}else y=null;for(OE={focusedElem:u,selectionRange:y},ty=!1,gr=h;gr!==null;)if(h=gr,u=h.child,(h.subtreeFlags&1028)!==0&&u!==null)u.return=h,gr=u;else for(;gr!==null;){switch(h=gr,D=h.alternate,u=h.flags,h.tag){case 0:if((u&4)!==0&&(u=h.updateQueue,u=u!==null?u.events:null,u!==null))for(y=0;y<u.length;y++)C=u[y],C.ref.impl=C.nextImpl;break;case 11:case 15:break;case 1:if((u&1024)!==0&&D!==null){u=void 0,y=h,C=D.memoizedProps,D=D.memoizedState,S=y.stateNode;try{var Ct=_d(y.type,C);u=S.getSnapshotBeforeUpdate(Ct,D),S.__reactInternalSnapshotBeforeUpdate=u}catch(zt){Dn(y,y.return,zt)}}break;case 3:if((u&1024)!==0){if(u=h.stateNode.containerInfo,y=u.nodeType,y===9)IE(u);else if(y===1)switch(u.nodeName){case"HEAD":case"HTML":case"BODY":IE(u);break;default:u.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((u&1024)!==0)throw Error(i(163))}if(u=h.sibling,u!==null){u.return=h.return,gr=u;break}gr=h.return}}function BI(u,h,y){var S=y.flags;switch(y.tag){case 0:case 11:case 15:ml(u,y),S&4&&Ym(5,y);break;case 1:if(ml(u,y),S&4)if(u=y.stateNode,h===null)try{u.componentDidMount()}catch(V){Dn(y,y.return,V)}else{var C=_d(y.type,h.memoizedProps);h=h.memoizedState;try{u.componentDidUpdate(C,h,u.__reactInternalSnapshotBeforeUpdate)}catch(V){Dn(y,y.return,V)}}S&64&&LI(y),S&512&&Zm(y,y.return);break;case 3:if(ml(u,y),S&64&&(u=y.updateQueue,u!==null)){if(h=null,y.child!==null)switch(y.child.tag){case 27:case 5:h=y.child.stateNode;break;case 1:h=y.child.stateNode}try{EL(u,h)}catch(V){Dn(y,y.return,V)}}break;case 27:h===null&&S&4&&FI(y);case 26:case 5:ml(u,y),h===null&&S&4&&UI(y),S&512&&Zm(y,y.return);break;case 12:ml(u,y);break;case 31:ml(u,y),S&4&&$I(u,y);break;case 13:ml(u,y),S&4&&GI(u,y),S&64&&(u=y.memoizedState,u!==null&&(u=u.dehydrated,u!==null&&(y=GJ.bind(null,y),dee(u,y))));break;case 22:if(S=y.memoizedState!==null||hl,!S){h=h!==null&&h.memoizedState!==null||Ui,C=hl;var D=Ui;hl=S,(Ui=h)&&!D?gl(u,y,(y.subtreeFlags&8772)!==0):ml(u,y),hl=C,Ui=D}break;case 30:break;default:ml(u,y)}}function HI(u){var h=u.alternate;h!==null&&(u.alternate=null,HI(h)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(h=u.stateNode,h!==null&&Ge(h)),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}var si=null,Sa=!1;function pl(u,h,y){for(y=y.child;y!==null;)VI(u,h,y),y=y.sibling}function VI(u,h,y){if(Re&&typeof Re.onCommitFiberUnmount=="function")try{Re.onCommitFiberUnmount(Ie,y)}catch{}switch(y.tag){case 26:Ui||To(y,h),pl(u,h,y),y.memoizedState?y.memoizedState.count--:y.stateNode&&(y=y.stateNode,y.parentNode.removeChild(y));break;case 27:Ui||To(y,h);var S=si,C=Sa;$c(y.type)&&(si=y.stateNode,Sa=!1),pl(u,h,y),sg(y.stateNode),si=S,Sa=C;break;case 5:Ui||To(y,h);case 6:if(S=si,C=Sa,si=null,pl(u,h,y),si=S,Sa=C,si!==null)if(Sa)try{(si.nodeType===9?si.body:si.nodeName==="HTML"?si.ownerDocument.body:si).removeChild(y.stateNode)}catch(D){Dn(y,h,D)}else try{si.removeChild(y.stateNode)}catch(D){Dn(y,h,D)}break;case 18:si!==null&&(Sa?(u=si,LU(u.nodeType===9?u.body:u.nodeName==="HTML"?u.ownerDocument.body:u,y.stateNode),vh(u)):LU(si,y.stateNode));break;case 4:S=si,C=Sa,si=y.stateNode.containerInfo,Sa=!0,pl(u,h,y),si=S,Sa=C;break;case 0:case 11:case 14:case 15:Uc(2,y,h),Ui||Uc(4,y,h),pl(u,h,y);break;case 1:Ui||(To(y,h),S=y.stateNode,typeof S.componentWillUnmount=="function"&&II(y,h,S)),pl(u,h,y);break;case 21:pl(u,h,y);break;case 22:Ui=(S=Ui)||y.memoizedState!==null,pl(u,h,y),Ui=S;break;default:pl(u,h,y)}}function $I(u,h){if(h.memoizedState===null&&(u=h.alternate,u!==null&&(u=u.memoizedState,u!==null))){u=u.dehydrated;try{vh(u)}catch(y){Dn(h,h.return,y)}}}function GI(u,h){if(h.memoizedState===null&&(u=h.alternate,u!==null&&(u=u.memoizedState,u!==null&&(u=u.dehydrated,u!==null))))try{vh(u)}catch(y){Dn(h,h.return,y)}}function UJ(u){switch(u.tag){case 31:case 13:case 19:var h=u.stateNode;return h===null&&(h=u.stateNode=new zI),h;case 22:return u=u.stateNode,h=u._retryCache,h===null&&(h=u._retryCache=new zI),h;default:throw Error(i(435,u.tag))}}function Lv(u,h){var y=UJ(u);h.forEach(function(S){if(!y.has(S)){y.add(S);var C=WJ.bind(null,u,S);S.then(C,C)}})}function wa(u,h){var y=h.deletions;if(y!==null)for(var S=0;S<y.length;S++){var C=y[S],D=u,V=h,ne=V;e:for(;ne!==null;){switch(ne.tag){case 27:if($c(ne.type)){si=ne.stateNode,Sa=!1;break e}break;case 5:si=ne.stateNode,Sa=!1;break e;case 3:case 4:si=ne.stateNode.containerInfo,Sa=!0;break e}ne=ne.return}if(si===null)throw Error(i(160));VI(D,V,C),si=null,Sa=!1,D=C.alternate,D!==null&&(D.return=null),C.return=null}if(h.subtreeFlags&13886)for(h=h.child;h!==null;)WI(h,u),h=h.sibling}var Qs=null;function WI(u,h){var y=u.alternate,S=u.flags;switch(u.tag){case 0:case 11:case 14:case 15:wa(h,u),Ma(u),S&4&&(Uc(3,u,u.return),Ym(3,u),Uc(5,u,u.return));break;case 1:wa(h,u),Ma(u),S&512&&(Ui||y===null||To(y,y.return)),S&64&&hl&&(u=u.updateQueue,u!==null&&(S=u.callbacks,S!==null&&(y=u.shared.hiddenCallbacks,u.shared.hiddenCallbacks=y===null?S:y.concat(S))));break;case 26:var C=Qs;if(wa(h,u),Ma(u),S&512&&(Ui||y===null||To(y,y.return)),S&4){var D=y!==null?y.memoizedState:null;if(S=u.memoizedState,y===null)if(S===null)if(u.stateNode===null){e:{S=u.type,y=u.memoizedProps,C=C.ownerDocument||C;t:switch(S){case"title":D=C.getElementsByTagName("title")[0],(!D||D[Xe]||D[fi]||D.namespaceURI==="http://www.w3.org/2000/svg"||D.hasAttribute("itemprop"))&&(D=C.createElement(S),C.head.insertBefore(D,C.querySelector("head > title"))),Or(D,S,y),D[fi]=u,Te(D),S=D;break e;case"link":var V=WU("link","href",C).get(S+(y.href||""));if(V){for(var ne=0;ne<V.length;ne++)if(D=V[ne],D.getAttribute("href")===(y.href==null||y.href===""?null:y.href)&&D.getAttribute("rel")===(y.rel==null?null:y.rel)&&D.getAttribute("title")===(y.title==null?null:y.title)&&D.getAttribute("crossorigin")===(y.crossOrigin==null?null:y.crossOrigin)){V.splice(ne,1);break t}}D=C.createElement(S),Or(D,S,y),C.head.appendChild(D);break;case"meta":if(V=WU("meta","content",C).get(S+(y.content||""))){for(ne=0;ne<V.length;ne++)if(D=V[ne],D.getAttribute("content")===(y.content==null?null:""+y.content)&&D.getAttribute("name")===(y.name==null?null:y.name)&&D.getAttribute("property")===(y.property==null?null:y.property)&&D.getAttribute("http-equiv")===(y.httpEquiv==null?null:y.httpEquiv)&&D.getAttribute("charset")===(y.charSet==null?null:y.charSet)){V.splice(ne,1);break t}}D=C.createElement(S),Or(D,S,y),C.head.appendChild(D);break;default:throw Error(i(468,S))}D[fi]=u,Te(D),S=D}u.stateNode=S}else qU(C,u.type,u.stateNode);else u.stateNode=GU(C,S,u.memoizedProps);else D!==S?(D===null?y.stateNode!==null&&(y=y.stateNode,y.parentNode.removeChild(y)):D.count--,S===null?qU(C,u.type,u.stateNode):GU(C,S,u.memoizedProps)):S===null&&u.stateNode!==null&&lE(u,u.memoizedProps,y.memoizedProps)}break;case 27:wa(h,u),Ma(u),S&512&&(Ui||y===null||To(y,y.return)),y!==null&&S&4&&lE(u,u.memoizedProps,y.memoizedProps);break;case 5:if(wa(h,u),Ma(u),S&512&&(Ui||y===null||To(y,y.return)),u.flags&32){C=u.stateNode;try{Mo(C,"")}catch(Ct){Dn(u,u.return,Ct)}}S&4&&u.stateNode!=null&&(C=u.memoizedProps,lE(u,C,y!==null?y.memoizedProps:C)),S&1024&&(dE=!0);break;case 6:if(wa(h,u),Ma(u),S&4){if(u.stateNode===null)throw Error(i(162));S=u.memoizedProps,y=u.stateNode;try{y.nodeValue=S}catch(Ct){Dn(u,u.return,Ct)}}break;case 3:if(Zv=null,C=Qs,Qs=Kv(h.containerInfo),wa(h,u),Qs=C,Ma(u),S&4&&y!==null&&y.memoizedState.isDehydrated)try{vh(h.containerInfo)}catch(Ct){Dn(u,u.return,Ct)}dE&&(dE=!1,qI(u));break;case 4:S=Qs,Qs=Kv(u.stateNode.containerInfo),wa(h,u),Ma(u),Qs=S;break;case 12:wa(h,u),Ma(u);break;case 31:wa(h,u),Ma(u),S&4&&(S=u.updateQueue,S!==null&&(u.updateQueue=null,Lv(u,S)));break;case 13:wa(h,u),Ma(u),u.child.flags&8192&&u.memoizedState!==null!=(y!==null&&y.memoizedState!==null)&&(Uv=k()),S&4&&(S=u.updateQueue,S!==null&&(u.updateQueue=null,Lv(u,S)));break;case 22:C=u.memoizedState!==null;var _e=y!==null&&y.memoizedState!==null,Fe=hl,Je=Ui;if(hl=Fe||C,Ui=Je||_e,wa(h,u),Ui=Je,hl=Fe,Ma(u),S&8192)e:for(h=u.stateNode,h._visibility=C?h._visibility&-2:h._visibility|1,C&&(y===null||_e||hl||Ui||Sd(u)),y=null,h=u;;){if(h.tag===5||h.tag===26){if(y===null){_e=y=h;try{if(D=_e.stateNode,C)V=D.style,typeof V.setProperty=="function"?V.setProperty("display","none","important"):V.display="none";else{ne=_e.stateNode;var st=_e.memoizedProps.style,Ve=st!=null&&st.hasOwnProperty("display")?st.display:null;ne.style.display=Ve==null||typeof Ve=="boolean"?"":(""+Ve).trim()}}catch(Ct){Dn(_e,_e.return,Ct)}}}else if(h.tag===6){if(y===null){_e=h;try{_e.stateNode.nodeValue=C?"":_e.memoizedProps}catch(Ct){Dn(_e,_e.return,Ct)}}}else if(h.tag===18){if(y===null){_e=h;try{var Ke=_e.stateNode;C?IU(Ke,!0):IU(_e.stateNode,!1)}catch(Ct){Dn(_e,_e.return,Ct)}}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===u)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===u)break e;for(;h.sibling===null;){if(h.return===null||h.return===u)break e;y===h&&(y=null),h=h.return}y===h&&(y=null),h.sibling.return=h.return,h=h.sibling}S&4&&(S=u.updateQueue,S!==null&&(y=S.retryQueue,y!==null&&(S.retryQueue=null,Lv(u,y))));break;case 19:wa(h,u),Ma(u),S&4&&(S=u.updateQueue,S!==null&&(u.updateQueue=null,Lv(u,S)));break;case 30:break;case 21:break;default:wa(h,u),Ma(u)}}function Ma(u){var h=u.flags;if(h&2){try{for(var y,S=u.return;S!==null;){if(jI(S)){y=S;break}S=S.return}if(y==null)throw Error(i(160));switch(y.tag){case 27:var C=y.stateNode,D=cE(u);kv(u,D,C);break;case 5:var V=y.stateNode;y.flags&32&&(Mo(V,""),y.flags&=-33);var ne=cE(u);kv(u,ne,V);break;case 3:case 4:var _e=y.stateNode.containerInfo,Fe=cE(u);uE(u,Fe,_e);break;default:throw Error(i(161))}}catch(Je){Dn(u,u.return,Je)}u.flags&=-3}h&4096&&(u.flags&=-4097)}function qI(u){if(u.subtreeFlags&1024)for(u=u.child;u!==null;){var h=u;qI(h),h.tag===5&&h.flags&1024&&h.stateNode.reset(),u=u.sibling}}function ml(u,h){if(h.subtreeFlags&8772)for(h=h.child;h!==null;)BI(u,h.alternate,h),h=h.sibling}function Sd(u){for(u=u.child;u!==null;){var h=u;switch(h.tag){case 0:case 11:case 14:case 15:Uc(4,h,h.return),Sd(h);break;case 1:To(h,h.return);var y=h.stateNode;typeof y.componentWillUnmount=="function"&&II(h,h.return,y),Sd(h);break;case 27:sg(h.stateNode);case 26:case 5:To(h,h.return),Sd(h);break;case 22:h.memoizedState===null&&Sd(h);break;case 30:Sd(h);break;default:Sd(h)}u=u.sibling}}function gl(u,h,y){for(y=y&&(h.subtreeFlags&8772)!==0,h=h.child;h!==null;){var S=h.alternate,C=u,D=h,V=D.flags;switch(D.tag){case 0:case 11:case 15:gl(C,D,y),Ym(4,D);break;case 1:if(gl(C,D,y),S=D,C=S.stateNode,typeof C.componentDidMount=="function")try{C.componentDidMount()}catch(Fe){Dn(S,S.return,Fe)}if(S=D,C=S.updateQueue,C!==null){var ne=S.stateNode;try{var _e=C.shared.hiddenCallbacks;if(_e!==null)for(C.shared.hiddenCallbacks=null,C=0;C<_e.length;C++)ML(_e[C],ne)}catch(Fe){Dn(S,S.return,Fe)}}y&&V&64&&LI(D),Zm(D,D.return);break;case 27:FI(D);case 26:case 5:gl(C,D,y),y&&S===null&&V&4&&UI(D),Zm(D,D.return);break;case 12:gl(C,D,y);break;case 31:gl(C,D,y),y&&V&4&&$I(C,D);break;case 13:gl(C,D,y),y&&V&4&&GI(C,D);break;case 22:D.memoizedState===null&&gl(C,D,y),Zm(D,D.return);break;case 30:break;default:gl(C,D,y)}h=h.sibling}}function fE(u,h){var y=null;u!==null&&u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(y=u.memoizedState.cachePool.pool),u=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(u=h.memoizedState.cachePool.pool),u!==y&&(u!=null&&u.refCount++,y!=null&&Um(y))}function hE(u,h){u=null,h.alternate!==null&&(u=h.alternate.memoizedState.cache),h=h.memoizedState.cache,h!==u&&(h.refCount++,u!=null&&Um(u))}function Js(u,h,y,S){if(h.subtreeFlags&10256)for(h=h.child;h!==null;)XI(u,h,y,S),h=h.sibling}function XI(u,h,y,S){var C=h.flags;switch(h.tag){case 0:case 11:case 15:Js(u,h,y,S),C&2048&&Ym(9,h);break;case 1:Js(u,h,y,S);break;case 3:Js(u,h,y,S),C&2048&&(u=null,h.alternate!==null&&(u=h.alternate.memoizedState.cache),h=h.memoizedState.cache,h!==u&&(h.refCount++,u!=null&&Um(u)));break;case 12:if(C&2048){Js(u,h,y,S),u=h.stateNode;try{var D=h.memoizedProps,V=D.id,ne=D.onPostCommit;typeof ne=="function"&&ne(V,h.alternate===null?"mount":"update",u.passiveEffectDuration,-0)}catch(_e){Dn(h,h.return,_e)}}else Js(u,h,y,S);break;case 31:Js(u,h,y,S);break;case 13:Js(u,h,y,S);break;case 23:break;case 22:D=h.stateNode,V=h.alternate,h.memoizedState!==null?D._visibility&2?Js(u,h,y,S):Qm(u,h):D._visibility&2?Js(u,h,y,S):(D._visibility|=2,oh(u,h,y,S,(h.subtreeFlags&10256)!==0||!1)),C&2048&&fE(V,h);break;case 24:Js(u,h,y,S),C&2048&&hE(h.alternate,h);break;default:Js(u,h,y,S)}}function oh(u,h,y,S,C){for(C=C&&((h.subtreeFlags&10256)!==0||!1),h=h.child;h!==null;){var D=u,V=h,ne=y,_e=S,Fe=V.flags;switch(V.tag){case 0:case 11:case 15:oh(D,V,ne,_e,C),Ym(8,V);break;case 23:break;case 22:var Je=V.stateNode;V.memoizedState!==null?Je._visibility&2?oh(D,V,ne,_e,C):Qm(D,V):(Je._visibility|=2,oh(D,V,ne,_e,C)),C&&Fe&2048&&fE(V.alternate,V);break;case 24:oh(D,V,ne,_e,C),C&&Fe&2048&&hE(V.alternate,V);break;default:oh(D,V,ne,_e,C)}h=h.sibling}}function Qm(u,h){if(h.subtreeFlags&10256)for(h=h.child;h!==null;){var y=u,S=h,C=S.flags;switch(S.tag){case 22:Qm(y,S),C&2048&&fE(S.alternate,S);break;case 24:Qm(y,S),C&2048&&hE(S.alternate,S);break;default:Qm(y,S)}h=h.sibling}}var Jm=8192;function lh(u,h,y){if(u.subtreeFlags&Jm)for(u=u.child;u!==null;)KI(u,h,y),u=u.sibling}function KI(u,h,y){switch(u.tag){case 26:lh(u,h,y),u.flags&Jm&&u.memoizedState!==null&&wee(y,Qs,u.memoizedState,u.memoizedProps);break;case 5:lh(u,h,y);break;case 3:case 4:var S=Qs;Qs=Kv(u.stateNode.containerInfo),lh(u,h,y),Qs=S;break;case 22:u.memoizedState===null&&(S=u.alternate,S!==null&&S.memoizedState!==null?(S=Jm,Jm=16777216,lh(u,h,y),Jm=S):lh(u,h,y));break;default:lh(u,h,y)}}function YI(u){var h=u.alternate;if(h!==null&&(u=h.child,u!==null)){h.child=null;do h=u.sibling,u.sibling=null,u=h;while(u!==null)}}function eg(u){var h=u.deletions;if((u.flags&16)!==0){if(h!==null)for(var y=0;y<h.length;y++){var S=h[y];gr=S,QI(S,u)}YI(u)}if(u.subtreeFlags&10256)for(u=u.child;u!==null;)ZI(u),u=u.sibling}function ZI(u){switch(u.tag){case 0:case 11:case 15:eg(u),u.flags&2048&&Uc(9,u,u.return);break;case 3:eg(u);break;case 12:eg(u);break;case 22:var h=u.stateNode;u.memoizedState!==null&&h._visibility&2&&(u.return===null||u.return.tag!==13)?(h._visibility&=-3,Iv(u)):eg(u);break;default:eg(u)}}function Iv(u){var h=u.deletions;if((u.flags&16)!==0){if(h!==null)for(var y=0;y<h.length;y++){var S=h[y];gr=S,QI(S,u)}YI(u)}for(u=u.child;u!==null;){switch(h=u,h.tag){case 0:case 11:case 15:Uc(8,h,h.return),Iv(h);break;case 22:y=h.stateNode,y._visibility&2&&(y._visibility&=-3,Iv(h));break;default:Iv(h)}u=u.sibling}}function QI(u,h){for(;gr!==null;){var y=gr;switch(y.tag){case 0:case 11:case 15:Uc(8,y,h);break;case 23:case 22:if(y.memoizedState!==null&&y.memoizedState.cachePool!==null){var S=y.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:Um(y.memoizedState.cache)}if(S=y.child,S!==null)S.return=y,gr=S;else e:for(y=u;gr!==null;){S=gr;var C=S.sibling,D=S.return;if(HI(S),S===y){gr=null;break e}if(C!==null){C.return=D,gr=C;break e}gr=D}}}var jJ={getCacheForType:function(u){var h=Pr(ki),y=h.data.get(u);return y===void 0&&(y=u(),h.data.set(u,y)),y},cacheSignal:function(){return Pr(ki).controller.signal}},FJ=typeof WeakMap=="function"?WeakMap:Map,An=0,Wn=null,un=null,pn=0,Pn=0,Wa=null,jc=!1,ch=!1,pE=!1,xl=0,bi=0,Fc=0,wd=0,mE=0,qa=0,uh=0,tg=null,Ea=null,gE=!1,Uv=0,JI=0,jv=1/0,Fv=null,zc=null,Zi=0,Bc=null,dh=null,vl=0,xE=0,vE=null,eU=null,ng=0,yE=null;function Xa(){return(An&2)!==0&&pn!==0?pn&-pn:q.T!==null?EE():Cr()}function tU(){if(qa===0)if((pn&536870912)===0||vn){var u=fe;fe<<=1,(fe&3932160)===0&&(fe=262144),qa=u}else qa=536870912;return u=$a.current,u!==null&&(u.flags|=32),qa}function Aa(u,h,y){(u===Wn&&(Pn===2||Pn===9)||u.cancelPendingCommit!==null)&&(fh(u,0),Hc(u,pn,qa,!1)),an(u,y),((An&2)===0||u!==Wn)&&(u===Wn&&((An&2)===0&&(wd|=y),bi===4&&Hc(u,pn,qa,!1)),Co(u))}function nU(u,h,y){if((An&6)!==0)throw Error(i(327));var S=!y&&(h&127)===0&&(h&u.expiredLanes)===0||Be(u,h),C=S?HJ(u,h):_E(u,h,!0),D=S;do{if(C===0){ch&&!S&&Hc(u,h,0,!1);break}else{if(y=u.current.alternate,D&&!zJ(y)){C=_E(u,h,!1),D=!1;continue}if(C===2){if(D=h,u.errorRecoveryDisabledLanes&D)var V=0;else V=u.pendingLanes&-536870913,V=V!==0?V:V&536870912?536870912:0;if(V!==0){h=V;e:{var ne=u;C=tg;var _e=ne.current.memoizedState.isDehydrated;if(_e&&(fh(ne,V).flags|=256),V=_E(ne,V,!1),V!==2){if(pE&&!_e){ne.errorRecoveryDisabledLanes|=D,wd|=D,C=4;break e}D=Ea,Ea=C,D!==null&&(Ea===null?Ea=D:Ea.push.apply(Ea,D))}C=V}if(D=!1,C!==2)continue}}if(C===1){fh(u,0),Hc(u,h,0,!0);break}e:{switch(S=u,D=C,D){case 0:case 1:throw Error(i(345));case 4:if((h&4194048)!==h)break;case 6:Hc(S,h,qa,!jc);break e;case 2:Ea=null;break;case 3:case 5:break;default:throw Error(i(329))}if((h&62914560)===h&&(C=Uv+300-k(),10<C)){if(Hc(S,h,qa,!jc),ge(S,0,!0)!==0)break e;vl=h,S.timeoutHandle=OU(iU.bind(null,S,y,Ea,Fv,gE,h,qa,wd,uh,jc,D,"Throttled",-0,0),C);break e}iU(S,y,Ea,Fv,gE,h,qa,wd,uh,jc,D,null,-0,0)}}break}while(!0);Co(u)}function iU(u,h,y,S,C,D,V,ne,_e,Fe,Je,st,Ve,Ke){if(u.timeoutHandle=-1,st=h.subtreeFlags,st&8192||(st&16785408)===16785408){st={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:il},KI(h,D,st);var Ct=(D&62914560)===D?Uv-k():(D&4194048)===D?JI-k():0;if(Ct=Mee(st,Ct),Ct!==null){vl=D,u.cancelPendingCommit=Ct(dU.bind(null,u,h,D,y,S,C,V,ne,_e,Je,st,null,Ve,Ke)),Hc(u,D,V,!Fe);return}}dU(u,h,D,y,S,C,V,ne,_e)}function zJ(u){for(var h=u;;){var y=h.tag;if((y===0||y===11||y===15)&&h.flags&16384&&(y=h.updateQueue,y!==null&&(y=y.stores,y!==null)))for(var S=0;S<y.length;S++){var C=y[S],D=C.getSnapshot;C=C.value;try{if(!Ha(D(),C))return!1}catch{return!1}}if(y=h.child,h.subtreeFlags&16384&&y!==null)y.return=h,h=y;else{if(h===u)break;for(;h.sibling===null;){if(h.return===null||h.return===u)return!0;h=h.return}h.sibling.return=h.return,h=h.sibling}}return!0}function Hc(u,h,y,S){h&=~mE,h&=~wd,u.suspendedLanes|=h,u.pingedLanes&=~h,S&&(u.warmLanes|=h),S=u.expirationTimes;for(var C=h;0<C;){var D=31-tt(C),V=1<<D;S[D]=-1,C&=~V}y!==0&&Nn(u,y,h)}function zv(){return(An&6)===0?(ig(0),!1):!0}function bE(){if(un!==null){if(Pn===0)var u=un.return;else u=un,ol=pd=null,IM(u),nh=null,Fm=0,u=un;for(;u!==null;)kI(u.alternate,u),u=u.return;un=null}}function fh(u,h){var y=u.timeoutHandle;y!==-1&&(u.timeoutHandle=-1,see(y)),y=u.cancelPendingCommit,y!==null&&(u.cancelPendingCommit=null,y()),vl=0,bE(),Wn=u,un=y=al(u.current,null),pn=h,Pn=0,Wa=null,jc=!1,ch=Be(u,h),pE=!1,uh=qa=mE=wd=Fc=bi=0,Ea=tg=null,gE=!1,(h&8)!==0&&(h|=h&32);var S=u.entangledLanes;if(S!==0)for(u=u.entanglements,S&=h;0<S;){var C=31-tt(S),D=1<<C;h|=u[C],S&=~D}return xl=h,ov(),y}function rU(u,h){Kt=null,q.H=qm,h===th||h===mv?(h=bL(),Pn=3):h===MM?(h=bL(),Pn=4):Pn=h===QM?8:h!==null&&typeof h=="object"&&typeof h.then=="function"?6:1,Wa=h,un===null&&(bi=1,Nv(u,ps(h,u.current)))}function aU(){var u=$a.current;return u===null?!0:(pn&4194048)===pn?vs===null:(pn&62914560)===pn||(pn&536870912)!==0?u===vs:!1}function sU(){var u=q.H;return q.H=qm,u===null?qm:u}function oU(){var u=q.A;return q.A=jJ,u}function Bv(){bi=4,jc||(pn&4194048)!==pn&&$a.current!==null||(ch=!0),(Fc&134217727)===0&&(wd&134217727)===0||Wn===null||Hc(Wn,pn,qa,!1)}function _E(u,h,y){var S=An;An|=2;var C=sU(),D=oU();(Wn!==u||pn!==h)&&(Fv=null,fh(u,h)),h=!1;var V=bi;e:do try{if(Pn!==0&&un!==null){var ne=un,_e=Wa;switch(Pn){case 8:bE(),V=6;break e;case 3:case 2:case 9:case 6:$a.current===null&&(h=!0);var Fe=Pn;if(Pn=0,Wa=null,hh(u,ne,_e,Fe),y&&ch){V=0;break e}break;default:Fe=Pn,Pn=0,Wa=null,hh(u,ne,_e,Fe)}}BJ(),V=bi;break}catch(Je){rU(u,Je)}while(!0);return h&&u.shellSuspendCounter++,ol=pd=null,An=S,q.H=C,q.A=D,un===null&&(Wn=null,pn=0,ov()),V}function BJ(){for(;un!==null;)lU(un)}function HJ(u,h){var y=An;An|=2;var S=sU(),C=oU();Wn!==u||pn!==h?(Fv=null,jv=k()+500,fh(u,h)):ch=Be(u,h);e:do try{if(Pn!==0&&un!==null){h=un;var D=Wa;t:switch(Pn){case 1:Pn=0,Wa=null,hh(u,h,D,1);break;case 2:case 9:if(vL(D)){Pn=0,Wa=null,cU(h);break}h=function(){Pn!==2&&Pn!==9||Wn!==u||(Pn=7),Co(u)},D.then(h,h);break e;case 3:Pn=7;break e;case 4:Pn=5;break e;case 7:vL(D)?(Pn=0,Wa=null,cU(h)):(Pn=0,Wa=null,hh(u,h,D,7));break;case 5:var V=null;switch(un.tag){case 26:V=un.memoizedState;case 5:case 27:var ne=un;if(V?XU(V):ne.stateNode.complete){Pn=0,Wa=null;var _e=ne.sibling;if(_e!==null)un=_e;else{var Fe=ne.return;Fe!==null?(un=Fe,Hv(Fe)):un=null}break t}}Pn=0,Wa=null,hh(u,h,D,5);break;case 6:Pn=0,Wa=null,hh(u,h,D,6);break;case 8:bE(),bi=6;break e;default:throw Error(i(462))}}VJ();break}catch(Je){rU(u,Je)}while(!0);return ol=pd=null,q.H=S,q.A=C,An=y,un!==null?0:(Wn=null,pn=0,ov(),bi)}function VJ(){for(;un!==null&&!te();)lU(un)}function lU(u){var h=DI(u.alternate,u,xl);u.memoizedProps=u.pendingProps,h===null?Hv(u):un=h}function cU(u){var h=u,y=h.alternate;switch(h.tag){case 15:case 0:h=AI(y,h,h.pendingProps,h.type,void 0,pn);break;case 11:h=AI(y,h,h.pendingProps,h.type.render,h.ref,pn);break;case 5:IM(h);default:kI(y,h),h=un=oL(h,xl),h=DI(y,h,xl)}u.memoizedProps=u.pendingProps,h===null?Hv(u):un=h}function hh(u,h,y,S){ol=pd=null,IM(h),nh=null,Fm=0;var C=h.return;try{if(PJ(u,C,h,y,pn)){bi=1,Nv(u,ps(y,u.current)),un=null;return}}catch(D){if(C!==null)throw un=C,D;bi=1,Nv(u,ps(y,u.current)),un=null;return}h.flags&32768?(vn||S===1?u=!0:ch||(pn&536870912)!==0?u=!1:(jc=u=!0,(S===2||S===9||S===3||S===6)&&(S=$a.current,S!==null&&S.tag===13&&(S.flags|=16384))),uU(h,u)):Hv(h)}function Hv(u){var h=u;do{if((h.flags&32768)!==0){uU(h,jc);return}u=h.return;var y=kJ(h.alternate,h,xl);if(y!==null){un=y;return}if(h=h.sibling,h!==null){un=h;return}un=h=u}while(h!==null);bi===0&&(bi=5)}function uU(u,h){do{var y=LJ(u.alternate,u);if(y!==null){y.flags&=32767,un=y;return}if(y=u.return,y!==null&&(y.flags|=32768,y.subtreeFlags=0,y.deletions=null),!h&&(u=u.sibling,u!==null)){un=u;return}un=u=y}while(u!==null);bi=6,un=null}function dU(u,h,y,S,C,D,V,ne,_e){u.cancelPendingCommit=null;do Vv();while(Zi!==0);if((An&6)!==0)throw Error(i(327));if(h!==null){if(h===u.current)throw Error(i(177));if(D=h.lanes|h.childLanes,D|=cM,Dt(u,y,D,V,ne,_e),u===Wn&&(un=Wn=null,pn=0),dh=h,Bc=u,vl=y,xE=D,vE=C,eU=S,(h.subtreeFlags&10256)!==0||(h.flags&10256)!==0?(u.callbackNode=null,u.callbackPriority=0,qJ(he,function(){return gU(),null})):(u.callbackNode=null,u.callbackPriority=0),S=(h.flags&13878)!==0,(h.subtreeFlags&13878)!==0||S){S=q.T,q.T=null,C=W.p,W.p=2,V=An,An|=4;try{IJ(u,h,y)}finally{An=V,W.p=C,q.T=S}}Zi=1,fU(),hU(),pU()}}function fU(){if(Zi===1){Zi=0;var u=Bc,h=dh,y=(h.flags&13878)!==0;if((h.subtreeFlags&13878)!==0||y){y=q.T,q.T=null;var S=W.p;W.p=2;var C=An;An|=4;try{WI(h,u);var D=OE,V=Qk(u.containerInfo),ne=D.focusedElem,_e=D.selectionRange;if(V!==ne&&ne&&ne.ownerDocument&&Zk(ne.ownerDocument.documentElement,ne)){if(_e!==null&&rM(ne)){var Fe=_e.start,Je=_e.end;if(Je===void 0&&(Je=Fe),"selectionStart"in ne)ne.selectionStart=Fe,ne.selectionEnd=Math.min(Je,ne.value.length);else{var st=ne.ownerDocument||document,Ve=st&&st.defaultView||window;if(Ve.getSelection){var Ke=Ve.getSelection(),Ct=ne.textContent.length,zt=Math.min(_e.start,Ct),Un=_e.end===void 0?zt:Math.min(_e.end,Ct);!Ke.extend&&zt>Un&&(V=Un,Un=zt,zt=V);var Oe=Yk(ne,zt),Ee=Yk(ne,Un);if(Oe&&Ee&&(Ke.rangeCount!==1||Ke.anchorNode!==Oe.node||Ke.anchorOffset!==Oe.offset||Ke.focusNode!==Ee.node||Ke.focusOffset!==Ee.offset)){var je=st.createRange();je.setStart(Oe.node,Oe.offset),Ke.removeAllRanges(),zt>Un?(Ke.addRange(je),Ke.extend(Ee.node,Ee.offset)):(je.setEnd(Ee.node,Ee.offset),Ke.addRange(je))}}}}for(st=[],Ke=ne;Ke=Ke.parentNode;)Ke.nodeType===1&&st.push({element:Ke,left:Ke.scrollLeft,top:Ke.scrollTop});for(typeof ne.focus=="function"&&ne.focus(),ne=0;ne<st.length;ne++){var it=st[ne];it.element.scrollLeft=it.left,it.element.scrollTop=it.top}}ty=!!DE,OE=DE=null}finally{An=C,W.p=S,q.T=y}}u.current=h,Zi=2}}function hU(){if(Zi===2){Zi=0;var u=Bc,h=dh,y=(h.flags&8772)!==0;if((h.subtreeFlags&8772)!==0||y){y=q.T,q.T=null;var S=W.p;W.p=2;var C=An;An|=4;try{BI(u,h.alternate,h)}finally{An=C,W.p=S,q.T=y}}Zi=3}}function pU(){if(Zi===4||Zi===3){Zi=0,j();var u=Bc,h=dh,y=vl,S=eU;(h.subtreeFlags&10256)!==0||(h.flags&10256)!==0?Zi=5:(Zi=0,dh=Bc=null,mU(u,u.pendingLanes));var C=u.pendingLanes;if(C===0&&(zc=null),hr(y),h=h.stateNode,Re&&typeof Re.onCommitFiberRoot=="function")try{Re.onCommitFiberRoot(Ie,h,void 0,(h.current.flags&128)===128)}catch{}if(S!==null){h=q.T,C=W.p,W.p=2,q.T=null;try{for(var D=u.onRecoverableError,V=0;V<S.length;V++){var ne=S[V];D(ne.value,{componentStack:ne.stack})}}finally{q.T=h,W.p=C}}(vl&3)!==0&&Vv(),Co(u),C=u.pendingLanes,(y&261930)!==0&&(C&42)!==0?u===yE?ng++:(ng=0,yE=u):ng=0,ig(0)}}function mU(u,h){(u.pooledCacheLanes&=h)===0&&(h=u.pooledCache,h!=null&&(u.pooledCache=null,Um(h)))}function Vv(){return fU(),hU(),pU(),gU()}function gU(){if(Zi!==5)return!1;var u=Bc,h=xE;xE=0;var y=hr(vl),S=q.T,C=W.p;try{W.p=32>y?32:y,q.T=null,y=vE,vE=null;var D=Bc,V=vl;if(Zi=0,dh=Bc=null,vl=0,(An&6)!==0)throw Error(i(331));var ne=An;if(An|=4,ZI(D.current),XI(D,D.current,V,y),An=ne,ig(0,!1),Re&&typeof Re.onPostCommitFiberRoot=="function")try{Re.onPostCommitFiberRoot(Ie,D)}catch{}return!0}finally{W.p=C,q.T=S,mU(u,h)}}function xU(u,h,y){h=ps(y,h),h=ZM(u.stateNode,h,2),u=kc(u,h,2),u!==null&&(an(u,2),Co(u))}function Dn(u,h,y){if(u.tag===3)xU(u,u,y);else for(;h!==null;){if(h.tag===3){xU(h,u,y);break}else if(h.tag===1){var S=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(zc===null||!zc.has(S))){u=ps(y,u),y=vI(2),S=kc(h,y,2),S!==null&&(yI(y,S,h,u),an(S,2),Co(S));break}}h=h.return}}function SE(u,h,y){var S=u.pingCache;if(S===null){S=u.pingCache=new FJ;var C=new Set;S.set(h,C)}else C=S.get(h),C===void 0&&(C=new Set,S.set(h,C));C.has(y)||(pE=!0,C.add(y),u=$J.bind(null,u,h,y),h.then(u,u))}function $J(u,h,y){var S=u.pingCache;S!==null&&S.delete(h),u.pingedLanes|=u.suspendedLanes&y,u.warmLanes&=~y,Wn===u&&(pn&y)===y&&(bi===4||bi===3&&(pn&62914560)===pn&&300>k()-Uv?(An&2)===0&&fh(u,0):mE|=y,uh===pn&&(uh=0)),Co(u)}function vU(u,h){h===0&&(h=bt()),u=dd(u,h),u!==null&&(an(u,h),Co(u))}function GJ(u){var h=u.memoizedState,y=0;h!==null&&(y=h.retryLane),vU(u,y)}function WJ(u,h){var y=0;switch(u.tag){case 31:case 13:var S=u.stateNode,C=u.memoizedState;C!==null&&(y=C.retryLane);break;case 19:S=u.stateNode;break;case 22:S=u.stateNode._retryCache;break;default:throw Error(i(314))}S!==null&&S.delete(h),vU(u,y)}function qJ(u,h){return De(u,h)}var $v=null,ph=null,wE=!1,Gv=!1,ME=!1,Vc=0;function Co(u){u!==ph&&u.next===null&&(ph===null?$v=ph=u:ph=ph.next=u),Gv=!0,wE||(wE=!0,KJ())}function ig(u,h){if(!ME&&Gv){ME=!0;do for(var y=!1,S=$v;S!==null;){if(u!==0){var C=S.pendingLanes;if(C===0)var D=0;else{var V=S.suspendedLanes,ne=S.pingedLanes;D=(1<<31-tt(42|u)+1)-1,D&=C&~(V&~ne),D=D&201326741?D&201326741|1:D?D|2:0}D!==0&&(y=!0,SU(S,D))}else D=pn,D=ge(S,S===Wn?D:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(D&3)===0||Be(S,D)||(y=!0,SU(S,D));S=S.next}while(y);ME=!1}}function XJ(){yU()}function yU(){Gv=wE=!1;var u=0;Vc!==0&&aee()&&(u=Vc);for(var h=k(),y=null,S=$v;S!==null;){var C=S.next,D=bU(S,h);D===0?(S.next=null,y===null?$v=C:y.next=C,C===null&&(ph=y)):(y=S,(u!==0||(D&3)!==0)&&(Gv=!0)),S=C}Zi!==0&&Zi!==5||ig(u),Vc!==0&&(Vc=0)}function bU(u,h){for(var y=u.suspendedLanes,S=u.pingedLanes,C=u.expirationTimes,D=u.pendingLanes&-62914561;0<D;){var V=31-tt(D),ne=1<<V,_e=C[V];_e===-1?((ne&y)===0||(ne&S)!==0)&&(C[V]=lt(ne,h)):_e<=h&&(u.expiredLanes|=ne),D&=~ne}if(h=Wn,y=pn,y=ge(u,u===h?y:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),S=u.callbackNode,y===0||u===h&&(Pn===2||Pn===9)||u.cancelPendingCommit!==null)return S!==null&&S!==null&&Ne(S),u.callbackNode=null,u.callbackPriority=0;if((y&3)===0||Be(u,y)){if(h=y&-y,h===u.callbackPriority)return h;switch(S!==null&&Ne(S),hr(y)){case 2:case 8:y=ye;break;case 32:y=he;break;case 268435456:y=Le;break;default:y=he}return S=_U.bind(null,u),y=De(y,S),u.callbackPriority=h,u.callbackNode=y,h}return S!==null&&S!==null&&Ne(S),u.callbackPriority=2,u.callbackNode=null,2}function _U(u,h){if(Zi!==0&&Zi!==5)return u.callbackNode=null,u.callbackPriority=0,null;var y=u.callbackNode;if(Vv()&&u.callbackNode!==y)return null;var S=pn;return S=ge(u,u===Wn?S:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),S===0?null:(nU(u,S,h),bU(u,k()),u.callbackNode!=null&&u.callbackNode===y?_U.bind(null,u):null)}function SU(u,h){if(Vv())return null;nU(u,h,!0)}function KJ(){oee(function(){(An&6)!==0?De(me,XJ):yU()})}function EE(){if(Vc===0){var u=Jf;u===0&&(u=nt,nt<<=1,(nt&261888)===0&&(nt=256)),Vc=u}return Vc}function wU(u){return u==null||typeof u=="symbol"||typeof u=="boolean"?null:typeof u=="function"?u:Jx(""+u)}function MU(u,h){var y=h.ownerDocument.createElement("input");return y.name=h.name,y.value=h.value,u.id&&y.setAttribute("form",u.id),h.parentNode.insertBefore(y,h),u=new FormData(u),y.parentNode.removeChild(y),u}function YJ(u,h,y,S,C){if(h==="submit"&&y&&y.stateNode===C){var D=wU((C[Ei]||null).action),V=S.submitter;V&&(h=(h=V[Ei]||null)?wU(h.formAction):V.getAttribute("formAction"),h!==null&&(D=h,V=null));var ne=new iv("action","action",null,S,C);u.push({event:ne,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(Vc!==0){var _e=V?MU(C,V):new FormData(C);GM(y,{pending:!0,data:_e,method:C.method,action:D},null,_e)}}else typeof D=="function"&&(ne.preventDefault(),_e=V?MU(C,V):new FormData(C),GM(y,{pending:!0,data:_e,method:C.method,action:D},D,_e))},currentTarget:C}]})}}for(var AE=0;AE<lM.length;AE++){var TE=lM[AE],ZJ=TE.toLowerCase(),QJ=TE[0].toUpperCase()+TE.slice(1);Zs(ZJ,"on"+QJ)}Zs(tL,"onAnimationEnd"),Zs(nL,"onAnimationIteration"),Zs(iL,"onAnimationStart"),Zs("dblclick","onDoubleClick"),Zs("focusin","onFocus"),Zs("focusout","onBlur"),Zs(pJ,"onTransitionRun"),Zs(mJ,"onTransitionStart"),Zs(gJ,"onTransitionCancel"),Zs(rL,"onTransitionEnd"),vt("onMouseEnter",["mouseout","mouseover"]),vt("onMouseLeave",["mouseout","mouseover"]),vt("onPointerEnter",["pointerout","pointerover"]),vt("onPointerLeave",["pointerout","pointerover"]),ut("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ut("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ut("onBeforeInput",["compositionend","keypress","textInput","paste"]),ut("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ut("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ut("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var rg="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),JJ=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(rg));function EU(u,h){h=(h&4)!==0;for(var y=0;y<u.length;y++){var S=u[y],C=S.event;S=S.listeners;e:{var D=void 0;if(h)for(var V=S.length-1;0<=V;V--){var ne=S[V],_e=ne.instance,Fe=ne.currentTarget;if(ne=ne.listener,_e!==D&&C.isPropagationStopped())break e;D=ne,C.currentTarget=Fe;try{D(C)}catch(Je){sv(Je)}C.currentTarget=null,D=_e}else for(V=0;V<S.length;V++){if(ne=S[V],_e=ne.instance,Fe=ne.currentTarget,ne=ne.listener,_e!==D&&C.isPropagationStopped())break e;D=ne,C.currentTarget=Fe;try{D(C)}catch(Je){sv(Je)}C.currentTarget=null,D=_e}}}}function dn(u,h){var y=h[Ac];y===void 0&&(y=h[Ac]=new Set);var S=u+"__bubble";y.has(S)||(AU(h,u,2,!1),y.add(S))}function CE(u,h,y){var S=0;h&&(S|=4),AU(y,u,S,h)}var Wv="_reactListening"+Math.random().toString(36).slice(2);function NE(u){if(!u[Wv]){u[Wv]=!0,Se.forEach(function(y){y!=="selectionchange"&&(JJ.has(y)||CE(y,!1,u),CE(y,!0,u))});var h=u.nodeType===9?u:u.ownerDocument;h===null||h[Wv]||(h[Wv]=!0,CE("selectionchange",!1,h))}}function AU(u,h,y,S){switch(t4(h)){case 2:var C=Tee;break;case 8:C=Cee;break;default:C=$E}y=C.bind(null,h,y,u),C=void 0,!Kw||h!=="touchstart"&&h!=="touchmove"&&h!=="wheel"||(C=!0),S?C!==void 0?u.addEventListener(h,y,{capture:!0,passive:C}):u.addEventListener(h,y,!0):C!==void 0?u.addEventListener(h,y,{passive:C}):u.addEventListener(h,y,!1)}function RE(u,h,y,S,C){var D=S;if((h&1)===0&&(h&2)===0&&S!==null)e:for(;;){if(S===null)return;var V=S.tag;if(V===3||V===4){var ne=S.stateNode.containerInfo;if(ne===C)break;if(V===4)for(V=S.return;V!==null;){var _e=V.tag;if((_e===3||_e===4)&&V.stateNode.containerInfo===C)return;V=V.return}for(;ne!==null;){if(V=_t(ne),V===null)return;if(_e=V.tag,_e===5||_e===6||_e===26||_e===27){S=D=V;continue e}ne=ne.parentNode}}S=S.return}Pk(function(){var Fe=D,Je=qw(y),st=[];e:{var Ve=aL.get(u);if(Ve!==void 0){var Ke=iv,Ct=u;switch(u){case"keypress":if(tv(y)===0)break e;case"keydown":case"keyup":Ke=WQ;break;case"focusin":Ct="focus",Ke=Jw;break;case"focusout":Ct="blur",Ke=Jw;break;case"beforeblur":case"afterblur":Ke=Jw;break;case"click":if(y.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ke=kk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ke=kQ;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ke=KQ;break;case tL:case nL:case iL:Ke=UQ;break;case rL:Ke=ZQ;break;case"scroll":case"scrollend":Ke=DQ;break;case"wheel":Ke=JQ;break;case"copy":case"cut":case"paste":Ke=FQ;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ke=Ik;break;case"toggle":case"beforetoggle":Ke=tJ}var zt=(h&4)!==0,Un=!zt&&(u==="scroll"||u==="scrollend"),Oe=zt?Ve!==null?Ve+"Capture":null:Ve;zt=[];for(var Ee=Fe,je;Ee!==null;){var it=Ee;if(je=it.stateNode,it=it.tag,it!==5&&it!==26&&it!==27||je===null||Oe===null||(it=Am(Ee,Oe),it!=null&&zt.push(ag(Ee,it,je))),Un)break;Ee=Ee.return}0<zt.length&&(Ve=new Ke(Ve,Ct,null,y,Je),st.push({event:Ve,listeners:zt}))}}if((h&7)===0){e:{if(Ve=u==="mouseover"||u==="pointerover",Ke=u==="mouseout"||u==="pointerout",Ve&&y!==Ww&&(Ct=y.relatedTarget||y.fromElement)&&(_t(Ct)||Ct[Ks]))break e;if((Ke||Ve)&&(Ve=Je.window===Je?Je:(Ve=Je.ownerDocument)?Ve.defaultView||Ve.parentWindow:window,Ke?(Ct=y.relatedTarget||y.toElement,Ke=Fe,Ct=Ct?_t(Ct):null,Ct!==null&&(Un=a(Ct),zt=Ct.tag,Ct!==Un||zt!==5&&zt!==27&&zt!==6)&&(Ct=null)):(Ke=null,Ct=Fe),Ke!==Ct)){if(zt=kk,it="onMouseLeave",Oe="onMouseEnter",Ee="mouse",(u==="pointerout"||u==="pointerover")&&(zt=Ik,it="onPointerLeave",Oe="onPointerEnter",Ee="pointer"),Un=Ke==null?Ve:be(Ke),je=Ct==null?Ve:be(Ct),Ve=new zt(it,Ee+"leave",Ke,y,Je),Ve.target=Un,Ve.relatedTarget=je,it=null,_t(Je)===Fe&&(zt=new zt(Oe,Ee+"enter",Ct,y,Je),zt.target=je,zt.relatedTarget=Un,it=zt),Un=it,Ke&&Ct)t:{for(zt=eee,Oe=Ke,Ee=Ct,je=0,it=Oe;it;it=zt(it))je++;it=0;for(var Lt=Ee;Lt;Lt=zt(Lt))it++;for(;0<je-it;)Oe=zt(Oe),je--;for(;0<it-je;)Ee=zt(Ee),it--;for(;je--;){if(Oe===Ee||Ee!==null&&Oe===Ee.alternate){zt=Oe;break t}Oe=zt(Oe),Ee=zt(Ee)}zt=null}else zt=null;Ke!==null&&TU(st,Ve,Ke,zt,!1),Ct!==null&&Un!==null&&TU(st,Un,Ct,zt,!0)}}e:{if(Ve=Fe?be(Fe):window,Ke=Ve.nodeName&&Ve.nodeName.toLowerCase(),Ke==="select"||Ke==="input"&&Ve.type==="file")var _n=$k;else if(Hk(Ve))if(Gk)_n=dJ;else{_n=cJ;var Pt=lJ}else Ke=Ve.nodeName,!Ke||Ke.toLowerCase()!=="input"||Ve.type!=="checkbox"&&Ve.type!=="radio"?Fe&&Gw(Fe.elementType)&&(_n=$k):_n=uJ;if(_n&&(_n=_n(u,Fe))){Vk(st,_n,y,Je);break e}Pt&&Pt(u,Ve,Fe),u==="focusout"&&Fe&&Ve.type==="number"&&Fe.memoizedProps.value!=null&&pr(Ve,"number",Ve.value)}switch(Pt=Fe?be(Fe):window,u){case"focusin":(Hk(Pt)||Pt.contentEditable==="true")&&(Gf=Pt,aM=Fe,km=null);break;case"focusout":km=aM=Gf=null;break;case"mousedown":sM=!0;break;case"contextmenu":case"mouseup":case"dragend":sM=!1,Jk(st,y,Je);break;case"selectionchange":if(hJ)break;case"keydown":case"keyup":Jk(st,y,Je)}var Zt;if(tM)e:{switch(u){case"compositionstart":var mn="onCompositionStart";break e;case"compositionend":mn="onCompositionEnd";break e;case"compositionupdate":mn="onCompositionUpdate";break e}mn=void 0}else $f?zk(u,y)&&(mn="onCompositionEnd"):u==="keydown"&&y.keyCode===229&&(mn="onCompositionStart");mn&&(Uk&&y.locale!=="ko"&&($f||mn!=="onCompositionStart"?mn==="onCompositionEnd"&&$f&&(Zt=Dk()):(Tc=Je,Yw="value"in Tc?Tc.value:Tc.textContent,$f=!0)),Pt=qv(Fe,mn),0<Pt.length&&(mn=new Lk(mn,u,null,y,Je),st.push({event:mn,listeners:Pt}),Zt?mn.data=Zt:(Zt=Bk(y),Zt!==null&&(mn.data=Zt)))),(Zt=iJ?rJ(u,y):aJ(u,y))&&(mn=qv(Fe,"onBeforeInput"),0<mn.length&&(Pt=new Lk("onBeforeInput","beforeinput",null,y,Je),st.push({event:Pt,listeners:mn}),Pt.data=Zt)),YJ(st,u,Fe,y,Je)}EU(st,h)})}function ag(u,h,y){return{instance:u,listener:h,currentTarget:y}}function qv(u,h){for(var y=h+"Capture",S=[];u!==null;){var C=u,D=C.stateNode;if(C=C.tag,C!==5&&C!==26&&C!==27||D===null||(C=Am(u,y),C!=null&&S.unshift(ag(u,C,D)),C=Am(u,h),C!=null&&S.push(ag(u,C,D))),u.tag===3)return S;u=u.return}return[]}function eee(u){if(u===null)return null;do u=u.return;while(u&&u.tag!==5&&u.tag!==27);return u||null}function TU(u,h,y,S,C){for(var D=h._reactName,V=[];y!==null&&y!==S;){var ne=y,_e=ne.alternate,Fe=ne.stateNode;if(ne=ne.tag,_e!==null&&_e===S)break;ne!==5&&ne!==26&&ne!==27||Fe===null||(_e=Fe,C?(Fe=Am(y,D),Fe!=null&&V.unshift(ag(y,Fe,_e))):C||(Fe=Am(y,D),Fe!=null&&V.push(ag(y,Fe,_e)))),y=y.return}V.length!==0&&u.push({event:h,listeners:V})}var tee=/\r\n?/g,nee=/\u0000|\uFFFD/g;function CU(u){return(typeof u=="string"?u:""+u).replace(tee,`
- `).replace(nee,"")}function NU(u,h){return h=CU(h),CU(u)===h}function In(u,h,y,S,C,D){switch(y){case"children":typeof S=="string"?h==="body"||h==="textarea"&&S===""||Mo(u,S):(typeof S=="number"||typeof S=="bigint")&&h!=="body"&&Mo(u,""+S);break;case"className":kt(u,"class",S);break;case"tabIndex":kt(u,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":kt(u,y,S);break;case"style":Nk(u,S,D);break;case"data":if(h!=="object"){kt(u,"data",S);break}case"src":case"href":if(S===""&&(h!=="a"||y!=="href")){u.removeAttribute(y);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){u.removeAttribute(y);break}S=Jx(""+S),u.setAttribute(y,S);break;case"action":case"formAction":if(typeof S=="function"){u.setAttribute(y,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof D=="function"&&(y==="formAction"?(h!=="input"&&In(u,h,"name",C.name,C,null),In(u,h,"formEncType",C.formEncType,C,null),In(u,h,"formMethod",C.formMethod,C,null),In(u,h,"formTarget",C.formTarget,C,null)):(In(u,h,"encType",C.encType,C,null),In(u,h,"method",C.method,C,null),In(u,h,"target",C.target,C,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){u.removeAttribute(y);break}S=Jx(""+S),u.setAttribute(y,S);break;case"onClick":S!=null&&(u.onclick=il);break;case"onScroll":S!=null&&dn("scroll",u);break;case"onScrollEnd":S!=null&&dn("scrollend",u);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(i(61));if(y=S.__html,y!=null){if(C.children!=null)throw Error(i(60));u.innerHTML=y}}break;case"multiple":u.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":u.muted=S&&typeof S!="function"&&typeof S!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(S==null||typeof S=="function"||typeof S=="boolean"||typeof S=="symbol"){u.removeAttribute("xlink:href");break}y=Jx(""+S),u.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",y);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":S!=null&&typeof S!="function"&&typeof S!="symbol"?u.setAttribute(y,""+S):u.removeAttribute(y);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":S&&typeof S!="function"&&typeof S!="symbol"?u.setAttribute(y,""):u.removeAttribute(y);break;case"capture":case"download":S===!0?u.setAttribute(y,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?u.setAttribute(y,S):u.removeAttribute(y);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?u.setAttribute(y,S):u.removeAttribute(y);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?u.removeAttribute(y):u.setAttribute(y,S);break;case"popover":dn("beforetoggle",u),dn("toggle",u),Vt(u,"popover",S);break;case"xlinkActuate":Qt(u,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":Qt(u,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":Qt(u,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":Qt(u,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":Qt(u,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":Qt(u,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":Qt(u,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":Qt(u,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":Qt(u,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":Vt(u,"is",S);break;case"innerText":case"textContent":break;default:(!(2<y.length)||y[0]!=="o"&&y[0]!=="O"||y[1]!=="n"&&y[1]!=="N")&&(y=RQ.get(y)||y,Vt(u,y,S))}}function PE(u,h,y,S,C,D){switch(y){case"style":Nk(u,S,D);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(i(61));if(y=S.__html,y!=null){if(C.children!=null)throw Error(i(60));u.innerHTML=y}}break;case"children":typeof S=="string"?Mo(u,S):(typeof S=="number"||typeof S=="bigint")&&Mo(u,""+S);break;case"onScroll":S!=null&&dn("scroll",u);break;case"onScrollEnd":S!=null&&dn("scrollend",u);break;case"onClick":S!=null&&(u.onclick=il);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Qe.hasOwnProperty(y))e:{if(y[0]==="o"&&y[1]==="n"&&(C=y.endsWith("Capture"),h=y.slice(2,C?y.length-7:void 0),D=u[Ei]||null,D=D!=null?D[y]:null,typeof D=="function"&&u.removeEventListener(h,D,C),typeof S=="function")){typeof D!="function"&&D!==null&&(y in u?u[y]=null:u.hasAttribute(y)&&u.removeAttribute(y)),u.addEventListener(h,S,C);break e}y in u?u[y]=S:S===!0?u.setAttribute(y,""):Vt(u,y,S)}}}function Or(u,h,y){switch(h){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":dn("error",u),dn("load",u);var S=!1,C=!1,D;for(D in y)if(y.hasOwnProperty(D)){var V=y[D];if(V!=null)switch(D){case"src":S=!0;break;case"srcSet":C=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,h));default:In(u,h,D,V,y,null)}}C&&In(u,h,"srcSet",y.srcSet,y,null),S&&In(u,h,"src",y.src,y,null);return;case"input":dn("invalid",u);var ne=D=V=C=null,_e=null,Fe=null;for(S in y)if(y.hasOwnProperty(S)){var Je=y[S];if(Je!=null)switch(S){case"name":C=Je;break;case"type":V=Je;break;case"checked":_e=Je;break;case"defaultChecked":Fe=Je;break;case"value":D=Je;break;case"defaultValue":ne=Je;break;case"children":case"dangerouslySetInnerHTML":if(Je!=null)throw Error(i(137,h));break;default:In(u,h,S,Je,y,null)}}Rn(u,D,ne,_e,Fe,V,C,!1);return;case"select":dn("invalid",u),S=V=D=null;for(C in y)if(y.hasOwnProperty(C)&&(ne=y[C],ne!=null))switch(C){case"value":D=ne;break;case"defaultValue":V=ne;break;case"multiple":S=ne;default:In(u,h,C,ne,y,null)}h=D,y=V,u.multiple=!!S,h!=null?Yi(u,!!S,h,!1):y!=null&&Yi(u,!!S,y,!0);return;case"textarea":dn("invalid",u),D=C=S=null;for(V in y)if(y.hasOwnProperty(V)&&(ne=y[V],ne!=null))switch(V){case"value":S=ne;break;case"defaultValue":C=ne;break;case"children":D=ne;break;case"dangerouslySetInnerHTML":if(ne!=null)throw Error(i(91));break;default:In(u,h,V,ne,y,null)}Nr(u,S,C,D);return;case"option":for(_e in y)if(y.hasOwnProperty(_e)&&(S=y[_e],S!=null))switch(_e){case"selected":u.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:In(u,h,_e,S,y,null)}return;case"dialog":dn("beforetoggle",u),dn("toggle",u),dn("cancel",u),dn("close",u);break;case"iframe":case"object":dn("load",u);break;case"video":case"audio":for(S=0;S<rg.length;S++)dn(rg[S],u);break;case"image":dn("error",u),dn("load",u);break;case"details":dn("toggle",u);break;case"embed":case"source":case"link":dn("error",u),dn("load",u);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Fe in y)if(y.hasOwnProperty(Fe)&&(S=y[Fe],S!=null))switch(Fe){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,h));default:In(u,h,Fe,S,y,null)}return;default:if(Gw(h)){for(Je in y)y.hasOwnProperty(Je)&&(S=y[Je],S!==void 0&&PE(u,h,Je,S,y,void 0));return}}for(ne in y)y.hasOwnProperty(ne)&&(S=y[ne],S!=null&&In(u,h,ne,S,y,null))}function iee(u,h,y,S){switch(h){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var C=null,D=null,V=null,ne=null,_e=null,Fe=null,Je=null;for(Ke in y){var st=y[Ke];if(y.hasOwnProperty(Ke)&&st!=null)switch(Ke){case"checked":break;case"value":break;case"defaultValue":_e=st;default:S.hasOwnProperty(Ke)||In(u,h,Ke,null,S,st)}}for(var Ve in S){var Ke=S[Ve];if(st=y[Ve],S.hasOwnProperty(Ve)&&(Ke!=null||st!=null))switch(Ve){case"type":D=Ke;break;case"name":C=Ke;break;case"checked":Fe=Ke;break;case"defaultChecked":Je=Ke;break;case"value":V=Ke;break;case"defaultValue":ne=Ke;break;case"children":case"dangerouslySetInnerHTML":if(Ke!=null)throw Error(i(137,h));break;default:Ke!==st&&In(u,h,Ve,Ke,S,st)}}Ys(u,V,ne,_e,Fe,Je,D,C);return;case"select":Ke=V=ne=Ve=null;for(D in y)if(_e=y[D],y.hasOwnProperty(D)&&_e!=null)switch(D){case"value":break;case"multiple":Ke=_e;default:S.hasOwnProperty(D)||In(u,h,D,null,S,_e)}for(C in S)if(D=S[C],_e=y[C],S.hasOwnProperty(C)&&(D!=null||_e!=null))switch(C){case"value":Ve=D;break;case"defaultValue":ne=D;break;case"multiple":V=D;default:D!==_e&&In(u,h,C,D,S,_e)}h=ne,y=V,S=Ke,Ve!=null?Yi(u,!!y,Ve,!1):!!S!=!!y&&(h!=null?Yi(u,!!y,h,!0):Yi(u,!!y,y?[]:"",!1));return;case"textarea":Ke=Ve=null;for(ne in y)if(C=y[ne],y.hasOwnProperty(ne)&&C!=null&&!S.hasOwnProperty(ne))switch(ne){case"value":break;case"children":break;default:In(u,h,ne,null,S,C)}for(V in S)if(C=S[V],D=y[V],S.hasOwnProperty(V)&&(C!=null||D!=null))switch(V){case"value":Ve=C;break;case"defaultValue":Ke=C;break;case"children":break;case"dangerouslySetInnerHTML":if(C!=null)throw Error(i(91));break;default:C!==D&&In(u,h,V,C,S,D)}mr(u,Ve,Ke);return;case"option":for(var Ct in y)if(Ve=y[Ct],y.hasOwnProperty(Ct)&&Ve!=null&&!S.hasOwnProperty(Ct))switch(Ct){case"selected":u.selected=!1;break;default:In(u,h,Ct,null,S,Ve)}for(_e in S)if(Ve=S[_e],Ke=y[_e],S.hasOwnProperty(_e)&&Ve!==Ke&&(Ve!=null||Ke!=null))switch(_e){case"selected":u.selected=Ve&&typeof Ve!="function"&&typeof Ve!="symbol";break;default:In(u,h,_e,Ve,S,Ke)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var zt in y)Ve=y[zt],y.hasOwnProperty(zt)&&Ve!=null&&!S.hasOwnProperty(zt)&&In(u,h,zt,null,S,Ve);for(Fe in S)if(Ve=S[Fe],Ke=y[Fe],S.hasOwnProperty(Fe)&&Ve!==Ke&&(Ve!=null||Ke!=null))switch(Fe){case"children":case"dangerouslySetInnerHTML":if(Ve!=null)throw Error(i(137,h));break;default:In(u,h,Fe,Ve,S,Ke)}return;default:if(Gw(h)){for(var Un in y)Ve=y[Un],y.hasOwnProperty(Un)&&Ve!==void 0&&!S.hasOwnProperty(Un)&&PE(u,h,Un,void 0,S,Ve);for(Je in S)Ve=S[Je],Ke=y[Je],!S.hasOwnProperty(Je)||Ve===Ke||Ve===void 0&&Ke===void 0||PE(u,h,Je,Ve,S,Ke);return}}for(var Oe in y)Ve=y[Oe],y.hasOwnProperty(Oe)&&Ve!=null&&!S.hasOwnProperty(Oe)&&In(u,h,Oe,null,S,Ve);for(st in S)Ve=S[st],Ke=y[st],!S.hasOwnProperty(st)||Ve===Ke||Ve==null&&Ke==null||In(u,h,st,Ve,S,Ke)}function RU(u){switch(u){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ree(){if(typeof performance.getEntriesByType=="function"){for(var u=0,h=0,y=performance.getEntriesByType("resource"),S=0;S<y.length;S++){var C=y[S],D=C.transferSize,V=C.initiatorType,ne=C.duration;if(D&&ne&&RU(V)){for(V=0,ne=C.responseEnd,S+=1;S<y.length;S++){var _e=y[S],Fe=_e.startTime;if(Fe>ne)break;var Je=_e.transferSize,st=_e.initiatorType;Je&&RU(st)&&(_e=_e.responseEnd,V+=Je*(_e<ne?1:(ne-Fe)/(_e-Fe)))}if(--S,h+=8*(D+V)/(C.duration/1e3),u++,10<u)break}}if(0<u)return h/u/1e6}return navigator.connection&&(u=navigator.connection.downlink,typeof u=="number")?u:5}var DE=null,OE=null;function Xv(u){return u.nodeType===9?u:u.ownerDocument}function PU(u){switch(u){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function DU(u,h){if(u===0)switch(h){case"svg":return 1;case"math":return 2;default:return 0}return u===1&&h==="foreignObject"?0:u}function kE(u,h){return u==="textarea"||u==="noscript"||typeof h.children=="string"||typeof h.children=="number"||typeof h.children=="bigint"||typeof h.dangerouslySetInnerHTML=="object"&&h.dangerouslySetInnerHTML!==null&&h.dangerouslySetInnerHTML.__html!=null}var LE=null;function aee(){var u=window.event;return u&&u.type==="popstate"?u===LE?!1:(LE=u,!0):(LE=null,!1)}var OU=typeof setTimeout=="function"?setTimeout:void 0,see=typeof clearTimeout=="function"?clearTimeout:void 0,kU=typeof Promise=="function"?Promise:void 0,oee=typeof queueMicrotask=="function"?queueMicrotask:typeof kU<"u"?function(u){return kU.resolve(null).then(u).catch(lee)}:OU;function lee(u){setTimeout(function(){throw u})}function $c(u){return u==="head"}function LU(u,h){var y=h,S=0;do{var C=y.nextSibling;if(u.removeChild(y),C&&C.nodeType===8)if(y=C.data,y==="/$"||y==="/&"){if(S===0){u.removeChild(C),vh(h);return}S--}else if(y==="$"||y==="$?"||y==="$~"||y==="$!"||y==="&")S++;else if(y==="html")sg(u.ownerDocument.documentElement);else if(y==="head"){y=u.ownerDocument.head,sg(y);for(var D=y.firstChild;D;){var V=D.nextSibling,ne=D.nodeName;D[Xe]||ne==="SCRIPT"||ne==="STYLE"||ne==="LINK"&&D.rel.toLowerCase()==="stylesheet"||y.removeChild(D),D=V}}else y==="body"&&sg(u.ownerDocument.body);y=C}while(y);vh(h)}function IU(u,h){var y=u;u=0;do{var S=y.nextSibling;if(y.nodeType===1?h?(y._stashedDisplay=y.style.display,y.style.display="none"):(y.style.display=y._stashedDisplay||"",y.getAttribute("style")===""&&y.removeAttribute("style")):y.nodeType===3&&(h?(y._stashedText=y.nodeValue,y.nodeValue=""):y.nodeValue=y._stashedText||""),S&&S.nodeType===8)if(y=S.data,y==="/$"){if(u===0)break;u--}else y!=="$"&&y!=="$?"&&y!=="$~"&&y!=="$!"||u++;y=S}while(y)}function IE(u){var h=u.firstChild;for(h&&h.nodeType===10&&(h=h.nextSibling);h;){var y=h;switch(h=h.nextSibling,y.nodeName){case"HTML":case"HEAD":case"BODY":IE(y),Ge(y);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(y.rel.toLowerCase()==="stylesheet")continue}u.removeChild(y)}}function cee(u,h,y,S){for(;u.nodeType===1;){var C=y;if(u.nodeName.toLowerCase()!==h.toLowerCase()){if(!S&&(u.nodeName!=="INPUT"||u.type!=="hidden"))break}else if(S){if(!u[Xe])switch(h){case"meta":if(!u.hasAttribute("itemprop"))break;return u;case"link":if(D=u.getAttribute("rel"),D==="stylesheet"&&u.hasAttribute("data-precedence"))break;if(D!==C.rel||u.getAttribute("href")!==(C.href==null||C.href===""?null:C.href)||u.getAttribute("crossorigin")!==(C.crossOrigin==null?null:C.crossOrigin)||u.getAttribute("title")!==(C.title==null?null:C.title))break;return u;case"style":if(u.hasAttribute("data-precedence"))break;return u;case"script":if(D=u.getAttribute("src"),(D!==(C.src==null?null:C.src)||u.getAttribute("type")!==(C.type==null?null:C.type)||u.getAttribute("crossorigin")!==(C.crossOrigin==null?null:C.crossOrigin))&&D&&u.hasAttribute("async")&&!u.hasAttribute("itemprop"))break;return u;default:return u}}else if(h==="input"&&u.type==="hidden"){var D=C.name==null?null:""+C.name;if(C.type==="hidden"&&u.getAttribute("name")===D)return u}else return u;if(u=ys(u.nextSibling),u===null)break}return null}function uee(u,h,y){if(h==="")return null;for(;u.nodeType!==3;)if((u.nodeType!==1||u.nodeName!=="INPUT"||u.type!=="hidden")&&!y||(u=ys(u.nextSibling),u===null))return null;return u}function UU(u,h){for(;u.nodeType!==8;)if((u.nodeType!==1||u.nodeName!=="INPUT"||u.type!=="hidden")&&!h||(u=ys(u.nextSibling),u===null))return null;return u}function UE(u){return u.data==="$?"||u.data==="$~"}function jE(u){return u.data==="$!"||u.data==="$?"&&u.ownerDocument.readyState!=="loading"}function dee(u,h){var y=u.ownerDocument;if(u.data==="$~")u._reactRetry=h;else if(u.data!=="$?"||y.readyState!=="loading")h();else{var S=function(){h(),y.removeEventListener("DOMContentLoaded",S)};y.addEventListener("DOMContentLoaded",S),u._reactRetry=S}}function ys(u){for(;u!=null;u=u.nextSibling){var h=u.nodeType;if(h===1||h===3)break;if(h===8){if(h=u.data,h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"||h==="F!"||h==="F")break;if(h==="/$"||h==="/&")return null}}return u}var FE=null;function jU(u){u=u.nextSibling;for(var h=0;u;){if(u.nodeType===8){var y=u.data;if(y==="/$"||y==="/&"){if(h===0)return ys(u.nextSibling);h--}else y!=="$"&&y!=="$!"&&y!=="$?"&&y!=="$~"&&y!=="&"||h++}u=u.nextSibling}return null}function FU(u){u=u.previousSibling;for(var h=0;u;){if(u.nodeType===8){var y=u.data;if(y==="$"||y==="$!"||y==="$?"||y==="$~"||y==="&"){if(h===0)return u;h--}else y!=="/$"&&y!=="/&"||h++}u=u.previousSibling}return null}function zU(u,h,y){switch(h=Xv(y),u){case"html":if(u=h.documentElement,!u)throw Error(i(452));return u;case"head":if(u=h.head,!u)throw Error(i(453));return u;case"body":if(u=h.body,!u)throw Error(i(454));return u;default:throw Error(i(451))}}function sg(u){for(var h=u.attributes;h.length;)u.removeAttributeNode(h[0]);Ge(u)}var bs=new Map,BU=new Set;function Kv(u){return typeof u.getRootNode=="function"?u.getRootNode():u.nodeType===9?u:u.ownerDocument}var yl=W.d;W.d={f:fee,r:hee,D:pee,C:mee,L:gee,m:xee,X:yee,S:vee,M:bee};function fee(){var u=yl.f(),h=zv();return u||h}function hee(u){var h=Z(u);h!==null&&h.tag===5&&h.type==="form"?rI(h):yl.r(u)}var mh=typeof document>"u"?null:document;function HU(u,h,y){var S=mh;if(S&&typeof h=="string"&&h){var C=Tn(h);C='link[rel="'+u+'"][href="'+C+'"]',typeof y=="string"&&(C+='[crossorigin="'+y+'"]'),BU.has(C)||(BU.add(C),u={rel:u,crossOrigin:y,href:h},S.querySelector(C)===null&&(h=S.createElement("link"),Or(h,"link",u),Te(h),S.head.appendChild(h)))}}function pee(u){yl.D(u),HU("dns-prefetch",u,null)}function mee(u,h){yl.C(u,h),HU("preconnect",u,h)}function gee(u,h,y){yl.L(u,h,y);var S=mh;if(S&&u&&h){var C='link[rel="preload"][as="'+Tn(h)+'"]';h==="image"&&y&&y.imageSrcSet?(C+='[imagesrcset="'+Tn(y.imageSrcSet)+'"]',typeof y.imageSizes=="string"&&(C+='[imagesizes="'+Tn(y.imageSizes)+'"]')):C+='[href="'+Tn(u)+'"]';var D=C;switch(h){case"style":D=gh(u);break;case"script":D=xh(u)}bs.has(D)||(u=f({rel:"preload",href:h==="image"&&y&&y.imageSrcSet?void 0:u,as:h},y),bs.set(D,u),S.querySelector(C)!==null||h==="style"&&S.querySelector(og(D))||h==="script"&&S.querySelector(lg(D))||(h=S.createElement("link"),Or(h,"link",u),Te(h),S.head.appendChild(h)))}}function xee(u,h){yl.m(u,h);var y=mh;if(y&&u){var S=h&&typeof h.as=="string"?h.as:"script",C='link[rel="modulepreload"][as="'+Tn(S)+'"][href="'+Tn(u)+'"]',D=C;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":D=xh(u)}if(!bs.has(D)&&(u=f({rel:"modulepreload",href:u},h),bs.set(D,u),y.querySelector(C)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(y.querySelector(lg(D)))return}S=y.createElement("link"),Or(S,"link",u),Te(S),y.head.appendChild(S)}}}function vee(u,h,y){yl.S(u,h,y);var S=mh;if(S&&u){var C=Ce(S).hoistableStyles,D=gh(u);h=h||"default";var V=C.get(D);if(!V){var ne={loading:0,preload:null};if(V=S.querySelector(og(D)))ne.loading=5;else{u=f({rel:"stylesheet",href:u,"data-precedence":h},y),(y=bs.get(D))&&zE(u,y);var _e=V=S.createElement("link");Te(_e),Or(_e,"link",u),_e._p=new Promise(function(Fe,Je){_e.onload=Fe,_e.onerror=Je}),_e.addEventListener("load",function(){ne.loading|=1}),_e.addEventListener("error",function(){ne.loading|=2}),ne.loading|=4,Yv(V,h,S)}V={type:"stylesheet",instance:V,count:1,state:ne},C.set(D,V)}}}function yee(u,h){yl.X(u,h);var y=mh;if(y&&u){var S=Ce(y).hoistableScripts,C=xh(u),D=S.get(C);D||(D=y.querySelector(lg(C)),D||(u=f({src:u,async:!0},h),(h=bs.get(C))&&BE(u,h),D=y.createElement("script"),Te(D),Or(D,"link",u),y.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(C,D))}}function bee(u,h){yl.M(u,h);var y=mh;if(y&&u){var S=Ce(y).hoistableScripts,C=xh(u),D=S.get(C);D||(D=y.querySelector(lg(C)),D||(u=f({src:u,async:!0,type:"module"},h),(h=bs.get(C))&&BE(u,h),D=y.createElement("script"),Te(D),Or(D,"link",u),y.head.appendChild(D)),D={type:"script",instance:D,count:1,state:null},S.set(C,D))}}function VU(u,h,y,S){var C=(C=re.current)?Kv(C):null;if(!C)throw Error(i(446));switch(u){case"meta":case"title":return null;case"style":return typeof y.precedence=="string"&&typeof y.href=="string"?(h=gh(y.href),y=Ce(C).hoistableStyles,S=y.get(h),S||(S={type:"style",instance:null,count:0,state:null},y.set(h,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(y.rel==="stylesheet"&&typeof y.href=="string"&&typeof y.precedence=="string"){u=gh(y.href);var D=Ce(C).hoistableStyles,V=D.get(u);if(V||(C=C.ownerDocument||C,V={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},D.set(u,V),(D=C.querySelector(og(u)))&&!D._p&&(V.instance=D,V.state.loading=5),bs.has(u)||(y={rel:"preload",as:"style",href:y.href,crossOrigin:y.crossOrigin,integrity:y.integrity,media:y.media,hrefLang:y.hrefLang,referrerPolicy:y.referrerPolicy},bs.set(u,y),D||_ee(C,u,y,V.state))),h&&S===null)throw Error(i(528,""));return V}if(h&&S!==null)throw Error(i(529,""));return null;case"script":return h=y.async,y=y.src,typeof y=="string"&&h&&typeof h!="function"&&typeof h!="symbol"?(h=xh(y),y=Ce(C).hoistableScripts,S=y.get(h),S||(S={type:"script",instance:null,count:0,state:null},y.set(h,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,u))}}function gh(u){return'href="'+Tn(u)+'"'}function og(u){return'link[rel="stylesheet"]['+u+"]"}function $U(u){return f({},u,{"data-precedence":u.precedence,precedence:null})}function _ee(u,h,y,S){u.querySelector('link[rel="preload"][as="style"]['+h+"]")?S.loading=1:(h=u.createElement("link"),S.preload=h,h.addEventListener("load",function(){return S.loading|=1}),h.addEventListener("error",function(){return S.loading|=2}),Or(h,"link",y),Te(h),u.head.appendChild(h))}function xh(u){return'[src="'+Tn(u)+'"]'}function lg(u){return"script[async]"+u}function GU(u,h,y){if(h.count++,h.instance===null)switch(h.type){case"style":var S=u.querySelector('style[data-href~="'+Tn(y.href)+'"]');if(S)return h.instance=S,Te(S),S;var C=f({},y,{"data-href":y.href,"data-precedence":y.precedence,href:null,precedence:null});return S=(u.ownerDocument||u).createElement("style"),Te(S),Or(S,"style",C),Yv(S,y.precedence,u),h.instance=S;case"stylesheet":C=gh(y.href);var D=u.querySelector(og(C));if(D)return h.state.loading|=4,h.instance=D,Te(D),D;S=$U(y),(C=bs.get(C))&&zE(S,C),D=(u.ownerDocument||u).createElement("link"),Te(D);var V=D;return V._p=new Promise(function(ne,_e){V.onload=ne,V.onerror=_e}),Or(D,"link",S),h.state.loading|=4,Yv(D,y.precedence,u),h.instance=D;case"script":return D=xh(y.src),(C=u.querySelector(lg(D)))?(h.instance=C,Te(C),C):(S=y,(C=bs.get(D))&&(S=f({},y),BE(S,C)),u=u.ownerDocument||u,C=u.createElement("script"),Te(C),Or(C,"link",S),u.head.appendChild(C),h.instance=C);case"void":return null;default:throw Error(i(443,h.type))}else h.type==="stylesheet"&&(h.state.loading&4)===0&&(S=h.instance,h.state.loading|=4,Yv(S,y.precedence,u));return h.instance}function Yv(u,h,y){for(var S=y.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),C=S.length?S[S.length-1]:null,D=C,V=0;V<S.length;V++){var ne=S[V];if(ne.dataset.precedence===h)D=ne;else if(D!==C)break}D?D.parentNode.insertBefore(u,D.nextSibling):(h=y.nodeType===9?y.head:y,h.insertBefore(u,h.firstChild))}function zE(u,h){u.crossOrigin==null&&(u.crossOrigin=h.crossOrigin),u.referrerPolicy==null&&(u.referrerPolicy=h.referrerPolicy),u.title==null&&(u.title=h.title)}function BE(u,h){u.crossOrigin==null&&(u.crossOrigin=h.crossOrigin),u.referrerPolicy==null&&(u.referrerPolicy=h.referrerPolicy),u.integrity==null&&(u.integrity=h.integrity)}var Zv=null;function WU(u,h,y){if(Zv===null){var S=new Map,C=Zv=new Map;C.set(y,S)}else C=Zv,S=C.get(y),S||(S=new Map,C.set(y,S));if(S.has(u))return S;for(S.set(u,null),y=y.getElementsByTagName(u),C=0;C<y.length;C++){var D=y[C];if(!(D[Xe]||D[fi]||u==="link"&&D.getAttribute("rel")==="stylesheet")&&D.namespaceURI!=="http://www.w3.org/2000/svg"){var V=D.getAttribute(h)||"";V=u+V;var ne=S.get(V);ne?ne.push(D):S.set(V,[D])}}return S}function qU(u,h,y){u=u.ownerDocument||u,u.head.insertBefore(y,h==="title"?u.querySelector("head > title"):null)}function See(u,h,y){if(y===1||h.itemProp!=null)return!1;switch(u){case"meta":case"title":return!0;case"style":if(typeof h.precedence!="string"||typeof h.href!="string"||h.href==="")break;return!0;case"link":if(typeof h.rel!="string"||typeof h.href!="string"||h.href===""||h.onLoad||h.onError)break;switch(h.rel){case"stylesheet":return u=h.disabled,typeof h.precedence=="string"&&u==null;default:return!0}case"script":if(h.async&&typeof h.async!="function"&&typeof h.async!="symbol"&&!h.onLoad&&!h.onError&&h.src&&typeof h.src=="string")return!0}return!1}function XU(u){return!(u.type==="stylesheet"&&(u.state.loading&3)===0)}function wee(u,h,y,S){if(y.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(y.state.loading&4)===0){if(y.instance===null){var C=gh(S.href),D=h.querySelector(og(C));if(D){h=D._p,h!==null&&typeof h=="object"&&typeof h.then=="function"&&(u.count++,u=Qv.bind(u),h.then(u,u)),y.state.loading|=4,y.instance=D,Te(D);return}D=h.ownerDocument||h,S=$U(S),(C=bs.get(C))&&zE(S,C),D=D.createElement("link"),Te(D);var V=D;V._p=new Promise(function(ne,_e){V.onload=ne,V.onerror=_e}),Or(D,"link",S),y.instance=D}u.stylesheets===null&&(u.stylesheets=new Map),u.stylesheets.set(y,h),(h=y.state.preload)&&(y.state.loading&3)===0&&(u.count++,y=Qv.bind(u),h.addEventListener("load",y),h.addEventListener("error",y))}}var HE=0;function Mee(u,h){return u.stylesheets&&u.count===0&&ey(u,u.stylesheets),0<u.count||0<u.imgCount?function(y){var S=setTimeout(function(){if(u.stylesheets&&ey(u,u.stylesheets),u.unsuspend){var D=u.unsuspend;u.unsuspend=null,D()}},6e4+h);0<u.imgBytes&&HE===0&&(HE=62500*ree());var C=setTimeout(function(){if(u.waitingForImages=!1,u.count===0&&(u.stylesheets&&ey(u,u.stylesheets),u.unsuspend)){var D=u.unsuspend;u.unsuspend=null,D()}},(u.imgBytes>HE?50:800)+h);return u.unsuspend=y,function(){u.unsuspend=null,clearTimeout(S),clearTimeout(C)}}:null}function Qv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ey(this,this.stylesheets);else if(this.unsuspend){var u=this.unsuspend;this.unsuspend=null,u()}}}var Jv=null;function ey(u,h){u.stylesheets=null,u.unsuspend!==null&&(u.count++,Jv=new Map,h.forEach(Eee,u),Jv=null,Qv.call(u))}function Eee(u,h){if(!(h.state.loading&4)){var y=Jv.get(u);if(y)var S=y.get(null);else{y=new Map,Jv.set(u,y);for(var C=u.querySelectorAll("link[data-precedence],style[data-precedence]"),D=0;D<C.length;D++){var V=C[D];(V.nodeName==="LINK"||V.getAttribute("media")!=="not all")&&(y.set(V.dataset.precedence,V),S=V)}S&&y.set(null,S)}C=h.instance,V=C.getAttribute("data-precedence"),D=y.get(V)||S,D===S&&y.set(null,C),y.set(V,C),this.count++,S=Qv.bind(this),C.addEventListener("load",S),C.addEventListener("error",S),D?D.parentNode.insertBefore(C,D.nextSibling):(u=u.nodeType===9?u.head:u,u.insertBefore(C,u.firstChild)),h.state.loading|=4}}var cg={$$typeof:w,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function Aee(u,h,y,S,C,D,V,ne,_e){this.tag=1,this.containerInfo=u,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Nt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nt(0),this.hiddenUpdates=Nt(null),this.identifierPrefix=S,this.onUncaughtError=C,this.onCaughtError=D,this.onRecoverableError=V,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=_e,this.incompleteTransitions=new Map}function KU(u,h,y,S,C,D,V,ne,_e,Fe,Je,st){return u=new Aee(u,h,y,V,_e,Fe,Je,st,ne),h=1,D===!0&&(h|=24),D=Va(3,null,null,h),u.current=D,D.stateNode=u,h=_M(),h.refCount++,u.pooledCache=h,h.refCount++,D.memoizedState={element:S,isDehydrated:y,cache:h},EM(D),u}function YU(u){return u?(u=Xf,u):Xf}function ZU(u,h,y,S,C,D){C=YU(C),S.context===null?S.context=C:S.pendingContext=C,S=Oc(h),S.payload={element:y},D=D===void 0?null:D,D!==null&&(S.callback=D),y=kc(u,S,h),y!==null&&(Aa(y,u,h),Bm(y,u,h))}function QU(u,h){if(u=u.memoizedState,u!==null&&u.dehydrated!==null){var y=u.retryLane;u.retryLane=y!==0&&y<h?y:h}}function VE(u,h){QU(u,h),(u=u.alternate)&&QU(u,h)}function JU(u){if(u.tag===13||u.tag===31){var h=dd(u,67108864);h!==null&&Aa(h,u,67108864),VE(u,67108864)}}function e4(u){if(u.tag===13||u.tag===31){var h=Xa();h=Ki(h);var y=dd(u,h);y!==null&&Aa(y,u,h),VE(u,h)}}var ty=!0;function Tee(u,h,y,S){var C=q.T;q.T=null;var D=W.p;try{W.p=2,$E(u,h,y,S)}finally{W.p=D,q.T=C}}function Cee(u,h,y,S){var C=q.T;q.T=null;var D=W.p;try{W.p=8,$E(u,h,y,S)}finally{W.p=D,q.T=C}}function $E(u,h,y,S){if(ty){var C=GE(S);if(C===null)RE(u,h,S,ny,y),n4(u,S);else if(Ree(C,u,h,y,S))S.stopPropagation();else if(n4(u,S),h&4&&-1<Nee.indexOf(u)){for(;C!==null;){var D=Z(C);if(D!==null)switch(D.tag){case 3:if(D=D.stateNode,D.current.memoizedState.isDehydrated){var V=Me(D.pendingLanes);if(V!==0){var ne=D;for(ne.pendingLanes|=2,ne.entangledLanes|=2;V;){var _e=1<<31-tt(V);ne.entanglements[1]|=_e,V&=~_e}Co(D),(An&6)===0&&(jv=k()+500,ig(0))}}break;case 31:case 13:ne=dd(D,2),ne!==null&&Aa(ne,D,2),zv(),VE(D,2)}if(D=GE(S),D===null&&RE(u,h,S,ny,y),D===C)break;C=D}C!==null&&S.stopPropagation()}else RE(u,h,S,null,y)}}function GE(u){return u=qw(u),WE(u)}var ny=null;function WE(u){if(ny=null,u=_t(u),u!==null){var h=a(u);if(h===null)u=null;else{var y=h.tag;if(y===13){if(u=s(h),u!==null)return u;u=null}else if(y===31){if(u=o(h),u!==null)return u;u=null}else if(y===3){if(h.stateNode.current.memoizedState.isDehydrated)return h.tag===3?h.stateNode.containerInfo:null;u=null}else h!==u&&(u=null)}}return ny=u,null}function t4(u){switch(u){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(K()){case me:return 2;case ye:return 8;case he:case Ye:return 32;case Le:return 268435456;default:return 32}default:return 32}}var qE=!1,Gc=null,Wc=null,qc=null,ug=new Map,dg=new Map,Xc=[],Nee="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function n4(u,h){switch(u){case"focusin":case"focusout":Gc=null;break;case"dragenter":case"dragleave":Wc=null;break;case"mouseover":case"mouseout":qc=null;break;case"pointerover":case"pointerout":ug.delete(h.pointerId);break;case"gotpointercapture":case"lostpointercapture":dg.delete(h.pointerId)}}function fg(u,h,y,S,C,D){return u===null||u.nativeEvent!==D?(u={blockedOn:h,domEventName:y,eventSystemFlags:S,nativeEvent:D,targetContainers:[C]},h!==null&&(h=Z(h),h!==null&&JU(h)),u):(u.eventSystemFlags|=S,h=u.targetContainers,C!==null&&h.indexOf(C)===-1&&h.push(C),u)}function Ree(u,h,y,S,C){switch(h){case"focusin":return Gc=fg(Gc,u,h,y,S,C),!0;case"dragenter":return Wc=fg(Wc,u,h,y,S,C),!0;case"mouseover":return qc=fg(qc,u,h,y,S,C),!0;case"pointerover":var D=C.pointerId;return ug.set(D,fg(ug.get(D)||null,u,h,y,S,C)),!0;case"gotpointercapture":return D=C.pointerId,dg.set(D,fg(dg.get(D)||null,u,h,y,S,C)),!0}return!1}function i4(u){var h=_t(u.target);if(h!==null){var y=a(h);if(y!==null){if(h=y.tag,h===13){if(h=s(y),h!==null){u.blockedOn=h,$r(u.priority,function(){e4(y)});return}}else if(h===31){if(h=o(y),h!==null){u.blockedOn=h,$r(u.priority,function(){e4(y)});return}}else if(h===3&&y.stateNode.current.memoizedState.isDehydrated){u.blockedOn=y.tag===3?y.stateNode.containerInfo:null;return}}}u.blockedOn=null}function iy(u){if(u.blockedOn!==null)return!1;for(var h=u.targetContainers;0<h.length;){var y=GE(u.nativeEvent);if(y===null){y=u.nativeEvent;var S=new y.constructor(y.type,y);Ww=S,y.target.dispatchEvent(S),Ww=null}else return h=Z(y),h!==null&&JU(h),u.blockedOn=y,!1;h.shift()}return!0}function r4(u,h,y){iy(u)&&y.delete(h)}function Pee(){qE=!1,Gc!==null&&iy(Gc)&&(Gc=null),Wc!==null&&iy(Wc)&&(Wc=null),qc!==null&&iy(qc)&&(qc=null),ug.forEach(r4),dg.forEach(r4)}function ry(u,h){u.blockedOn===h&&(u.blockedOn=null,qE||(qE=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Pee)))}var ay=null;function a4(u){ay!==u&&(ay=u,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ay===u&&(ay=null);for(var h=0;h<u.length;h+=3){var y=u[h],S=u[h+1],C=u[h+2];if(typeof S!="function"){if(WE(S||y)===null)continue;break}var D=Z(y);D!==null&&(u.splice(h,3),h-=3,GM(D,{pending:!0,data:C,method:y.method,action:S},S,C))}}))}function vh(u){function h(_e){return ry(_e,u)}Gc!==null&&ry(Gc,u),Wc!==null&&ry(Wc,u),qc!==null&&ry(qc,u),ug.forEach(h),dg.forEach(h);for(var y=0;y<Xc.length;y++){var S=Xc[y];S.blockedOn===u&&(S.blockedOn=null)}for(;0<Xc.length&&(y=Xc[0],y.blockedOn===null);)i4(y),y.blockedOn===null&&Xc.shift();if(y=(u.ownerDocument||u).$$reactFormReplay,y!=null)for(S=0;S<y.length;S+=3){var C=y[S],D=y[S+1],V=C[Ei]||null;if(typeof D=="function")V||a4(y);else if(V){var ne=null;if(D&&D.hasAttribute("formAction")){if(C=D,V=D[Ei]||null)ne=V.formAction;else if(WE(C)!==null)continue}else ne=V.action;typeof ne=="function"?y[S+1]=ne:(y.splice(S,3),S-=3),a4(y)}}}function s4(){function u(D){D.canIntercept&&D.info==="react-transition"&&D.intercept({handler:function(){return new Promise(function(V){return C=V})},focusReset:"manual",scroll:"manual"})}function h(){C!==null&&(C(),C=null),S||setTimeout(y,20)}function y(){if(!S&&!navigation.transition){var D=navigation.currentEntry;D&&D.url!=null&&navigation.navigate(D.url,{state:D.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,C=null;return navigation.addEventListener("navigate",u),navigation.addEventListener("navigatesuccess",h),navigation.addEventListener("navigateerror",h),setTimeout(y,100),function(){S=!0,navigation.removeEventListener("navigate",u),navigation.removeEventListener("navigatesuccess",h),navigation.removeEventListener("navigateerror",h),C!==null&&(C(),C=null)}}}function XE(u){this._internalRoot=u}sy.prototype.render=XE.prototype.render=function(u){var h=this._internalRoot;if(h===null)throw Error(i(409));var y=h.current,S=Xa();ZU(y,S,u,h,null,null)},sy.prototype.unmount=XE.prototype.unmount=function(){var u=this._internalRoot;if(u!==null){this._internalRoot=null;var h=u.containerInfo;ZU(u.current,2,null,u,null,null),zv(),h[Ks]=null}};function sy(u){this._internalRoot=u}sy.prototype.unstable_scheduleHydration=function(u){if(u){var h=Cr();u={blockedOn:null,target:u,priority:h};for(var y=0;y<Xc.length&&h!==0&&h<Xc[y].priority;y++);Xc.splice(y,0,u),y===0&&i4(u)}};var o4=e.version;if(o4!=="19.2.0")throw Error(i(527,o4,"19.2.0"));W.findDOMNode=function(u){var h=u._reactInternals;if(h===void 0)throw typeof u.render=="function"?Error(i(188)):(u=Object.keys(u).join(","),Error(i(268,u)));return u=c(h),u=u!==null?d(u):null,u=u===null?null:u.stateNode,u};var Dee={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:q,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var oy=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!oy.isDisabled&&oy.supportsFiber)try{Ie=oy.inject(Dee),Re=oy}catch{}}return pg.createRoot=function(u,h){if(!r(u))throw Error(i(299));var y=!1,S="",C=pI,D=mI,V=gI;return h!=null&&(h.unstable_strictMode===!0&&(y=!0),h.identifierPrefix!==void 0&&(S=h.identifierPrefix),h.onUncaughtError!==void 0&&(C=h.onUncaughtError),h.onCaughtError!==void 0&&(D=h.onCaughtError),h.onRecoverableError!==void 0&&(V=h.onRecoverableError)),h=KU(u,1,!1,null,null,y,S,null,C,D,V,s4),u[Ks]=h.current,NE(u),new XE(h)},pg.hydrateRoot=function(u,h,y){if(!r(u))throw Error(i(299));var S=!1,C="",D=pI,V=mI,ne=gI,_e=null;return y!=null&&(y.unstable_strictMode===!0&&(S=!0),y.identifierPrefix!==void 0&&(C=y.identifierPrefix),y.onUncaughtError!==void 0&&(D=y.onUncaughtError),y.onCaughtError!==void 0&&(V=y.onCaughtError),y.onRecoverableError!==void 0&&(ne=y.onRecoverableError),y.formState!==void 0&&(_e=y.formState)),h=KU(u,1,!0,h,y??null,S,C,_e,D,V,ne,s4),h.context=YU(null),y=h.current,S=Xa(),S=Ki(S),C=Oc(S),C.callback=null,kc(y,C,S),y=S,h.current.lanes=y,an(h,y),Co(h),u[Ks]=h.current,NE(u),new sy(h)},pg.version="19.2.0",pg}var x4;function Vee(){if(x4)return ZE.exports;x4=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),ZE.exports=Hee(),ZE.exports}var $ee=Vee();var v4="popstate";function Gee(t={}){function e(i,r){let{pathname:a,search:s,hash:o}=i.location;return jC("",{pathname:a,search:s,hash:o},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(i,r){return typeof r=="string"?r:v0(r)}return qee(e,n,null,t)}function pi(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function vo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Wee(){return Math.random().toString(36).substring(2,10)}function y4(t,e){return{usr:t.state,key:t.key,idx:e}}function jC(t,e,n=null,i){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?nm(e):e,state:n,key:e&&e.key||i||Wee()}}function v0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function nm(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let i=t.indexOf("?");i>=0&&(e.search=t.substring(i),t=t.substring(0,i)),t&&(e.pathname=t)}return e}function qee(t,e,n,i={}){let{window:r=document.defaultView,v5Compat:a=!1}=i,s=r.history,o="POP",l=null,c=d();c==null&&(c=0,s.replaceState({...s.state,idx:c},""));function d(){return(s.state||{idx:null}).idx}function f(){o="POP";let v=d(),x=v==null?null:v-c;c=v,l&&l({action:o,location:b.location,delta:x})}function p(v,x){o="PUSH";let M=jC(b.location,v,x);c=d()+1;let w=y4(M,c),E=b.createHref(M);try{s.pushState(w,"",E)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;r.location.assign(E)}a&&l&&l({action:o,location:b.location,delta:1})}function m(v,x){o="REPLACE";let M=jC(b.location,v,x);c=d();let w=y4(M,c),E=b.createHref(M);s.replaceState(w,"",E),a&&l&&l({action:o,location:b.location,delta:0})}function _(v){return Xee(v)}let b={get action(){return o},get location(){return t(r,s)},listen(v){if(l)throw new Error("A history only accepts one active listener");return r.addEventListener(v4,f),l=v,()=>{r.removeEventListener(v4,f),l=null}},createHref(v){return e(r,v)},createURL:_,encodeLocation(v){let x=_(v);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:p,replace:m,go(v){return s.go(v)}};return b}function Xee(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),pi(n,"No window.location.(origin|href) available to create URL");let i=typeof t=="string"?t:v0(t);return i=i.replace(/ $/,"%20"),!e&&i.startsWith("//")&&(i=n+i),new URL(i,n)}function a$(t,e,n="/"){return Kee(t,e,n,!1)}function Kee(t,e,n,i){let r=typeof e=="string"?nm(e):e,a=ac(r.pathname||"/",n);if(a==null)return null;let s=s$(t);Yee(s);let o=null;for(let l=0;o==null&&l<s.length;++l){let c=ote(a);o=ate(s[l],c,i)}return o}function s$(t,e=[],n=[],i="",r=!1){let a=(s,o,l=r,c)=>{let d={relativePath:c===void 0?s.path||"":c,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(i)&&l)return;pi(d.relativePath.startsWith(i),`Absolute route path "${d.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(i.length)}let f=Zl([i,d.relativePath]),p=n.concat(d);s.children&&s.children.length>0&&(pi(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),s$(s.children,e,p,f,l)),!(s.path==null&&!s.index)&&e.push({path:f,score:ite(f,s.index),routesMeta:p})};return t.forEach((s,o)=>{if(s.path===""||!s.path?.includes("?"))a(s,o);else for(let l of o$(s.path))a(s,o,!0,l)}),e}function o$(t){let e=t.split("/");if(e.length===0)return[];let[n,...i]=e,r=n.endsWith("?"),a=n.replace(/\?$/,"");if(i.length===0)return r?[a,""]:[a];let s=o$(i.join("/")),o=[];return o.push(...s.map(l=>l===""?a:[a,l].join("/"))),r&&o.push(...s),o.map(l=>t.startsWith("/")&&l===""?"/":l)}function Yee(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:rte(e.routesMeta.map(i=>i.childrenIndex),n.routesMeta.map(i=>i.childrenIndex)))}var Zee=/^:[\w-]+$/,Qee=3,Jee=2,ete=1,tte=10,nte=-2,b4=t=>t==="*";function ite(t,e){let n=t.split("/"),i=n.length;return n.some(b4)&&(i+=nte),e&&(i+=Jee),n.filter(r=>!b4(r)).reduce((r,a)=>r+(Zee.test(a)?Qee:a===""?ete:tte),i)}function rte(t,e){return t.length===e.length&&t.slice(0,-1).every((i,r)=>i===e[r])?t[t.length-1]-e[e.length-1]:0}function ate(t,e,n=!1){let{routesMeta:i}=t,r={},a="/",s=[];for(let o=0;o<i.length;++o){let l=i[o],c=o===i.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=d_({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},d),p=l.route;if(!f&&c&&n&&!i[i.length-1].route.index&&(f=d_({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!f)return null;Object.assign(r,f.params),s.push({params:r,pathname:Zl([a,f.pathname]),pathnameBase:fte(Zl([a,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(a=Zl([a,f.pathnameBase]))}return s}function d_(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,i]=ste(t.path,t.caseSensitive,t.end),r=e.match(n);if(!r)return null;let a=r[0],s=a.replace(/(.)\/+$/,"$1"),o=r.slice(1);return{params:i.reduce((c,{paramName:d,isOptional:f},p)=>{if(d==="*"){let _=o[p]||"";s=a.slice(0,a.length-_.length).replace(/(.)\/+$/,"$1")}const m=o[p];return f&&!m?c[d]=void 0:c[d]=(m||"").replace(/%2F/g,"/"),c},{}),pathname:a,pathnameBase:s,pattern:t}}function ste(t,e=!1,n=!0){vo(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let i=[],r="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,o,l)=>(i.push({paramName:o,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(i.push({paramName:"*"}),r+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":t!==""&&t!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,e?void 0:"i"),i]}function ote(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return vo(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),t}}function ac(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,i=t.charAt(n);return i&&i!=="/"?null:t.slice(n)||"/"}var lte=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,cte=t=>lte.test(t);function ute(t,e="/"){let{pathname:n,search:i="",hash:r=""}=typeof t=="string"?nm(t):t,a;if(n)if(cte(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),vo(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=_4(n.substring(1),"/"):a=_4(n,e)}else a=e;return{pathname:a,search:hte(i),hash:pte(r)}}function _4(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function tA(t,e,n,i){return`Cannot include a '${t}' character in a manually specified \`to.${e}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function dte(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function l$(t){let e=dte(t);return e.map((n,i)=>i===e.length-1?n.pathname:n.pathnameBase)}function c$(t,e,n,i=!1){let r;typeof t=="string"?r=nm(t):(r={...t},pi(!r.pathname||!r.pathname.includes("?"),tA("?","pathname","search",r)),pi(!r.pathname||!r.pathname.includes("#"),tA("#","pathname","hash",r)),pi(!r.search||!r.search.includes("#"),tA("#","search","hash",r)));let a=t===""||r.pathname==="",s=a?"/":r.pathname,o;if(s==null)o=n;else{let f=e.length-1;if(!i&&s.startsWith("..")){let p=s.split("/");for(;p[0]==="..";)p.shift(),f-=1;r.pathname=p.join("/")}o=f>=0?e[f]:"/"}let l=ute(r,o),c=s&&s!=="/"&&s.endsWith("/"),d=(a||s===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(c||d)&&(l.pathname+="/"),l}var Zl=t=>t.join("/").replace(/\/\/+/g,"/"),fte=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),hte=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,pte=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function mte(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var u$=["POST","PUT","PATCH","DELETE"];new Set(u$);var gte=["GET",...u$];new Set(gte);var im=A.createContext(null);im.displayName="DataRouter";var gS=A.createContext(null);gS.displayName="DataRouterState";A.createContext(!1);var d$=A.createContext({isTransitioning:!1});d$.displayName="ViewTransition";var xte=A.createContext(new Map);xte.displayName="Fetchers";var vte=A.createContext(null);vte.displayName="Await";var Jo=A.createContext(null);Jo.displayName="Navigation";var dx=A.createContext(null);dx.displayName="Location";var el=A.createContext({outlet:null,matches:[],isDataRoute:!1});el.displayName="Route";var $R=A.createContext(null);$R.displayName="RouteError";function yte(t,{relative:e}={}){pi(fx(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:i}=A.useContext(Jo),{hash:r,pathname:a,search:s}=hx(t,{relative:e}),o=a;return n!=="/"&&(o=a==="/"?n:Zl([n,a])),i.createHref({pathname:o,search:s,hash:r})}function fx(){return A.useContext(dx)!=null}function Ju(){return pi(fx(),"useLocation() may be used only in the context of a <Router> component."),A.useContext(dx).location}var f$="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function h$(t){A.useContext(Jo).static||A.useLayoutEffect(t)}function GR(){let{isDataRoute:t}=A.useContext(el);return t?kte():bte()}function bte(){pi(fx(),"useNavigate() may be used only in the context of a <Router> component.");let t=A.useContext(im),{basename:e,navigator:n}=A.useContext(Jo),{matches:i}=A.useContext(el),{pathname:r}=Ju(),a=JSON.stringify(l$(i)),s=A.useRef(!1);return h$(()=>{s.current=!0}),A.useCallback((l,c={})=>{if(vo(s.current,f$),!s.current)return;if(typeof l=="number"){n.go(l);return}let d=c$(l,JSON.parse(a),r,c.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Zl([e,d.pathname])),(c.replace?n.replace:n.push)(d,c.state,c)},[e,n,a,r,t])}var _te=A.createContext(null);function Ste(t){let e=A.useContext(el).outlet;return A.useMemo(()=>e&&A.createElement(_te.Provider,{value:t},e),[e,t])}function hx(t,{relative:e}={}){let{matches:n}=A.useContext(el),{pathname:i}=Ju(),r=JSON.stringify(l$(n));return A.useMemo(()=>c$(t,JSON.parse(r),i,e==="path"),[t,r,i,e])}function wte(t,e){return p$(t,e)}function p$(t,e,n,i,r){pi(fx(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=A.useContext(Jo),{matches:s}=A.useContext(el),o=s[s.length-1],l=o?o.params:{},c=o?o.pathname:"/",d=o?o.pathnameBase:"/",f=o&&o.route;{let M=f&&f.path||"";m$(c,!f||M.endsWith("*")||M.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${M}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
- Please change the parent <Route path="${M}"> to <Route path="${M==="/"?"*":`${M}/*`}">.`)}let p=Ju(),m;if(e){let M=typeof e=="string"?nm(e):e;pi(d==="/"||M.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${M.pathname}" was given in the \`location\` prop.`),m=M}else m=p;let _=m.pathname||"/",b=_;if(d!=="/"){let M=d.replace(/^\//,"").split("/");b="/"+_.replace(/^\//,"").split("/").slice(M.length).join("/")}let v=a$(t,{pathname:b});vo(f||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),vo(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let x=Cte(v&&v.map(M=>Object.assign({},M,{params:Object.assign({},l,M.params),pathname:Zl([d,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?d:Zl([d,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),s,n,i,r);return e&&x?A.createElement(dx.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},x):x}function Mte(){let t=Ote(),e=mte(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,i="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:i},a={padding:"2px 4px",backgroundColor:i},s=null;return console.error("Error handled by React Router default ErrorBoundary:",t),s=A.createElement(A.Fragment,null,A.createElement("p",null,"💿 Hey developer 👋"),A.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",A.createElement("code",{style:a},"ErrorBoundary")," or"," ",A.createElement("code",{style:a},"errorElement")," prop on your route.")),A.createElement(A.Fragment,null,A.createElement("h2",null,"Unexpected Application Error!"),A.createElement("h3",{style:{fontStyle:"italic"}},e),n?A.createElement("pre",{style:r},n):null,s)}var Ete=A.createElement(Mte,null),Ate=class extends A.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,e){return e.location!==t.location||e.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:e.error,location:e.location,revalidation:t.revalidation||e.revalidation}}componentDidCatch(t,e){this.props.onError?this.props.onError(t,e):console.error("React Router caught the following error during render",t)}render(){return this.state.error!==void 0?A.createElement(el.Provider,{value:this.props.routeContext},A.createElement($R.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Tte({routeContext:t,match:e,children:n}){let i=A.useContext(im);return i&&i.static&&i.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=e.route.id),A.createElement(el.Provider,{value:t},n)}function Cte(t,e=[],n=null,i=null,r=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,s=n?.errors;if(s!=null){let d=a.findIndex(f=>f.route.id&&s?.[f.route.id]!==void 0);pi(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let o=!1,l=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=d),f.route.id){let{loaderData:p,errors:m}=n,_=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||_){o=!0,l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}let c=n&&i?(d,f)=>{i(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,p)=>{let m,_=!1,b=null,v=null;n&&(m=s&&f.route.id?s[f.route.id]:void 0,b=f.route.errorElement||Ete,o&&(l<0&&p===0?(m$("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),_=!0,v=null):l===p&&(_=!0,v=f.route.hydrateFallbackElement||null)));let x=e.concat(a.slice(0,p+1)),M=()=>{let w;return m?w=b:_?w=v:f.route.Component?w=A.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,A.createElement(Tte,{match:f,routeContext:{outlet:d,matches:x,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?A.createElement(Ate,{location:n.location,revalidation:n.revalidation,component:b,error:m,children:M(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:c}):M()},null)}function WR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Nte(t){let e=A.useContext(im);return pi(e,WR(t)),e}function Rte(t){let e=A.useContext(gS);return pi(e,WR(t)),e}function Pte(t){let e=A.useContext(el);return pi(e,WR(t)),e}function qR(t){let e=Pte(t),n=e.matches[e.matches.length-1];return pi(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Dte(){return qR("useRouteId")}function Ote(){let t=A.useContext($R),e=Rte("useRouteError"),n=qR("useRouteError");return t!==void 0?t:e.errors?.[n]}function kte(){let{router:t}=Nte("useNavigate"),e=qR("useNavigate"),n=A.useRef(!1);return h$(()=>{n.current=!0}),A.useCallback(async(r,a={})=>{vo(n.current,f$),n.current&&(typeof r=="number"?t.navigate(r):await t.navigate(r,{fromRouteId:e,...a}))},[t,e])}var S4={};function m$(t,e,n){!e&&!S4[t]&&(S4[t]=!0,vo(!1,n))}A.memo(Lte);function Lte({routes:t,future:e,state:n,unstable_onError:i}){return p$(t,void 0,n,i,e)}function Ite(t){return Ste(t.context)}function kl(t){pi(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ute({basename:t="/",children:e=null,location:n,navigationType:i="POP",navigator:r,static:a=!1}){pi(!fx(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),o=A.useMemo(()=>({basename:s,navigator:r,static:a,future:{}}),[s,r,a]);typeof n=="string"&&(n=nm(n));let{pathname:l="/",search:c="",hash:d="",state:f=null,key:p="default"}=n,m=A.useMemo(()=>{let _=ac(l,s);return _==null?null:{location:{pathname:_,search:c,hash:d,state:f,key:p},navigationType:i}},[s,l,c,d,f,p,i]);return vo(m!=null,`<Router basename="${s}"> is not able to match the URL "${l}${c}${d}" because it does not start with the basename, so the <Router> won't render anything.`),m==null?null:A.createElement(Jo.Provider,{value:o},A.createElement(dx.Provider,{children:e,value:m}))}function jte({children:t,location:e}){return wte(FC(t),e)}function FC(t,e=[]){let n=[];return A.Children.forEach(t,(i,r)=>{if(!A.isValidElement(i))return;let a=[...e,r];if(i.type===A.Fragment){n.push.apply(n,FC(i.props.children,a));return}pi(i.type===kl,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),pi(!i.props.index||!i.props.children,"An index route cannot have child routes.");let s={id:i.props.id||a.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(s.children=FC(i.props.children,a)),n.push(s)}),n}var Bb="get",Hb="application/x-www-form-urlencoded";function xS(t){return t!=null&&typeof t.tagName=="string"}function Fte(t){return xS(t)&&t.tagName.toLowerCase()==="button"}function zte(t){return xS(t)&&t.tagName.toLowerCase()==="form"}function Bte(t){return xS(t)&&t.tagName.toLowerCase()==="input"}function Hte(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Vte(t,e){return t.button===0&&(!e||e==="_self")&&!Hte(t)}var cy=null;function $te(){if(cy===null)try{new FormData(document.createElement("form"),0),cy=!1}catch{cy=!0}return cy}var Gte=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function nA(t){return t!=null&&!Gte.has(t)?(vo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Hb}"`),null):t}function Wte(t,e){let n,i,r,a,s;if(zte(t)){let o=t.getAttribute("action");i=o?ac(o,e):null,n=t.getAttribute("method")||Bb,r=nA(t.getAttribute("enctype"))||Hb,a=new FormData(t)}else if(Fte(t)||Bte(t)&&(t.type==="submit"||t.type==="image")){let o=t.form;if(o==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=t.getAttribute("formaction")||o.getAttribute("action");if(i=l?ac(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||Bb,r=nA(t.getAttribute("formenctype"))||nA(o.getAttribute("enctype"))||Hb,a=new FormData(o,t),!$te()){let{name:c,type:d,value:f}=t;if(d==="image"){let p=c?`${c}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else c&&a.append(c,f)}}else{if(xS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Bb,i=null,r=Hb,s=t}return a&&r==="text/plain"&&(s=a,a=void 0),{action:i,method:n.toLowerCase(),encType:r,formData:a,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function XR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function qte(t,e,n){let i=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return i.pathname==="/"?i.pathname=`_root.${n}`:e&&ac(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${n}`,i}async function Xte(t,e){if(t.id in e)return e[t.id];try{let n=await import(t.module);return e[t.id]=n,n}catch(n){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Kte(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Yte(t,e,n){let i=await Promise.all(t.map(async r=>{let a=e.routes[r.route.id];if(a){let s=await Xte(a,n);return s.links?s.links():[]}return[]}));return ene(i.flat(1).filter(Kte).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function w4(t,e,n,i,r,a){let s=(l,c)=>n[c]?l.route.id!==n[c].route.id:!0,o=(l,c)=>n[c].pathname!==l.pathname||n[c].route.path?.endsWith("*")&&n[c].params["*"]!==l.params["*"];return a==="assets"?e.filter((l,c)=>s(l,c)||o(l,c)):a==="data"?e.filter((l,c)=>{let d=i.routes[l.route.id];if(!d||!d.hasLoader)return!1;if(s(l,c)||o(l,c))return!0;if(l.route.shouldRevalidate){let f=l.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Zte(t,e,{includeHydrateFallback:n}={}){return Qte(t.map(i=>{let r=e.routes[i.route.id];if(!r)return[];let a=[r.module];return r.clientActionModule&&(a=a.concat(r.clientActionModule)),r.clientLoaderModule&&(a=a.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(a=a.concat(r.hydrateFallbackModule)),r.imports&&(a=a.concat(r.imports)),a}).flat(1))}function Qte(t){return[...new Set(t)]}function Jte(t){let e={},n=Object.keys(t).sort();for(let i of n)e[i]=t[i];return e}function ene(t,e){let n=new Set;return new Set(e),t.reduce((i,r)=>{let a=JSON.stringify(Jte(r));return n.has(a)||(n.add(a),i.push({key:a,link:r})),i},[])}function g$(){let t=A.useContext(im);return XR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function tne(){let t=A.useContext(gS);return XR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var KR=A.createContext(void 0);KR.displayName="FrameworkContext";function x$(){let t=A.useContext(KR);return XR(t,"You must render this element inside a <HydratedRouter> element"),t}function nne(t,e){let n=A.useContext(KR),[i,r]=A.useState(!1),[a,s]=A.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:d,onTouchStart:f}=e,p=A.useRef(null);A.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let b=x=>{x.forEach(M=>{s(M.isIntersecting)})},v=new IntersectionObserver(b,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[t]),A.useEffect(()=>{if(i){let b=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(b)}}},[i]);let m=()=>{r(!0)},_=()=>{r(!1),s(!1)};return n?t!=="intent"?[a,p,{}]:[a,p,{onFocus:mg(o,m),onBlur:mg(l,_),onMouseEnter:mg(c,m),onMouseLeave:mg(d,_),onTouchStart:mg(f,m)}]:[!1,p,{}]}function mg(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function ine({page:t,...e}){let{router:n}=g$(),i=A.useMemo(()=>a$(n.routes,t,n.basename),[n.routes,t,n.basename]);return i?A.createElement(ane,{page:t,matches:i,...e}):null}function rne(t){let{manifest:e,routeModules:n}=x$(),[i,r]=A.useState([]);return A.useEffect(()=>{let a=!1;return Yte(t,e,n).then(s=>{a||r(s)}),()=>{a=!0}},[t,e,n]),i}function ane({page:t,matches:e,...n}){let i=Ju(),{manifest:r,routeModules:a}=x$(),{basename:s}=g$(),{loaderData:o,matches:l}=tne(),c=A.useMemo(()=>w4(t,e,l,r,i,"data"),[t,e,l,r,i]),d=A.useMemo(()=>w4(t,e,l,r,i,"assets"),[t,e,l,r,i]),f=A.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let _=new Set,b=!1;if(e.forEach(x=>{let M=r.routes[x.route.id];!M||!M.hasLoader||(!c.some(w=>w.route.id===x.route.id)&&x.route.id in o&&a[x.route.id]?.shouldRevalidate||M.hasClientLoader?b=!0:_.add(x.route.id))}),_.size===0)return[];let v=qte(t,s,"data");return b&&_.size>0&&v.searchParams.set("_routes",e.filter(x=>_.has(x.route.id)).map(x=>x.route.id).join(",")),[v.pathname+v.search]},[s,o,i,r,c,e,t,a]),p=A.useMemo(()=>Zte(d,r),[d,r]),m=rne(d);return A.createElement(A.Fragment,null,f.map(_=>A.createElement("link",{key:_,rel:"prefetch",as:"fetch",href:_,...n})),p.map(_=>A.createElement("link",{key:_,rel:"modulepreload",href:_,...n})),m.map(({key:_,link:b})=>A.createElement("link",{key:_,nonce:n.nonce,...b})))}function sne(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var v$=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{v$&&(window.__reactRouterVersion="7.9.6")}catch{}function one({basename:t,children:e,window:n}){let i=A.useRef();i.current==null&&(i.current=Gee({window:n,v5Compat:!0}));let r=i.current,[a,s]=A.useState({action:r.action,location:r.location}),o=A.useCallback(l=>{A.startTransition(()=>s(l))},[s]);return A.useLayoutEffect(()=>r.listen(o),[r,o]),A.createElement(Ute,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:r})}var y$=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,vS=A.forwardRef(function({onClick:e,discover:n="render",prefetch:i="none",relative:r,reloadDocument:a,replace:s,state:o,target:l,to:c,preventScrollReset:d,viewTransition:f,...p},m){let{basename:_}=A.useContext(Jo),b=typeof c=="string"&&y$.test(c),v,x=!1;if(typeof c=="string"&&b&&(v=c,v$))try{let R=new URL(window.location.href),O=c.startsWith("//")?new URL(R.protocol+c):new URL(c),z=ac(O.pathname,_);O.origin===R.origin&&z!=null?c=z+O.search+O.hash:x=!0}catch{vo(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=yte(c,{relative:r}),[w,E,T]=nne(i,p),P=une(c,{replace:s,state:o,target:l,preventScrollReset:d,relative:r,viewTransition:f});function N(R){e&&e(R),R.defaultPrevented||P(R)}let U=A.createElement("a",{...p,...T,href:v||M,onClick:x||a?e:N,ref:sne(m,E),target:l,"data-discover":!b&&n==="render"?"true":void 0});return w&&!b?A.createElement(A.Fragment,null,U,A.createElement(ine,{page:M})):U});vS.displayName="Link";var b$=A.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:i="",end:r=!1,style:a,to:s,viewTransition:o,children:l,...c},d){let f=hx(s,{relative:c.relative}),p=Ju(),m=A.useContext(gS),{navigator:_,basename:b}=A.useContext(Jo),v=m!=null&&mne(f)&&o===!0,x=_.encodeLocation?_.encodeLocation(f).pathname:f.pathname,M=p.pathname,w=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(M=M.toLowerCase(),w=w?w.toLowerCase():null,x=x.toLowerCase()),w&&b&&(w=ac(w,b)||w);const E=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let T=M===x||!r&&M.startsWith(x)&&M.charAt(E)==="/",P=w!=null&&(w===x||!r&&w.startsWith(x)&&w.charAt(x.length)==="/"),N={isActive:T,isPending:P,isTransitioning:v},U=T?e:void 0,R;typeof i=="function"?R=i(N):R=[i,T?"active":null,P?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let O=typeof a=="function"?a(N):a;return A.createElement(vS,{...c,"aria-current":U,className:R,ref:d,style:O,to:s,viewTransition:o},typeof l=="function"?l(N):l)});b$.displayName="NavLink";var lne=A.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:i,replace:r,state:a,method:s=Bb,action:o,onSubmit:l,relative:c,preventScrollReset:d,viewTransition:f,...p},m)=>{let _=hne(),b=pne(o,{relative:c}),v=s.toLowerCase()==="get"?"get":"post",x=typeof o=="string"&&y$.test(o),M=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let E=w.nativeEvent.submitter,T=E?.getAttribute("formmethod")||s;_(E||w.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:r,state:a,relative:c,preventScrollReset:d,viewTransition:f})};return A.createElement("form",{ref:m,method:v,action:b,onSubmit:i?l:M,...p,"data-discover":!x&&t==="render"?"true":void 0})});lne.displayName="Form";function cne(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function _$(t){let e=A.useContext(im);return pi(e,cne(t)),e}function une(t,{target:e,replace:n,state:i,preventScrollReset:r,relative:a,viewTransition:s}={}){let o=GR(),l=Ju(),c=hx(t,{relative:a});return A.useCallback(d=>{if(Vte(d,e)){d.preventDefault();let f=n!==void 0?n:v0(l)===v0(c);o(t,{replace:f,state:i,preventScrollReset:r,relative:a,viewTransition:s})}},[l,o,c,n,i,e,t,r,a,s])}var dne=0,fne=()=>`__${String(++dne)}__`;function hne(){let{router:t}=_$("useSubmit"),{basename:e}=A.useContext(Jo),n=Dte();return A.useCallback(async(i,r={})=>{let{action:a,method:s,encType:o,formData:l,body:c}=Wte(i,e);if(r.navigate===!1){let d=r.fetcherKey||fne();await t.fetch(d,n,r.action||a,{preventScrollReset:r.preventScrollReset,formData:l,body:c,formMethod:r.method||s,formEncType:r.encType||o,flushSync:r.flushSync})}else await t.navigate(r.action||a,{preventScrollReset:r.preventScrollReset,formData:l,body:c,formMethod:r.method||s,formEncType:r.encType||o,replace:r.replace,state:r.state,fromRouteId:n,flushSync:r.flushSync,viewTransition:r.viewTransition})},[t,e,n])}function pne(t,{relative:e}={}){let{basename:n}=A.useContext(Jo),i=A.useContext(el);pi(i,"useFormAction must be used inside a RouteContext");let[r]=i.matches.slice(-1),a={...hx(t||".",{relative:e})},s=Ju();if(t==null){a.search=s.search;let o=new URLSearchParams(a.search),l=o.getAll("index");if(l.some(d=>d==="")){o.delete("index"),l.filter(f=>f).forEach(f=>o.append("index",f));let d=o.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&r.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Zl([n,a.pathname])),v0(a)}function mne(t,{relative:e}={}){let n=A.useContext(d$);pi(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=_$("useViewTransitionState"),r=hx(t,{relative:e});if(!n.isTransitioning)return!1;let a=ac(n.currentLocation.pathname,i)||n.currentLocation.pathname,s=ac(n.nextLocation.pathname,i)||n.nextLocation.pathname;return d_(r.pathname,s)!=null||d_(r.pathname,a)!=null}var $l=r$();const gne=qs($l);var rm=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},xne={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},vne=class{#e=xne;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Wd=new vne;function yne(t){setTimeout(t,0)}var mf=typeof window>"u"||"Deno"in globalThis;function ua(){}function bne(t,e){return typeof t=="function"?t(e):t}function zC(t){return typeof t=="number"&&t>=0&&t!==1/0}function S$(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Nu(t,e){return typeof t=="function"?t(e):t}function Ns(t,e){return typeof t=="function"?t(e):t}function M4(t,e){const{type:n="all",exact:i,fetchStatus:r,predicate:a,queryKey:s,stale:o}=t;if(s){if(i){if(e.queryHash!==YR(s,e.options))return!1}else if(!y0(e.queryKey,s))return!1}if(n!=="all"){const l=e.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||r&&r!==e.state.fetchStatus||a&&!a(e))}function E4(t,e){const{exact:n,status:i,predicate:r,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(gf(e.options.mutationKey)!==gf(a))return!1}else if(!y0(e.options.mutationKey,a))return!1}return!(i&&e.state.status!==i||r&&!r(e))}function YR(t,e){return(e?.queryKeyHashFn||gf)(t)}function gf(t){return JSON.stringify(t,(e,n)=>BC(n)?Object.keys(n).sort().reduce((i,r)=>(i[r]=n[r],i),{}):n)}function y0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>y0(t[n],e[n])):!1}var _ne=Object.prototype.hasOwnProperty;function w$(t,e){if(t===e)return t;const n=A4(t)&&A4(e);if(!n&&!(BC(t)&&BC(e)))return e;const r=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),s=a.length,o=n?new Array(s):{};let l=0;for(let c=0;c<s;c++){const d=n?c:a[c],f=t[d],p=e[d];if(f===p){o[d]=f,(n?c<r:_ne.call(t,d))&&l++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){o[d]=p;continue}const m=w$(f,p);o[d]=m,m===f&&l++}return r===s&&l===r?t:o}function f_(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function A4(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function BC(t){if(!T4(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!T4(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function T4(t){return Object.prototype.toString.call(t)==="[object Object]"}function Sne(t){return new Promise(e=>{Wd.setTimeout(e,t)})}function HC(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?w$(t,e):e}function wne(t,e,n=0){const i=[...t,e];return n&&i.length>n?i.slice(1):i}function Mne(t,e,n=0){const i=[e,...t];return n&&i.length>n?i.slice(0,-1):i}var ZR=Symbol();function M$(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===ZR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function E$(t,e){return typeof t=="function"?t(...e):!!t}var Ene=class extends rm{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!mf&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},QR=new Ene;function VC(){let t,e;const n=new Promise((r,a)=>{t=r,e=a});n.status="pending",n.catch(()=>{});function i(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{i({status:"fulfilled",value:r}),t(r)},n.reject=r=>{i({status:"rejected",reason:r}),e(r)},n}var Ane=yne;function Tne(){let t=[],e=0,n=o=>{o()},i=o=>{o()},r=Ane;const a=o=>{e?t.push(o):r(()=>{n(o)})},s=()=>{const o=t;t=[],o.length&&r(()=>{i(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;e++;try{l=o()}finally{e--,e||s()}return l},batchCalls:o=>(...l)=>{a(()=>{o(...l)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{i=o},setScheduler:o=>{r=o}}}var nr=Tne(),Cne=class extends rm{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!mf&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},h_=new Cne;function Nne(t){return Math.min(1e3*2**t,3e4)}function A$(t){return(t??"online")==="online"?h_.isOnline():!0}var $C=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function T$(t){let e=!1,n=0,i;const r=VC(),a=()=>r.status!=="pending",s=b=>{if(!a()){const v=new $C(b);p(v),t.onCancel?.(v)}},o=()=>{e=!0},l=()=>{e=!1},c=()=>QR.isFocused()&&(t.networkMode==="always"||h_.isOnline())&&t.canRun(),d=()=>A$(t.networkMode)&&t.canRun(),f=b=>{a()||(i?.(),r.resolve(b))},p=b=>{a()||(i?.(),r.reject(b))},m=()=>new Promise(b=>{i=v=>{(a()||c())&&b(v)},t.onPause?.()}).then(()=>{i=void 0,a()||t.onContinue?.()}),_=()=>{if(a())return;let b;const v=n===0?t.initialPromise:void 0;try{b=v??t.fn()}catch(x){b=Promise.reject(x)}Promise.resolve(b).then(f).catch(x=>{if(a())return;const M=t.retry??(mf?0:3),w=t.retryDelay??Nne,E=typeof w=="function"?w(n,x):w,T=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,x);if(e||!T){p(x);return}n++,t.onFail?.(n,x),Sne(E).then(()=>c()?void 0:m()).then(()=>{e?p(x):_()})})};return{promise:r,status:()=>r.status,cancel:s,continue:()=>(i?.(),r),cancelRetry:o,continueRetry:l,canStart:d,start:()=>(d()?_():m().then(_),r)}}var C$=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zC(this.gcTime)&&(this.#e=Wd.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(mf?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Wd.clearTimeout(this.#e),this.#e=void 0)}},Rne=class extends C${#e;#t;#n;#r;#i;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#r=t.client,this.#n=this.#r.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=N4(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=N4(this.options);e.data!==void 0&&(this.setState(C4(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=HC(this.state.data,t,this.options);return this.#a({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t,e){this.#a({type:"setState",state:t,setStateOptions:e})}cancel(t){const e=this.#i?.promise;return this.#i?.cancel(t),e?e.then(ua).catch(ua):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>Ns(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ZR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Nu(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!S$(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(t&&this.setOptions(t),!this.options.queryFn){const o=this.observers.find(l=>l.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,i=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},r=()=>{const o=M$(this.options,e),c=(()=>{const d={client:this.#r,queryKey:this.queryKey,meta:this.meta};return i(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,c,this):o(c)},s=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:r};return i(o),o})();this.options.behavior?.onFetch(s,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#a({type:"fetch",meta:s.fetchOptions?.meta}),this.#i=T$({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:o=>{o instanceof $C&&o.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(o,l)=>{this.#a({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0});try{const o=await this.#i.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof $C){if(o.silent)return this.#i.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#a({type:"error",error:o}),this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#a(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...N$(n.data,this.options),fetchMeta:t.meta??null};case"success":const i={...n,...C4(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?i:void 0,i;case"error":const r=t.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),nr.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function N$(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:A$(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function C4(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function N4(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,i=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Pne=class extends rm{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=VC(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#s;#o;#a;#m;#f;#h;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),R4(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return GC(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return GC(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#_(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ns(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),e._defaulted&&!f_(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&P4(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),i&&(this.#t!==n||Ns(this.options.enabled,this.#t)!==Ns(e.enabled,this.#t)||Nu(this.options.staleTime,this.#t)!==Nu(e.staleTime,this.#t))&&this.#g();const r=this.#x();i&&(this.#t!==n||Ns(this.options.enabled,this.#t)!==Ns(e.enabled,this.#t)||r!==this.#l)&&this.#v(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return One(this,n)&&(this.#r=n,this.#s=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(t,e){return new Proxy(t,{get:(n,i)=>(this.trackProp(i),e?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#d({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(t){this.#S();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(ua)),e}#g(){this.#b();const t=Nu(this.options.staleTime,this.#t);if(mf||this.#r.isStale||!zC(t))return;const n=S$(this.#r.dataUpdatedAt,t)+1;this.#c=Wd.setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(t){this.#_(),this.#l=t,!(mf||Ns(this.options.enabled,this.#t)===!1||!zC(this.#l)||this.#l===0)&&(this.#u=Wd.setInterval(()=>{(this.options.refetchIntervalInBackground||QR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#v(this.#x())}#b(){this.#c&&(Wd.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Wd.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,i=this.options,r=this.#r,a=this.#i,s=this.#s,l=t!==n?t.state:this.#n,{state:c}=t;let d={...c},f=!1,p;if(e._optimisticResults){const U=this.hasListeners(),R=!U&&R4(t,e),O=U&&P4(t,n,e,i);(R||O)&&(d={...d,...N$(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:_,status:b}=d;p=d.data;let v=!1;if(e.placeholderData!==void 0&&p===void 0&&b==="pending"){let U;r?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(U=r.data,v=!0):U=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,U!==void 0&&(b="success",p=HC(r?.data,U,e),f=!0)}if(e.select&&p!==void 0&&!v)if(r&&p===a?.data&&e.select===this.#m)p=this.#f;else try{this.#m=e.select,p=e.select(p),p=HC(r?.data,p,e),this.#f=p,this.#a=null}catch(U){this.#a=U}this.#a&&(m=this.#a,p=this.#f,_=Date.now(),b="error");const x=d.fetchStatus==="fetching",M=b==="pending",w=b==="error",E=M&&x,T=p!==void 0,N={status:b,fetchStatus:d.fetchStatus,isPending:M,isSuccess:b==="success",isError:w,isInitialLoading:E,isLoading:E,data:p,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:_,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:x,isRefetching:x&&!M,isLoadingError:w&&!T,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&T,isStale:JR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ns(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const U=z=>{N.status==="error"?z.reject(N.error):N.data!==void 0&&z.resolve(N.data)},R=()=>{const z=this.#o=N.promise=VC();U(z)},O=this.#o;switch(O.status){case"pending":t.queryHash===n.queryHash&&U(O);break;case"fulfilled":(N.status==="error"||N.data!==O.value)&&R();break;case"rejected":(N.status!=="error"||N.error!==O.reason)&&R();break}}return N}updateResult(){const t=this.#r,e=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#s=this.options,this.#i.data!==void 0&&(this.#h=this.#t),f_(e,t))return;this.#r=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,r=typeof i=="function"?i():i;if(r==="all"||!r&&!this.#p.size)return!0;const a=new Set(r??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#r).some(s=>{const o=s;return this.#r[o]!==t[o]&&a.has(o)})};this.#w({listeners:n()})}#S(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#w(t){nr.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Dne(t,e){return Ns(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function R4(t,e){return Dne(t,e)||t.state.data!==void 0&&GC(t,e,e.refetchOnMount)}function GC(t,e,n){if(Ns(e.enabled,t)!==!1&&Nu(e.staleTime,t)!=="static"){const i=typeof n=="function"?n(t):n;return i==="always"||i!==!1&&JR(t,e)}return!1}function P4(t,e,n,i){return(t!==e||Ns(i.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&JR(t,n)}function JR(t,e){return Ns(e.enabled,t)!==!1&&t.isStaleByTime(Nu(e.staleTime,t))}function One(t,e){return!f_(t.getCurrentResult(),e)}function D4(t){return{onFetch:(e,n)=>{const i=e.options,r=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],s=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const c=async()=>{let d=!1;const f=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},p=M$(e.options,e.fetchOptions),m=async(_,b,v)=>{if(d)return Promise.reject();if(b==null&&_.pages.length)return Promise.resolve(_);const M=(()=>{const P={client:e.client,queryKey:e.queryKey,pageParam:b,direction:v?"backward":"forward",meta:e.options.meta};return f(P),P})(),w=await p(M),{maxPages:E}=e.options,T=v?Mne:wne;return{pages:T(_.pages,w,E),pageParams:T(_.pageParams,b,E)}};if(r&&a.length){const _=r==="backward",b=_?kne:O4,v={pages:a,pageParams:s},x=b(i,v);o=await m(v,x,_)}else{const _=t??a.length;do{const b=l===0?s[0]??i.initialPageParam:O4(i,o);if(l>0&&b==null)break;o=await m(o,b),l++}while(l<_)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=c}}}function O4(t,{pages:e,pageParams:n}){const i=e.length-1;return e.length>0?t.getNextPageParam(e[i],e,n[i],n):void 0}function kne(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Lne=class extends C${#e;#t;#n;#r;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||R$(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#i({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=T$({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,s)=>{this.#i({type:"failed",failureCount:a,error:s})},onPause:()=>{this.#i({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const i=this.state.status==="pending",r=!this.#r.canStart();try{if(i)e();else{this.#i({type:"pending",variables:t,isPaused:r}),await this.#n.config.onMutate?.(t,this,n);const s=await this.options.onMutate?.(t,n);s!==this.state.context&&this.#i({type:"pending",context:s,variables:t,isPaused:r})}const a=await this.#r.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#i({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#i({type:"error",error:a})}}finally{this.#n.runNext(this)}}#i(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),nr.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function R$(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ine=class extends rm{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const i=new Lne({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(i),i}add(t){this.#e.add(t);const e=uy(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=uy(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=uy(t);if(typeof e=="string"){const i=this.#t.get(e)?.find(r=>r.state.status==="pending");return!i||i===t}else return!0}runNext(t){const e=uy(t);return typeof e=="string"?this.#t.get(e)?.find(i=>i!==t&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){nr.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>E4(e,n))}findAll(t={}){return this.getAll().filter(e=>E4(t,e))}notify(t){nr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return nr.batch(()=>Promise.all(t.map(e=>e.continue().catch(ua))))}};function uy(t){return t.options.scope?.id}var Une=class extends rm{#e;#t=void 0;#n;#r;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),f_(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&gf(n.mutationKey)!==gf(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#s()}mutate(e,n){return this.#r=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){const e=this.#n?.state??R$();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){nr.batch(()=>{if(this.#r&&this.hasListeners()){const n=this.#t.variables,i=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#r.onSuccess?.(e.data,n,i,r),this.#r.onSettled?.(e.data,null,n,i,r)):e?.type==="error"&&(this.#r.onError?.(e.error,n,i,r),this.#r.onSettled?.(void 0,e.error,n,i,r))}this.listeners.forEach(n=>{n(this.#t)})})}},jne=class extends rm{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const i=e.queryKey,r=e.queryHash??YR(i,e);let a=this.get(r);return a||(a=new Rne({client:t,queryKey:i,queryHash:r,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(i)}),this.add(a)),a}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){nr.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>M4(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>M4(t,n)):e}notify(t){nr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){nr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){nr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Fne=class{#e;#t;#n;#r;#i;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new jne,this.#t=t.mutationCache||new Ine,this.#n=t.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=QR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=h_.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),i=n.state.data;return i===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Nu(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const i=n.data;return[e,i]})}setQueryData(t,e,n){const i=this.defaultQueryOptions({queryKey:t}),a=this.#e.get(i.queryHash)?.state.data,s=bne(e,a);if(s!==void 0)return this.#e.build(this,i).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return nr.batch(()=>this.#e.findAll(t).map(({queryKey:i})=>[i,this.setQueryData(i,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;nr.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return nr.batch(()=>(n.findAll(t).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},i=nr.batch(()=>this.#e.findAll(t).map(r=>r.cancel(n)));return Promise.all(i).then(ua).catch(ua)}invalidateQueries(t,e={}){return nr.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},i=nr.batch(()=>this.#e.findAll(t).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let a=r.fetch(void 0,n);return n.throwOnError||(a=a.catch(ua)),r.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(i).then(ua)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(Nu(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ua).catch(ua)}fetchInfiniteQuery(t){return t.behavior=D4(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ua).catch(ua)}ensureInfiniteQueryData(t){return t.behavior=D4(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return h_.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#r.set(gf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(i=>{y0(t,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(t,e){this.#i.set(gf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(i=>{y0(t,i.mutationKey)&&Object.assign(n,i.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=YR(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===ZR&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},P$=A.createContext(void 0),ui=t=>{const e=A.useContext(P$);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},zne=({client:t,children:e})=>(A.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),g.jsx(P$.Provider,{value:t,children:e})),D$=A.createContext(!1),Bne=()=>A.useContext(D$);D$.Provider;function Hne(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Vne=A.createContext(Hne()),$ne=()=>A.useContext(Vne),Gne=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Wne=t=>{A.useEffect(()=>{t.clearReset()},[t])},qne=({result:t,errorResetBoundary:e,throwOnError:n,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||E$(n,[t.error,i])),Xne=t=>{if(t.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>n(i(...r)):n(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Kne=(t,e)=>t.isLoading&&t.isFetching&&!e,Yne=(t,e)=>t?.suspense&&e.isPending,k4=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Zne(t,e,n){const i=Bne(),r=$ne(),a=ui(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=i?"isRestoring":"optimistic",Xne(s),Gne(s,r),Wne(r);const o=!a.getQueryCache().get(s.queryHash),[l]=A.useState(()=>new e(a,s)),c=l.getOptimisticResult(s),d=!i&&t.subscribed!==!1;if(A.useSyncExternalStore(A.useCallback(f=>{const p=d?l.subscribe(nr.batchCalls(f)):ua;return l.updateResult(),p},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),A.useEffect(()=>{l.setOptions(s)},[s,l]),Yne(s,c))throw k4(s,l,r);if(qne({result:c,errorResetBoundary:r,throwOnError:s.throwOnError,query:a.getQueryCache().get(s.queryHash),suspense:s.suspense}))throw c.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(s,c),s.experimental_prefetchInRender&&!mf&&Kne(c,i)&&(o?k4(s,l,r):a.getQueryCache().get(s.queryHash)?.promise)?.catch(ua).finally(()=>{l.updateResult()}),s.notifyOnChangeProps?c:l.trackResult(c)}function Bt(t,e){return Zne(t,Pne)}function Ut(t,e){const n=ui(),[i]=A.useState(()=>new Une(n,t));A.useEffect(()=>{i.setOptions(t)},[i,t]);const r=A.useSyncExternalStore(A.useCallback(s=>i.subscribe(nr.batchCalls(s)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),a=A.useCallback((s,o)=>{i.mutate(s,o).catch(ua)},[i]);if(r.error&&E$(i.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}const Qne=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Jne=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase()),L4=t=>{const e=Jne(t);return e.charAt(0).toUpperCase()+e.slice(1)},O$=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim(),eie=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var tie={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const nie=A.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:a,iconNode:s,...o},l)=>A.createElement("svg",{ref:l,...tie,width:e,height:e,stroke:t,strokeWidth:i?Number(n)*24/Number(e):n,className:O$("lucide",r),...!a&&!eie(o)&&{"aria-hidden":"true"},...o},[...s.map(([c,d])=>A.createElement(c,d)),...Array.isArray(a)?a:[a]]));const at=(t,e)=>{const n=A.forwardRef(({className:i,...r},a)=>A.createElement(nie,{ref:a,iconNode:e,className:O$(`lucide-${Qne(L4(t))}`,`lucide-${t}`,i),...r}));return n.displayName=L4(t),n};const iie=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],rie=at("archive",iie);const aie=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],sie=at("arrow-down",aie);const oie=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],lie=at("arrow-up-down",oie);const cie=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],uie=at("arrow-up",cie);const die=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],WC=at("bell",die);const fie=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],hie=at("bold",fie);const pie=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],b0=at("box",pie);const mie=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],gie=at("cable",mie);const xie=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],vie=at("calendar-days",xie);const yie=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],$o=at("calendar",yie);const bie=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],qC=at("camera",bie);const _ie=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Sie=at("chart-column",_ie);const wie=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],_0=at("check",wie);const Mie=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],yS=at("chevron-down",Mie);const Eie=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],If=at("chevron-right",Eie);const Aie=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],xf=at("chevron-left",Aie);const Tie=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],k$=at("chevron-up",Tie);const Cie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ed=at("circle-alert",Cie);const Nie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],I4=at("circle-arrow-up",Nie);const Rie=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],td=at("circle-check-big",Rie);const Pie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Die=at("circle-stop",Pie);const Oie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],px=at("circle-x",Oie);const kie=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],fs=at("clock",kie);const Lie=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],eP=at("cloud",Lie);const Iie=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Uie=at("code-xml",Iie);const jie=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],XC=at("copy",jie);const Fie=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],U4=at("database",Fie);const zie=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],j4=at("dollar-sign",zie);const Bie=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Fu=at("download",Bie);const Hie=[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]],L$=at("droplet",Hie);const Vie=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],$ie=at("ellipsis-vertical",Vie);const Gie=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],sc=at("external-link",Gie);const Wie=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],qie=at("eye-off",Wie);const Xie=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],F4=at("eye",Xie);const Kie=[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.8",key:"1kchwa"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}],["path",{d:"M3 13.1a2 2 0 0 0-.999 1.76v3.24a2 2 0 0 0 .969 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01z",key:"19flxy"}],["path",{d:"M7 17v5",key:"1yj1jh"}]],Yie=at("file-box",Kie);const Zie=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],z4=at("file-code",Zie);const Qie=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Jie=at("file-exclamation-point",Qie);const ere=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],cp=at("file-text",ere);const tre=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],I$=at("file",tre);const nre=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],gp=at("film",nre);const ire=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],rre=at("flame",ire);const are=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],sre=at("folder-open",are);const ore=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],lre=at("folder",ore);const cre=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],ure=at("funnel",cre);const dre=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],tP=at("gauge",dre);const fre=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],B4=at("github",fre);const hre=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],KC=at("globe",hre);const pre=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],nP=at("grip-vertical",pre);const mre=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],U$=at("hard-drive",mre);const gre=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],bS=at("image",gre);const xre=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],j$=at("info",xre);const vre=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],yre=at("italic",vre);const bre=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],_re=at("key",bre);const Sre=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],YC=at("keyboard",Sre);const wre=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],F$=at("layers",wre);const Mre=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Ere=at("layout-grid",Mre);const Are=[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],Tre=at("link-2-off",Are);const Cre=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Nre=at("link-2",Cre);const Rre=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],Pre=at("link",Rre);const Dre=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Ore=at("list-ordered",Dre);const kre=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],z$=at("list",kre);const Lre=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Yt=at("loader-circle",Lre);const Ire=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],H4=at("log-in",Ire);const Ure=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],jre=at("log-out",Ure);const Fre=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],zre=at("maximize-2",Fre);const Bre=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Hre=at("minimize-2",Bre);const Vre=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],p_=at("moon",Vre);const $re=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],m_=at("package",$re);const Gre=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Wre=at("pause",Gre);const qre=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],B$=at("pen-line",qre);const Xre=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],H$=at("pen",Xre);const Kre=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],V4=at("pencil",Kre);const Yre=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],_S=at("play",Yre);const Zre=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],ZC=at("plug",Zre);const Qre=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],oc=at("plus",Qre);const Jre=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],V$=at("power-off",Jre);const eae=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],SS=at("power",eae);const tae=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],lc=at("printer",tae);const nae=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],iae=at("qr-code",nae);const rae=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],zu=at("refresh-cw",rae);const aae=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],wS=at("rotate-ccw",aae);const sae=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],oae=at("ruler",sae);const lae=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],mx=at("save",lae);const cae=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]],uae=at("scan-search",cae);const dae=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],g_=at("search",dae);const fae=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],$$=at("send",fae);const hae=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],MS=at("settings-2",hae);const pae=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],mae=at("settings",pae);const gae=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],xae=at("skip-back",gae);const vae=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],G$=at("skip-forward",vae);const yae=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],bae=at("sparkles",yae);const _ae=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],x_=at("square-check-big",_ae);const Sae=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],S0=at("square",Sae);const wae=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],w0=at("star",wae);const Mae=[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]],Eae=at("sticky-note",Mae);const Aae=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],$4=at("sun",Aae);const Tae=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],M0=at("tag",Tae);const Cae=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Nae=at("target",Cae);const Rae=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Pae=at("terminal",Rae);const Dae=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Oae=at("text-align-center",Dae);const kae=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Lae=at("text-align-end",kae);const Iae=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Uae=at("text-align-start",Iae);const jae=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Vb=at("thermometer",jae);const Fae=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ta=at("trash-2",Fae);const zae=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Bu=at("triangle-alert",zae);const Bae=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Hae=at("underline",Bae);const Vae=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],$ae=at("unlink",Vae);const Gae=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],E0=at("upload",Gae);const Wae=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],G4=at("user",Wae);const qae=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ES=at("wifi-off",qae);const Xae=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],iP=at("wifi",Xae);const Kae=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Np=at("wrench",Kae);const Yae=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Cn=at("x",Yae);const Zae=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Qae=at("zoom-in",Zae);const Jae=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],W$=at("zap",Jae);const ese=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],tse=at("zoom-out",ese),q$=A.createContext(void 0);function nse({children:t}){const[e,n]=A.useState(()=>{const a=localStorage.getItem("theme");return a||(window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark")});A.useEffect(()=>{const a=document.documentElement;e==="dark"?a.classList.add("dark"):a.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const i=()=>{n(a=>a==="dark"?"light":"dark")},r=a=>{n(a)};return g.jsx(q$.Provider,{value:{theme:e,toggleTheme:i,setTheme:r},children:t})}function ise(){const t=A.useContext(q$);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function cn({children:t,className:e="",onClick:n,onContextMenu:i}){return g.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:i,children:t})}function Fl({children:t,className:e=""}){return g.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function gn({children:t,className:e=""}){return g.jsx("div",{className:`p-6 ${e}`,children:t})}function rse(t){return[{category:"Navigation",items:t?t.map((n,i)=>({keys:[String(i+1)],description:`Go to ${n.label}`})):[{keys:["1"],description:"Go to Printers"},{keys:["2"],description:"Go to Archives"},{keys:["3"],description:"Go to Queue"},{keys:["4"],description:"Go to Statistics"},{keys:["5"],description:"Go to Cloud Profiles"},{keys:["6"],description:"Go to Settings"}]},{category:"Archives",items:[{keys:["/"],description:"Focus search"},{keys:["U"],description:"Open upload modal"},{keys:["Esc"],description:"Clear selection / blur input"},{keys:["Right-click"],description:"Context menu on cards"}]},{category:"General",items:[{keys:["?"],description:"Show this help"}]}]}function W4({children:t}){return g.jsx("kbd",{className:"px-2 py-1 text-xs font-mono bg-bambu-dark border border-bambu-dark-tertiary rounded text-white",children:t})}function ase({onClose:t,navItems:e}){const n=rse(e);return A.useEffect(()=>{const i=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:g.jsx(cn,{className:"w-full max-w-md",onClick:i=>i.stopPropagation(),children:g.jsxs(gn,{className:"p-0",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(YC,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),g.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:n.map(i=>g.jsxs("div",{children:[g.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:i.category}),g.jsx("div",{className:"space-y-2",children:i.items.map(r=>g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("span",{className:"text-white text-sm",children:r.description}),g.jsx("div",{className:"flex gap-1",children:r.keys.map(a=>g.jsx(W4,{children:a},a))})]},r.description))})]},i.category))}),g.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:g.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",g.jsx(W4,{children:"Esc"})," or click outside to close"]})})]})})})}const Ji="/api/v1";async function gt(t,e={}){const n=await fetch(`${Ji}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${n.status}`)}return n.json()}const Ze={getPrinters:()=>gt("/printers/"),getPrinter:t=>gt(`/printers/${t}`),createPrinter:t=>gt("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>gt(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>gt(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>gt(`/printers/${t}/status`),connectPrinter:t=>gt(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>gt(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>gt(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>gt(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>gt(`/printers/${t}/logging`),clearMQTTLogs:t=>gt(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>gt(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Ji}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>gt(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>gt(`/printers/${t}/storage`),getArchives:(t,e=50,n=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),i.set("limit",String(e)),i.set("offset",String(n)),gt(`/archives/?${i}`)},getArchive:t=>gt(`/archives/${t}`),updateArchive:(t,e)=>gt(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>gt(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>gt(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>gt("/archives/stats"),getArchiveDuplicates:t=>gt(`/archives/${t}/duplicates`),backfillContentHashes:()=>gt("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Ji}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${Ji}/archives/${t}/download`,getArchiveGcode:t=>`${Ji}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${Ji}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>gt(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>gt(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const i=await fetch(`${Ji}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${Ji}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const i=await fetch(`${Ji}/archives/${t}/photos`,{method:"POST",body:n});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${i.status}`)}return i.json()},deleteArchivePhoto:(t,e)=>gt(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Ji}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Ji}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const i=await fetch(`${Ji}/archives/${t}/source`,{method:"POST",body:n});if(!i.ok){const r=await i.json().catch(()=>({}));throw new Error(r.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>gt(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Ji}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>gt(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>gt(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>gt(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Ji}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Ji}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>gt(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const i=e?`${Ji}/archives/upload?printer_id=${e}`:`${Ji}/archives/upload`,r=await fetch(i,{method:"POST",body:n});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${r.status}`)}return r.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const i=e?`${Ji}/archives/upload-bulk?printer_id=${e}`:`${Ji}/archives/upload-bulk`,r=await fetch(i,{method:"POST",body:n});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${r.status}`)}return r.json()},getSettings:()=>gt("/settings/"),updateSettings:t=>gt("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>gt("/settings/reset",{method:"POST"}),checkFfmpeg:()=>gt("/settings/check-ffmpeg"),getCloudStatus:()=>gt("/cloud/status"),cloudLogin:(t,e,n="global")=>gt("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>gt("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>gt("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>gt("/cloud/logout",{method:"POST"}),getCloudSettings:(t="01.09.00.00")=>gt(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>gt(`/cloud/settings/${t}`),getCloudDevices:()=>gt("/cloud/devices"),getSmartPlugs:()=>gt("/smart-plugs/"),getSmartPlug:t=>gt(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>gt(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>gt("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>gt(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>gt(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>gt(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>gt(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>gt("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),gt(`/queue/?${n}`)},getQueueItem:t=>gt(`/queue/${t}`),addToQueue:t=>gt("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>gt(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>gt(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>gt("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>gt(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>gt(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>gt(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>gt(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>gt(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),getNotificationProviders:()=>gt("/notifications/"),getNotificationProvider:t=>gt(`/notifications/${t}`),createNotificationProvider:t=>gt("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>gt(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>gt(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>gt(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>gt("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),getSpoolmanStatus:()=>gt("/spoolman/status"),connectSpoolman:()=>gt("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>gt("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>gt(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>gt("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>gt("/spoolman/spools"),getSpoolmanFilaments:()=>gt("/spoolman/filaments"),getVersion:()=>gt("/updates/version"),checkForUpdates:()=>gt("/updates/check"),applyUpdate:()=>gt("/updates/apply",{method:"POST"}),getUpdateStatus:()=>gt("/updates/status"),getMaintenanceTypes:()=>gt("/maintenance/types"),createMaintenanceType:t=>gt("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>gt(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>gt(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>gt("/maintenance/overview"),getPrinterMaintenance:t=>gt(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>gt(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>gt(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>gt(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>gt("/maintenance/summary"),setPrinterHours:(t,e)=>gt(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"})},$b=[{id:"printers",to:"/",icon:lc,label:"Printers"},{id:"archives",to:"/archives",icon:rie,label:"Archives"},{id:"queue",to:"/queue",icon:$o,label:"Queue"},{id:"stats",to:"/stats",icon:Sie,label:"Statistics"},{id:"profiles",to:"/profiles",icon:eP,label:"Profiles"},{id:"maintenance",to:"/maintenance",icon:Np,label:"Maintenance"},{id:"settings",to:"/settings",icon:mae,label:"Settings"}];function sse(){const t=localStorage.getItem("sidebarOrder");if(t)try{const e=JSON.parse(t),n=new Map($b.map(r=>[r.id,r])),i=[];for(const r of e){const a=n.get(r);a&&(i.push(a),n.delete(r))}for(const r of n.values())i.push(r);return i}catch{return $b}return $b}function ose(t){localStorage.setItem("sidebarOrder",JSON.stringify(t.map(e=>e.id)))}function X$(){return localStorage.getItem("defaultView")||"/"}function lse(t){localStorage.setItem("defaultView",t)}function cse(){const t=GR(),e=Ju(),{theme:n,toggleTheme:i}=ise(),[r,a]=A.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[s,o]=A.useState(!1),[l,c]=A.useState(sse),[d,f]=A.useState(null),[p,m]=A.useState(null),_=A.useRef(!1),{data:b}=Bt({queryKey:["version"],queryFn:Ze.getVersion,staleTime:1/0}),{data:v}=Bt({queryKey:["settings"],queryFn:Ze.getSettings,staleTime:300*1e3}),{data:x}=Bt({queryKey:["updateCheck"],queryFn:Ze.checkForUpdates,enabled:v?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3});A.useEffect(()=>{if(!_.current&&e.pathname==="/"){const U=X$();U!=="/"&&(_.current=!0,t(U,{replace:!0}))}},[e.pathname,t]),A.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(r))},[r]);const M=(U,R)=>{f(R),U.dataTransfer.effectAllowed="move",U.dataTransfer.setData("text/plain",String(R))},w=(U,R)=>{U.preventDefault(),U.dataTransfer.dropEffect="move",m(R)},E=()=>{m(null)},T=(U,R)=>{if(U.preventDefault(),d===null||d===R){f(null),m(null);return}const O=[...l],[z]=O.splice(d,1);O.splice(R,0,z),c(O),ose(O),f(null),m(null)},P=()=>{f(null),m(null)},N=A.useCallback(U=>{const R=U.target;if(!(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable)&&!U.metaKey&&!U.ctrlKey&&!U.altKey){const O=parseInt(U.key);if(O>=1&&O<=l.length){U.preventDefault(),t(l[O-1].to);return}switch(U.key){case"?":U.preventDefault(),o(!0);break;case"Escape":o(!1);break}}},[t,l]);return A.useEffect(()=>(document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)),[N]),g.jsxs("div",{className:"flex min-h-screen",children:[g.jsxs("aside",{className:`${r?"w-64":"w-16"} bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col fixed inset-y-0 left-0 z-30 transition-all duration-300`,children:[g.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${r?"p-4":"p-2"}`,children:g.jsx("img",{src:n==="dark"?"/img/bambusy_logo_dark.png":"/img/bambusy_logo_light.png",alt:"Bambusy",className:r?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),g.jsx("nav",{className:"flex-1 p-2",children:g.jsx("ul",{className:"space-y-2",children:l.map(({id:U,to:R,icon:O,label:z},I)=>g.jsx("li",{draggable:!0,onDragStart:G=>M(G,I),onDragOver:G=>w(G,I),onDragLeave:E,onDrop:G=>T(G,I),onDragEnd:P,className:`relative ${d===I?"opacity-50":""} ${p===I&&d!==I?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:g.jsxs(b$,{to:R,className:({isActive:G})=>`flex items-center ${r?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${G?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:r?void 0:z,children:[r&&g.jsx(nP,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),g.jsx(O,{className:"w-5 h-5 flex-shrink-0"}),r&&g.jsx("span",{children:z})]})},U))})}),g.jsx("button",{onClick:()=>a(!r),className:"p-2 mx-2 mb-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white flex items-center justify-center",title:r?"Collapse sidebar":"Expand sidebar",children:r?g.jsx(xf,{className:"w-5 h-5"}):g.jsx(If,{className:"w-5 h-5"})}),g.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:r?g.jsxs("div",{className:"flex items-center justify-between px-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",b?.version||"..."]}),x?.update_available&&g.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:`Update available: v${x.latest_version}`,children:[g.jsx(I4,{className:"w-4 h-4"}),g.jsx("span",{children:"Update"})]})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("a",{href:"https://github.com/maziggy/bambusy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:"View on GitHub",children:g.jsx(B4,{className:"w-5 h-5"})}),g.jsx("button",{onClick:()=>o(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:"Keyboard shortcuts (?)",children:g.jsx(YC,{className:"w-5 h-5"})}),g.jsx("button",{onClick:i,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:n==="dark"?"Switch to light mode":"Switch to dark mode",children:n==="dark"?g.jsx($4,{className:"w-5 h-5"}):g.jsx(p_,{className:"w-5 h-5"})})]})]}):g.jsxs("div",{className:"flex flex-col items-center gap-1",children:[x?.update_available&&g.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:`Update available: v${x.latest_version}`,children:g.jsx(I4,{className:"w-5 h-5"})}),g.jsx("a",{href:"https://github.com/maziggy/bambusy",target:"_blank",rel:"noopener noreferrer",className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:"View on GitHub",children:g.jsx(B4,{className:"w-5 h-5"})}),g.jsx("button",{onClick:()=>o(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:"Keyboard shortcuts (?)",children:g.jsx(YC,{className:"w-5 h-5"})}),g.jsx("button",{onClick:i,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:n==="dark"?"Switch to light mode":"Switch to dark mode",children:n==="dark"?g.jsx($4,{className:"w-5 h-5"}):g.jsx(p_,{className:"w-5 h-5"})})]})})]}),g.jsx("main",{className:`flex-1 bg-bambu-dark overflow-auto ${r?"ml-64":"ml-16"} transition-all duration-300`,children:g.jsx(Ite,{})}),s&&g.jsx(ase,{onClose:()=>o(!1),navItems:l})]})}function ot({variant:t="primary",size:e="md",className:n="",children:i,...r}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",s={primary:"bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green",secondary:"bg-bambu-dark-tertiary hover:bg-bambu-gray-dark text-white focus:ring-bambu-gray",danger:"bg-red-600 hover:bg-red-700 text-white focus:ring-red-500",ghost:"bg-transparent hover:bg-bambu-dark-tertiary text-bambu-gray-light hover:text-white"},o={sm:"px-3 py-1.5 text-sm gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-6 py-3 text-base gap-2"};return g.jsx("button",{className:`${a} ${s[t]} ${o[e]} ${n}`,...r,children:i})}function pa({title:t,message:e,confirmText:n="Confirm",cancelText:i="Cancel",variant:r="default",onConfirm:a,onCancel:s}){A.useEffect(()=>{const c=d=>{d.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]);const l={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600"},warning:{icon:"text-yellow-400",button:"bg-yellow-500 hover:bg-yellow-600"},default:{icon:"text-bambu-green",button:"bg-bambu-green hover:bg-bambu-green-dark"}}[r];return g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:g.jsx(cn,{className:"w-full max-w-md",onClick:c=>c.stopPropagation(),children:g.jsxs(gn,{className:"p-6",children:[g.jsxs("div",{className:"flex items-start gap-4",children:[g.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:g.jsx(Bu,{className:"w-6 h-6"})}),g.jsxs("div",{className:"flex-1",children:[g.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),g.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),g.jsxs("div",{className:"flex gap-3 mt-6",children:[g.jsx(ot,{variant:"secondary",onClick:s,className:"flex-1",children:i}),g.jsx(ot,{onClick:a,className:`flex-1 ${l.button}`,children:n})]})]})})})}const K$=A.createContext(void 0);function _o(){const t=A.useContext(K$);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const use={success:g.jsx(td,{className:"w-5 h-5 text-green-400"}),error:g.jsx(px,{className:"w-5 h-5 text-red-400"}),warning:g.jsx(ed,{className:"w-5 h-5 text-yellow-400"}),info:g.jsx(j$,{className:"w-5 h-5 text-blue-400"})},dse={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30"};function fse({children:t}){const[e,n]=A.useState([]),i=A.useCallback((a,s="success")=>{const o=Math.random().toString(36).substr(2,9);n(l=>[...l,{id:o,message:a,type:s}]),setTimeout(()=>{n(l=>l.filter(c=>c.id!==o))},3e3)},[]),r=A.useCallback(a=>{n(s=>s.filter(o=>o.id!==a))},[]);return g.jsxs(K$.Provider,{value:{showToast:i},children:[t,g.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(a=>g.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${dse[a.type]}`,children:[use[a.type],g.jsx("span",{className:"text-white text-sm",children:a.message}),g.jsx("button",{onClick:()=>r(a.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-4 h-4"})})]},a.id))})]})}function hse(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],i=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,i)).toFixed(1))} ${n[i]}`}function pse(t){if(t===0)return"0 GB";const e=t/(1024*1024*1024);return e>=1?`${e.toFixed(1)} GB`:`${(t/(1024*1024)).toFixed(0)} MB`}function mse(t,e){if(e)return lre;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Yie;case"gcode":return cp;case"mp4":case"avi":return gp;case"png":case"jpg":case"jpeg":return bS;default:return I$}}function gse({printerId:t,printerName:e,onClose:n}){const{showToast:i}=_o(),r=ui(),[a,s]=A.useState("/"),[o,l]=A.useState(null),[c,d]=A.useState(""),[f,p]=A.useState(null);A.useEffect(()=>{const N=U=>{U.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const{data:m,isLoading:_,refetch:b}=Bt({queryKey:["printerFiles",t,a],queryFn:()=>Ze.getPrinterFiles(t,a)}),{data:v}=Bt({queryKey:["printerStorage",t],queryFn:()=>Ze.getPrinterStorage(t),staleTime:3e4}),x=Ut({mutationFn:N=>Ze.deletePrinterFile(t,N),onSuccess:(N,U)=>{i(`Deleted: ${U.split("/").pop()}`),r.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:N=>{i(`Delete failed: ${N.message}`,"error")}}),M=N=>{s(N),l(null)},w=()=>{if(a==="/")return;const N=a.split("/").filter(Boolean);N.pop(),s(N.length?"/"+N.join("/"):"/"),l(null)},E=N=>{window.open(Ze.getPrinterFileDownloadUrl(t,N),"_blank")},T=N=>{p(N)},P=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return g.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[g.jsxs("div",{className:"w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden",onClick:N=>N.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(U$,{className:"w-5 h-5 text-bambu-green"}),g.jsxs("div",{children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),g.jsxs("div",{className:"flex items-center gap-4",children:[v?.used_bytes!=null&&v.used_bytes>0&&g.jsxs("div",{className:"text-sm text-bambu-gray",children:["Used: ",pse(v.used_bytes)]}),g.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]})]}),g.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[P.map(N=>g.jsx("button",{onClick:()=>{M(N.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===N.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:N.label},N.path)),g.jsx("div",{className:"flex-1"}),g.jsxs("div",{className:"relative",children:[g.jsx(g_,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),g.jsx("input",{type:"text",placeholder:"Filter files...",value:c,onChange:N=>d(N.target.value),className:"w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}),g.jsx(ot,{variant:"secondary",size:"sm",onClick:()=>b(),disabled:_,children:g.jsx(zu,{className:`w-4 h-4 ${_?"animate-spin":""}`})})]}),g.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[g.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:g.jsx(xf,{className:"w-4 h-4"})}),g.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),g.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:_?g.jsx("div",{className:"flex items-center justify-center py-12",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?.files?.length?g.jsx("div",{className:"space-y-1",children:[...m.files].filter(N=>!c||N.name.toLowerCase().includes(c.toLowerCase())).sort((N,U)=>N.is_directory&&!U.is_directory?-1:!N.is_directory&&U.is_directory?1:N.name.localeCompare(U.name)).map(N=>{const U=mse(N.name,N.is_directory),R=o===N.path;return g.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${R?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{N.is_directory?M(N.path):l(R?null:N.path)},children:[g.jsx(U,{className:`w-5 h-5 flex-shrink-0 ${N.is_directory?"text-bambu-green":"text-bambu-gray"}`}),g.jsx("span",{className:"flex-1 text-white truncate",children:N.name}),!N.is_directory&&g.jsx("span",{className:"text-sm text-bambu-gray",children:hse(N.size)}),N.is_directory&&g.jsx(xf,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},N.path)})}):g.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),g.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[g.jsx("div",{className:"text-sm text-bambu-gray",children:c?`${m?.files?.filter(N=>N.name.toLowerCase().includes(c.toLowerCase())).length||0} of ${m?.files?.length||0} items`:`${m?.files?.length||0} items`}),g.jsxs("div",{className:"flex gap-2",children:[g.jsxs(ot,{variant:"secondary",disabled:!o,onClick:()=>o&&E(o),children:[g.jsx(Fu,{className:"w-4 h-4"}),"Download"]}),g.jsxs(ot,{variant:"secondary",disabled:!o||x.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[x.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(ta,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&g.jsx(pa,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{x.mutate(f),p(null)},onCancel:()=>p(null)})]})}function xse({printerId:t,printerName:e,onClose:n}){const i=ui(),[r,a]=A.useState(!0),[s,o]=A.useState(new Set),l=A.useRef(null),{data:c,isLoading:d,refetch:f}=Bt({queryKey:["mqtt-logs",t],queryFn:()=>Ze.getMQTTLogs(t),refetchInterval:1e3}),p=Ut({mutationFn:()=>Ze.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),m=Ut({mutationFn:()=>Ze.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),_=Ut({mutationFn:()=>Ze.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});A.useEffect(()=>{const E=T=>{T.key==="Escape"&&n()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[n]),A.useEffect(()=>{r&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[c?.logs,r]);const b=E=>{o(T=>{const P=new Set(T);return P.has(E)?P.delete(E):P.add(E),P})},v=E=>new Date(E).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),x=(E,T)=>{const P=JSON.stringify(E,null,T?2:0);return!T&&P.length>100?P.substring(0,100)+"...":P},M=c?.logging_enabled??!1,w=c?.logs??[];return g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("div",{children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),g.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[M?g.jsxs(ot,{size:"sm",variant:"secondary",onClick:()=>m.mutate(),disabled:m.isPending,children:[g.jsx(S0,{className:"w-4 h-4"}),"Stop"]}):g.jsxs(ot,{size:"sm",onClick:()=>p.mutate(),disabled:p.isPending,children:[g.jsx(_S,{className:"w-4 h-4"}),"Start Logging"]}),g.jsxs(ot,{size:"sm",variant:"secondary",onClick:()=>_.mutate(),disabled:_.isPending||w.length===0,children:[g.jsx(ta,{className:"w-4 h-4"}),"Clear"]}),g.jsx(ot,{size:"sm",variant:"secondary",onClick:()=>f(),disabled:d,children:g.jsx(zu,{className:`w-4 h-4 ${d?"animate-spin":""}`})}),g.jsx("div",{className:"flex-1"}),g.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:r,onChange:E=>a(E.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),g.jsxs("span",{className:"text-sm text-bambu-gray",children:[w.length," message",w.length!==1?"s":""]})]}),g.jsx("div",{ref:l,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-bambu-dark min-h-[400px]",children:w.length===0?g.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[g.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!M&&g.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):g.jsx("div",{className:"space-y-1",children:w.map((E,T)=>{const P=s.has(T),N=E.direction==="in";return g.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${P?"bg-bambu-dark-secondary":""}`,onClick:()=>b(T),children:[g.jsxs("div",{className:"flex items-start gap-2",children:[g.jsx("span",{className:"text-bambu-gray shrink-0",children:v(E.timestamp)}),g.jsx("span",{className:`shrink-0 ${N?"text-blue-400":"text-green-400"}`,title:N?"Incoming":"Outgoing",children:N?g.jsx(sie,{className:"w-3 h-3"}):g.jsx(uie,{className:"w-3 h-3"})}),g.jsx("span",{className:"text-purple-400 shrink-0",children:E.topic})]}),g.jsx("pre",{className:`mt-1 text-white/80 overflow-x-auto ${P?"whitespace-pre-wrap":"truncate"}`,children:x(E.payload,P)})]},T)})})}),g.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[g.jsx("div",{className:"text-sm text-bambu-gray",children:M?g.jsxs("span",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):g.jsx("span",{children:"Logging stopped"})}),g.jsx(ot,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const vse={"0x20054":"The heatbed temperature is abnormal. The sensor may be disconnected or damaged.","0x50005":"Motor driver overheated. Let the printer cool down.","0x50006":"Motor driver communication error.","0x70001":"AMS communication error.","0x70002":"AMS filament runout.","0x70003":"AMS filament not detected.","0xC0003":"First layer inspection failed.","0xC0004":"Nozzle clog detected.","0xC8000":"Foreign object detected on print bed.","0x50000":"Motor X axis lost steps.","0x50001":"Motor Y axis lost steps.","0x50002":"Motor Z axis lost steps."};function yse(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Bu};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Bu};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:ed};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:j$}}}function bse(t){const e=parseInt(t.replace("0x",""),16),n=(e>>24&255).toString(16).padStart(2,"0").toUpperCase(),i=(e>>16&255).toString(16).padStart(2,"0").toUpperCase(),r=(e>>8&255).toString(16).padStart(2,"0").toUpperCase(),a=(e&255).toString(16).padStart(2,"0").toUpperCase();return`https://wiki.bambulab.com/en/x1/troubleshooting/hmscode/HMS_${n}${i}_${r}${a}`}function _se({printerName:t,errors:e,onClose:n}){return A.useEffect(()=>{const i=r=>{r.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(Bu,{className:"w-5 h-5 text-orange-400"}),g.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),g.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:g.jsx(Cn,{className:"w-5 h-5 text-bambu-gray"})})]}),g.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?g.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[g.jsx(ed,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),g.jsx("p",{children:"No HMS errors"})]}):g.jsx("div",{className:"space-y-3",children:e.map((i,r)=>{const{label:a,color:s,bgColor:o,Icon:l}=yse(i.severity),c=vse[i.code]||"Unknown error. Click the link below for details.",d=bse(i.code);return g.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:g.jsxs("div",{className:"flex items-start gap-3",children:[g.jsx(l,{className:`w-5 h-5 ${s} flex-shrink-0 mt-0.5`}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[g.jsx("span",{className:`font-mono text-sm ${s}`,children:i.code}),g.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${s}`,children:a})]}),g.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:c}),g.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[g.jsx(sc,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${r}`)})})}),g.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:g.jsx("p",{className:"text-xs text-bambu-gray",children:"HMS (Health Management System) monitors printer health. Clear errors on the printer to dismiss them here."})})]})})}function Sse(t){if(!t)return"ASAP";const e=new Date(t),n=new Date,i=e.getTime()-n.getTime();return i<0?"Now":i<6e4?"In <1 min":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)}h`:e.toLocaleDateString()}function wse({printerId:t}){const{data:e}=Bt({queryKey:["queue",t,"pending"],queryFn:()=>Ze.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],i=e?.length||0;return i===0?null:g.jsx("div",{className:"mt-3 p-2 bg-bambu-dark rounded-lg",children:g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g.jsx($o,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),g.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),g.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[g.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[g.jsx(fs,{className:"w-3 h-3"}),Sse(n?.scheduled_time||null)]}),i>1&&g.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",i-1]}),g.jsx(vS,{to:"/queue",className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors text-bambu-gray hover:text-white",title:"View queue",children:g.jsx(If,{className:"w-4 h-4"})})]})]})})}function Mse(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Ese({url:t,printName:e}){const[n,i]=A.useState(!1),[r,a]=A.useState(!1),[s,o]=A.useState(!1);return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:`w-20 h-20 flex-shrink-0 rounded-lg overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${t&&n?"cursor-pointer":""}`,onClick:()=>t&&n&&o(!0),children:t&&!r?g.jsxs(g.Fragment,{children:[g.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>a(!0)}),!n&&g.jsx(b0,{className:"w-8 h-8 text-bambu-gray"})]}):g.jsx(b0,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&g.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:g.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[g.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&g.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function Ase({printer:t,hideIfDisconnected:e,maintenanceInfo:n}){const i=ui(),r=GR(),[a,s]=A.useState(!1),[o,l]=A.useState(!1),[c,d]=A.useState(!1),[f,p]=A.useState(!1),[m,_]=A.useState(!1),[b,v]=A.useState(!1),[x,M]=A.useState(!1),{data:w}=Bt({queryKey:["printerStatus",t.id],queryFn:()=>Ze.getPrinterStatus(t.id),refetchInterval:3e4}),{data:E}=Bt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>Ze.getSmartPlugByPrinter(t.id)}),{data:T}=Bt({queryKey:["smartPlugStatus",E?.id],queryFn:()=>E?Ze.getSmartPlugStatus(E.id):null,enabled:!!E,refetchInterval:1e4}),P=e&&w&&!w.connected,N=Ut({mutationFn:()=>Ze.deletePrinter(t.id),onSuccess:()=>{i.invalidateQueries({queryKey:["printers"]})}}),U=Ut({mutationFn:()=>Ze.connectPrinter(t.id),onSuccess:()=>{i.invalidateQueries({queryKey:["printerStatus",t.id]})}}),R=Ut({mutationFn:z=>E?Ze.controlSmartPlug(E.id,z):Promise.reject("No plug"),onSuccess:()=>{i.invalidateQueries({queryKey:["smartPlugStatus",E?.id]})}}),O=Ut({mutationFn:z=>E?Ze.updateSmartPlug(E.id,{auto_off:z}):Promise.reject("No plug"),onSuccess:()=>{i.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),i.invalidateQueries({queryKey:["smart-plugs"]})}});return P?null:g.jsxs(cn,{className:"relative",children:[g.jsxs(gn,{children:[g.jsxs("div",{className:"flex items-start justify-between mb-4",children:[g.jsxs("div",{children:[g.jsx("h3",{className:"text-lg font-semibold text-white",children:t.name}),g.jsx("p",{className:"text-sm text-bambu-gray",children:t.model||"Unknown Model"})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${w?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[w?.connected?g.jsx(iP,{className:"w-3 h-3"}):g.jsx(ES,{className:"w-3 h-3"}),w?.connected?"Connected":"Offline"]}),w?.connected&&g.jsxs("button",{onClick:()=>M(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${w.hms_errors&&w.hms_errors.length>0?w.hms_errors.some(z=>z.severity<=2)?"bg-red-500/20 text-red-400":"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:"Click to view HMS errors",children:[g.jsx(Bu,{className:"w-3 h-3"}),w.hms_errors&&w.hms_errors.length>0?w.hms_errors.length:"OK"]}),n&&g.jsxs("button",{onClick:()=>r("/maintenance"),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?"bg-red-500/20 text-red-400":n.warning_count>0?"bg-orange-500/20 text-orange-400":"bg-bambu-green/20 text-bambu-green"}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:""}${n.due_count>0&&n.warning_count>0?", ":""}${n.warning_count>0?`${n.warning_count} due soon`:""} - Click to view`:"All maintenance up to date - Click to view",children:[g.jsx(Np,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),g.jsxs("div",{className:"relative",children:[g.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>s(!a),children:g.jsx($ie,{className:"w-4 h-4"})}),a&&g.jsxs("div",{className:"absolute right-0 mt-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10",children:[g.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{U.mutate(),s(!1)},children:[g.jsx(zu,{className:"w-4 h-4"}),"Reconnect"]}),g.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{p(!0),s(!1)},children:[g.jsx(Pae,{className:"w-4 h-4"}),"MQTT Debug"]}),g.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{l(!0),s(!1)},children:[g.jsx(ta,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),o&&g.jsx(pa,{title:"Delete Printer",message:`Are you sure you want to delete "${t.name}"? This will also remove all connection settings.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{N.mutate(),l(!1)},onCancel:()=>l(!1)}),w?.connected&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:g.jsxs("div",{className:"flex gap-3",children:[g.jsx(Ese,{url:w.state==="RUNNING"?w.cover_url:null,printName:w.state==="RUNNING"&&(w.subtask_name||w.current_print)||void 0}),g.jsx("div",{className:"flex-1 min-w-0",children:w.current_print&&w.state==="RUNNING"?g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),g.jsx("p",{className:"text-white text-sm mb-2 truncate",children:w.subtask_name||w.current_print}),g.jsxs("div",{className:"flex items-center justify-between text-sm",children:[g.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:g.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${w.progress||0}%`}})}),g.jsxs("span",{className:"text-white",children:[Math.round(w.progress||0),"%"]})]}),g.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[w.remaining_time!=null&&w.remaining_time>0&&g.jsxs("span",{className:"flex items-center gap-1",children:[g.jsx(fs,{className:"w-3 h-3"}),Mse(w.remaining_time*60)]}),w.layer_num!=null&&w.total_layers!=null&&w.total_layers>0&&g.jsxs("span",{children:["Layer ",w.layer_num,"/",w.total_layers]})]})]}):g.jsxs(g.Fragment,{children:[g.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),g.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:w.state?.toLowerCase()||"Idle"}),g.jsxs("div",{className:"flex items-center justify-between text-sm",children:[g.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:g.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),g.jsx("span",{className:"text-bambu-gray",children:"—"})]}),g.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),w.state!=="RUNNING"&&g.jsx(wse,{printerId:t.id}),w.temperatures&&g.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[g.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[g.jsx(Vb,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),g.jsxs("p",{className:"text-sm text-white",children:[Math.round(w.temperatures.nozzle||0),"°C"]})]}),g.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[g.jsx(Vb,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),g.jsxs("p",{className:"text-sm text-white",children:[Math.round(w.temperatures.bed||0),"°C"]})]}),w.temperatures.chamber!==void 0&&g.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[g.jsx(Vb,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),g.jsxs("p",{className:"text-sm text-white",children:[Math.round(w.temperatures.chamber||0),"°C"]})]})]})]}),E&&g.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g.jsx(W$,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),g.jsx("span",{className:"text-sm text-white truncate",children:E.name}),T&&g.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${T.state==="ON"?"bg-bambu-green/20 text-bambu-green":T.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:T.state||"?"}),T?.energy?.power!=null&&T.state==="ON"&&g.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[T.energy.power,"W"]})]}),g.jsx("div",{className:"flex-1"}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsxs("button",{onClick:()=>_(!0),disabled:R.isPending||T?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${T?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[g.jsx(SS,{className:"w-3 h-3"}),"On"]}),g.jsxs("button",{onClick:()=>v(!0),disabled:R.isPending||T?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${T?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[g.jsx(V$,{className:"w-3 h-3"}),"Off"]})]}),g.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[g.jsx("span",{className:`text-xs hidden sm:inline ${E.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:E.auto_off_executed?"Auto-off done":"Auto-off"}),g.jsx("button",{onClick:()=>O.mutate(!E.auto_off),disabled:O.isPending||E.auto_off_executed,title:E.auto_off_executed?"Auto-off was executed - turn printer on to reset":"Auto power-off after print",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${E.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":E.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:g.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${E.auto_off||E.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),g.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[g.jsxs("div",{className:"text-xs text-bambu-gray",children:[g.jsx("p",{children:t.ip_address}),g.jsx("p",{className:"truncate",children:t.serial_number})]}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>d(!0),title:"Browse printer files",children:[g.jsx(U$,{className:"w-4 h-4"}),"Files"]})]})]}),c&&g.jsx(gse,{printerId:t.id,printerName:t.name,onClose:()=>d(!1)}),f&&g.jsx(xse,{printerId:t.id,printerName:t.name,onClose:()=>p(!1)}),m&&E&&g.jsx(pa,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{R.mutate("on"),_(!1)},onCancel:()=>_(!1)}),b&&E&&g.jsx(pa,{title:"Power Off Printer",message:w?.state==="RUNNING"?`WARNING: "${t.name}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`:`Are you sure you want to turn OFF the power for "${t.name}"?`,confirmText:"Power Off",variant:"danger",onConfirm:()=>{R.mutate("off"),v(!1)},onCancel:()=>v(!1)}),x&&g.jsx(_se,{printerName:t.name,errors:w?.hms_errors||[],onClose:()=>M(!1)})]})}function Tse({onClose:t,onAdd:e}){const[n,i]=A.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return A.useEffect(()=>{const r=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t]),g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:g.jsx(cn,{className:"w-full max-w-md",onClick:r=>r.stopPropagation(),children:g.jsxs(gn,{children:[g.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),g.jsxs("form",{onSubmit:r=>{r.preventDefault(),e(n)},className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),g.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.name,onChange:r=>i({...n,name:r.target.value}),placeholder:"My Printer"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),g.jsx("input",{type:"text",required:!0,pattern:"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.ip_address,onChange:r=>i({...n,ip_address:r.target.value}),placeholder:"192.168.1.100"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),g.jsx("input",{type:"text",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.serial_number,onChange:r=>i({...n,serial_number:r.target.value}),placeholder:"01P00A000000000"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),g.jsx("input",{type:"password",required:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.access_code,onChange:r=>i({...n,access_code:r.target.value}),placeholder:"From printer settings"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),g.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n.model||"",onChange:r=>i({...n,model:r.target.value}),children:[g.jsx("option",{value:"",children:"Select model..."}),g.jsxs("optgroup",{label:"H2 Series",children:[g.jsx("option",{value:"H2C",children:"H2C"}),g.jsx("option",{value:"H2D",children:"H2D"}),g.jsx("option",{value:"H2S",children:"H2S"})]}),g.jsxs("optgroup",{label:"X1 Series",children:[g.jsx("option",{value:"X1E",children:"X1E"}),g.jsx("option",{value:"X1C",children:"X1 Carbon"}),g.jsx("option",{value:"X1",children:"X1"})]}),g.jsxs("optgroup",{label:"P Series",children:[g.jsx("option",{value:"P2S",children:"P2S"}),g.jsx("option",{value:"P1S",children:"P1S"}),g.jsx("option",{value:"P1P",children:"P1P"})]}),g.jsxs("optgroup",{label:"A1 Series",children:[g.jsx("option",{value:"A1",children:"A1"}),g.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("input",{type:"checkbox",id:"auto_archive",checked:n.auto_archive,onChange:r=>i({...n,auto_archive:r.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),g.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),g.jsxs("div",{className:"flex gap-3 pt-4",children:[g.jsx(ot,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),g.jsx(ot,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function Cse(){const[t,e]=A.useState(!1),[n,i]=A.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),r=ui(),{data:a,isLoading:s}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),{data:o}=Bt({queryKey:["maintenanceOverview"],queryFn:Ze.getMaintenanceOverview,staleTime:60*1e3}),l=o?.reduce((f,p)=>(f[p.printer_id]={due_count:p.due_count,warning_count:p.warning_count},f),{})||{},c=Ut({mutationFn:Ze.createPrinter,onSuccess:()=>{r.invalidateQueries({queryKey:["printers"]}),e(!1)}}),d=()=>{const f=!n;i(f),localStorage.setItem("hideDisconnectedPrinters",String(f))};return g.jsxs("div",{className:"p-8",children:[g.jsxs("div",{className:"flex items-center justify-between mb-8",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),g.jsx("p",{className:"text-bambu-gray",children:"Manage your Bambu Lab printers"})]}),g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:n,onChange:d,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),g.jsxs(ot,{onClick:()=>e(!0),children:[g.jsx(oc,{className:"w-4 h-4"}),"Add Printer"]})]})]}),s?g.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):a?.length===0?g.jsx(cn,{children:g.jsxs(gn,{className:"text-center py-12",children:[g.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),g.jsxs(ot,{onClick:()=>e(!0),children:[g.jsx(oc,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):g.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:a?.map(f=>g.jsx(Ase,{printer:f,hideIfDisconnected:n,maintenanceInfo:l[f.id]},f.id))}),t&&g.jsx(Tse,{onClose:()=>e(!1),onAdd:f=>c.mutate(f)})]})}const rP="181",xp={ROTATE:0,DOLLY:1,PAN:2},up={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Nse=0,q4=1,Rse=2,Y$=1,Pse=2,Ll=3,Hu=0,Oa=1,Io=2,Ql=0,vp=1,X4=2,K4=3,Y4=4,Dse=5,zd=100,Ose=101,kse=102,Lse=103,Ise=104,Use=200,jse=201,Fse=202,zse=203,QC=204,JC=205,Bse=206,Hse=207,Vse=208,$se=209,Gse=210,Wse=211,qse=212,Xse=213,Kse=214,eN=0,tN=1,nN=2,Rp=3,iN=4,rN=5,aN=6,sN=7,aP=0,Yse=1,Zse=2,Ru=0,Qse=1,Jse=2,eoe=3,toe=4,noe=5,ioe=6,roe=7,Z$=300,Pp=301,Dp=302,oN=303,lN=304,AS=306,cN=1e3,Gl=1001,uN=1002,as=1003,aoe=1004,dy=1005,js=1006,iA=1007,qd=1008,Go=1009,Q$=1010,J$=1011,A0=1012,sP=1013,vf=1014,Wl=1015,am=1016,oP=1017,lP=1018,T0=1020,eG=35902,tG=35899,nG=1021,iG=1022,ho=1023,C0=1026,N0=1027,rG=1028,cP=1029,uP=1030,dP=1031,fP=1033,Gb=33776,Wb=33777,qb=33778,Xb=33779,dN=35840,fN=35841,hN=35842,pN=35843,mN=36196,gN=37492,xN=37496,vN=37808,yN=37809,bN=37810,_N=37811,SN=37812,wN=37813,MN=37814,EN=37815,AN=37816,TN=37817,CN=37818,NN=37819,RN=37820,PN=37821,DN=36492,ON=36494,kN=36495,LN=36283,IN=36284,UN=36285,jN=36286,soe=3200,ooe=3201,aG=0,loe=1,yu="",Rs="srgb",Op="srgb-linear",v_="linear",Fn="srgb",yh=7680,Z4=519,coe=512,uoe=513,doe=514,sG=515,foe=516,hoe=517,poe=518,moe=519,Q4=35044,J4="300 es",jo=2e3,y_=2001;function oG(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function b_(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function goe(){const t=b_("canvas");return t.style.display="block",t}const ej={};function tj(...t){const e="THREE."+t.shift();console.log(e,...t)}function $t(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Ri(...t){const e="THREE."+t.shift();console.error(e,...t)}function R0(...t){const e=t.join(" ");e in ej||(ej[e]=!0,$t(...t))}function xoe(t,e,n){return new Promise(function(i,r){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}}setTimeout(a,n)})}let Uf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(n)===-1&&i[e].push(n)}hasEventListener(e,n){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(n)!==-1}removeEventListener(e,n){const i=this._listeners;if(i===void 0)return;const r=i[e];if(r!==void 0){const a=r.indexOf(n);a!==-1&&r.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const i=n[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}};const Wr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Kb=Math.PI/180,FN=180/Math.PI;function gx(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Wr[t&255]+Wr[t>>8&255]+Wr[t>>16&255]+Wr[t>>24&255]+"-"+Wr[e&255]+Wr[e>>8&255]+"-"+Wr[e>>16&15|64]+Wr[e>>24&255]+"-"+Wr[n&63|128]+Wr[n>>8&255]+"-"+Wr[n>>16&255]+Wr[n>>24&255]+Wr[i&255]+Wr[i>>8&255]+Wr[i>>16&255]+Wr[i>>24&255]).toLowerCase()}function fn(t,e,n){return Math.max(e,Math.min(n,t))}function voe(t,e){return(t%e+e)%e}function rA(t,e,n){return(1-n)*t+n*e}function gg(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function Ta(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const yoe={DEG2RAD:Kb};let nn=class lG{constructor(e=0,n=0){lG.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,i=this.y,r=e.elements;return this.x=r[0]*n+r[3]*i+r[6],this.y=r[1]*n+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=fn(this.x,e.x,n.x),this.y=fn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=fn(this.x,e,n),this.y=fn(this.y,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(fn(i,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(e)/n;return Math.acos(fn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y;return n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const i=Math.cos(n),r=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},yf=class{constructor(e=0,n=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=i,this._w=r}static slerpFlat(e,n,i,r,a,s,o){let l=i[r+0],c=i[r+1],d=i[r+2],f=i[r+3],p=a[s+0],m=a[s+1],_=a[s+2],b=a[s+3];if(o<=0){e[n+0]=l,e[n+1]=c,e[n+2]=d,e[n+3]=f;return}if(o>=1){e[n+0]=p,e[n+1]=m,e[n+2]=_,e[n+3]=b;return}if(f!==b||l!==p||c!==m||d!==_){let v=l*p+c*m+d*_+f*b;v<0&&(p=-p,m=-m,_=-_,b=-b,v=-v);let x=1-o;if(v<.9995){const M=Math.acos(v),w=Math.sin(M);x=Math.sin(x*M)/w,o=Math.sin(o*M)/w,l=l*x+p*o,c=c*x+m*o,d=d*x+_*o,f=f*x+b*o}else{l=l*x+p*o,c=c*x+m*o,d=d*x+_*o,f=f*x+b*o;const M=1/Math.sqrt(l*l+c*c+d*d+f*f);l*=M,c*=M,d*=M,f*=M}}e[n]=l,e[n+1]=c,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,i,r,a,s){const o=i[r],l=i[r+1],c=i[r+2],d=i[r+3],f=a[s],p=a[s+1],m=a[s+2],_=a[s+3];return e[n]=o*_+d*f+l*m-c*p,e[n+1]=l*_+d*p+c*f-o*m,e[n+2]=c*_+d*m+o*p-l*f,e[n+3]=d*_-o*f-l*p-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,i,r){return this._x=e,this._y=n,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,l=Math.sin,c=o(i/2),d=o(r/2),f=o(a/2),p=l(i/2),m=l(r/2),_=l(a/2);switch(s){case"XYZ":this._x=p*d*f+c*m*_,this._y=c*m*f-p*d*_,this._z=c*d*_+p*m*f,this._w=c*d*f-p*m*_;break;case"YXZ":this._x=p*d*f+c*m*_,this._y=c*m*f-p*d*_,this._z=c*d*_-p*m*f,this._w=c*d*f+p*m*_;break;case"ZXY":this._x=p*d*f-c*m*_,this._y=c*m*f+p*d*_,this._z=c*d*_+p*m*f,this._w=c*d*f-p*m*_;break;case"ZYX":this._x=p*d*f-c*m*_,this._y=c*m*f+p*d*_,this._z=c*d*_-p*m*f,this._w=c*d*f+p*m*_;break;case"YZX":this._x=p*d*f+c*m*_,this._y=c*m*f+p*d*_,this._z=c*d*_-p*m*f,this._w=c*d*f-p*m*_;break;case"XZY":this._x=p*d*f-c*m*_,this._y=c*m*f-p*d*_,this._z=c*d*_+p*m*f,this._w=c*d*f+p*m*_;break;default:$t("Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const i=n/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,i=n[0],r=n[4],a=n[8],s=n[1],o=n[5],l=n[9],c=n[2],d=n[6],f=n[10],p=i+o+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-l)*m,this._y=(a-c)*m,this._z=(s-r)*m}else if(i>o&&i>f){const m=2*Math.sqrt(1+i-o-f);this._w=(d-l)/m,this._x=.25*m,this._y=(r+s)/m,this._z=(a+c)/m}else if(o>f){const m=2*Math.sqrt(1+o-i-f);this._w=(a-c)/m,this._x=(r+s)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+f-i-o);this._w=(s-r)/m,this._x=(a+c)/m,this._y=(l+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let i=e.dot(n)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(fn(this.dot(e),-1,1)))}rotateTowards(e,n){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,n/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const i=e._x,r=e._y,a=e._z,s=e._w,o=n._x,l=n._y,c=n._z,d=n._w;return this._x=i*d+s*o+r*c-a*l,this._y=r*d+s*l+a*o-i*c,this._z=a*d+s*c+i*l-r*o,this._w=s*d-i*o-r*l-a*c,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let i=e._x,r=e._y,a=e._z,s=e._w,o=this.dot(e);o<0&&(i=-i,r=-r,a=-a,s=-s,o=-o);let l=1-n;if(o<.9995){const c=Math.acos(o),d=Math.sin(c);l=Math.sin(l*c)/d,n=Math.sin(n*c)/d,this._x=this._x*l+i*n,this._y=this._y*l+r*n,this._z=this._z*l+a*n,this._w=this._w*l+s*n,this._onChangeCallback()}else this._x=this._x*l+i*n,this._y=this._y*l+r*n,this._z=this._z*l+a*n,this._w=this._w*l+s*n,this.normalize();return this}slerpQuaternions(e,n,i){return this.copy(e).slerp(n,i)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),a=Math.sqrt(i);return this.set(r*Math.sin(e),r*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},$e=class cG{constructor(e=0,n=0,i=0){cG.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}set(e,n,i){return i===void 0&&(i=this.z),this.x=e,this.y=n,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(nj.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(nj.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[3]*i+a[6]*r,this.y=a[1]*n+a[4]*i+a[7]*r,this.z=a[2]*n+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*n+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*n+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*n+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*n+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){const n=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,l=e.w,c=2*(s*r-o*i),d=2*(o*n-a*r),f=2*(a*i-s*n);return this.x=n+l*c+s*f-o*d,this.y=i+l*d+o*c-a*f,this.z=r+l*f+a*d-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[4]*i+a[8]*r,this.y=a[1]*n+a[5]*i+a[9]*r,this.z=a[2]*n+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=fn(this.x,e.x,n.x),this.y=fn(this.y,e.y,n.y),this.z=fn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=fn(this.x,e,n),this.y=fn(this.y,e,n),this.z=fn(this.z,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(fn(i,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const i=e.x,r=e.y,a=e.z,s=n.x,o=n.y,l=n.z;return this.x=r*l-a*o,this.y=a*s-i*l,this.z=i*o-r*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return aA.copy(this).projectOnVector(e),this.sub(aA)}reflect(e){return this.sub(aA.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(e)/n;return Math.acos(fn(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return n*n+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,i){const r=Math.sin(n)*e;return this.x=r*Math.sin(i),this.y=Math.cos(n)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,i){return this.x=e*Math.sin(n),this.y=i,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=r,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,i=Math.sqrt(1-n*n);return this.x=i*Math.cos(e),this.y=n,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const aA=new $e,nj=new yf;let sn=class uG{constructor(e,n,i,r,a,s,o,l,c){uG.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,i,r,a,s,o,l,c)}set(e,n,i,r,a,s,o,l,c){const d=this.elements;return d[0]=e,d[1]=r,d[2]=o,d[3]=n,d[4]=a,d[5]=l,d[6]=i,d[7]=s,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(e,n,i){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[3],l=i[6],c=i[1],d=i[4],f=i[7],p=i[2],m=i[5],_=i[8],b=r[0],v=r[3],x=r[6],M=r[1],w=r[4],E=r[7],T=r[2],P=r[5],N=r[8];return a[0]=s*b+o*M+l*T,a[3]=s*v+o*w+l*P,a[6]=s*x+o*E+l*N,a[1]=c*b+d*M+f*T,a[4]=c*v+d*w+f*P,a[7]=c*x+d*E+f*N,a[2]=p*b+m*M+_*T,a[5]=p*v+m*w+_*P,a[8]=p*x+m*E+_*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return n*s*d-n*o*c-i*a*d+i*o*l+r*a*c-r*s*l}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],d=e[8],f=d*s-o*c,p=o*l-d*a,m=c*a-s*l,_=n*f+i*p+r*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/_;return e[0]=f*b,e[1]=(r*c-d*i)*b,e[2]=(o*i-r*s)*b,e[3]=p*b,e[4]=(d*n-r*l)*b,e[5]=(r*a-o*n)*b,e[6]=m*b,e[7]=(i*l-c*n)*b,e[8]=(s*n-i*a)*b,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,i,r,a,s,o){const l=Math.cos(a),c=Math.sin(a);return this.set(i*l,i*c,-i*(l*s+c*o)+s+e,-r*c,r*l,-r*(-c*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(sA.makeScale(e,n)),this}rotate(e){return this.premultiply(sA.makeRotation(-e)),this}translate(e,n){return this.premultiply(sA.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,i,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,i=e.elements;for(let r=0;r<9;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<9;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const sA=new sn,ij=new sn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),rj=new sn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function boe(){const t={enabled:!0,workingColorSpace:Op,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Fn&&(r.r=Jl(r.r),r.g=Jl(r.g),r.b=Jl(r.b)),this.spaces[a].primaries!==this.spaces[s].primaries&&(r.applyMatrix3(this.spaces[a].toXYZ),r.applyMatrix3(this.spaces[s].fromXYZ)),this.spaces[s].transfer===Fn&&(r.r=yp(r.r),r.g=yp(r.g),r.b=yp(r.b))),r},workingToColorSpace:function(r,a){return this.convert(r,this.workingColorSpace,a)},colorSpaceToWorking:function(r,a){return this.convert(r,a,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===yu?v_:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,a=this.workingColorSpace){return r.fromArray(this.spaces[a].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,a,s){return r.copy(this.spaces[a].toXYZ).multiply(this.spaces[s].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,a){return R0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return R0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(r,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return t.define({[Op]:{primaries:e,whitePoint:i,transfer:v_,toXYZ:ij,fromXYZ:rj,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Rs},outputColorSpaceConfig:{drawingBufferColorSpace:Rs}},[Rs]:{primaries:e,whitePoint:i,transfer:Fn,toXYZ:ij,fromXYZ:rj,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Rs}}}),t}const wn=boe();function Jl(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function yp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let bh,_oe=class{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{bh===void 0&&(bh=b_("canvas")),bh.width=e.width,bh.height=e.height;const r=bh.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=bh}return i.toDataURL(n)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=b_("canvas");n.width=e.width,n.height=e.height;const i=n.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=Jl(a[s]/255)*255;return i.putImageData(r,0,0),n}else if(e.data){const n=e.data.slice(0);for(let i=0;i<n.length;i++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[i]=Math.floor(Jl(n[i]/255)*255):n[i]=Jl(n[i]);return{data:n,width:e.width,height:e.height}}else return $t("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Soe=0,hP=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Soe++}),this.uuid=gx(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,o=r.length;s<o;s++)r[s].isDataTexture?a.push(oA(r[s].image)):a.push(oA(r[s]))}else a=oA(r);i.url=a}return n||(e.images[this.uuid]=i),i}};function oA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?_oe.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:($t("Texture: Unable to serialize Texture."),{})}let woe=0;const lA=new $e;let So=class Yb extends Uf{constructor(e=Yb.DEFAULT_IMAGE,n=Yb.DEFAULT_MAPPING,i=Gl,r=Gl,a=js,s=qd,o=ho,l=Go,c=Yb.DEFAULT_ANISOTROPY,d=yu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:woe++}),this.uuid=gx(),this.name="",this.source=new hP(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new nn(0,0),this.repeat=new nn(1,1),this.center=new nn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new sn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(lA).x}get height(){return this.source.getSize(lA).y}get depth(){return this.source.getSize(lA).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const n in e){const i=e[n];if(i===void 0){$t(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){$t(`Texture.setValues(): property '${n}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[n]=i}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),n||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Z$)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case cN:e.x=e.x-Math.floor(e.x);break;case Gl:e.x=e.x<0?0:1;break;case uN:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case cN:e.y=e.y-Math.floor(e.y);break;case Gl:e.y=e.y<0?0:1;break;case uN:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};So.DEFAULT_IMAGE=null;So.DEFAULT_MAPPING=Z$;So.DEFAULT_ANISOTROPY=1;let Bi=class dG{constructor(e=0,n=0,i=0,r=1){dG.prototype.isVector4=!0,this.x=e,this.y=n,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,i,r){return this.x=e,this.y=n,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*n+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*n+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*n+s[7]*i+s[11]*r+s[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,i,r,a;const l=e.elements,c=l[0],d=l[4],f=l[8],p=l[1],m=l[5],_=l[9],b=l[2],v=l[6],x=l[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(_-v)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(_+v)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,E=(m+1)/2,T=(x+1)/2,P=(d+p)/4,N=(f+b)/4,U=(_+v)/4;return w>E&&w>T?w<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(w),r=P/i,a=N/i):E>T?E<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(E),i=P/r,a=U/r):T<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(T),i=N/a,r=U/a),this.set(i,r,a,n),this}let M=Math.sqrt((v-_)*(v-_)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(M)<.001&&(M=1),this.x=(v-_)/M,this.y=(f-b)/M,this.z=(p-d)/M,this.w=Math.acos((c+m+x-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=fn(this.x,e.x,n.x),this.y=fn(this.y,e.y,n.y),this.z=fn(this.z,e.z,n.z),this.w=fn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=fn(this.x,e,n),this.y=fn(this.y,e,n),this.z=fn(this.z,e,n),this.w=fn(this.w,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(fn(i,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this.w=e.w+(n.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},Moe=class extends Uf{constructor(e=1,n=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:js,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=i.depth,this.scissor=new Bi(0,0,e,n),this.scissorTest=!1,this.viewport=new Bi(0,0,e,n);const r={width:e,height:n,depth:i.depth},a=new So(r);this.textures=[];const s=i.count;for(let o=0;o<s;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_setTextureOptions(e={}){const n={minFilter:js,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let i=0;i<this.textures.length;i++)this.textures[i].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,i=1){if(this.width!==e||this.height!==n||this.depth!==i){this.width=e,this.height=n,this.depth=i;for(let r=0,a=this.textures.length;r<a;r++)this.textures[r].image.width=e,this.textures[r].image.height=n,this.textures[r].image.depth=i,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,i=e.textures.length;n<i;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const r=Object.assign({},e.textures[n].image);this.textures[n].source=new hP(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},bf=class extends Moe{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}},fG=class extends So{constructor(e=null,n=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=as,this.minFilter=as,this.wrapR=Gl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Eoe=class extends So{constructor(e=null,n=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=as,this.minFilter=as,this.wrapR=Gl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},_f=class{constructor(e=new $e(1/0,1/0,1/0),n=new $e(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,i=e.length;n<i;n+=3)this.expandByPoint(eo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,i=e.count;n<i;n++)this.expandByPoint(eo.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,i=e.length;n<i;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const i=eo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const a=i.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,eo):eo.fromBufferAttribute(a,s),eo.applyMatrix4(e.matrixWorld),this.expandByPoint(eo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),fy.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),fy.copy(i.boundingBox)),fy.applyMatrix4(e.matrixWorld),this.union(fy)}const r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,eo),eo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(xg),hy.subVectors(this.max,xg),_h.subVectors(e.a,xg),Sh.subVectors(e.b,xg),wh.subVectors(e.c,xg),Yc.subVectors(Sh,_h),Zc.subVectors(wh,Sh),Md.subVectors(_h,wh);let n=[0,-Yc.z,Yc.y,0,-Zc.z,Zc.y,0,-Md.z,Md.y,Yc.z,0,-Yc.x,Zc.z,0,-Zc.x,Md.z,0,-Md.x,-Yc.y,Yc.x,0,-Zc.y,Zc.x,0,-Md.y,Md.x,0];return!cA(n,_h,Sh,wh,hy)||(n=[1,0,0,0,1,0,0,0,1],!cA(n,_h,Sh,wh,hy))?!1:(py.crossVectors(Yc,Zc),n=[py.x,py.y,py.z],cA(n,_h,Sh,wh,hy))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,eo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(eo).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(bl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),bl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),bl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),bl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),bl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),bl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),bl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),bl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(bl),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const bl=[new $e,new $e,new $e,new $e,new $e,new $e,new $e,new $e],eo=new $e,fy=new _f,_h=new $e,Sh=new $e,wh=new $e,Yc=new $e,Zc=new $e,Md=new $e,xg=new $e,hy=new $e,py=new $e,Ed=new $e;function cA(t,e,n,i,r){for(let a=0,s=t.length-3;a<=s;a+=3){Ed.fromArray(t,a);const o=r.x*Math.abs(Ed.x)+r.y*Math.abs(Ed.y)+r.z*Math.abs(Ed.z),l=e.dot(Ed),c=n.dot(Ed),d=i.dot(Ed);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const Aoe=new _f,vg=new $e,uA=new $e;let TS=class{constructor(e=new $e,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const i=this.center;n!==void 0?i.copy(n):Aoe.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const i=this.center.distanceToSquared(e);return n.copy(e),i>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;vg.subVectors(e,this.center);const n=vg.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),r=(i-this.radius)*.5;this.center.addScaledVector(vg,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(uA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(vg.copy(e.center).add(uA)),this.expandByPoint(vg.copy(e.center).sub(uA))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const _l=new $e,dA=new $e,my=new $e,Qc=new $e,fA=new $e,gy=new $e,hA=new $e;let pP=class{constructor(e=new $e,n=new $e(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_l)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=_l.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(_l.copy(this.origin).addScaledVector(this.direction,n),_l.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){dA.copy(e).add(n).multiplyScalar(.5),my.copy(n).sub(e).normalize(),Qc.copy(this.origin).sub(dA);const a=e.distanceTo(n)*.5,s=-this.direction.dot(my),o=Qc.dot(this.direction),l=-Qc.dot(my),c=Qc.lengthSq(),d=Math.abs(1-s*s);let f,p,m,_;if(d>0)if(f=s*l-o,p=s*o-l,_=a*d,f>=0)if(p>=-_)if(p<=_){const b=1/d;f*=b,p*=b,m=f*(f+s*p+2*o)+p*(s*f+p+2*l)+c}else p=a,f=Math.max(0,-(s*p+o)),m=-f*f+p*(p+2*l)+c;else p=-a,f=Math.max(0,-(s*p+o)),m=-f*f+p*(p+2*l)+c;else p<=-_?(f=Math.max(0,-(-s*a+o)),p=f>0?-a:Math.min(Math.max(-a,-l),a),m=-f*f+p*(p+2*l)+c):p<=_?(f=0,p=Math.min(Math.max(-a,-l),a),m=p*(p+2*l)+c):(f=Math.max(0,-(s*a+o)),p=f>0?a:Math.min(Math.max(-a,-l),a),m=-f*f+p*(p+2*l)+c);else p=s>0?-a:a,f=Math.max(0,-(s*p+o)),m=-f*f+p*(p+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(dA).addScaledVector(my,p),m}intersectSphere(e,n){_l.subVectors(e.center,this.origin);const i=_l.dot(this.direction),r=_l.dot(_l)-i*i,a=e.radius*e.radius;if(r>a)return null;const s=Math.sqrt(a-r),o=i-s,l=i+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null}intersectPlane(e,n){const i=this.distanceToPlane(e);return i===null?null:this.at(i,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let i,r,a,s,o,l;const c=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return c>=0?(i=(e.min.x-p.x)*c,r=(e.max.x-p.x)*c):(i=(e.max.x-p.x)*c,r=(e.min.x-p.x)*c),d>=0?(a=(e.min.y-p.y)*d,s=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,s=(e.min.y-p.y)*d),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-p.z)*f,l=(e.max.z-p.z)*f):(o=(e.max.z-p.z)*f,l=(e.min.z-p.z)*f),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,n)}intersectsBox(e){return this.intersectBox(e,_l)!==null}intersectTriangle(e,n,i,r,a){fA.subVectors(n,e),gy.subVectors(i,e),hA.crossVectors(fA,gy);let s=this.direction.dot(hA),o;if(s>0){if(r)return null;o=1}else if(s<0)o=-1,s=-s;else return null;Qc.subVectors(this.origin,e);const l=o*this.direction.dot(gy.crossVectors(Qc,gy));if(l<0)return null;const c=o*this.direction.dot(fA.cross(Qc));if(c<0||l+c>s)return null;const d=-o*Qc.dot(hA);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Gi=class zN{constructor(e,n,i,r,a,s,o,l,c,d,f,p,m,_,b,v){zN.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,i,r,a,s,o,l,c,d,f,p,m,_,b,v)}set(e,n,i,r,a,s,o,l,c,d,f,p,m,_,b,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=i,x[12]=r,x[1]=a,x[5]=s,x[9]=o,x[13]=l,x[2]=c,x[6]=d,x[10]=f,x[14]=p,x[3]=m,x[7]=_,x[11]=b,x[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new zN().fromArray(this.elements)}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(e){const n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,i){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,i=e.elements,r=1/Mh.setFromMatrixColumn(e,0).length(),a=1/Mh.setFromMatrixColumn(e,1).length(),s=1/Mh.setFromMatrixColumn(e,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*a,n[5]=i[5]*a,n[6]=i[6]*a,n[7]=0,n[8]=i[8]*s,n[9]=i[9]*s,n[10]=i[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=s*d,m=s*f,_=o*d,b=o*f;n[0]=l*d,n[4]=-l*f,n[8]=c,n[1]=m+_*c,n[5]=p-b*c,n[9]=-o*l,n[2]=b-p*c,n[6]=_+m*c,n[10]=s*l}else if(e.order==="YXZ"){const p=l*d,m=l*f,_=c*d,b=c*f;n[0]=p+b*o,n[4]=_*o-m,n[8]=s*c,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=m*o-_,n[6]=b+p*o,n[10]=s*l}else if(e.order==="ZXY"){const p=l*d,m=l*f,_=c*d,b=c*f;n[0]=p-b*o,n[4]=-s*f,n[8]=_+m*o,n[1]=m+_*o,n[5]=s*d,n[9]=b-p*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const p=s*d,m=s*f,_=o*d,b=o*f;n[0]=l*d,n[4]=_*c-m,n[8]=p*c+b,n[1]=l*f,n[5]=b*c+p,n[9]=m*c-_,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const p=s*l,m=s*c,_=o*l,b=o*c;n[0]=l*d,n[4]=b-p*f,n[8]=_*f+m,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-c*d,n[6]=m*f+_,n[10]=p-b*f}else if(e.order==="XZY"){const p=s*l,m=s*c,_=o*l,b=o*c;n[0]=l*d,n[4]=-f,n[8]=c*d,n[1]=p*f+b,n[5]=s*d,n[9]=m*f-_,n[2]=_*f-m,n[6]=o*d,n[10]=b*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Toe,e,Coe)}lookAt(e,n,i){const r=this.elements;return Ka.subVectors(e,n),Ka.lengthSq()===0&&(Ka.z=1),Ka.normalize(),Jc.crossVectors(i,Ka),Jc.lengthSq()===0&&(Math.abs(i.z)===1?Ka.x+=1e-4:Ka.z+=1e-4,Ka.normalize(),Jc.crossVectors(i,Ka)),Jc.normalize(),xy.crossVectors(Ka,Jc),r[0]=Jc.x,r[4]=xy.x,r[8]=Ka.x,r[1]=Jc.y,r[5]=xy.y,r[9]=Ka.y,r[2]=Jc.z,r[6]=xy.z,r[10]=Ka.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[4],l=i[8],c=i[12],d=i[1],f=i[5],p=i[9],m=i[13],_=i[2],b=i[6],v=i[10],x=i[14],M=i[3],w=i[7],E=i[11],T=i[15],P=r[0],N=r[4],U=r[8],R=r[12],O=r[1],z=r[5],I=r[9],G=r[13],L=r[2],B=r[6],q=r[10],W=r[14],X=r[3],Q=r[7],ie=r[11],H=r[15];return a[0]=s*P+o*O+l*L+c*X,a[4]=s*N+o*z+l*B+c*Q,a[8]=s*U+o*I+l*q+c*ie,a[12]=s*R+o*G+l*W+c*H,a[1]=d*P+f*O+p*L+m*X,a[5]=d*N+f*z+p*B+m*Q,a[9]=d*U+f*I+p*q+m*ie,a[13]=d*R+f*G+p*W+m*H,a[2]=_*P+b*O+v*L+x*X,a[6]=_*N+b*z+v*B+x*Q,a[10]=_*U+b*I+v*q+x*ie,a[14]=_*R+b*G+v*W+x*H,a[3]=M*P+w*O+E*L+T*X,a[7]=M*N+w*z+E*B+T*Q,a[11]=M*U+w*I+E*q+T*ie,a[15]=M*R+w*G+E*W+T*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],l=e[9],c=e[13],d=e[2],f=e[6],p=e[10],m=e[14],_=e[3],b=e[7],v=e[11],x=e[15];return _*(+a*l*f-r*c*f-a*o*p+i*c*p+r*o*m-i*l*m)+b*(+n*l*m-n*c*p+a*s*p-r*s*m+r*c*d-a*l*d)+v*(+n*c*f-n*o*m-a*s*f+i*s*m+a*o*d-i*c*d)+x*(-r*o*d-n*l*f+n*o*p+r*s*f-i*s*p+i*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=n,r[14]=i),this}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],d=e[8],f=e[9],p=e[10],m=e[11],_=e[12],b=e[13],v=e[14],x=e[15],M=f*v*c-b*p*c+b*l*m-o*v*m-f*l*x+o*p*x,w=_*p*c-d*v*c-_*l*m+s*v*m+d*l*x-s*p*x,E=d*b*c-_*f*c+_*o*m-s*b*m-d*o*x+s*f*x,T=_*f*l-d*b*l-_*o*p+s*b*p+d*o*v-s*f*v,P=n*M+i*w+r*E+a*T;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/P;return e[0]=M*N,e[1]=(b*p*a-f*v*a-b*r*m+i*v*m+f*r*x-i*p*x)*N,e[2]=(o*v*a-b*l*a+b*r*c-i*v*c-o*r*x+i*l*x)*N,e[3]=(f*l*a-o*p*a-f*r*c+i*p*c+o*r*m-i*l*m)*N,e[4]=w*N,e[5]=(d*v*a-_*p*a+_*r*m-n*v*m-d*r*x+n*p*x)*N,e[6]=(_*l*a-s*v*a-_*r*c+n*v*c+s*r*x-n*l*x)*N,e[7]=(s*p*a-d*l*a+d*r*c-n*p*c-s*r*m+n*l*m)*N,e[8]=E*N,e[9]=(_*f*a-d*b*a-_*i*m+n*b*m+d*i*x-n*f*x)*N,e[10]=(s*b*a-_*o*a+_*i*c-n*b*c-s*i*x+n*o*x)*N,e[11]=(d*o*a-s*f*a-d*i*c+n*f*c+s*i*m-n*o*m)*N,e[12]=T*N,e[13]=(d*b*r-_*f*r+_*i*p-n*b*p-d*i*v+n*f*v)*N,e[14]=(_*o*r-s*b*r-_*i*l+n*b*l+s*i*v-n*o*v)*N,e[15]=(s*f*r-d*o*r+d*i*l-n*f*l-s*i*p+n*o*p)*N,this}scale(e){const n=this.elements,i=e.x,r=e.y,a=e.z;return n[0]*=i,n[4]*=r,n[8]*=a,n[1]*=i,n[5]*=r,n[9]*=a,n[2]*=i,n[6]*=r,n[10]*=a,n[3]*=i,n[7]*=r,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,i,r))}makeTranslation(e,n,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,i,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const i=Math.cos(n),r=Math.sin(n),a=1-i,s=e.x,o=e.y,l=e.z,c=a*s,d=a*o;return this.set(c*s+i,c*o-r*l,c*l+r*o,0,c*o+r*l,d*o+i,d*l-r*s,0,c*l-r*o,d*l+r*s,a*l*l+i,0,0,0,0,1),this}makeScale(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,n,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,n,r,1,0,0,0,0,1),this}compose(e,n,i){const r=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,c=a+a,d=s+s,f=o+o,p=a*c,m=a*d,_=a*f,b=s*d,v=s*f,x=o*f,M=l*c,w=l*d,E=l*f,T=i.x,P=i.y,N=i.z;return r[0]=(1-(b+x))*T,r[1]=(m+E)*T,r[2]=(_-w)*T,r[3]=0,r[4]=(m-E)*P,r[5]=(1-(p+x))*P,r[6]=(v+M)*P,r[7]=0,r[8]=(_+w)*N,r[9]=(v-M)*N,r[10]=(1-(p+b))*N,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,n,i){const r=this.elements;let a=Mh.set(r[0],r[1],r[2]).length();const s=Mh.set(r[4],r[5],r[6]).length(),o=Mh.set(r[8],r[9],r[10]).length();this.determinant()<0&&(a=-a),e.x=r[12],e.y=r[13],e.z=r[14],to.copy(this);const c=1/a,d=1/s,f=1/o;return to.elements[0]*=c,to.elements[1]*=c,to.elements[2]*=c,to.elements[4]*=d,to.elements[5]*=d,to.elements[6]*=d,to.elements[8]*=f,to.elements[9]*=f,to.elements[10]*=f,n.setFromRotationMatrix(to),i.x=a,i.y=s,i.z=o,this}makePerspective(e,n,i,r,a,s,o=jo,l=!1){const c=this.elements,d=2*a/(n-e),f=2*a/(i-r),p=(n+e)/(n-e),m=(i+r)/(i-r);let _,b;if(l)_=a/(s-a),b=s*a/(s-a);else if(o===jo)_=-(s+a)/(s-a),b=-2*s*a/(s-a);else if(o===y_)_=-s/(s-a),b=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=f,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=_,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,i,r,a,s,o=jo,l=!1){const c=this.elements,d=2/(n-e),f=2/(i-r),p=-(n+e)/(n-e),m=-(i+r)/(i-r);let _,b;if(l)_=1/(s-a),b=s/(s-a);else if(o===jo)_=-2/(s-a),b=-(s+a)/(s-a);else if(o===y_)_=-1/(s-a),b=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=d,c[4]=0,c[8]=0,c[12]=p,c[1]=0,c[5]=f,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=_,c[14]=b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,i=e.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<16;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}};const Mh=new $e,to=new Gi,Toe=new $e(0,0,0),Coe=new $e(1,1,1),Jc=new $e,xy=new $e,Ka=new $e,aj=new Gi,sj=new yf;let Vu=class hG{constructor(e=0,n=0,i=0,r=hG.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,i,r=this._order){return this._x=e,this._y=n,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,i=!0){const r=e.elements,a=r[0],s=r[4],o=r[8],l=r[1],c=r[5],d=r[9],f=r[2],p=r[6],m=r[10];switch(n){case"XYZ":this._y=Math.asin(fn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-fn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(fn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-fn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(fn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-fn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:$t("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,i){return aj.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aj,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return sj.setFromEuler(this),this.setFromQuaternion(sj,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Vu.DEFAULT_ORDER="XYZ";let pG=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Noe=0;const oj=new $e,Eh=new yf,Sl=new Gi,vy=new $e,yg=new $e,Roe=new $e,Poe=new yf,lj=new $e(1,0,0),cj=new $e(0,1,0),uj=new $e(0,0,1),dj={type:"added"},Doe={type:"removed"},Ah={type:"childadded",child:null},pA={type:"childremoved",child:null};let us=class Zb extends Uf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Noe++}),this.uuid=gx(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zb.DEFAULT_UP.clone();const e=new $e,n=new Vu,i=new yf,r=new $e(1,1,1);function a(){i.setFromEuler(n,!1)}function s(){n.setFromQuaternion(i,void 0,!1)}n._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Gi},normalMatrix:{value:new sn}}),this.matrix=new Gi,this.matrixWorld=new Gi,this.matrixAutoUpdate=Zb.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zb.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pG,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return Eh.setFromAxisAngle(e,n),this.quaternion.multiply(Eh),this}rotateOnWorldAxis(e,n){return Eh.setFromAxisAngle(e,n),this.quaternion.premultiply(Eh),this}rotateX(e){return this.rotateOnAxis(lj,e)}rotateY(e){return this.rotateOnAxis(cj,e)}rotateZ(e){return this.rotateOnAxis(uj,e)}translateOnAxis(e,n){return oj.copy(e).applyQuaternion(this.quaternion),this.position.add(oj.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(lj,e)}translateY(e){return this.translateOnAxis(cj,e)}translateZ(e){return this.translateOnAxis(uj,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Sl.copy(this.matrixWorld).invert())}lookAt(e,n,i){e.isVector3?vy.copy(e):vy.set(e,n,i);const r=this.parent;this.updateWorldMatrix(!0,!1),yg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Sl.lookAt(yg,vy,this.up):Sl.lookAt(vy,yg,this.up),this.quaternion.setFromRotationMatrix(Sl),r&&(Sl.extractRotation(r.matrixWorld),Eh.setFromRotationMatrix(Sl),this.quaternion.premultiply(Eh.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Ri("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(dj),Ah.child=e,this.dispatchEvent(Ah),Ah.child=null):Ri("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(Doe),pA.child=e,this.dispatchEvent(pA),pA.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Sl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Sl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Sl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(dj),Ah.child=e,this.dispatchEvent(Ah),Ah.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let i=0,r=this.children.length;i<r;i++){const s=this.children[i].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,i=[]){this[e]===n&&i.push(this);const r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,n,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yg,e,Roe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yg,Poe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let i=0,r=n.length;i<r;i++)n[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let i=0,r=n.length;i<r;i++)n[i].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let i=0,r=n.length;i<r;i++)n[i].updateMatrixWorld(e)}updateWorldMatrix(e,n){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",i={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function a(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const f=l[c];a(e.shapes,f)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(e.materials,this.material[l]));r.material=o}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(a(e.animations,l))}}if(n){const o=s(e.geometries),l=s(e.materials),c=s(e.textures),d=s(e.images),f=s(e.shapes),p=s(e.skeletons),m=s(e.animations),_=s(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),d.length>0&&(i.images=d),f.length>0&&(i.shapes=f),p.length>0&&(i.skeletons=p),m.length>0&&(i.animations=m),_.length>0&&(i.nodes=_)}return i.object=r,i;function s(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}};us.DEFAULT_UP=new $e(0,1,0);us.DEFAULT_MATRIX_AUTO_UPDATE=!0;us.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const no=new $e,wl=new $e,mA=new $e,Ml=new $e,Th=new $e,Ch=new $e,fj=new $e,gA=new $e,xA=new $e,vA=new $e,yA=new Bi,bA=new Bi,_A=new Bi;let bg=class ip{constructor(e=new $e,n=new $e,i=new $e){this.a=e,this.b=n,this.c=i}static getNormal(e,n,i,r){r.subVectors(i,n),no.subVectors(e,n),r.cross(no);const a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,n,i,r,a){no.subVectors(r,n),wl.subVectors(i,n),mA.subVectors(e,n);const s=no.dot(no),o=no.dot(wl),l=no.dot(mA),c=wl.dot(wl),d=wl.dot(mA),f=s*c-o*o;if(f===0)return a.set(0,0,0),null;const p=1/f,m=(c*l-o*d)*p,_=(s*d-o*l)*p;return a.set(1-m-_,_,m)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,Ml)===null?!1:Ml.x>=0&&Ml.y>=0&&Ml.x+Ml.y<=1}static getInterpolation(e,n,i,r,a,s,o,l){return this.getBarycoord(e,n,i,r,Ml)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(a,Ml.x),l.addScaledVector(s,Ml.y),l.addScaledVector(o,Ml.z),l)}static getInterpolatedAttribute(e,n,i,r,a,s){return yA.setScalar(0),bA.setScalar(0),_A.setScalar(0),yA.fromBufferAttribute(e,n),bA.fromBufferAttribute(e,i),_A.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(yA,a.x),s.addScaledVector(bA,a.y),s.addScaledVector(_A,a.z),s}static isFrontFacing(e,n,i,r){return no.subVectors(i,n),wl.subVectors(e,n),no.cross(wl).dot(r)<0}set(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(e,n,i,r){return this.a.copy(e[n]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,n,i,r){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return no.subVectors(this.c,this.b),wl.subVectors(this.a,this.b),no.cross(wl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ip.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return ip.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,i,r,a){return ip.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}containsPoint(e){return ip.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ip.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const i=this.a,r=this.b,a=this.c;let s,o;Th.subVectors(r,i),Ch.subVectors(a,i),gA.subVectors(e,i);const l=Th.dot(gA),c=Ch.dot(gA);if(l<=0&&c<=0)return n.copy(i);xA.subVectors(e,r);const d=Th.dot(xA),f=Ch.dot(xA);if(d>=0&&f<=d)return n.copy(r);const p=l*f-d*c;if(p<=0&&l>=0&&d<=0)return s=l/(l-d),n.copy(i).addScaledVector(Th,s);vA.subVectors(e,a);const m=Th.dot(vA),_=Ch.dot(vA);if(_>=0&&m<=_)return n.copy(a);const b=m*c-l*_;if(b<=0&&c>=0&&_<=0)return o=c/(c-_),n.copy(i).addScaledVector(Ch,o);const v=d*_-m*f;if(v<=0&&f-d>=0&&m-_>=0)return fj.subVectors(a,r),o=(f-d)/(f-d+(m-_)),n.copy(r).addScaledVector(fj,o);const x=1/(v+b+p);return s=b*x,o=p*x,n.copy(i).addScaledVector(Th,s).addScaledVector(Ch,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const mG={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},eu={h:0,s:0,l:0},yy={h:0,s:0,l:0};function SA(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let xn=class{constructor(e,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,i)}set(e,n,i){if(n===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,n,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Rs){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,wn.colorSpaceToWorking(this,n),this}setRGB(e,n,i,r=wn.workingColorSpace){return this.r=e,this.g=n,this.b=i,wn.colorSpaceToWorking(this,r),this}setHSL(e,n,i,r=wn.workingColorSpace){if(e=voe(e,1),n=fn(n,0,1),i=fn(i,0,1),n===0)this.r=this.g=this.b=i;else{const a=i<=.5?i*(1+n):i+n-i*n,s=2*i-a;this.r=SA(s,a,e+1/3),this.g=SA(s,a,e),this.b=SA(s,a,e-1/3)}return wn.colorSpaceToWorking(this,r),this}setStyle(e,n=Rs){function i(a){a!==void 0&&parseFloat(a)<1&&$t("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=r[1],o=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:$t("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);$t("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Rs){const i=mG[e.toLowerCase()];return i!==void 0?this.setHex(i,n):$t("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Jl(e.r),this.g=Jl(e.g),this.b=Jl(e.b),this}copyLinearToSRGB(e){return this.r=yp(e.r),this.g=yp(e.g),this.b=yp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Rs){return wn.workingToColorSpace(qr.copy(this),e),Math.round(fn(qr.r*255,0,255))*65536+Math.round(fn(qr.g*255,0,255))*256+Math.round(fn(qr.b*255,0,255))}getHexString(e=Rs){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=wn.workingColorSpace){wn.workingToColorSpace(qr.copy(this),n);const i=qr.r,r=qr.g,a=qr.b,s=Math.max(i,r,a),o=Math.min(i,r,a);let l,c;const d=(o+s)/2;if(o===s)l=0,c=0;else{const f=s-o;switch(c=d<=.5?f/(s+o):f/(2-s-o),s){case i:l=(r-a)/f+(r<a?6:0);break;case r:l=(a-i)/f+2;break;case a:l=(i-r)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,n=wn.workingColorSpace){return wn.workingToColorSpace(qr.copy(this),n),e.r=qr.r,e.g=qr.g,e.b=qr.b,e}getStyle(e=Rs){wn.workingToColorSpace(qr.copy(this),e);const n=qr.r,i=qr.g,r=qr.b;return e!==Rs?`color(${e} ${n.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,n,i){return this.getHSL(eu),this.setHSL(eu.h+e,eu.s+n,eu.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,i){return this.r=e.r+(n.r-e.r)*i,this.g=e.g+(n.g-e.g)*i,this.b=e.b+(n.b-e.b)*i,this}lerpHSL(e,n){this.getHSL(eu),e.getHSL(yy);const i=rA(eu.h,yy.h,n),r=rA(eu.s,yy.s,n),a=rA(eu.l,yy.l,n);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*n+a[3]*i+a[6]*r,this.g=a[1]*n+a[4]*i+a[7]*r,this.b=a[2]*n+a[5]*i+a[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const qr=new xn;xn.NAMES=mG;let Ooe=0,sm=class extends Uf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ooe++}),this.uuid=gx(),this.name="",this.type="Material",this.blending=vp,this.side=Hu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=QC,this.blendDst=JC,this.blendEquation=zd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xn(0,0,0),this.blendAlpha=0,this.depthFunc=Rp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Z4,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=yh,this.stencilZFail=yh,this.stencilZPass=yh,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const i=e[n];if(i===void 0){$t(`Material: parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){$t(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[n]=i}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==vp&&(i.blending=this.blending),this.side!==Hu&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==QC&&(i.blendSrc=this.blendSrc),this.blendDst!==JC&&(i.blendDst=this.blendDst),this.blendEquation!==zd&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Rp&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Z4&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==yh&&(i.stencilFail=this.stencilFail),this.stencilZFail!==yh&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==yh&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){const s=[];for(const o in a){const l=a[o];delete l.metadata,s.push(l)}return s}if(n){const a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let i=null;if(n!==null){const r=n.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=n[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},mP=class extends sm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vu,this.combine=aP,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const ji=new $e,by=new nn;let koe=0,zs=class{constructor(e,n,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:koe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=i,this.usage=Q4,this.updateRanges=[],this.gpuType=Wl,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,i){e*=this.itemSize,i*=n.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=n.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,i=this.count;n<i;n++)by.fromBufferAttribute(this,n),by.applyMatrix3(e),this.setXY(n,by.x,by.y);else if(this.itemSize===3)for(let n=0,i=this.count;n<i;n++)ji.fromBufferAttribute(this,n),ji.applyMatrix3(e),this.setXYZ(n,ji.x,ji.y,ji.z);return this}applyMatrix4(e){for(let n=0,i=this.count;n<i;n++)ji.fromBufferAttribute(this,n),ji.applyMatrix4(e),this.setXYZ(n,ji.x,ji.y,ji.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)ji.fromBufferAttribute(this,n),ji.applyNormalMatrix(e),this.setXYZ(n,ji.x,ji.y,ji.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)ji.fromBufferAttribute(this,n),ji.transformDirection(e),this.setXYZ(n,ji.x,ji.y,ji.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let i=this.array[e*this.itemSize+n];return this.normalized&&(i=gg(i,this.array)),i}setComponent(e,n,i){return this.normalized&&(i=Ta(i,this.array)),this.array[e*this.itemSize+n]=i,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=gg(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ta(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=gg(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ta(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=gg(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ta(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=gg(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ta(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,i){return e*=this.itemSize,this.normalized&&(n=Ta(n,this.array),i=Ta(i,this.array)),this.array[e+0]=n,this.array[e+1]=i,this}setXYZ(e,n,i,r){return e*=this.itemSize,this.normalized&&(n=Ta(n,this.array),i=Ta(i,this.array),r=Ta(r,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,n,i,r,a){return e*=this.itemSize,this.normalized&&(n=Ta(n,this.array),i=Ta(i,this.array),r=Ta(r,this.array),a=Ta(a,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Q4&&(e.usage=this.usage),e}},gG=class extends zs{constructor(e,n,i){super(new Uint16Array(e),n,i)}},xG=class extends zs{constructor(e,n,i){super(new Uint32Array(e),n,i)}},go=class extends zs{constructor(e,n,i){super(new Float32Array(e),n,i)}},Loe=0;const _s=new Gi,wA=new us,Nh=new $e,Ya=new _f,_g=new _f,xr=new $e;let tl=class vG extends Uf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Loe++}),this.uuid=gx(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(oG(e)?xG:gG)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,i=0){this.groups.push({start:e,count:n,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const a=new sn().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return _s.makeRotationFromQuaternion(e),this.applyMatrix4(_s),this}rotateX(e){return _s.makeRotationX(e),this.applyMatrix4(_s),this}rotateY(e){return _s.makeRotationY(e),this.applyMatrix4(_s),this}rotateZ(e){return _s.makeRotationZ(e),this.applyMatrix4(_s),this}translate(e,n,i){return _s.makeTranslation(e,n,i),this.applyMatrix4(_s),this}scale(e,n,i){return _s.makeScale(e,n,i),this.applyMatrix4(_s),this}lookAt(e){return wA.lookAt(e),wA.updateMatrix(),this.applyMatrix4(wA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Nh).negate(),this.translate(Nh.x,Nh.y,Nh.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const i=[];for(let r=0,a=e.length;r<a;r++){const s=e[r];i.push(s.x,s.y,s.z||0)}this.setAttribute("position",new go(i,3))}else{const i=Math.min(e.length,n.count);for(let r=0;r<i;r++){const a=e[r];n.setXYZ(r,a.x,a.y,a.z||0)}e.length>n.count&&$t("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),n.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _f);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ri("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new $e(-1/0,-1/0,-1/0),new $e(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let i=0,r=n.length;i<r;i++){const a=n[i];Ya.setFromBufferAttribute(a),this.morphTargetsRelative?(xr.addVectors(this.boundingBox.min,Ya.min),this.boundingBox.expandByPoint(xr),xr.addVectors(this.boundingBox.max,Ya.max),this.boundingBox.expandByPoint(xr)):(this.boundingBox.expandByPoint(Ya.min),this.boundingBox.expandByPoint(Ya.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ri('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new TS);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ri("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new $e,1/0);return}if(e){const i=this.boundingSphere.center;if(Ya.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];_g.setFromBufferAttribute(o),this.morphTargetsRelative?(xr.addVectors(Ya.min,_g.min),Ya.expandByPoint(xr),xr.addVectors(Ya.max,_g.max),Ya.expandByPoint(xr)):(Ya.expandByPoint(_g.min),Ya.expandByPoint(_g.max))}Ya.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)xr.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(xr));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)xr.fromBufferAttribute(o,c),l&&(Nh.fromBufferAttribute(e,c),xr.add(Nh)),r=Math.max(r,i.distanceToSquared(xr))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Ri('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){Ri("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=n.position,r=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new zs(new Float32Array(4*i.count),4));const s=this.getAttribute("tangent"),o=[],l=[];for(let U=0;U<i.count;U++)o[U]=new $e,l[U]=new $e;const c=new $e,d=new $e,f=new $e,p=new nn,m=new nn,_=new nn,b=new $e,v=new $e;function x(U,R,O){c.fromBufferAttribute(i,U),d.fromBufferAttribute(i,R),f.fromBufferAttribute(i,O),p.fromBufferAttribute(a,U),m.fromBufferAttribute(a,R),_.fromBufferAttribute(a,O),d.sub(c),f.sub(c),m.sub(p),_.sub(p);const z=1/(m.x*_.y-_.x*m.y);isFinite(z)&&(b.copy(d).multiplyScalar(_.y).addScaledVector(f,-m.y).multiplyScalar(z),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-_.x).multiplyScalar(z),o[U].add(b),o[R].add(b),o[O].add(b),l[U].add(v),l[R].add(v),l[O].add(v))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let U=0,R=M.length;U<R;++U){const O=M[U],z=O.start,I=O.count;for(let G=z,L=z+I;G<L;G+=3)x(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const w=new $e,E=new $e,T=new $e,P=new $e;function N(U){T.fromBufferAttribute(r,U),P.copy(T);const R=o[U];w.copy(R),w.sub(T.multiplyScalar(T.dot(R))).normalize(),E.crossVectors(P,R);const z=E.dot(l[U])<0?-1:1;s.setXYZW(U,w.x,w.y,w.z,z)}for(let U=0,R=M.length;U<R;++U){const O=M[U],z=O.start,I=O.count;for(let G=z,L=z+I;G<L;G+=3)N(e.getX(G+0)),N(e.getX(G+1)),N(e.getX(G+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new zs(new Float32Array(n.count*3),3),this.setAttribute("normal",i);else for(let p=0,m=i.count;p<m;p++)i.setXYZ(p,0,0,0);const r=new $e,a=new $e,s=new $e,o=new $e,l=new $e,c=new $e,d=new $e,f=new $e;if(e)for(let p=0,m=e.count;p<m;p+=3){const _=e.getX(p+0),b=e.getX(p+1),v=e.getX(p+2);r.fromBufferAttribute(n,_),a.fromBufferAttribute(n,b),s.fromBufferAttribute(n,v),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,_),l.fromBufferAttribute(i,b),c.fromBufferAttribute(i,v),o.add(d),l.add(d),c.add(d),i.setXYZ(_,o.x,o.y,o.z),i.setXYZ(b,l.x,l.y,l.z),i.setXYZ(v,c.x,c.y,c.z)}else for(let p=0,m=n.count;p<m;p+=3)r.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),s.fromBufferAttribute(n,p+2),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),i.setXYZ(p+0,d.x,d.y,d.z),i.setXYZ(p+1,d.x,d.y,d.z),i.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,i=e.count;n<i;n++)xr.fromBufferAttribute(e,n),xr.normalize(),e.setXYZ(n,xr.x,xr.y,xr.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,f=o.normalized,p=new c.constructor(l.length*d);let m=0,_=0;for(let b=0,v=l.length;b<v;b++){o.isInterleavedBufferAttribute?m=l[b]*o.data.stride+o.offset:m=l[b]*d;for(let x=0;x<d;x++)p[_++]=c[m++]}return new zs(p,d,f)}if(this.index===null)return $t("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new vG,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);n.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let d=0,f=c.length;d<f;d++){const p=c[d],m=e(p,i);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,l=s.length;o<l;o++){const c=s[o];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let f=0,p=c.length;f<p;f++){const m=c[f];d.push(m.toJSON(e.data))}d.length>0&&(r[l]=d,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const r=e.attributes;for(const c in r){const d=r[c];this.setAttribute(c,d.clone(n))}const a=e.morphAttributes;for(const c in a){const d=[],f=a[c];for(let p=0,m=f.length;p<m;p++)d.push(f[p].clone(n));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,d=s.length;c<d;c++){const f=s[c];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const hj=new Gi,Ad=new pP,_y=new TS,pj=new $e,Sy=new $e,wy=new $e,My=new $e,MA=new $e,Ey=new $e,mj=new $e,Ay=new $e;let Wo=class extends us{constructor(e=new tl,n=new mP){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,i=Object.keys(n);if(i.length>0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){const o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;n.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(a&&o){Ey.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const d=o[l],f=a[l];d!==0&&(MA.fromBufferAttribute(f,e),s?Ey.addScaledVector(MA,d):Ey.addScaledVector(MA.sub(n),d))}n.add(Ey)}return n}raycast(e,n){const i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),_y.copy(i.boundingSphere),_y.applyMatrix4(a),Ad.copy(e.ray).recast(e.near),!(_y.containsPoint(Ad.origin)===!1&&(Ad.intersectSphere(_y,pj)===null||Ad.origin.distanceToSquared(pj)>(e.far-e.near)**2))&&(hj.copy(a).invert(),Ad.copy(e.ray).applyMatrix4(hj),!(i.boundingBox!==null&&Ad.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,n,Ad)))}_computeIntersections(e,n,i){let r;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let _=0,b=p.length;_<b;_++){const v=p[_],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let E=M,T=w;E<T;E+=3){const P=o.getX(E),N=o.getX(E+1),U=o.getX(E+2);r=Ty(this,x,e,i,c,d,f,P,N,U),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const _=Math.max(0,m.start),b=Math.min(o.count,m.start+m.count);for(let v=_,x=b;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),E=o.getX(v+2);r=Ty(this,s,e,i,c,d,f,M,w,E),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}else if(l!==void 0)if(Array.isArray(s))for(let _=0,b=p.length;_<b;_++){const v=p[_],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let E=M,T=w;E<T;E+=3){const P=E,N=E+1,U=E+2;r=Ty(this,x,e,i,c,d,f,P,N,U),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const _=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let v=_,x=b;v<x;v+=3){const M=v,w=v+1,E=v+2;r=Ty(this,s,e,i,c,d,f,M,w,E),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}}};function Ioe(t,e,n,i,r,a,s,o){let l;if(e.side===Oa?l=i.intersectTriangle(s,a,r,!0,o):l=i.intersectTriangle(r,a,s,e.side===Hu,o),l===null)return null;Ay.copy(o),Ay.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Ay);return c<n.near||c>n.far?null:{distance:c,point:Ay.clone(),object:t}}function Ty(t,e,n,i,r,a,s,o,l,c){t.getVertexPosition(o,Sy),t.getVertexPosition(l,wy),t.getVertexPosition(c,My);const d=Ioe(t,e,n,i,Sy,wy,My,mj);if(d){const f=new $e;bg.getBarycoord(mj,Sy,wy,My,f),r&&(d.uv=bg.getInterpolatedAttribute(r,o,l,c,f,new nn)),a&&(d.uv1=bg.getInterpolatedAttribute(a,o,l,c,f,new nn)),s&&(d.normal=bg.getInterpolatedAttribute(s,o,l,c,f,new $e),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));const p={a:o,b:l,c,normal:new $e,materialIndex:0};bg.getNormal(Sy,wy,My,p.normal),d.face=p,d.barycoord=f}return d}let gP=class yG extends tl{constructor(e=1,n=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};const o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);const l=[],c=[],d=[],f=[];let p=0,m=0;_("z","y","x",-1,-1,i,n,e,s,a,0),_("z","y","x",1,-1,i,n,-e,s,a,1),_("x","z","y",1,1,e,i,n,r,s,2),_("x","z","y",1,-1,e,i,-n,r,s,3),_("x","y","z",1,-1,e,n,i,r,a,4),_("x","y","z",-1,-1,e,n,-i,r,a,5),this.setIndex(l),this.setAttribute("position",new go(c,3)),this.setAttribute("normal",new go(d,3)),this.setAttribute("uv",new go(f,2));function _(b,v,x,M,w,E,T,P,N,U,R){const O=E/N,z=T/U,I=E/2,G=T/2,L=P/2,B=N+1,q=U+1;let W=0,X=0;const Q=new $e;for(let ie=0;ie<q;ie++){const H=ie*z-G;for(let Y=0;Y<B;Y++){const se=Y*O-I;Q[b]=se*M,Q[v]=H*w,Q[x]=L,c.push(Q.x,Q.y,Q.z),Q[b]=0,Q[v]=0,Q[x]=P>0?1:-1,d.push(Q.x,Q.y,Q.z),f.push(Y/N),f.push(1-ie/U),W+=1}}for(let ie=0;ie<U;ie++)for(let H=0;H<N;H++){const Y=p+H+B*ie,se=p+H+B*(ie+1),ue=p+(H+1)+B*(ie+1),xe=p+(H+1)+B*ie;l.push(Y,se,xe),l.push(se,ue,xe),X+=6}o.addGroup(m,X,R),m+=X,p+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yG(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function kp(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?($t("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function la(t){const e={};for(let n=0;n<t.length;n++){const i=kp(t[n]);for(const r in i)e[r]=i[r]}return e}function Uoe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function bG(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:wn.workingColorSpace}const joe={clone:kp,merge:la};var Foe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,zoe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let cc=class extends sm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Foe,this.fragmentShader=zoe,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=kp(e.uniforms),this.uniformsGroups=Uoe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const r in this.uniforms){const s=this.uniforms[r].value;s&&s.isTexture?n.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[r]={type:"m4",value:s.toArray()}:n.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(n.extensions=i),n}},_G=class extends us{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gi,this.projectionMatrix=new Gi,this.projectionMatrixInverse=new Gi,this.coordinateSystem=jo,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const tu=new $e,gj=new nn,xj=new nn;let Os=class extends _G{constructor(e=50,n=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=FN*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Kb*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return FN*2*Math.atan(Math.tan(Kb*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,n,i){tu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(tu.x,tu.y).multiplyScalar(-e/tu.z),tu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(tu.x,tu.y).multiplyScalar(-e/tu.z)}getViewSize(e,n){return this.getViewBounds(e,gj,xj),n.subVectors(xj,gj)}setViewOffset(e,n,i,r,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Kb*.5*this.fov)/this.zoom,i=2*n,r=this.aspect*i,a=-.5*r;const s=this.view;if(this.view!==null&&this.view.enabled){const l=s.fullWidth,c=s.fullHeight;a+=s.offsetX*r/l,n-=s.offsetY*i/c,r*=s.width/l,i*=s.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,n,n-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const Rh=-90,Ph=1;let Boe=class extends us{constructor(e,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Os(Rh,Ph,e,n);r.layers=this.layers,this.add(r);const a=new Os(Rh,Ph,e,n);a.layers=this.layers,this.add(a);const s=new Os(Rh,Ph,e,n);s.layers=this.layers,this.add(s);const o=new Os(Rh,Ph,e,n);o.layers=this.layers,this.add(o);const l=new Os(Rh,Ph,e,n);l.layers=this.layers,this.add(l);const c=new Os(Rh,Ph,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[i,r,a,s,o,l]=n;for(const c of n)this.remove(c);if(e===jo)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===y_)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,l,c,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const b=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(n,a),e.setRenderTarget(i,1,r),e.render(n,s),e.setRenderTarget(i,2,r),e.render(n,o),e.setRenderTarget(i,3,r),e.render(n,l),e.setRenderTarget(i,4,r),e.render(n,c),i.texture.generateMipmaps=b,e.setRenderTarget(i,5,r),e.render(n,d),e.setRenderTarget(f,p,m),e.xr.enabled=_,i.texture.needsPMREMUpdate=!0}},SG=class extends So{constructor(e=[],n=Pp,i,r,a,s,o,l,c,d){super(e,n,i,r,a,s,o,l,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Hoe=class extends bf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new SG(r),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},r=new gP(5,5,5),a=new cc({name:"CubemapFromEquirect",uniforms:kp(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Oa,blending:Ql});a.uniforms.tEquirect.value=n;const s=new Wo(r,a),o=n.minFilter;return n.minFilter===qd&&(n.minFilter=js),new Boe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n=!0,i=!0,r=!0){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,i,r);e.setRenderTarget(a)}},Bg=class extends us{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Voe={type:"move"};let EA=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Bg,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Bg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new $e,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new $e),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Bg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new $e,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new $e),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const i of e.hand.values())this._getHandJoint(n,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,i){let r=null,a=null,s=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(const b of e.hand.values()){const v=n.getJointPose(b,i),x=this._getHandJoint(c,b);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const d=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],p=d.position.distanceTo(f.position),m=.02,_=.005;c.inputState.pinching&&p>m+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,i),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=n.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Voe)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const i=new Bg;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}},$oe=class extends us{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Vu,this.environmentIntensity=1,this.environmentRotation=new Vu,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(n.object.environmentIntensity=this.environmentIntensity),n.object.environmentRotation=this.environmentRotation.toArray(),n}},Goe=class extends So{constructor(e=null,n=1,i=1,r,a,s,o,l,c=as,d=as,f,p){super(null,s,o,l,c,d,r,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const AA=new $e,Woe=new $e,qoe=new sn;let du=class{constructor(e=new $e(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,i,r){return this.normal.set(e,n,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,i){const r=AA.subVectors(i,n).cross(Woe.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const i=e.delta(AA),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return a<0||a>1?null:n.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const i=n||qoe.getNormalMatrix(e),r=this.coplanarPoint(AA).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const Td=new TS,Xoe=new nn(.5,.5),Cy=new $e;let xP=class{constructor(e=new du,n=new du,i=new du,r=new du,a=new du,s=new du){this.planes=[e,n,i,r,a,s]}set(e,n,i,r,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let i=0;i<6;i++)n[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,n=jo,i=!1){const r=this.planes,a=e.elements,s=a[0],o=a[1],l=a[2],c=a[3],d=a[4],f=a[5],p=a[6],m=a[7],_=a[8],b=a[9],v=a[10],x=a[11],M=a[12],w=a[13],E=a[14],T=a[15];if(r[0].setComponents(c-s,m-d,x-_,T-M).normalize(),r[1].setComponents(c+s,m+d,x+_,T+M).normalize(),r[2].setComponents(c+o,m+f,x+b,T+w).normalize(),r[3].setComponents(c-o,m-f,x-b,T-w).normalize(),i)r[4].setComponents(l,p,v,E).normalize(),r[5].setComponents(c-l,m-p,x-v,T-E).normalize();else if(r[4].setComponents(c-l,m-p,x-v,T-E).normalize(),n===jo)r[5].setComponents(c+l,m+p,x+v,T+E).normalize();else if(n===y_)r[5].setComponents(l,p,v,E).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Td.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Td.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Td)}intersectsSprite(e){Td.center.set(0,0,0);const n=Xoe.distanceTo(e.center);return Td.radius=.7071067811865476+n,Td.applyMatrix4(e.matrixWorld),this.intersectsSphere(Td)}intersectsSphere(e){const n=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const n=this.planes;for(let i=0;i<6;i++){const r=n[i];if(Cy.x=r.normal.x>0?e.max.x:e.min.x,Cy.y=r.normal.y>0?e.max.y:e.min.y,Cy.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Cy)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let i=0;i<6;i++)if(n[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},wG=class extends sm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const __=new $e,S_=new $e,vj=new Gi,Sg=new pP,Ny=new TS,TA=new $e,yj=new $e;let Koe=class extends us{constructor(e=new tl,n=new wG){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,i=[0];for(let r=1,a=n.count;r<a;r++)__.fromBufferAttribute(n,r-1),S_.fromBufferAttribute(n,r),i[r]=i[r-1],i[r]+=__.distanceTo(S_);e.setAttribute("lineDistance",new go(i,1))}else $t("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Ny.copy(i.boundingSphere),Ny.applyMatrix4(r),Ny.radius+=a,e.ray.intersectsSphere(Ny)===!1)return;vj.copy(r).invert(),Sg.copy(e.ray).applyMatrix4(vj);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,d=i.index,p=i.attributes.position;if(d!==null){const m=Math.max(0,s.start),_=Math.min(d.count,s.start+s.count);for(let b=m,v=_-1;b<v;b+=c){const x=d.getX(b),M=d.getX(b+1),w=Ry(this,e,Sg,l,x,M,b);w&&n.push(w)}if(this.isLineLoop){const b=d.getX(_-1),v=d.getX(m),x=Ry(this,e,Sg,l,b,v,_-1);x&&n.push(x)}}else{const m=Math.max(0,s.start),_=Math.min(p.count,s.start+s.count);for(let b=m,v=_-1;b<v;b+=c){const x=Ry(this,e,Sg,l,b,b+1,b);x&&n.push(x)}if(this.isLineLoop){const b=Ry(this,e,Sg,l,_-1,m,_-1);b&&n.push(b)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,i=Object.keys(n);if(i.length>0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){const o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}};function Ry(t,e,n,i,r,a,s){const o=t.geometry.attributes.position;if(__.fromBufferAttribute(o,r),S_.fromBufferAttribute(o,a),n.distanceSqToSegment(__,S_,TA,yj)>i)return;TA.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(TA);if(!(c<e.near||c>e.far))return{distance:c,point:yj.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const bj=new $e,_j=new $e;let Yoe=class extends Koe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,i=[];for(let r=0,a=n.count;r<a;r+=2)bj.fromBufferAttribute(n,r),_j.fromBufferAttribute(n,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+bj.distanceTo(_j);e.setAttribute("lineDistance",new go(i,1))}else $t("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},MG=class extends So{constructor(e,n,i=vf,r,a,s,o=as,l=as,c,d=C0,f=1){if(d!==C0&&d!==N0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:f};super(p,r,a,s,o,l,d,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new hP(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}};class EG extends So{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let vP=class AG extends tl{constructor(e=1,n=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:i,heightSegments:r};const a=e/2,s=n/2,o=Math.floor(i),l=Math.floor(r),c=o+1,d=l+1,f=e/o,p=n/l,m=[],_=[],b=[],v=[];for(let x=0;x<d;x++){const M=x*p-s;for(let w=0;w<c;w++){const E=w*f-a;_.push(E,-M,0),b.push(0,0,1),v.push(w/o),v.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,E=M+c*(x+1),T=M+1+c*(x+1),P=M+1+c*x;m.push(w,E,P),m.push(E,T,P)}this.setIndex(m),this.setAttribute("position",new go(_,3)),this.setAttribute("normal",new go(b,3)),this.setAttribute("uv",new go(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new AG(e.width,e.height,e.widthSegments,e.heightSegments)}};class Zoe extends sm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new xn(16777215),this.specular=new xn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=aG,this.normalScale=new nn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Vu,this.combine=aP,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}let Qoe=class extends sm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=soe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Joe=class extends sm{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},TG=class extends us{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new xn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const CA=new Gi,Sj=new $e,wj=new $e;let ele=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new nn(512,512),this.mapType=Go,this.map=null,this.mapPass=null,this.matrix=new Gi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new xP,this._frameExtents=new nn(1,1),this._viewportCount=1,this._viewports=[new Bi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,i=this.matrix;Sj.setFromMatrixPosition(e.matrixWorld),n.position.copy(Sj),wj.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(wj),n.updateMatrixWorld(),CA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(CA,n.coordinateSystem,n.reversedDepth),n.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(CA)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},CG=class extends _G{constructor(e=-1,n=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,i,r,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let a=i-e,s=i+e,o=r+n,l=r-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}};class tle extends ele{constructor(){super(new CG(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Mj extends TG{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(us.DEFAULT_UP),this.updateMatrix(),this.target=new us,this.shadow=new tle}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let nle=class extends TG{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},ile=class extends Os{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},Ej=class{constructor(e=1,n=0,i=0){this.radius=e,this.phi=n,this.theta=i}set(e,n,i){return this.radius=e,this.phi=n,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=fn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,i){return this.radius=Math.sqrt(e*e+n*n+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(fn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class rle extends Yoe{constructor(e=10,n=10,i=4473924,r=8947848){i=new xn(i),r=new xn(r);const a=n/2,s=e/n,o=e/2,l=[],c=[];for(let p=0,m=0,_=-o;p<=n;p++,_+=s){l.push(-o,0,_,o,0,_),l.push(_,0,-o,_,0,o);const b=p===a?i:r;b.toArray(c,m),m+=3,b.toArray(c,m),m+=3,b.toArray(c,m),m+=3,b.toArray(c,m),m+=3}const d=new tl;d.setAttribute("position",new go(l,3)),d.setAttribute("color",new go(c,3));const f=new wG({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ale extends Uf{constructor(e,n=null){super(),this.object=e,this.domElement=n,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){$t("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Aj(t,e,n,i){const r=sle(i);switch(n){case nG:return t*e;case rG:return t*e/r.components*r.byteLength;case cP:return t*e/r.components*r.byteLength;case uP:return t*e*2/r.components*r.byteLength;case dP:return t*e*2/r.components*r.byteLength;case iG:return t*e*3/r.components*r.byteLength;case ho:return t*e*4/r.components*r.byteLength;case fP:return t*e*4/r.components*r.byteLength;case Gb:case Wb:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case qb:case Xb:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case fN:case pN:return Math.max(t,16)*Math.max(e,8)/4;case dN:case hN:return Math.max(t,8)*Math.max(e,8)/2;case mN:case gN:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case xN:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case vN:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case yN:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case bN:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case _N:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case SN:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case wN:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case MN:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case EN:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case AN:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case TN:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case CN:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case NN:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case RN:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case PN:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case DN:case ON:case kN:return Math.ceil(t/4)*Math.ceil(e/4)*16;case LN:case IN:return Math.ceil(t/4)*Math.ceil(e/4)*8;case UN:case jN:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function sle(t){switch(t){case Go:case Q$:return{byteLength:1,components:1};case A0:case J$:case am:return{byteLength:2,components:1};case oP:case lP:return{byteLength:2,components:4};case vf:case sP:case Wl:return{byteLength:4,components:1};case eG:case tG:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:rP}}));typeof window<"u"&&(window.__THREE__?$t("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=rP);function NG(){let t=null,e=!1,n=null,i=null;function r(a,s){n(a,s),i=t.requestAnimationFrame(r)}return{start:function(){e!==!0&&n!==null&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function ole(t){const e=new WeakMap;function n(o,l){const c=o.array,d=o.usage,f=c.byteLength,p=t.createBuffer();t.bindBuffer(l,p),t.bufferData(l,c,d),o.onUploadCallback();let m;if(c instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=t.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=t.SHORT;else if(c instanceof Uint32Array)m=t.UNSIGNED_INT;else if(c instanceof Int32Array)m=t.INT;else if(c instanceof Int8Array)m=t.BYTE;else if(c instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:f}}function i(o,l,c){const d=l.array,f=l.updateRanges;if(t.bindBuffer(c,o),f.length===0)t.bufferSubData(c,0,d);else{f.sort((m,_)=>m.start-_.start);let p=0;for(let m=1;m<f.length;m++){const _=f[p],b=f[m];b.start<=_.start+_.count+1?_.count=Math.max(_.count,b.start+b.count-_.start):(++p,f[p]=b)}f.length=p+1;for(let m=0,_=f.length;m<_;m++){const b=f[m];t.bufferSubData(c,b.start*d.BYTES_PER_ELEMENT,d,b.start,b.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(t.deleteBuffer(l.buffer),e.delete(o))}function s(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const d=e.get(o);(!d||d.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,n(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:a,update:s}}var lle=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,cle=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,ule=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,dle=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,fle=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,hle=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,ple=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,mle=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,gle=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,xle=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,vle=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,yle=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,ble=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,_le=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,Sle=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,wle=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,Mle=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,Ele=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,Ale=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,Tle=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,Cle=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,Nle=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,Rle=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,Ple=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,Dle=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,Ole=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,kle=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Lle=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,Ile=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,Ule=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,jle="gl_FragColor = linearToOutputTexel( gl_FragColor );",Fle=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,zle=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,Ble=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,Hle=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,Vle=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,$le=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,Gle=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,Wle=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,qle=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,Xle=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,Kle=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,Yle=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,Zle=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,Qle=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Jle=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,ece=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,tce=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,nce=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,ice=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,rce=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ace=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,sce=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,oce=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,lce=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,cce=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,uce=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,dce=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,fce=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,hce=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,pce=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,mce=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,gce=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,xce=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,vce=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,yce=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,bce=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,_ce=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,Sce=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,wce=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,Mce=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,Ece=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,Ace=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,Tce=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Cce=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Nce=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Rce=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,Pce=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Dce=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Oce=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,kce=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Lce=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ice=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,Uce=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,jce=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,Fce=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,zce=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,Bce=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Hce=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Vce=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,$ce=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,Gce=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,Wce=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,qce=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,Xce=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,Kce=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,Yce=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,Zce=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,Qce=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,Jce=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,eue=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,tue=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,nue=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,iue=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,rue=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,aue=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,sue=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const oue=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,lue=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,cue=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,uue=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,due=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,fue=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,hue=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,pue=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,mue=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,gue=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,xue=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,vue=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,yue=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,bue=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,_ue=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,Sue=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,wue=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Mue=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Eue=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,Aue=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Tue=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,Cue=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,Nue=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,Rue=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Pue=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,Due=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Oue=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,kue=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,Lue=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,Iue=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,Uue=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,jue=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Fue=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,zue=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,en={alphahash_fragment:lle,alphahash_pars_fragment:cle,alphamap_fragment:ule,alphamap_pars_fragment:dle,alphatest_fragment:fle,alphatest_pars_fragment:hle,aomap_fragment:ple,aomap_pars_fragment:mle,batching_pars_vertex:gle,batching_vertex:xle,begin_vertex:vle,beginnormal_vertex:yle,bsdfs:ble,iridescence_fragment:_le,bumpmap_pars_fragment:Sle,clipping_planes_fragment:wle,clipping_planes_pars_fragment:Mle,clipping_planes_pars_vertex:Ele,clipping_planes_vertex:Ale,color_fragment:Tle,color_pars_fragment:Cle,color_pars_vertex:Nle,color_vertex:Rle,common:Ple,cube_uv_reflection_fragment:Dle,defaultnormal_vertex:Ole,displacementmap_pars_vertex:kle,displacementmap_vertex:Lle,emissivemap_fragment:Ile,emissivemap_pars_fragment:Ule,colorspace_fragment:jle,colorspace_pars_fragment:Fle,envmap_fragment:zle,envmap_common_pars_fragment:Ble,envmap_pars_fragment:Hle,envmap_pars_vertex:Vle,envmap_physical_pars_fragment:ece,envmap_vertex:$le,fog_vertex:Gle,fog_pars_vertex:Wle,fog_fragment:qle,fog_pars_fragment:Xle,gradientmap_pars_fragment:Kle,lightmap_pars_fragment:Yle,lights_lambert_fragment:Zle,lights_lambert_pars_fragment:Qle,lights_pars_begin:Jle,lights_toon_fragment:tce,lights_toon_pars_fragment:nce,lights_phong_fragment:ice,lights_phong_pars_fragment:rce,lights_physical_fragment:ace,lights_physical_pars_fragment:sce,lights_fragment_begin:oce,lights_fragment_maps:lce,lights_fragment_end:cce,logdepthbuf_fragment:uce,logdepthbuf_pars_fragment:dce,logdepthbuf_pars_vertex:fce,logdepthbuf_vertex:hce,map_fragment:pce,map_pars_fragment:mce,map_particle_fragment:gce,map_particle_pars_fragment:xce,metalnessmap_fragment:vce,metalnessmap_pars_fragment:yce,morphinstance_vertex:bce,morphcolor_vertex:_ce,morphnormal_vertex:Sce,morphtarget_pars_vertex:wce,morphtarget_vertex:Mce,normal_fragment_begin:Ece,normal_fragment_maps:Ace,normal_pars_fragment:Tce,normal_pars_vertex:Cce,normal_vertex:Nce,normalmap_pars_fragment:Rce,clearcoat_normal_fragment_begin:Pce,clearcoat_normal_fragment_maps:Dce,clearcoat_pars_fragment:Oce,iridescence_pars_fragment:kce,opaque_fragment:Lce,packing:Ice,premultiplied_alpha_fragment:Uce,project_vertex:jce,dithering_fragment:Fce,dithering_pars_fragment:zce,roughnessmap_fragment:Bce,roughnessmap_pars_fragment:Hce,shadowmap_pars_fragment:Vce,shadowmap_pars_vertex:$ce,shadowmap_vertex:Gce,shadowmask_pars_fragment:Wce,skinbase_vertex:qce,skinning_pars_vertex:Xce,skinning_vertex:Kce,skinnormal_vertex:Yce,specularmap_fragment:Zce,specularmap_pars_fragment:Qce,tonemapping_fragment:Jce,tonemapping_pars_fragment:eue,transmission_fragment:tue,transmission_pars_fragment:nue,uv_pars_fragment:iue,uv_pars_vertex:rue,uv_vertex:aue,worldpos_vertex:sue,background_vert:oue,background_frag:lue,backgroundCube_vert:cue,backgroundCube_frag:uue,cube_vert:due,cube_frag:fue,depth_vert:hue,depth_frag:pue,distanceRGBA_vert:mue,distanceRGBA_frag:gue,equirect_vert:xue,equirect_frag:vue,linedashed_vert:yue,linedashed_frag:bue,meshbasic_vert:_ue,meshbasic_frag:Sue,meshlambert_vert:wue,meshlambert_frag:Mue,meshmatcap_vert:Eue,meshmatcap_frag:Aue,meshnormal_vert:Tue,meshnormal_frag:Cue,meshphong_vert:Nue,meshphong_frag:Rue,meshphysical_vert:Pue,meshphysical_frag:Due,meshtoon_vert:Oue,meshtoon_frag:kue,points_vert:Lue,points_frag:Iue,shadow_vert:Uue,shadow_frag:jue,sprite_vert:Fue,sprite_frag:zue},St={common:{diffuse:{value:new xn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new sn},alphaMap:{value:null},alphaMapTransform:{value:new sn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new sn}},envmap:{envMap:{value:null},envMapRotation:{value:new sn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new sn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new sn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new sn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new sn},normalScale:{value:new nn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new sn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new sn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new sn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new sn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new sn},alphaTest:{value:0},uvTransform:{value:new sn}},sprite:{diffuse:{value:new xn(16777215)},opacity:{value:1},center:{value:new nn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new sn},alphaMap:{value:null},alphaMapTransform:{value:new sn},alphaTest:{value:0}}},Lo={basic:{uniforms:la([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:en.meshbasic_vert,fragmentShader:en.meshbasic_frag},lambert:{uniforms:la([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new xn(0)}}]),vertexShader:en.meshlambert_vert,fragmentShader:en.meshlambert_frag},phong:{uniforms:la([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.fog,St.lights,{emissive:{value:new xn(0)},specular:{value:new xn(1118481)},shininess:{value:30}}]),vertexShader:en.meshphong_vert,fragmentShader:en.meshphong_frag},standard:{uniforms:la([St.common,St.envmap,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.roughnessmap,St.metalnessmap,St.fog,St.lights,{emissive:{value:new xn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:en.meshphysical_vert,fragmentShader:en.meshphysical_frag},toon:{uniforms:la([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new xn(0)}}]),vertexShader:en.meshtoon_vert,fragmentShader:en.meshtoon_frag},matcap:{uniforms:la([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:en.meshmatcap_vert,fragmentShader:en.meshmatcap_frag},points:{uniforms:la([St.points,St.fog]),vertexShader:en.points_vert,fragmentShader:en.points_frag},dashed:{uniforms:la([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:en.linedashed_vert,fragmentShader:en.linedashed_frag},depth:{uniforms:la([St.common,St.displacementmap]),vertexShader:en.depth_vert,fragmentShader:en.depth_frag},normal:{uniforms:la([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:en.meshnormal_vert,fragmentShader:en.meshnormal_frag},sprite:{uniforms:la([St.sprite,St.fog]),vertexShader:en.sprite_vert,fragmentShader:en.sprite_frag},background:{uniforms:{uvTransform:{value:new sn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:en.background_vert,fragmentShader:en.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new sn}},vertexShader:en.backgroundCube_vert,fragmentShader:en.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:en.cube_vert,fragmentShader:en.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:en.equirect_vert,fragmentShader:en.equirect_frag},distanceRGBA:{uniforms:la([St.common,St.displacementmap,{referencePosition:{value:new $e},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:en.distanceRGBA_vert,fragmentShader:en.distanceRGBA_frag},shadow:{uniforms:la([St.lights,St.fog,{color:{value:new xn(0)},opacity:{value:1}}]),vertexShader:en.shadow_vert,fragmentShader:en.shadow_frag}};Lo.physical={uniforms:la([Lo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new sn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new sn},clearcoatNormalScale:{value:new nn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new sn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new sn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new sn},sheen:{value:0},sheenColor:{value:new xn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new sn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new sn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new sn},transmissionSamplerSize:{value:new nn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new sn},attenuationDistance:{value:0},attenuationColor:{value:new xn(0)},specularColor:{value:new xn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new sn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new sn},anisotropyVector:{value:new nn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new sn}}]),vertexShader:en.meshphysical_vert,fragmentShader:en.meshphysical_frag};const Py={r:0,b:0,g:0},Cd=new Vu,Bue=new Gi;function Hue(t,e,n,i,r,a,s){const o=new xn(0);let l=a===!0?0:1,c,d,f=null,p=0,m=null;function _(w){let E=w.isScene===!0?w.background:null;return E&&E.isTexture&&(E=(w.backgroundBlurriness>0?n:e).get(E)),E}function b(w){let E=!1;const T=_(w);T===null?x(o,l):T&&T.isColor&&(x(T,1),E=!0);const P=t.xr.getEnvironmentBlendMode();P==="additive"?i.buffers.color.setClear(0,0,0,1,s):P==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,s),(t.autoClear||E)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function v(w,E){const T=_(E);T&&(T.isCubeTexture||T.mapping===AS)?(d===void 0&&(d=new Wo(new gP(1,1,1),new cc({name:"BackgroundCubeMaterial",uniforms:kp(Lo.backgroundCube.uniforms),vertexShader:Lo.backgroundCube.vertexShader,fragmentShader:Lo.backgroundCube.fragmentShader,side:Oa,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(P,N,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(d)),Cd.copy(E.backgroundRotation),Cd.x*=-1,Cd.y*=-1,Cd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Cd.y*=-1,Cd.z*=-1),d.material.uniforms.envMap.value=T,d.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(Bue.makeRotationFromEuler(Cd)),d.material.toneMapped=wn.getTransfer(T.colorSpace)!==Fn,(f!==T||p!==T.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=T,p=T.version,m=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):T&&T.isTexture&&(c===void 0&&(c=new Wo(new vP(2,2),new cc({name:"BackgroundMaterial",uniforms:kp(Lo.background.uniforms),vertexShader:Lo.background.vertexShader,fragmentShader:Lo.background.fragmentShader,side:Hu,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=T,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=wn.getTransfer(T.colorSpace)!==Fn,T.matrixAutoUpdate===!0&&T.updateMatrix(),c.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||p!==T.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,f=T,p=T.version,m=t.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function x(w,E){w.getRGB(Py,bG(t)),i.buffers.color.setClear(Py.r,Py.g,Py.b,E,s)}function M(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,E=1){o.set(w),l=E,x(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,x(o,l)},render:b,addToRenderList:v,dispose:M}}function Vue(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=p(null);let a=r,s=!1;function o(O,z,I,G,L){let B=!1;const q=f(G,I,z);a!==q&&(a=q,c(a.object)),B=m(O,G,I,L),B&&_(O,G,I,L),L!==null&&e.update(L,t.ELEMENT_ARRAY_BUFFER),(B||s)&&(s=!1,E(O,z,I,G),L!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(L).buffer))}function l(){return t.createVertexArray()}function c(O){return t.bindVertexArray(O)}function d(O){return t.deleteVertexArray(O)}function f(O,z,I){const G=I.wireframe===!0;let L=i[O.id];L===void 0&&(L={},i[O.id]=L);let B=L[z.id];B===void 0&&(B={},L[z.id]=B);let q=B[G];return q===void 0&&(q=p(l()),B[G]=q),q}function p(O){const z=[],I=[],G=[];for(let L=0;L<n;L++)z[L]=0,I[L]=0,G[L]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:I,attributeDivisors:G,object:O,attributes:{},index:null}}function m(O,z,I,G){const L=a.attributes,B=z.attributes;let q=0;const W=I.getAttributes();for(const X in W)if(W[X].location>=0){const ie=L[X];let H=B[X];if(H===void 0&&(X==="instanceMatrix"&&O.instanceMatrix&&(H=O.instanceMatrix),X==="instanceColor"&&O.instanceColor&&(H=O.instanceColor)),ie===void 0||ie.attribute!==H||H&&ie.data!==H.data)return!0;q++}return a.attributesNum!==q||a.index!==G}function _(O,z,I,G){const L={},B=z.attributes;let q=0;const W=I.getAttributes();for(const X in W)if(W[X].location>=0){let ie=B[X];ie===void 0&&(X==="instanceMatrix"&&O.instanceMatrix&&(ie=O.instanceMatrix),X==="instanceColor"&&O.instanceColor&&(ie=O.instanceColor));const H={};H.attribute=ie,ie&&ie.data&&(H.data=ie.data),L[X]=H,q++}a.attributes=L,a.attributesNum=q,a.index=G}function b(){const O=a.newAttributes;for(let z=0,I=O.length;z<I;z++)O[z]=0}function v(O){x(O,0)}function x(O,z){const I=a.newAttributes,G=a.enabledAttributes,L=a.attributeDivisors;I[O]=1,G[O]===0&&(t.enableVertexAttribArray(O),G[O]=1),L[O]!==z&&(t.vertexAttribDivisor(O,z),L[O]=z)}function M(){const O=a.newAttributes,z=a.enabledAttributes;for(let I=0,G=z.length;I<G;I++)z[I]!==O[I]&&(t.disableVertexAttribArray(I),z[I]=0)}function w(O,z,I,G,L,B,q){q===!0?t.vertexAttribIPointer(O,z,I,L,B):t.vertexAttribPointer(O,z,I,G,L,B)}function E(O,z,I,G){b();const L=G.attributes,B=I.getAttributes(),q=z.defaultAttributeValues;for(const W in B){const X=B[W];if(X.location>=0){let Q=L[W];if(Q===void 0&&(W==="instanceMatrix"&&O.instanceMatrix&&(Q=O.instanceMatrix),W==="instanceColor"&&O.instanceColor&&(Q=O.instanceColor)),Q!==void 0){const ie=Q.normalized,H=Q.itemSize,Y=e.get(Q);if(Y===void 0)continue;const se=Y.buffer,ue=Y.type,xe=Y.bytesPerElement,re=ue===t.INT||ue===t.UNSIGNED_INT||Q.gpuType===sP;if(Q.isInterleavedBufferAttribute){const ve=Q.data,Pe=ve.stride,pe=Q.offset;if(ve.isInstancedInterleavedBuffer){for(let we=0;we<X.locationSize;we++)x(X.location+we,ve.meshPerAttribute);O.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ve.meshPerAttribute*ve.count)}else for(let we=0;we<X.locationSize;we++)v(X.location+we);t.bindBuffer(t.ARRAY_BUFFER,se);for(let we=0;we<X.locationSize;we++)w(X.location+we,H/X.locationSize,ue,ie,Pe*xe,(pe+H/X.locationSize*we)*xe,re)}else{if(Q.isInstancedBufferAttribute){for(let ve=0;ve<X.locationSize;ve++)x(X.location+ve,Q.meshPerAttribute);O.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ve=0;ve<X.locationSize;ve++)v(X.location+ve);t.bindBuffer(t.ARRAY_BUFFER,se);for(let ve=0;ve<X.locationSize;ve++)w(X.location+ve,H/X.locationSize,ue,ie,H*xe,H/X.locationSize*ve*xe,re)}}else if(q!==void 0){const ie=q[W];if(ie!==void 0)switch(ie.length){case 2:t.vertexAttrib2fv(X.location,ie);break;case 3:t.vertexAttrib3fv(X.location,ie);break;case 4:t.vertexAttrib4fv(X.location,ie);break;default:t.vertexAttrib1fv(X.location,ie)}}}}M()}function T(){U();for(const O in i){const z=i[O];for(const I in z){const G=z[I];for(const L in G)d(G[L].object),delete G[L];delete z[I]}delete i[O]}}function P(O){if(i[O.id]===void 0)return;const z=i[O.id];for(const I in z){const G=z[I];for(const L in G)d(G[L].object),delete G[L];delete z[I]}delete i[O.id]}function N(O){for(const z in i){const I=i[z];if(I[O.id]===void 0)continue;const G=I[O.id];for(const L in G)d(G[L].object),delete G[L];delete I[O.id]}}function U(){R(),s=!0,a!==r&&(a=r,c(a.object))}function R(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:U,resetDefaultState:R,dispose:T,releaseStatesOfGeometry:P,releaseStatesOfProgram:N,initAttributes:b,enableAttribute:v,disableUnusedAttributes:M}}function $ue(t,e,n){let i;function r(c){i=c}function a(c,d){t.drawArrays(i,c,d),n.update(d,i,1)}function s(c,d,f){f!==0&&(t.drawArraysInstanced(i,c,d,f),n.update(d,i,f))}function o(c,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,d,0,f);let m=0;for(let _=0;_<f;_++)m+=d[_];n.update(m,i,1)}function l(c,d,f,p){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let _=0;_<c.length;_++)s(c[_],d[_],p[_]);else{m.multiDrawArraysInstancedWEBGL(i,c,0,d,0,p,0,f);let _=0;for(let b=0;b<f;b++)_+=d[b]*p[b];n.update(_,i,1)}}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Gue(t,e,n,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(N){return!(N!==ho&&i.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(N){const U=N===am&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(N!==Go&&i.convert(N)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&N!==Wl&&!U)}function l(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=n.precision!==void 0?n.precision:"highp";const d=l(c);d!==c&&($t("WebGLRenderer:",c,"not supported, using",d,"instead."),c=d);const f=n.logarithmicDepthBuffer===!0,p=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),_=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),x=t.getParameter(t.MAX_VERTEX_ATTRIBS),M=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=_>0,P=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:s,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:p,maxTextures:m,maxVertexTextures:_,maxTextureSize:b,maxCubemapSize:v,maxAttributes:x,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:E,vertexTextures:T,maxSamples:P}}function Wue(t){const e=this;let n=null,i=0,r=!1,a=!1;const s=new du,o=new sn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||i!==0||r;return r=p,i=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const _=f.clippingPlanes,b=f.clipIntersection,v=f.clipShadows,x=t.get(f);if(!r||_===null||_.length===0||a&&!v)a?d(null):c();else{const M=a?0:i,w=M*4;let E=x.clippingState||null;l.value=E,E=d(_,p,w,m);for(let T=0;T!==w;++T)E[T]=n[T];x.clippingState=E,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(f,p,m,_){const b=f!==null?f.length:0;let v=null;if(b!==0){if(v=l.value,_!==!0||v===null){const x=m+b*4,M=p.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,E=m;w!==b;++w,E+=4)s.copy(f[w]).applyMatrix4(M,o),s.normal.toArray(v,E),v[E+3]=s.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,v}}function que(t){let e=new WeakMap;function n(s,o){return o===oN?s.mapping=Pp:o===lN&&(s.mapping=Dp),s}function i(s){if(s&&s.isTexture){const o=s.mapping;if(o===oN||o===lN)if(e.has(s)){const l=e.get(s).texture;return n(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const c=new Hoe(l.height);return c.fromEquirectangularTexture(t,s),e.set(s,c),s.addEventListener("dispose",r),n(c.texture,s.mapping)}else return null}}return s}function r(s){const o=s.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function a(){e=new WeakMap}return{get:i,dispose:a}}const wu=4,Tj=[.125,.215,.35,.446,.526,.582],Bd=20,Xue=256,wg=new CG,Cj=new xn;let NA=null,RA=0,PA=0,DA=!1;const Kue=new $e;let Nj=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,i=.1,r=100,a={}){const{size:s=256,position:o=Kue}=a;NA=this._renderer.getRenderTarget(),RA=this._renderer.getActiveCubeFace(),PA=this._renderer.getActiveMipmapLevel(),DA=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(s);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,r,l,o),n>0&&this._blur(l,0,0,n),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Dj(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Pj(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(NA,RA,PA),this._renderer.xr.enabled=DA,e.scissorTest=!1,Dh(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Pp||e.mapping===Dp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),NA=this._renderer.getRenderTarget(),RA=this._renderer.getActiveCubeFace(),PA=this._renderer.getActiveMipmapLevel(),DA=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=n||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,i={magFilter:js,minFilter:js,generateMipmaps:!1,type:am,format:ho,colorSpace:Op,depthBuffer:!1},r=Rj(e,n,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Rj(e,n,i);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Yue(a)),this._blurMaterial=Que(a,e,n),this._ggxMaterial=Zue(a,e,n)}return r}_compileMaterial(e){const n=new Wo(new tl,e);this._renderer.compile(n,wg)}_sceneToCubeUV(e,n,i,r,a){const l=new Os(90,1,n,i),c=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,p=f.autoClear,m=f.toneMapping;f.getClearColor(Cj),f.toneMapping=Ru,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Wo(new gP,new mP({name:"PMREM.Background",side:Oa,depthWrite:!1,depthTest:!1})));const b=this._backgroundBox,v=b.material;let x=!1;const M=e.background;M?M.isColor&&(v.color.copy(M),e.background=null,x=!0):(v.color.copy(Cj),x=!0);for(let w=0;w<6;w++){const E=w%3;E===0?(l.up.set(0,c[w],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x+d[w],a.y,a.z)):E===1?(l.up.set(0,0,c[w]),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y+d[w],a.z)):(l.up.set(0,c[w],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y,a.z+d[w]));const T=this._cubeSize;Dh(r,E*T,w>2?T:0,T,T),f.setRenderTarget(r),x&&f.render(b,l),f.render(e,l)}f.toneMapping=m,f.autoClear=p,e.background=M}_textureToCubeUV(e,n){const i=this._renderer,r=e.mapping===Pp||e.mapping===Dp;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Dj()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Pj());const a=r?this._cubemapMaterial:this._equirectMaterial,s=this._lodMeshes[0];s.material=a;const o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;Dh(n,0,0,3*l,2*l),i.setRenderTarget(n),i.render(s,wg)}_applyPMREM(e){const n=this._renderer,i=n.autoClear;n.autoClear=!1;const r=this._lodMeshes.length;for(let a=1;a<r;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=i}_applyGGXFilter(e,n,i){const r=this._renderer,a=this._pingPongRenderTarget,s=this._ggxMaterial,o=this._lodMeshes[i];o.material=s;const l=s.uniforms,c=i/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(c*c-d*d),p=.05+c*.95,m=f*p,{_lodMax:_}=this,b=this._sizeLods[i],v=3*b*(i>_-wu?i-_+wu:0),x=4*(this._cubeSize-b);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=_-n,Dh(a,v,x,3*b,2*b),r.setRenderTarget(a),r.render(o,wg),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=_-i,Dh(e,v,x,3*b,2*b),r.setRenderTarget(e),r.render(o,wg)}_blur(e,n,i,r,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,i,r,"latitudinal",a),this._halfBlur(s,e,i,i,r,"longitudinal",a)}_halfBlur(e,n,i,r,a,s,o){const l=this._renderer,c=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&Ri("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[r];f.material=c;const p=c.uniforms,m=this._sizeLods[i]-1,_=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Bd-1),b=a/_,v=isFinite(a)?1+Math.floor(d*b):Bd;v>Bd&&$t(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Bd}`);const x=[];let M=0;for(let N=0;N<Bd;++N){const U=N/b,R=Math.exp(-U*U/2);x.push(R),N===0?M+=R:N<v&&(M+=2*R)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=x,p.latitudinal.value=s==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:w}=this;p.dTheta.value=_,p.mipInt.value=w-i;const E=this._sizeLods[r],T=3*E*(r>w-wu?r-w+wu:0),P=4*(this._cubeSize-E);Dh(n,T,P,3*E,2*E),l.setRenderTarget(n),l.render(f,wg)}};function Yue(t){const e=[],n=[],i=[];let r=t;const a=t-wu+1+Tj.length;for(let s=0;s<a;s++){const o=Math.pow(2,r);e.push(o);let l=1/o;s>t-wu?l=Tj[s-t+wu-1]:s===0&&(l=0),n.push(l);const c=1/(o-2),d=-c,f=1+c,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,_=6,b=3,v=2,x=1,M=new Float32Array(b*_*m),w=new Float32Array(v*_*m),E=new Float32Array(x*_*m);for(let P=0;P<m;P++){const N=P%3*2/3-1,U=P>2?0:-1,R=[N,U,0,N+2/3,U,0,N+2/3,U+1,0,N,U,0,N+2/3,U+1,0,N,U+1,0];M.set(R,b*_*P),w.set(p,v*_*P);const O=[P,P,P,P,P,P];E.set(O,x*_*P)}const T=new tl;T.setAttribute("position",new zs(M,b)),T.setAttribute("uv",new zs(w,v)),T.setAttribute("faceIndex",new zs(E,x)),i.push(new Wo(T,null)),r>wu&&r--}return{lodMeshes:i,sizeLods:e,sigmas:n}}function Rj(t,e,n){const i=new bf(t,e,n);return i.texture.mapping=AS,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Dh(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function Zue(t,e,n){return new cc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Xue,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:CS(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:Ql,depthTest:!1,depthWrite:!1})}function Que(t,e,n){const i=new Float32Array(Bd),r=new $e(0,1,0);return new cc({name:"SphericalGaussianBlur",defines:{n:Bd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:CS(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Ql,depthTest:!1,depthWrite:!1})}function Pj(){return new cc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:CS(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Ql,depthTest:!1,depthWrite:!1})}function Dj(){return new cc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:CS(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Ql,depthTest:!1,depthWrite:!1})}function CS(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function Jue(t){let e=new WeakMap,n=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===oN||l===lN,d=l===Pp||l===Dp;if(c||d){let f=e.get(o);const p=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==p)return n===null&&(n=new Nj(t)),f=c?n.fromEquirectangular(o,f):n.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const m=o.image;return c&&m&&m.height>0||d&&m&&r(m)?(n===null&&(n=new Nj(t)),f=c?n.fromEquirectangular(o):n.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",a),f.texture):null}}}return o}function r(o){let l=0;const c=6;for(let d=0;d<c;d++)o[d]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:s}}function ede(t){const e={};function n(i){if(e[i]!==void 0)return e[i];const r=t.getExtension(i);return e[i]=r,r}return{has:function(i){return n(i)!==null},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(i){const r=n(i);return r===null&&R0("WebGLRenderer: "+i+" extension not supported."),r}}}function tde(t,e,n,i){const r={},a=new WeakMap;function s(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const _ in p.attributes)e.remove(p.attributes[_]);p.removeEventListener("dispose",s),delete r[p.id];const m=a.get(p);m&&(e.remove(m),a.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function o(f,p){return r[p.id]===!0||(p.addEventListener("dispose",s),r[p.id]=!0,n.memory.geometries++),p}function l(f){const p=f.attributes;for(const m in p)e.update(p[m],t.ARRAY_BUFFER)}function c(f){const p=[],m=f.index,_=f.attributes.position;let b=0;if(m!==null){const M=m.array;b=m.version;for(let w=0,E=M.length;w<E;w+=3){const T=M[w+0],P=M[w+1],N=M[w+2];p.push(T,P,P,N,N,T)}}else if(_!==void 0){const M=_.array;b=_.version;for(let w=0,E=M.length/3-1;w<E;w+=3){const T=w+0,P=w+1,N=w+2;p.push(T,P,P,N,N,T)}}else return;const v=new(oG(p)?xG:gG)(p,1);v.version=b;const x=a.get(f);x&&e.remove(x),a.set(f,v)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&c(f)}else c(f);return a.get(f)}return{get:o,update:l,getWireframeAttribute:d}}function nde(t,e,n){let i;function r(p){i=p}let a,s;function o(p){a=p.type,s=p.bytesPerElement}function l(p,m){t.drawElements(i,m,a,p*s),n.update(m,i,1)}function c(p,m,_){_!==0&&(t.drawElementsInstanced(i,m,a,p*s,_),n.update(m,i,_))}function d(p,m,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,m,0,a,p,0,_);let v=0;for(let x=0;x<_;x++)v+=m[x];n.update(v,i,1)}function f(p,m,_,b){if(_===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<p.length;x++)c(p[x]/s,m[x],b[x]);else{v.multiDrawElementsInstancedWEBGL(i,m,0,a,p,0,b,0,_);let x=0;for(let M=0;M<_;M++)x+=m[M]*b[M];n.update(x,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function ide(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:Ri("WebGLInfo: Unknown draw mode:",s);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:r,update:i}}function rde(t,e,n){const i=new WeakMap,r=new Bi;function a(s,o,l){const c=s.morphTargetInfluences,d=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=d!==void 0?d.length:0;let p=i.get(o);if(p===void 0||p.count!==f){let O=function(){U.dispose(),i.delete(o),o.removeEventListener("dispose",O)};var m=O;p!==void 0&&p.texture.dispose();const _=o.morphAttributes.position!==void 0,b=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],M=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let E=0;_===!0&&(E=1),b===!0&&(E=2),v===!0&&(E=3);let T=o.attributes.position.count*E,P=1;T>e.maxTextureSize&&(P=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const N=new Float32Array(T*P*4*f),U=new fG(N,T,P,f);U.type=Wl,U.needsUpdate=!0;const R=E*4;for(let z=0;z<f;z++){const I=x[z],G=M[z],L=w[z],B=T*P*4*z;for(let q=0;q<I.count;q++){const W=q*R;_===!0&&(r.fromBufferAttribute(I,q),N[B+W+0]=r.x,N[B+W+1]=r.y,N[B+W+2]=r.z,N[B+W+3]=0),b===!0&&(r.fromBufferAttribute(G,q),N[B+W+4]=r.x,N[B+W+5]=r.y,N[B+W+6]=r.z,N[B+W+7]=0),v===!0&&(r.fromBufferAttribute(L,q),N[B+W+8]=r.x,N[B+W+9]=r.y,N[B+W+10]=r.z,N[B+W+11]=L.itemSize===4?r.w:1)}}p={count:f,texture:U,size:new nn(T,P)},i.set(o,p),o.addEventListener("dispose",O)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let _=0;for(let v=0;v<c.length;v++)_+=c[v];const b=o.morphTargetsRelative?1:1-_;l.getUniforms().setValue(t,"morphTargetBaseInfluence",b),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",p.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:a}}function ade(t,e,n,i){let r=new WeakMap;function a(l){const c=i.render.frame,d=l.geometry,f=e.get(l,d);if(r.get(f)!==c&&(e.update(f),r.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;r.get(p)!==c&&(p.update(),r.set(p,c))}return f}function s(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:a,dispose:s}}const RG=new So,Oj=new MG(1,1),PG=new fG,DG=new Eoe,OG=new SG,kj=[],Lj=[],Ij=new Float32Array(16),Uj=new Float32Array(9),jj=new Float32Array(4);function om(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let a=kj[r];if(a===void 0&&(a=new Float32Array(r),kj[r]=a),e!==0){i.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function ir(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function rr(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function NS(t,e){let n=Lj[e];n===void 0&&(n=new Int32Array(e),Lj[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function sde(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function ode(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ir(n,e))return;t.uniform2fv(this.addr,e),rr(n,e)}}function lde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ir(n,e))return;t.uniform3fv(this.addr,e),rr(n,e)}}function cde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ir(n,e))return;t.uniform4fv(this.addr,e),rr(n,e)}}function ude(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(ir(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),rr(n,e)}else{if(ir(n,i))return;jj.set(i),t.uniformMatrix2fv(this.addr,!1,jj),rr(n,i)}}function dde(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(ir(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),rr(n,e)}else{if(ir(n,i))return;Uj.set(i),t.uniformMatrix3fv(this.addr,!1,Uj),rr(n,i)}}function fde(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(ir(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),rr(n,e)}else{if(ir(n,i))return;Ij.set(i),t.uniformMatrix4fv(this.addr,!1,Ij),rr(n,i)}}function hde(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function pde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ir(n,e))return;t.uniform2iv(this.addr,e),rr(n,e)}}function mde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ir(n,e))return;t.uniform3iv(this.addr,e),rr(n,e)}}function gde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ir(n,e))return;t.uniform4iv(this.addr,e),rr(n,e)}}function xde(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function vde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ir(n,e))return;t.uniform2uiv(this.addr,e),rr(n,e)}}function yde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ir(n,e))return;t.uniform3uiv(this.addr,e),rr(n,e)}}function bde(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ir(n,e))return;t.uniform4uiv(this.addr,e),rr(n,e)}}function _de(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r);let a;this.type===t.SAMPLER_2D_SHADOW?(Oj.compareFunction=sG,a=Oj):a=RG,n.setTexture2D(e||a,r)}function Sde(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||DG,r)}function wde(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||OG,r)}function Mde(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||PG,r)}function Ede(t){switch(t){case 5126:return sde;case 35664:return ode;case 35665:return lde;case 35666:return cde;case 35674:return ude;case 35675:return dde;case 35676:return fde;case 5124:case 35670:return hde;case 35667:case 35671:return pde;case 35668:case 35672:return mde;case 35669:case 35673:return gde;case 5125:return xde;case 36294:return vde;case 36295:return yde;case 36296:return bde;case 35678:case 36198:case 36298:case 36306:case 35682:return _de;case 35679:case 36299:case 36307:return Sde;case 35680:case 36300:case 36308:case 36293:return wde;case 36289:case 36303:case 36311:case 36292:return Mde}}function Ade(t,e){t.uniform1fv(this.addr,e)}function Tde(t,e){const n=om(e,this.size,2);t.uniform2fv(this.addr,n)}function Cde(t,e){const n=om(e,this.size,3);t.uniform3fv(this.addr,n)}function Nde(t,e){const n=om(e,this.size,4);t.uniform4fv(this.addr,n)}function Rde(t,e){const n=om(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Pde(t,e){const n=om(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Dde(t,e){const n=om(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Ode(t,e){t.uniform1iv(this.addr,e)}function kde(t,e){t.uniform2iv(this.addr,e)}function Lde(t,e){t.uniform3iv(this.addr,e)}function Ide(t,e){t.uniform4iv(this.addr,e)}function Ude(t,e){t.uniform1uiv(this.addr,e)}function jde(t,e){t.uniform2uiv(this.addr,e)}function Fde(t,e){t.uniform3uiv(this.addr,e)}function zde(t,e){t.uniform4uiv(this.addr,e)}function Bde(t,e,n){const i=this.cache,r=e.length,a=NS(n,r);ir(i,a)||(t.uniform1iv(this.addr,a),rr(i,a));for(let s=0;s!==r;++s)n.setTexture2D(e[s]||RG,a[s])}function Hde(t,e,n){const i=this.cache,r=e.length,a=NS(n,r);ir(i,a)||(t.uniform1iv(this.addr,a),rr(i,a));for(let s=0;s!==r;++s)n.setTexture3D(e[s]||DG,a[s])}function Vde(t,e,n){const i=this.cache,r=e.length,a=NS(n,r);ir(i,a)||(t.uniform1iv(this.addr,a),rr(i,a));for(let s=0;s!==r;++s)n.setTextureCube(e[s]||OG,a[s])}function $de(t,e,n){const i=this.cache,r=e.length,a=NS(n,r);ir(i,a)||(t.uniform1iv(this.addr,a),rr(i,a));for(let s=0;s!==r;++s)n.setTexture2DArray(e[s]||PG,a[s])}function Gde(t){switch(t){case 5126:return Ade;case 35664:return Tde;case 35665:return Cde;case 35666:return Nde;case 35674:return Rde;case 35675:return Pde;case 35676:return Dde;case 5124:case 35670:return Ode;case 35667:case 35671:return kde;case 35668:case 35672:return Lde;case 35669:case 35673:return Ide;case 5125:return Ude;case 36294:return jde;case 36295:return Fde;case 36296:return zde;case 35678:case 36198:case 36298:case 36306:case 35682:return Bde;case 35679:case 36299:case 36307:return Hde;case 35680:case 36300:case 36308:case 36293:return Vde;case 36289:case 36303:case 36311:case 36292:return $de}}let Wde=class{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.setValue=Ede(n.type)}},qde=class{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Gde(n.type)}},Xde=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,i){const r=this.seq;for(let a=0,s=r.length;a!==s;++a){const o=r[a];o.setValue(e,n[o.id],i)}}};const OA=/(\w+)(\])?(\[|\.)?/g;function Fj(t,e){t.seq.push(e),t.map[e.id]=e}function Kde(t,e,n){const i=t.name,r=i.length;for(OA.lastIndex=0;;){const a=OA.exec(i),s=OA.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===r){Fj(n,c===void 0?new Wde(o,t,e):new qde(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new Xde(o),Fj(n,f)),n=f}}}let Qb=class{constructor(e,n){this.seq=[],this.map={};const i=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const a=e.getActiveUniform(n,r),s=e.getUniformLocation(n,a.name);Kde(a,s,this)}}setValue(e,n,i,r){const a=this.map[n];a!==void 0&&a.setValue(e,i,r)}setOptional(e,n,i){const r=n[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,n,i,r){for(let a=0,s=n.length;a!==s;++a){const o=n[a],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,n){const i=[];for(let r=0,a=e.length;r!==a;++r){const s=e[r];s.id in n&&i.push(s)}return i}};function zj(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const Yde=37297;let Zde=0;function Qde(t,e){const n=t.split(`
- `),i=[],r=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=r;s<a;s++){const o=s+1;i.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return i.join(`
- `)}const Bj=new sn;function Jde(t){wn._getMatrix(Bj,wn.workingColorSpace,t);const e=`mat3( ${Bj.elements.map(n=>n.toFixed(4))} )`;switch(wn.getTransfer(t)){case v_:return[e,"LinearTransferOETF"];case Fn:return[e,"sRGBTransferOETF"];default:return $t("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function Hj(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(i&&a==="")return"";const s=/ERROR: 0:(\d+)/.exec(a);if(s){const o=parseInt(s[1]);return n.toUpperCase()+`
- `+a+`
- `+Qde(t.getShaderSource(e),o)}else return a}function efe(t,e){const n=Jde(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function tfe(t,e){let n;switch(e){case Qse:n="Linear";break;case Jse:n="Reinhard";break;case eoe:n="Cineon";break;case toe:n="ACESFilmic";break;case ioe:n="AgX";break;case roe:n="Neutral";break;case noe:n="Custom";break;default:$t("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Dy=new $e;function nfe(){wn.getLuminanceCoefficients(Dy);const t=Dy.x.toFixed(4),e=Dy.y.toFixed(4),n=Dy.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function ife(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Hg).join(`
- `)}function rfe(t){const e=[];for(const n in t){const i=t[n];i!==!1&&e.push("#define "+n+" "+i)}return e.join(`
- `)}function afe(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const a=t.getActiveAttrib(e,r),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Hg(t){return t!==""}function Vj(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function $j(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const sfe=/^[ \t]*#include +<([\w\d./]+)>/gm;function BN(t){return t.replace(sfe,lfe)}const ofe=new Map;function lfe(t,e){let n=en[e];if(n===void 0){const i=ofe.get(e);if(i!==void 0)n=en[i],$t('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return BN(n)}const cfe=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Gj(t){return t.replace(cfe,ufe)}function ufe(t,e,n,i){let r="";for(let a=parseInt(e);a<parseInt(n);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function Wj(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function dfe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===Y$?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Pse?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Ll&&(e="SHADOWMAP_TYPE_VSM"),e}function ffe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Pp:case Dp:e="ENVMAP_TYPE_CUBE";break;case AS:e="ENVMAP_TYPE_CUBE_UV";break}return e}function hfe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Dp:e="ENVMAP_MODE_REFRACTION";break}return e}function pfe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case aP:e="ENVMAP_BLENDING_MULTIPLY";break;case Yse:e="ENVMAP_BLENDING_MIX";break;case Zse:e="ENVMAP_BLENDING_ADD";break}return e}function mfe(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function gfe(t,e,n,i){const r=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=dfe(n),c=ffe(n),d=hfe(n),f=pfe(n),p=mfe(n),m=ife(n),_=rfe(a),b=r.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(Hg).join(`
- `),v.length>0&&(v+=`
- `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(Hg).join(`
- `),x.length>0&&(x+=`
- `)):(v=[Wj(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Hg).join(`
- `),x=[Wj(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ru?"#define TONE_MAPPING":"",n.toneMapping!==Ru?en.tonemapping_pars_fragment:"",n.toneMapping!==Ru?tfe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",en.colorspace_pars_fragment,efe("linearToOutputTexel",n.outputColorSpace),nfe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Hg).join(`
- `)),s=BN(s),s=Vj(s,n),s=$j(s,n),o=BN(o),o=Vj(o,n),o=$j(o,n),s=Gj(s),o=Gj(o),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,x=["#define varying in",n.glslVersion===J4?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===J4?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+x);const w=M+v+s,E=M+x+o,T=zj(r,r.VERTEX_SHADER,w),P=zj(r,r.FRAGMENT_SHADER,E);r.attachShader(b,T),r.attachShader(b,P),n.index0AttributeName!==void 0?r.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&r.bindAttribLocation(b,0,"position"),r.linkProgram(b);function N(z){if(t.debug.checkShaderErrors){const I=r.getProgramInfoLog(b)||"",G=r.getShaderInfoLog(T)||"",L=r.getShaderInfoLog(P)||"",B=I.trim(),q=G.trim(),W=L.trim();let X=!0,Q=!0;if(r.getProgramParameter(b,r.LINK_STATUS)===!1)if(X=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(r,b,T,P);else{const ie=Hj(r,T,"vertex"),H=Hj(r,P,"fragment");Ri("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(b,r.VALIDATE_STATUS)+`
- Material Name: `+z.name+`
- Material Type: `+z.type+`
- Program Info Log: `+B+`
- `+ie+`
- `+H)}else B!==""?$t("WebGLProgram: Program Info Log:",B):(q===""||W==="")&&(Q=!1);Q&&(z.diagnostics={runnable:X,programLog:B,vertexShader:{log:q,prefix:v},fragmentShader:{log:W,prefix:x}})}r.deleteShader(T),r.deleteShader(P),U=new Qb(r,b),R=afe(r,b)}let U;this.getUniforms=function(){return U===void 0&&N(this),U};let R;this.getAttributes=function(){return R===void 0&&N(this),R};let O=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return O===!1&&(O=r.getProgramParameter(b,Yde)),O},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Zde++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=T,this.fragmentShader=P,this}let xfe=0,vfe=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(n),a=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(r)===!1&&(s.add(r),r.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const i of n)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let i=n.get(e);return i===void 0&&(i=new Set,n.set(e,i)),i}_getShaderStage(e){const n=this.shaderCache;let i=n.get(e);return i===void 0&&(i=new yfe(e),n.set(e,i)),i}},yfe=class{constructor(e){this.id=xfe++,this.code=e,this.usedTimes=0}};function bfe(t,e,n,i,r,a,s){const o=new pG,l=new vfe,c=new Set,d=[],f=r.logarithmicDepthBuffer,p=r.vertexTextures;let m=r.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(R){return c.add(R),R===0?"uv":`uv${R}`}function v(R,O,z,I,G){const L=I.fog,B=G.geometry,q=R.isMeshStandardMaterial?I.environment:null,W=(R.isMeshStandardMaterial?n:e).get(R.envMap||q),X=W&&W.mapping===AS?W.image.height:null,Q=_[R.type];R.precision!==null&&(m=r.getMaxPrecision(R.precision),m!==R.precision&&$t("WebGLProgram.getParameters:",R.precision,"not supported, using",m,"instead."));const ie=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,H=ie!==void 0?ie.length:0;let Y=0;B.morphAttributes.position!==void 0&&(Y=1),B.morphAttributes.normal!==void 0&&(Y=2),B.morphAttributes.color!==void 0&&(Y=3);let se,ue,xe,re;if(Q){const Nt=Lo[Q];se=Nt.vertexShader,ue=Nt.fragmentShader}else se=R.vertexShader,ue=R.fragmentShader,l.update(R),xe=l.getVertexShaderID(R),re=l.getFragmentShaderID(R);const ve=t.getRenderTarget(),Pe=t.state.buffers.depth.getReversed(),pe=G.isInstancedMesh===!0,we=G.isBatchedMesh===!0,ze=!!R.map,ce=!!R.matcap,ft=!!W,F=!!R.aoMap,$=!!R.lightMap,ae=!!R.bumpMap,J=!!R.normalMap,ee=!!R.displacementMap,oe=!!R.emissiveMap,De=!!R.metalnessMap,Ne=!!R.roughnessMap,te=R.anisotropy>0,j=R.clearcoat>0,k=R.dispersion>0,K=R.iridescence>0,me=R.sheen>0,ye=R.transmission>0,he=te&&!!R.anisotropyMap,Ye=j&&!!R.clearcoatMap,Le=j&&!!R.clearcoatNormalMap,qe=j&&!!R.clearcoatRoughnessMap,rt=K&&!!R.iridescenceMap,Ie=K&&!!R.iridescenceThicknessMap,Re=me&&!!R.sheenColorMap,ht=me&&!!R.sheenRoughnessMap,tt=!!R.specularMap,et=!!R.specularColorMap,ct=!!R.specularIntensityMap,de=ye&&!!R.transmissionMap,nt=ye&&!!R.thicknessMap,fe=!!R.gradientMap,ke=!!R.alphaMap,Me=R.alphaTest>0,ge=!!R.alphaHash,Be=!!R.extensions;let lt=Ru;R.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(lt=t.toneMapping);const bt={shaderID:Q,shaderType:R.type,shaderName:R.name,vertexShader:se,fragmentShader:ue,defines:R.defines,customVertexShaderID:xe,customFragmentShaderID:re,isRawShaderMaterial:R.isRawShaderMaterial===!0,glslVersion:R.glslVersion,precision:m,batching:we,batchingColor:we&&G._colorsTexture!==null,instancing:pe,instancingColor:pe&&G.instanceColor!==null,instancingMorph:pe&&G.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:Op,alphaToCoverage:!!R.alphaToCoverage,map:ze,matcap:ce,envMap:ft,envMapMode:ft&&W.mapping,envMapCubeUVHeight:X,aoMap:F,lightMap:$,bumpMap:ae,normalMap:J,displacementMap:p&&ee,emissiveMap:oe,normalMapObjectSpace:J&&R.normalMapType===loe,normalMapTangentSpace:J&&R.normalMapType===aG,metalnessMap:De,roughnessMap:Ne,anisotropy:te,anisotropyMap:he,clearcoat:j,clearcoatMap:Ye,clearcoatNormalMap:Le,clearcoatRoughnessMap:qe,dispersion:k,iridescence:K,iridescenceMap:rt,iridescenceThicknessMap:Ie,sheen:me,sheenColorMap:Re,sheenRoughnessMap:ht,specularMap:tt,specularColorMap:et,specularIntensityMap:ct,transmission:ye,transmissionMap:de,thicknessMap:nt,gradientMap:fe,opaque:R.transparent===!1&&R.blending===vp&&R.alphaToCoverage===!1,alphaMap:ke,alphaTest:Me,alphaHash:ge,combine:R.combine,mapUv:ze&&b(R.map.channel),aoMapUv:F&&b(R.aoMap.channel),lightMapUv:$&&b(R.lightMap.channel),bumpMapUv:ae&&b(R.bumpMap.channel),normalMapUv:J&&b(R.normalMap.channel),displacementMapUv:ee&&b(R.displacementMap.channel),emissiveMapUv:oe&&b(R.emissiveMap.channel),metalnessMapUv:De&&b(R.metalnessMap.channel),roughnessMapUv:Ne&&b(R.roughnessMap.channel),anisotropyMapUv:he&&b(R.anisotropyMap.channel),clearcoatMapUv:Ye&&b(R.clearcoatMap.channel),clearcoatNormalMapUv:Le&&b(R.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:qe&&b(R.clearcoatRoughnessMap.channel),iridescenceMapUv:rt&&b(R.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&b(R.iridescenceThicknessMap.channel),sheenColorMapUv:Re&&b(R.sheenColorMap.channel),sheenRoughnessMapUv:ht&&b(R.sheenRoughnessMap.channel),specularMapUv:tt&&b(R.specularMap.channel),specularColorMapUv:et&&b(R.specularColorMap.channel),specularIntensityMapUv:ct&&b(R.specularIntensityMap.channel),transmissionMapUv:de&&b(R.transmissionMap.channel),thicknessMapUv:nt&&b(R.thicknessMap.channel),alphaMapUv:ke&&b(R.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(J||te),vertexColors:R.vertexColors,vertexAlphas:R.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:G.isPoints===!0&&!!B.attributes.uv&&(ze||ke),fog:!!L,useFog:R.fog===!0,fogExp2:!!L&&L.isFogExp2,flatShading:R.flatShading===!0&&R.wireframe===!1,sizeAttenuation:R.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Pe,skinning:G.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:Y,numDirLights:O.directional.length,numPointLights:O.point.length,numSpotLights:O.spot.length,numSpotLightMaps:O.spotLightMap.length,numRectAreaLights:O.rectArea.length,numHemiLights:O.hemi.length,numDirLightShadows:O.directionalShadowMap.length,numPointLightShadows:O.pointShadowMap.length,numSpotLightShadows:O.spotShadowMap.length,numSpotLightShadowsWithMaps:O.numSpotLightShadowsWithMaps,numLightProbes:O.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:R.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:lt,decodeVideoTexture:ze&&R.map.isVideoTexture===!0&&wn.getTransfer(R.map.colorSpace)===Fn,decodeVideoTextureEmissive:oe&&R.emissiveMap.isVideoTexture===!0&&wn.getTransfer(R.emissiveMap.colorSpace)===Fn,premultipliedAlpha:R.premultipliedAlpha,doubleSided:R.side===Io,flipSided:R.side===Oa,useDepthPacking:R.depthPacking>=0,depthPacking:R.depthPacking||0,index0AttributeName:R.index0AttributeName,extensionClipCullDistance:Be&&R.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Be&&R.extensions.multiDraw===!0||we)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:R.customProgramCacheKey()};return bt.vertexUv1s=c.has(1),bt.vertexUv2s=c.has(2),bt.vertexUv3s=c.has(3),c.clear(),bt}function x(R){const O=[];if(R.shaderID?O.push(R.shaderID):(O.push(R.customVertexShaderID),O.push(R.customFragmentShaderID)),R.defines!==void 0)for(const z in R.defines)O.push(z),O.push(R.defines[z]);return R.isRawShaderMaterial===!1&&(M(O,R),w(O,R),O.push(t.outputColorSpace)),O.push(R.customProgramCacheKey),O.join()}function M(R,O){R.push(O.precision),R.push(O.outputColorSpace),R.push(O.envMapMode),R.push(O.envMapCubeUVHeight),R.push(O.mapUv),R.push(O.alphaMapUv),R.push(O.lightMapUv),R.push(O.aoMapUv),R.push(O.bumpMapUv),R.push(O.normalMapUv),R.push(O.displacementMapUv),R.push(O.emissiveMapUv),R.push(O.metalnessMapUv),R.push(O.roughnessMapUv),R.push(O.anisotropyMapUv),R.push(O.clearcoatMapUv),R.push(O.clearcoatNormalMapUv),R.push(O.clearcoatRoughnessMapUv),R.push(O.iridescenceMapUv),R.push(O.iridescenceThicknessMapUv),R.push(O.sheenColorMapUv),R.push(O.sheenRoughnessMapUv),R.push(O.specularMapUv),R.push(O.specularColorMapUv),R.push(O.specularIntensityMapUv),R.push(O.transmissionMapUv),R.push(O.thicknessMapUv),R.push(O.combine),R.push(O.fogExp2),R.push(O.sizeAttenuation),R.push(O.morphTargetsCount),R.push(O.morphAttributeCount),R.push(O.numDirLights),R.push(O.numPointLights),R.push(O.numSpotLights),R.push(O.numSpotLightMaps),R.push(O.numHemiLights),R.push(O.numRectAreaLights),R.push(O.numDirLightShadows),R.push(O.numPointLightShadows),R.push(O.numSpotLightShadows),R.push(O.numSpotLightShadowsWithMaps),R.push(O.numLightProbes),R.push(O.shadowMapType),R.push(O.toneMapping),R.push(O.numClippingPlanes),R.push(O.numClipIntersection),R.push(O.depthPacking)}function w(R,O){o.disableAll(),O.supportsVertexTextures&&o.enable(0),O.instancing&&o.enable(1),O.instancingColor&&o.enable(2),O.instancingMorph&&o.enable(3),O.matcap&&o.enable(4),O.envMap&&o.enable(5),O.normalMapObjectSpace&&o.enable(6),O.normalMapTangentSpace&&o.enable(7),O.clearcoat&&o.enable(8),O.iridescence&&o.enable(9),O.alphaTest&&o.enable(10),O.vertexColors&&o.enable(11),O.vertexAlphas&&o.enable(12),O.vertexUv1s&&o.enable(13),O.vertexUv2s&&o.enable(14),O.vertexUv3s&&o.enable(15),O.vertexTangents&&o.enable(16),O.anisotropy&&o.enable(17),O.alphaHash&&o.enable(18),O.batching&&o.enable(19),O.dispersion&&o.enable(20),O.batchingColor&&o.enable(21),O.gradientMap&&o.enable(22),R.push(o.mask),o.disableAll(),O.fog&&o.enable(0),O.useFog&&o.enable(1),O.flatShading&&o.enable(2),O.logarithmicDepthBuffer&&o.enable(3),O.reversedDepthBuffer&&o.enable(4),O.skinning&&o.enable(5),O.morphTargets&&o.enable(6),O.morphNormals&&o.enable(7),O.morphColors&&o.enable(8),O.premultipliedAlpha&&o.enable(9),O.shadowMapEnabled&&o.enable(10),O.doubleSided&&o.enable(11),O.flipSided&&o.enable(12),O.useDepthPacking&&o.enable(13),O.dithering&&o.enable(14),O.transmission&&o.enable(15),O.sheen&&o.enable(16),O.opaque&&o.enable(17),O.pointsUvs&&o.enable(18),O.decodeVideoTexture&&o.enable(19),O.decodeVideoTextureEmissive&&o.enable(20),O.alphaToCoverage&&o.enable(21),R.push(o.mask)}function E(R){const O=_[R.type];let z;if(O){const I=Lo[O];z=joe.clone(I.uniforms)}else z=R.uniforms;return z}function T(R,O){let z;for(let I=0,G=d.length;I<G;I++){const L=d[I];if(L.cacheKey===O){z=L,++z.usedTimes;break}}return z===void 0&&(z=new gfe(t,O,R,a),d.push(z)),z}function P(R){if(--R.usedTimes===0){const O=d.indexOf(R);d[O]=d[d.length-1],d.pop(),R.destroy()}}function N(R){l.remove(R)}function U(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:E,acquireProgram:T,releaseProgram:P,releaseShaderCache:N,programs:d,dispose:U}}function _fe(){let t=new WeakMap;function e(s){return t.has(s)}function n(s){let o=t.get(s);return o===void 0&&(o={},t.set(s,o)),o}function i(s){t.delete(s)}function r(s,o,l){t.get(s)[o]=l}function a(){t=new WeakMap}return{has:e,get:n,remove:i,update:r,dispose:a}}function Sfe(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function qj(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function Xj(){const t=[];let e=0;const n=[],i=[],r=[];function a(){e=0,n.length=0,i.length=0,r.length=0}function s(f,p,m,_,b,v){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:p,material:m,groupOrder:_,renderOrder:f.renderOrder,z:b,group:v},t[e]=x):(x.id=f.id,x.object=f,x.geometry=p,x.material=m,x.groupOrder=_,x.renderOrder=f.renderOrder,x.z=b,x.group=v),e++,x}function o(f,p,m,_,b,v){const x=s(f,p,m,_,b,v);m.transmission>0?i.push(x):m.transparent===!0?r.push(x):n.push(x)}function l(f,p,m,_,b,v){const x=s(f,p,m,_,b,v);m.transmission>0?i.unshift(x):m.transparent===!0?r.unshift(x):n.unshift(x)}function c(f,p){n.length>1&&n.sort(f||Sfe),i.length>1&&i.sort(p||qj),r.length>1&&r.sort(p||qj)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:a,push:o,unshift:l,finish:d,sort:c}}function wfe(){let t=new WeakMap;function e(i,r){const a=t.get(i);let s;return a===void 0?(s=new Xj,t.set(i,[s])):r>=a.length?(s=new Xj,a.push(s)):s=a[r],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function Mfe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new $e,color:new xn};break;case"SpotLight":n={position:new $e,direction:new $e,color:new xn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new $e,color:new xn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new $e,skyColor:new xn,groundColor:new xn};break;case"RectAreaLight":n={color:new xn,position:new $e,halfWidth:new $e,halfHeight:new $e};break}return t[e.id]=n,n}}}function Efe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Afe=0;function Tfe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Cfe(t){const e=new Mfe,n=Efe(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new $e);const r=new $e,a=new Gi,s=new Gi;function o(c){let d=0,f=0,p=0;for(let R=0;R<9;R++)i.probe[R].set(0,0,0);let m=0,_=0,b=0,v=0,x=0,M=0,w=0,E=0,T=0,P=0,N=0;c.sort(Tfe);for(let R=0,O=c.length;R<O;R++){const z=c[R],I=z.color,G=z.intensity,L=z.distance,B=z.shadow&&z.shadow.map?z.shadow.map.texture:null;if(z.isAmbientLight)d+=I.r*G,f+=I.g*G,p+=I.b*G;else if(z.isLightProbe){for(let q=0;q<9;q++)i.probe[q].addScaledVector(z.sh.coefficients[q],G);N++}else if(z.isDirectionalLight){const q=e.get(z);if(q.color.copy(z.color).multiplyScalar(z.intensity),z.castShadow){const W=z.shadow,X=n.get(z);X.shadowIntensity=W.intensity,X.shadowBias=W.bias,X.shadowNormalBias=W.normalBias,X.shadowRadius=W.radius,X.shadowMapSize=W.mapSize,i.directionalShadow[m]=X,i.directionalShadowMap[m]=B,i.directionalShadowMatrix[m]=z.shadow.matrix,M++}i.directional[m]=q,m++}else if(z.isSpotLight){const q=e.get(z);q.position.setFromMatrixPosition(z.matrixWorld),q.color.copy(I).multiplyScalar(G),q.distance=L,q.coneCos=Math.cos(z.angle),q.penumbraCos=Math.cos(z.angle*(1-z.penumbra)),q.decay=z.decay,i.spot[b]=q;const W=z.shadow;if(z.map&&(i.spotLightMap[T]=z.map,T++,W.updateMatrices(z),z.castShadow&&P++),i.spotLightMatrix[b]=W.matrix,z.castShadow){const X=n.get(z);X.shadowIntensity=W.intensity,X.shadowBias=W.bias,X.shadowNormalBias=W.normalBias,X.shadowRadius=W.radius,X.shadowMapSize=W.mapSize,i.spotShadow[b]=X,i.spotShadowMap[b]=B,E++}b++}else if(z.isRectAreaLight){const q=e.get(z);q.color.copy(I).multiplyScalar(G),q.halfWidth.set(z.width*.5,0,0),q.halfHeight.set(0,z.height*.5,0),i.rectArea[v]=q,v++}else if(z.isPointLight){const q=e.get(z);if(q.color.copy(z.color).multiplyScalar(z.intensity),q.distance=z.distance,q.decay=z.decay,z.castShadow){const W=z.shadow,X=n.get(z);X.shadowIntensity=W.intensity,X.shadowBias=W.bias,X.shadowNormalBias=W.normalBias,X.shadowRadius=W.radius,X.shadowMapSize=W.mapSize,X.shadowCameraNear=W.camera.near,X.shadowCameraFar=W.camera.far,i.pointShadow[_]=X,i.pointShadowMap[_]=B,i.pointShadowMatrix[_]=z.shadow.matrix,w++}i.point[_]=q,_++}else if(z.isHemisphereLight){const q=e.get(z);q.skyColor.copy(z.color).multiplyScalar(G),q.groundColor.copy(z.groundColor).multiplyScalar(G),i.hemi[x]=q,x++}}v>0&&(t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=St.LTC_FLOAT_1,i.rectAreaLTC2=St.LTC_FLOAT_2):(i.rectAreaLTC1=St.LTC_HALF_1,i.rectAreaLTC2=St.LTC_HALF_2)),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=p;const U=i.hash;(U.directionalLength!==m||U.pointLength!==_||U.spotLength!==b||U.rectAreaLength!==v||U.hemiLength!==x||U.numDirectionalShadows!==M||U.numPointShadows!==w||U.numSpotShadows!==E||U.numSpotMaps!==T||U.numLightProbes!==N)&&(i.directional.length=m,i.spot.length=b,i.rectArea.length=v,i.point.length=_,i.hemi.length=x,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=E,i.spotShadowMap.length=E,i.directionalShadowMatrix.length=M,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=E+T-P,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=P,i.numLightProbes=N,U.directionalLength=m,U.pointLength=_,U.spotLength=b,U.rectAreaLength=v,U.hemiLength=x,U.numDirectionalShadows=M,U.numPointShadows=w,U.numSpotShadows=E,U.numSpotMaps=T,U.numLightProbes=N,i.version=Afe++)}function l(c,d){let f=0,p=0,m=0,_=0,b=0;const v=d.matrixWorldInverse;for(let x=0,M=c.length;x<M;x++){const w=c[x];if(w.isDirectionalLight){const E=i.directional[f];E.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(v),f++}else if(w.isSpotLight){const E=i.spot[m];E.position.setFromMatrixPosition(w.matrixWorld),E.position.applyMatrix4(v),E.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(v),m++}else if(w.isRectAreaLight){const E=i.rectArea[_];E.position.setFromMatrixPosition(w.matrixWorld),E.position.applyMatrix4(v),s.identity(),a.copy(w.matrixWorld),a.premultiply(v),s.extractRotation(a),E.halfWidth.set(w.width*.5,0,0),E.halfHeight.set(0,w.height*.5,0),E.halfWidth.applyMatrix4(s),E.halfHeight.applyMatrix4(s),_++}else if(w.isPointLight){const E=i.point[p];E.position.setFromMatrixPosition(w.matrixWorld),E.position.applyMatrix4(v),p++}else if(w.isHemisphereLight){const E=i.hemi[b];E.direction.setFromMatrixPosition(w.matrixWorld),E.direction.transformDirection(v),b++}}}return{setup:o,setupView:l,state:i}}function Kj(t){const e=new Cfe(t),n=[],i=[];function r(d){c.camera=d,n.length=0,i.length=0}function a(d){n.push(d)}function s(d){i.push(d)}function o(){e.setup(n)}function l(d){e.setupView(n,d)}const c={lightsArray:n,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:a,pushShadow:s}}function Nfe(t){let e=new WeakMap;function n(r,a=0){const s=e.get(r);let o;return s===void 0?(o=new Kj(t),e.set(r,[o])):a>=s.length?(o=new Kj(t),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:n,dispose:i}}const Rfe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,Pfe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function Dfe(t,e,n){let i=new xP;const r=new nn,a=new nn,s=new Bi,o=new Qoe({depthPacking:ooe}),l=new Joe,c={},d=n.maxTextureSize,f={[Hu]:Oa,[Oa]:Hu,[Io]:Io},p=new cc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new nn},radius:{value:4}},vertexShader:Rfe,fragmentShader:Pfe}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const _=new tl;_.setAttribute("position",new zs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Wo(_,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Y$;let x=this.type;this.render=function(P,N,U){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||P.length===0)return;const R=t.getRenderTarget(),O=t.getActiveCubeFace(),z=t.getActiveMipmapLevel(),I=t.state;I.setBlending(Ql),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const G=x!==Ll&&this.type===Ll,L=x===Ll&&this.type!==Ll;for(let B=0,q=P.length;B<q;B++){const W=P[B],X=W.shadow;if(X===void 0){$t("WebGLShadowMap:",W,"has no shadow.");continue}if(X.autoUpdate===!1&&X.needsUpdate===!1)continue;r.copy(X.mapSize);const Q=X.getFrameExtents();if(r.multiply(Q),a.copy(X.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/Q.x),r.x=a.x*Q.x,X.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/Q.y),r.y=a.y*Q.y,X.mapSize.y=a.y)),X.map===null||G===!0||L===!0){const H=this.type!==Ll?{minFilter:as,magFilter:as}:{};X.map!==null&&X.map.dispose(),X.map=new bf(r.x,r.y,H),X.map.texture.name=W.name+".shadowMap",X.camera.updateProjectionMatrix()}t.setRenderTarget(X.map),t.clear();const ie=X.getViewportCount();for(let H=0;H<ie;H++){const Y=X.getViewport(H);s.set(a.x*Y.x,a.y*Y.y,a.x*Y.z,a.y*Y.w),I.viewport(s),X.updateMatrices(W,H),i=X.getFrustum(),E(N,U,X.camera,W,this.type)}X.isPointLightShadow!==!0&&this.type===Ll&&M(X,U),X.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(R,O,z)};function M(P,N){const U=e.update(b);p.defines.VSM_SAMPLES!==P.blurSamples&&(p.defines.VSM_SAMPLES=P.blurSamples,m.defines.VSM_SAMPLES=P.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new bf(r.x,r.y)),p.uniforms.shadow_pass.value=P.map.texture,p.uniforms.resolution.value=P.mapSize,p.uniforms.radius.value=P.radius,t.setRenderTarget(P.mapPass),t.clear(),t.renderBufferDirect(N,null,U,p,b,null),m.uniforms.shadow_pass.value=P.mapPass.texture,m.uniforms.resolution.value=P.mapSize,m.uniforms.radius.value=P.radius,t.setRenderTarget(P.map),t.clear(),t.renderBufferDirect(N,null,U,m,b,null)}function w(P,N,U,R){let O=null;const z=U.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(z!==void 0)O=z;else if(O=U.isPointLight===!0?l:o,t.localClippingEnabled&&N.clipShadows===!0&&Array.isArray(N.clippingPlanes)&&N.clippingPlanes.length!==0||N.displacementMap&&N.displacementScale!==0||N.alphaMap&&N.alphaTest>0||N.map&&N.alphaTest>0||N.alphaToCoverage===!0){const I=O.uuid,G=N.uuid;let L=c[I];L===void 0&&(L={},c[I]=L);let B=L[G];B===void 0&&(B=O.clone(),L[G]=B,N.addEventListener("dispose",T)),O=B}if(O.visible=N.visible,O.wireframe=N.wireframe,R===Ll?O.side=N.shadowSide!==null?N.shadowSide:N.side:O.side=N.shadowSide!==null?N.shadowSide:f[N.side],O.alphaMap=N.alphaMap,O.alphaTest=N.alphaToCoverage===!0?.5:N.alphaTest,O.map=N.map,O.clipShadows=N.clipShadows,O.clippingPlanes=N.clippingPlanes,O.clipIntersection=N.clipIntersection,O.displacementMap=N.displacementMap,O.displacementScale=N.displacementScale,O.displacementBias=N.displacementBias,O.wireframeLinewidth=N.wireframeLinewidth,O.linewidth=N.linewidth,U.isPointLight===!0&&O.isMeshDistanceMaterial===!0){const I=t.properties.get(O);I.light=U}return O}function E(P,N,U,R,O){if(P.visible===!1)return;if(P.layers.test(N.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&O===Ll)&&(!P.frustumCulled||i.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,P.matrixWorld);const G=e.update(P),L=P.material;if(Array.isArray(L)){const B=G.groups;for(let q=0,W=B.length;q<W;q++){const X=B[q],Q=L[X.materialIndex];if(Q&&Q.visible){const ie=w(P,Q,R,O);P.onBeforeShadow(t,P,N,U,G,ie,X),t.renderBufferDirect(U,null,G,ie,P,X),P.onAfterShadow(t,P,N,U,G,ie,X)}}}else if(L.visible){const B=w(P,L,R,O);P.onBeforeShadow(t,P,N,U,G,B,null),t.renderBufferDirect(U,null,G,B,P,null),P.onAfterShadow(t,P,N,U,G,B,null)}}const I=P.children;for(let G=0,L=I.length;G<L;G++)E(I[G],N,U,R,O)}function T(P){P.target.removeEventListener("dispose",T);for(const U in c){const R=c[U],O=P.target.uuid;O in R&&(R[O].dispose(),delete R[O])}}}const Ofe={[eN]:tN,[nN]:aN,[iN]:sN,[Rp]:rN,[tN]:eN,[aN]:nN,[sN]:iN,[rN]:Rp};function kfe(t,e){function n(){let de=!1;const nt=new Bi;let fe=null;const ke=new Bi(0,0,0,0);return{setMask:function(Me){fe!==Me&&!de&&(t.colorMask(Me,Me,Me,Me),fe=Me)},setLocked:function(Me){de=Me},setClear:function(Me,ge,Be,lt,bt){bt===!0&&(Me*=lt,ge*=lt,Be*=lt),nt.set(Me,ge,Be,lt),ke.equals(nt)===!1&&(t.clearColor(Me,ge,Be,lt),ke.copy(nt))},reset:function(){de=!1,fe=null,ke.set(-1,0,0,0)}}}function i(){let de=!1,nt=!1,fe=null,ke=null,Me=null;return{setReversed:function(ge){if(nt!==ge){const Be=e.get("EXT_clip_control");ge?Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.ZERO_TO_ONE_EXT):Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.NEGATIVE_ONE_TO_ONE_EXT),nt=ge;const lt=Me;Me=null,this.setClear(lt)}},getReversed:function(){return nt},setTest:function(ge){ge?ve(t.DEPTH_TEST):Pe(t.DEPTH_TEST)},setMask:function(ge){fe!==ge&&!de&&(t.depthMask(ge),fe=ge)},setFunc:function(ge){if(nt&&(ge=Ofe[ge]),ke!==ge){switch(ge){case eN:t.depthFunc(t.NEVER);break;case tN:t.depthFunc(t.ALWAYS);break;case nN:t.depthFunc(t.LESS);break;case Rp:t.depthFunc(t.LEQUAL);break;case iN:t.depthFunc(t.EQUAL);break;case rN:t.depthFunc(t.GEQUAL);break;case aN:t.depthFunc(t.GREATER);break;case sN:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ke=ge}},setLocked:function(ge){de=ge},setClear:function(ge){Me!==ge&&(nt&&(ge=1-ge),t.clearDepth(ge),Me=ge)},reset:function(){de=!1,fe=null,ke=null,Me=null,nt=!1}}}function r(){let de=!1,nt=null,fe=null,ke=null,Me=null,ge=null,Be=null,lt=null,bt=null;return{setTest:function(Nt){de||(Nt?ve(t.STENCIL_TEST):Pe(t.STENCIL_TEST))},setMask:function(Nt){nt!==Nt&&!de&&(t.stencilMask(Nt),nt=Nt)},setFunc:function(Nt,an,Dt){(fe!==Nt||ke!==an||Me!==Dt)&&(t.stencilFunc(Nt,an,Dt),fe=Nt,ke=an,Me=Dt)},setOp:function(Nt,an,Dt){(ge!==Nt||Be!==an||lt!==Dt)&&(t.stencilOp(Nt,an,Dt),ge=Nt,Be=an,lt=Dt)},setLocked:function(Nt){de=Nt},setClear:function(Nt){bt!==Nt&&(t.clearStencil(Nt),bt=Nt)},reset:function(){de=!1,nt=null,fe=null,ke=null,Me=null,ge=null,Be=null,lt=null,bt=null}}}const a=new n,s=new i,o=new r,l=new WeakMap,c=new WeakMap;let d={},f={},p=new WeakMap,m=[],_=null,b=!1,v=null,x=null,M=null,w=null,E=null,T=null,P=null,N=new xn(0,0,0),U=0,R=!1,O=null,z=null,I=null,G=null,L=null;const B=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let q=!1,W=0;const X=t.getParameter(t.VERSION);X.indexOf("WebGL")!==-1?(W=parseFloat(/^WebGL (\d)/.exec(X)[1]),q=W>=1):X.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),q=W>=2);let Q=null,ie={};const H=t.getParameter(t.SCISSOR_BOX),Y=t.getParameter(t.VIEWPORT),se=new Bi().fromArray(H),ue=new Bi().fromArray(Y);function xe(de,nt,fe,ke){const Me=new Uint8Array(4),ge=t.createTexture();t.bindTexture(de,ge),t.texParameteri(de,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(de,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Be=0;Be<fe;Be++)de===t.TEXTURE_3D||de===t.TEXTURE_2D_ARRAY?t.texImage3D(nt,0,t.RGBA,1,1,ke,0,t.RGBA,t.UNSIGNED_BYTE,Me):t.texImage2D(nt+Be,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Me);return ge}const re={};re[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),re[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),re[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ve(t.DEPTH_TEST),s.setFunc(Rp),ae(!1),J(q4),ve(t.CULL_FACE),F(Ql);function ve(de){d[de]!==!0&&(t.enable(de),d[de]=!0)}function Pe(de){d[de]!==!1&&(t.disable(de),d[de]=!1)}function pe(de,nt){return f[de]!==nt?(t.bindFramebuffer(de,nt),f[de]=nt,de===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=nt),de===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=nt),!0):!1}function we(de,nt){let fe=m,ke=!1;if(de){fe=p.get(nt),fe===void 0&&(fe=[],p.set(nt,fe));const Me=de.textures;if(fe.length!==Me.length||fe[0]!==t.COLOR_ATTACHMENT0){for(let ge=0,Be=Me.length;ge<Be;ge++)fe[ge]=t.COLOR_ATTACHMENT0+ge;fe.length=Me.length,ke=!0}}else fe[0]!==t.BACK&&(fe[0]=t.BACK,ke=!0);ke&&t.drawBuffers(fe)}function ze(de){return _!==de?(t.useProgram(de),_=de,!0):!1}const ce={[zd]:t.FUNC_ADD,[Ose]:t.FUNC_SUBTRACT,[kse]:t.FUNC_REVERSE_SUBTRACT};ce[Lse]=t.MIN,ce[Ise]=t.MAX;const ft={[Use]:t.ZERO,[jse]:t.ONE,[Fse]:t.SRC_COLOR,[QC]:t.SRC_ALPHA,[Gse]:t.SRC_ALPHA_SATURATE,[Vse]:t.DST_COLOR,[Bse]:t.DST_ALPHA,[zse]:t.ONE_MINUS_SRC_COLOR,[JC]:t.ONE_MINUS_SRC_ALPHA,[$se]:t.ONE_MINUS_DST_COLOR,[Hse]:t.ONE_MINUS_DST_ALPHA,[Wse]:t.CONSTANT_COLOR,[qse]:t.ONE_MINUS_CONSTANT_COLOR,[Xse]:t.CONSTANT_ALPHA,[Kse]:t.ONE_MINUS_CONSTANT_ALPHA};function F(de,nt,fe,ke,Me,ge,Be,lt,bt,Nt){if(de===Ql){b===!0&&(Pe(t.BLEND),b=!1);return}if(b===!1&&(ve(t.BLEND),b=!0),de!==Dse){if(de!==v||Nt!==R){if((x!==zd||E!==zd)&&(t.blendEquation(t.FUNC_ADD),x=zd,E=zd),Nt)switch(de){case vp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case X4:t.blendFunc(t.ONE,t.ONE);break;case K4:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case Y4:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ri("WebGLState: Invalid blending: ",de);break}else switch(de){case vp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case X4:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case K4:Ri("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Y4:Ri("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ri("WebGLState: Invalid blending: ",de);break}M=null,w=null,T=null,P=null,N.set(0,0,0),U=0,v=de,R=Nt}return}Me=Me||nt,ge=ge||fe,Be=Be||ke,(nt!==x||Me!==E)&&(t.blendEquationSeparate(ce[nt],ce[Me]),x=nt,E=Me),(fe!==M||ke!==w||ge!==T||Be!==P)&&(t.blendFuncSeparate(ft[fe],ft[ke],ft[ge],ft[Be]),M=fe,w=ke,T=ge,P=Be),(lt.equals(N)===!1||bt!==U)&&(t.blendColor(lt.r,lt.g,lt.b,bt),N.copy(lt),U=bt),v=de,R=!1}function $(de,nt){de.side===Io?Pe(t.CULL_FACE):ve(t.CULL_FACE);let fe=de.side===Oa;nt&&(fe=!fe),ae(fe),de.blending===vp&&de.transparent===!1?F(Ql):F(de.blending,de.blendEquation,de.blendSrc,de.blendDst,de.blendEquationAlpha,de.blendSrcAlpha,de.blendDstAlpha,de.blendColor,de.blendAlpha,de.premultipliedAlpha),s.setFunc(de.depthFunc),s.setTest(de.depthTest),s.setMask(de.depthWrite),a.setMask(de.colorWrite);const ke=de.stencilWrite;o.setTest(ke),ke&&(o.setMask(de.stencilWriteMask),o.setFunc(de.stencilFunc,de.stencilRef,de.stencilFuncMask),o.setOp(de.stencilFail,de.stencilZFail,de.stencilZPass)),oe(de.polygonOffset,de.polygonOffsetFactor,de.polygonOffsetUnits),de.alphaToCoverage===!0?ve(t.SAMPLE_ALPHA_TO_COVERAGE):Pe(t.SAMPLE_ALPHA_TO_COVERAGE)}function ae(de){O!==de&&(de?t.frontFace(t.CW):t.frontFace(t.CCW),O=de)}function J(de){de!==Nse?(ve(t.CULL_FACE),de!==z&&(de===q4?t.cullFace(t.BACK):de===Rse?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Pe(t.CULL_FACE),z=de}function ee(de){de!==I&&(q&&t.lineWidth(de),I=de)}function oe(de,nt,fe){de?(ve(t.POLYGON_OFFSET_FILL),(G!==nt||L!==fe)&&(t.polygonOffset(nt,fe),G=nt,L=fe)):Pe(t.POLYGON_OFFSET_FILL)}function De(de){de?ve(t.SCISSOR_TEST):Pe(t.SCISSOR_TEST)}function Ne(de){de===void 0&&(de=t.TEXTURE0+B-1),Q!==de&&(t.activeTexture(de),Q=de)}function te(de,nt,fe){fe===void 0&&(Q===null?fe=t.TEXTURE0+B-1:fe=Q);let ke=ie[fe];ke===void 0&&(ke={type:void 0,texture:void 0},ie[fe]=ke),(ke.type!==de||ke.texture!==nt)&&(Q!==fe&&(t.activeTexture(fe),Q=fe),t.bindTexture(de,nt||re[de]),ke.type=de,ke.texture=nt)}function j(){const de=ie[Q];de!==void 0&&de.type!==void 0&&(t.bindTexture(de.type,null),de.type=void 0,de.texture=void 0)}function k(){try{t.compressedTexImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function K(){try{t.compressedTexImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function me(){try{t.texSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function ye(){try{t.texSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function he(){try{t.compressedTexSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Ye(){try{t.compressedTexSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Le(){try{t.texStorage2D(...arguments)}catch(de){de("WebGLState:",de)}}function qe(){try{t.texStorage3D(...arguments)}catch(de){de("WebGLState:",de)}}function rt(){try{t.texImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Ie(){try{t.texImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Re(de){se.equals(de)===!1&&(t.scissor(de.x,de.y,de.z,de.w),se.copy(de))}function ht(de){ue.equals(de)===!1&&(t.viewport(de.x,de.y,de.z,de.w),ue.copy(de))}function tt(de,nt){let fe=c.get(nt);fe===void 0&&(fe=new WeakMap,c.set(nt,fe));let ke=fe.get(de);ke===void 0&&(ke=t.getUniformBlockIndex(nt,de.name),fe.set(de,ke))}function et(de,nt){const ke=c.get(nt).get(de);l.get(nt)!==ke&&(t.uniformBlockBinding(nt,ke,de.__bindingPointIndex),l.set(nt,ke))}function ct(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),s.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},Q=null,ie={},f={},p=new WeakMap,m=[],_=null,b=!1,v=null,x=null,M=null,w=null,E=null,T=null,P=null,N=new xn(0,0,0),U=0,R=!1,O=null,z=null,I=null,G=null,L=null,se.set(0,0,t.canvas.width,t.canvas.height),ue.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:ve,disable:Pe,bindFramebuffer:pe,drawBuffers:we,useProgram:ze,setBlending:F,setMaterial:$,setFlipSided:ae,setCullFace:J,setLineWidth:ee,setPolygonOffset:oe,setScissorTest:De,activeTexture:Ne,bindTexture:te,unbindTexture:j,compressedTexImage2D:k,compressedTexImage3D:K,texImage2D:rt,texImage3D:Ie,updateUBOMapping:tt,uniformBlockBinding:et,texStorage2D:Le,texStorage3D:qe,texSubImage2D:me,texSubImage3D:ye,compressedTexSubImage2D:he,compressedTexSubImage3D:Ye,scissor:Re,viewport:ht,reset:ct}}function Lfe(t,e,n,i,r,a,s){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new nn,d=new WeakMap;let f;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(j,k){return m?new OffscreenCanvas(j,k):b_("canvas")}function b(j,k,K){let me=1;const ye=te(j);if((ye.width>K||ye.height>K)&&(me=K/Math.max(ye.width,ye.height)),me<1)if(typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&j instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&j instanceof ImageBitmap||typeof VideoFrame<"u"&&j instanceof VideoFrame){const he=Math.floor(me*ye.width),Ye=Math.floor(me*ye.height);f===void 0&&(f=_(he,Ye));const Le=k?_(he,Ye):f;return Le.width=he,Le.height=Ye,Le.getContext("2d").drawImage(j,0,0,he,Ye),$t("WebGLRenderer: Texture has been resized from ("+ye.width+"x"+ye.height+") to ("+he+"x"+Ye+")."),Le}else return"data"in j&&$t("WebGLRenderer: Image in DataTexture is too big ("+ye.width+"x"+ye.height+")."),j;return j}function v(j){return j.generateMipmaps}function x(j){t.generateMipmap(j)}function M(j){return j.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:j.isWebGL3DRenderTarget?t.TEXTURE_3D:j.isWebGLArrayRenderTarget||j.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(j,k,K,me,ye=!1){if(j!==null){if(t[j]!==void 0)return t[j];$t("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+j+"'")}let he=k;if(k===t.RED&&(K===t.FLOAT&&(he=t.R32F),K===t.HALF_FLOAT&&(he=t.R16F),K===t.UNSIGNED_BYTE&&(he=t.R8)),k===t.RED_INTEGER&&(K===t.UNSIGNED_BYTE&&(he=t.R8UI),K===t.UNSIGNED_SHORT&&(he=t.R16UI),K===t.UNSIGNED_INT&&(he=t.R32UI),K===t.BYTE&&(he=t.R8I),K===t.SHORT&&(he=t.R16I),K===t.INT&&(he=t.R32I)),k===t.RG&&(K===t.FLOAT&&(he=t.RG32F),K===t.HALF_FLOAT&&(he=t.RG16F),K===t.UNSIGNED_BYTE&&(he=t.RG8)),k===t.RG_INTEGER&&(K===t.UNSIGNED_BYTE&&(he=t.RG8UI),K===t.UNSIGNED_SHORT&&(he=t.RG16UI),K===t.UNSIGNED_INT&&(he=t.RG32UI),K===t.BYTE&&(he=t.RG8I),K===t.SHORT&&(he=t.RG16I),K===t.INT&&(he=t.RG32I)),k===t.RGB_INTEGER&&(K===t.UNSIGNED_BYTE&&(he=t.RGB8UI),K===t.UNSIGNED_SHORT&&(he=t.RGB16UI),K===t.UNSIGNED_INT&&(he=t.RGB32UI),K===t.BYTE&&(he=t.RGB8I),K===t.SHORT&&(he=t.RGB16I),K===t.INT&&(he=t.RGB32I)),k===t.RGBA_INTEGER&&(K===t.UNSIGNED_BYTE&&(he=t.RGBA8UI),K===t.UNSIGNED_SHORT&&(he=t.RGBA16UI),K===t.UNSIGNED_INT&&(he=t.RGBA32UI),K===t.BYTE&&(he=t.RGBA8I),K===t.SHORT&&(he=t.RGBA16I),K===t.INT&&(he=t.RGBA32I)),k===t.RGB&&(K===t.UNSIGNED_INT_5_9_9_9_REV&&(he=t.RGB9_E5),K===t.UNSIGNED_INT_10F_11F_11F_REV&&(he=t.R11F_G11F_B10F)),k===t.RGBA){const Ye=ye?v_:wn.getTransfer(me);K===t.FLOAT&&(he=t.RGBA32F),K===t.HALF_FLOAT&&(he=t.RGBA16F),K===t.UNSIGNED_BYTE&&(he=Ye===Fn?t.SRGB8_ALPHA8:t.RGBA8),K===t.UNSIGNED_SHORT_4_4_4_4&&(he=t.RGBA4),K===t.UNSIGNED_SHORT_5_5_5_1&&(he=t.RGB5_A1)}return(he===t.R16F||he===t.R32F||he===t.RG16F||he===t.RG32F||he===t.RGBA16F||he===t.RGBA32F)&&e.get("EXT_color_buffer_float"),he}function E(j,k){let K;return j?k===null||k===vf||k===T0?K=t.DEPTH24_STENCIL8:k===Wl?K=t.DEPTH32F_STENCIL8:k===A0&&(K=t.DEPTH24_STENCIL8,$t("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):k===null||k===vf||k===T0?K=t.DEPTH_COMPONENT24:k===Wl?K=t.DEPTH_COMPONENT32F:k===A0&&(K=t.DEPTH_COMPONENT16),K}function T(j,k){return v(j)===!0||j.isFramebufferTexture&&j.minFilter!==as&&j.minFilter!==js?Math.log2(Math.max(k.width,k.height))+1:j.mipmaps!==void 0&&j.mipmaps.length>0?j.mipmaps.length:j.isCompressedTexture&&Array.isArray(j.image)?k.mipmaps.length:1}function P(j){const k=j.target;k.removeEventListener("dispose",P),U(k),k.isVideoTexture&&d.delete(k)}function N(j){const k=j.target;k.removeEventListener("dispose",N),O(k)}function U(j){const k=i.get(j);if(k.__webglInit===void 0)return;const K=j.source,me=p.get(K);if(me){const ye=me[k.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&R(j),Object.keys(me).length===0&&p.delete(K)}i.remove(j)}function R(j){const k=i.get(j);t.deleteTexture(k.__webglTexture);const K=j.source,me=p.get(K);delete me[k.__cacheKey],s.memory.textures--}function O(j){const k=i.get(j);if(j.depthTexture&&(j.depthTexture.dispose(),i.remove(j.depthTexture)),j.isWebGLCubeRenderTarget)for(let me=0;me<6;me++){if(Array.isArray(k.__webglFramebuffer[me]))for(let ye=0;ye<k.__webglFramebuffer[me].length;ye++)t.deleteFramebuffer(k.__webglFramebuffer[me][ye]);else t.deleteFramebuffer(k.__webglFramebuffer[me]);k.__webglDepthbuffer&&t.deleteRenderbuffer(k.__webglDepthbuffer[me])}else{if(Array.isArray(k.__webglFramebuffer))for(let me=0;me<k.__webglFramebuffer.length;me++)t.deleteFramebuffer(k.__webglFramebuffer[me]);else t.deleteFramebuffer(k.__webglFramebuffer);if(k.__webglDepthbuffer&&t.deleteRenderbuffer(k.__webglDepthbuffer),k.__webglMultisampledFramebuffer&&t.deleteFramebuffer(k.__webglMultisampledFramebuffer),k.__webglColorRenderbuffer)for(let me=0;me<k.__webglColorRenderbuffer.length;me++)k.__webglColorRenderbuffer[me]&&t.deleteRenderbuffer(k.__webglColorRenderbuffer[me]);k.__webglDepthRenderbuffer&&t.deleteRenderbuffer(k.__webglDepthRenderbuffer)}const K=j.textures;for(let me=0,ye=K.length;me<ye;me++){const he=i.get(K[me]);he.__webglTexture&&(t.deleteTexture(he.__webglTexture),s.memory.textures--),i.remove(K[me])}i.remove(j)}let z=0;function I(){z=0}function G(){const j=z;return j>=r.maxTextures&&$t("WebGLTextures: Trying to use "+j+" texture units while this GPU supports only "+r.maxTextures),z+=1,j}function L(j){const k=[];return k.push(j.wrapS),k.push(j.wrapT),k.push(j.wrapR||0),k.push(j.magFilter),k.push(j.minFilter),k.push(j.anisotropy),k.push(j.internalFormat),k.push(j.format),k.push(j.type),k.push(j.generateMipmaps),k.push(j.premultiplyAlpha),k.push(j.flipY),k.push(j.unpackAlignment),k.push(j.colorSpace),k.join()}function B(j,k){const K=i.get(j);if(j.isVideoTexture&&De(j),j.isRenderTargetTexture===!1&&j.isExternalTexture!==!0&&j.version>0&&K.__version!==j.version){const me=j.image;if(me===null)$t("WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)$t("WebGLRenderer: Texture marked for update but image is incomplete");else{re(K,j,k);return}}else j.isExternalTexture&&(K.__webglTexture=j.sourceTexture?j.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,K.__webglTexture,t.TEXTURE0+k)}function q(j,k){const K=i.get(j);if(j.isRenderTargetTexture===!1&&j.version>0&&K.__version!==j.version){re(K,j,k);return}else j.isExternalTexture&&(K.__webglTexture=j.sourceTexture?j.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,K.__webglTexture,t.TEXTURE0+k)}function W(j,k){const K=i.get(j);if(j.isRenderTargetTexture===!1&&j.version>0&&K.__version!==j.version){re(K,j,k);return}n.bindTexture(t.TEXTURE_3D,K.__webglTexture,t.TEXTURE0+k)}function X(j,k){const K=i.get(j);if(j.version>0&&K.__version!==j.version){ve(K,j,k);return}n.bindTexture(t.TEXTURE_CUBE_MAP,K.__webglTexture,t.TEXTURE0+k)}const Q={[cN]:t.REPEAT,[Gl]:t.CLAMP_TO_EDGE,[uN]:t.MIRRORED_REPEAT},ie={[as]:t.NEAREST,[aoe]:t.NEAREST_MIPMAP_NEAREST,[dy]:t.NEAREST_MIPMAP_LINEAR,[js]:t.LINEAR,[iA]:t.LINEAR_MIPMAP_NEAREST,[qd]:t.LINEAR_MIPMAP_LINEAR},H={[coe]:t.NEVER,[moe]:t.ALWAYS,[uoe]:t.LESS,[sG]:t.LEQUAL,[doe]:t.EQUAL,[poe]:t.GEQUAL,[foe]:t.GREATER,[hoe]:t.NOTEQUAL};function Y(j,k){if(k.type===Wl&&e.has("OES_texture_float_linear")===!1&&(k.magFilter===js||k.magFilter===iA||k.magFilter===dy||k.magFilter===qd||k.minFilter===js||k.minFilter===iA||k.minFilter===dy||k.minFilter===qd)&&$t("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(j,t.TEXTURE_WRAP_S,Q[k.wrapS]),t.texParameteri(j,t.TEXTURE_WRAP_T,Q[k.wrapT]),(j===t.TEXTURE_3D||j===t.TEXTURE_2D_ARRAY)&&t.texParameteri(j,t.TEXTURE_WRAP_R,Q[k.wrapR]),t.texParameteri(j,t.TEXTURE_MAG_FILTER,ie[k.magFilter]),t.texParameteri(j,t.TEXTURE_MIN_FILTER,ie[k.minFilter]),k.compareFunction&&(t.texParameteri(j,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(j,t.TEXTURE_COMPARE_FUNC,H[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(k.magFilter===as||k.minFilter!==dy&&k.minFilter!==qd||k.type===Wl&&e.has("OES_texture_float_linear")===!1)return;if(k.anisotropy>1||i.get(k).__currentAnisotropy){const K=e.get("EXT_texture_filter_anisotropic");t.texParameterf(j,K.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),i.get(k).__currentAnisotropy=k.anisotropy}}}function se(j,k){let K=!1;j.__webglInit===void 0&&(j.__webglInit=!0,k.addEventListener("dispose",P));const me=k.source;let ye=p.get(me);ye===void 0&&(ye={},p.set(me,ye));const he=L(k);if(he!==j.__cacheKey){ye[he]===void 0&&(ye[he]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,K=!0),ye[he].usedTimes++;const Ye=ye[j.__cacheKey];Ye!==void 0&&(ye[j.__cacheKey].usedTimes--,Ye.usedTimes===0&&R(k)),j.__cacheKey=he,j.__webglTexture=ye[he].texture}return K}function ue(j,k,K){return Math.floor(Math.floor(j/K)/k)}function xe(j,k,K,me){const he=j.updateRanges;if(he.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,k.width,k.height,K,me,k.data);else{he.sort((Ie,Re)=>Ie.start-Re.start);let Ye=0;for(let Ie=1;Ie<he.length;Ie++){const Re=he[Ye],ht=he[Ie],tt=Re.start+Re.count,et=ue(ht.start,k.width,4),ct=ue(Re.start,k.width,4);ht.start<=tt+1&&et===ct&&ue(ht.start+ht.count-1,k.width,4)===et?Re.count=Math.max(Re.count,ht.start+ht.count-Re.start):(++Ye,he[Ye]=ht)}he.length=Ye+1;const Le=t.getParameter(t.UNPACK_ROW_LENGTH),qe=t.getParameter(t.UNPACK_SKIP_PIXELS),rt=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,k.width);for(let Ie=0,Re=he.length;Ie<Re;Ie++){const ht=he[Ie],tt=Math.floor(ht.start/4),et=Math.ceil(ht.count/4),ct=tt%k.width,de=Math.floor(tt/k.width),nt=et,fe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ct),t.pixelStorei(t.UNPACK_SKIP_ROWS,de),n.texSubImage2D(t.TEXTURE_2D,0,ct,de,nt,fe,K,me,k.data)}j.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Le),t.pixelStorei(t.UNPACK_SKIP_PIXELS,qe),t.pixelStorei(t.UNPACK_SKIP_ROWS,rt)}}function re(j,k,K){let me=t.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),k.isData3DTexture&&(me=t.TEXTURE_3D);const ye=se(j,k),he=k.source;n.bindTexture(me,j.__webglTexture,t.TEXTURE0+K);const Ye=i.get(he);if(he.version!==Ye.__version||ye===!0){n.activeTexture(t.TEXTURE0+K);const Le=wn.getPrimaries(wn.workingColorSpace),qe=k.colorSpace===yu?null:wn.getPrimaries(k.colorSpace),rt=k.colorSpace===yu||Le===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,k.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,k.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,rt);let Ie=b(k.image,!1,r.maxTextureSize);Ie=Ne(k,Ie);const Re=a.convert(k.format,k.colorSpace),ht=a.convert(k.type);let tt=w(k.internalFormat,Re,ht,k.colorSpace,k.isVideoTexture);Y(me,k);let et;const ct=k.mipmaps,de=k.isVideoTexture!==!0,nt=Ye.__version===void 0||ye===!0,fe=he.dataReady,ke=T(k,Ie);if(k.isDepthTexture)tt=E(k.format===N0,k.type),nt&&(de?n.texStorage2D(t.TEXTURE_2D,1,tt,Ie.width,Ie.height):n.texImage2D(t.TEXTURE_2D,0,tt,Ie.width,Ie.height,0,Re,ht,null));else if(k.isDataTexture)if(ct.length>0){de&&nt&&n.texStorage2D(t.TEXTURE_2D,ke,tt,ct[0].width,ct[0].height);for(let Me=0,ge=ct.length;Me<ge;Me++)et=ct[Me],de?fe&&n.texSubImage2D(t.TEXTURE_2D,Me,0,0,et.width,et.height,Re,ht,et.data):n.texImage2D(t.TEXTURE_2D,Me,tt,et.width,et.height,0,Re,ht,et.data);k.generateMipmaps=!1}else de?(nt&&n.texStorage2D(t.TEXTURE_2D,ke,tt,Ie.width,Ie.height),fe&&xe(k,Ie,Re,ht)):n.texImage2D(t.TEXTURE_2D,0,tt,Ie.width,Ie.height,0,Re,ht,Ie.data);else if(k.isCompressedTexture)if(k.isCompressedArrayTexture){de&&nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ke,tt,ct[0].width,ct[0].height,Ie.depth);for(let Me=0,ge=ct.length;Me<ge;Me++)if(et=ct[Me],k.format!==ho)if(Re!==null)if(de){if(fe)if(k.layerUpdates.size>0){const Be=Aj(et.width,et.height,k.format,k.type);for(const lt of k.layerUpdates){const bt=et.data.subarray(lt*Be/et.data.BYTES_PER_ELEMENT,(lt+1)*Be/et.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,lt,et.width,et.height,1,Re,bt)}k.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,0,et.width,et.height,Ie.depth,Re,et.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Me,tt,et.width,et.height,Ie.depth,0,et.data,0,0);else $t("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else de?fe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,0,et.width,et.height,Ie.depth,Re,ht,et.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Me,tt,et.width,et.height,Ie.depth,0,Re,ht,et.data)}else{de&&nt&&n.texStorage2D(t.TEXTURE_2D,ke,tt,ct[0].width,ct[0].height);for(let Me=0,ge=ct.length;Me<ge;Me++)et=ct[Me],k.format!==ho?Re!==null?de?fe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Me,0,0,et.width,et.height,Re,et.data):n.compressedTexImage2D(t.TEXTURE_2D,Me,tt,et.width,et.height,0,et.data):$t("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):de?fe&&n.texSubImage2D(t.TEXTURE_2D,Me,0,0,et.width,et.height,Re,ht,et.data):n.texImage2D(t.TEXTURE_2D,Me,tt,et.width,et.height,0,Re,ht,et.data)}else if(k.isDataArrayTexture)if(de){if(nt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ke,tt,Ie.width,Ie.height,Ie.depth),fe)if(k.layerUpdates.size>0){const Me=Aj(Ie.width,Ie.height,k.format,k.type);for(const ge of k.layerUpdates){const Be=Ie.data.subarray(ge*Me/Ie.data.BYTES_PER_ELEMENT,(ge+1)*Me/Ie.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ge,Ie.width,Ie.height,1,Re,ht,Be)}k.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ie.width,Ie.height,Ie.depth,Re,ht,Ie.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,tt,Ie.width,Ie.height,Ie.depth,0,Re,ht,Ie.data);else if(k.isData3DTexture)de?(nt&&n.texStorage3D(t.TEXTURE_3D,ke,tt,Ie.width,Ie.height,Ie.depth),fe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ie.width,Ie.height,Ie.depth,Re,ht,Ie.data)):n.texImage3D(t.TEXTURE_3D,0,tt,Ie.width,Ie.height,Ie.depth,0,Re,ht,Ie.data);else if(k.isFramebufferTexture){if(nt)if(de)n.texStorage2D(t.TEXTURE_2D,ke,tt,Ie.width,Ie.height);else{let Me=Ie.width,ge=Ie.height;for(let Be=0;Be<ke;Be++)n.texImage2D(t.TEXTURE_2D,Be,tt,Me,ge,0,Re,ht,null),Me>>=1,ge>>=1}}else if(ct.length>0){if(de&&nt){const Me=te(ct[0]);n.texStorage2D(t.TEXTURE_2D,ke,tt,Me.width,Me.height)}for(let Me=0,ge=ct.length;Me<ge;Me++)et=ct[Me],de?fe&&n.texSubImage2D(t.TEXTURE_2D,Me,0,0,Re,ht,et):n.texImage2D(t.TEXTURE_2D,Me,tt,Re,ht,et);k.generateMipmaps=!1}else if(de){if(nt){const Me=te(Ie);n.texStorage2D(t.TEXTURE_2D,ke,tt,Me.width,Me.height)}fe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,Re,ht,Ie)}else n.texImage2D(t.TEXTURE_2D,0,tt,Re,ht,Ie);v(k)&&x(me),Ye.__version=he.version,k.onUpdate&&k.onUpdate(k)}j.__version=k.version}function ve(j,k,K){if(k.image.length!==6)return;const me=se(j,k),ye=k.source;n.bindTexture(t.TEXTURE_CUBE_MAP,j.__webglTexture,t.TEXTURE0+K);const he=i.get(ye);if(ye.version!==he.__version||me===!0){n.activeTexture(t.TEXTURE0+K);const Ye=wn.getPrimaries(wn.workingColorSpace),Le=k.colorSpace===yu?null:wn.getPrimaries(k.colorSpace),qe=k.colorSpace===yu||Ye===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,k.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,k.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const rt=k.isCompressedTexture||k.image[0].isCompressedTexture,Ie=k.image[0]&&k.image[0].isDataTexture,Re=[];for(let ge=0;ge<6;ge++)!rt&&!Ie?Re[ge]=b(k.image[ge],!0,r.maxCubemapSize):Re[ge]=Ie?k.image[ge].image:k.image[ge],Re[ge]=Ne(k,Re[ge]);const ht=Re[0],tt=a.convert(k.format,k.colorSpace),et=a.convert(k.type),ct=w(k.internalFormat,tt,et,k.colorSpace),de=k.isVideoTexture!==!0,nt=he.__version===void 0||me===!0,fe=ye.dataReady;let ke=T(k,ht);Y(t.TEXTURE_CUBE_MAP,k);let Me;if(rt){de&&nt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,ct,ht.width,ht.height);for(let ge=0;ge<6;ge++){Me=Re[ge].mipmaps;for(let Be=0;Be<Me.length;Be++){const lt=Me[Be];k.format!==ho?tt!==null?de?fe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,0,0,lt.width,lt.height,tt,lt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,ct,lt.width,lt.height,0,lt.data):$t("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,0,0,lt.width,lt.height,tt,et,lt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,ct,lt.width,lt.height,0,tt,et,lt.data)}}}else{if(Me=k.mipmaps,de&&nt){Me.length>0&&ke++;const ge=te(Re[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,ct,ge.width,ge.height)}for(let ge=0;ge<6;ge++)if(Ie){de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,0,0,Re[ge].width,Re[ge].height,tt,et,Re[ge].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,ct,Re[ge].width,Re[ge].height,0,tt,et,Re[ge].data);for(let Be=0;Be<Me.length;Be++){const bt=Me[Be].image[ge].image;de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,0,0,bt.width,bt.height,tt,et,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,ct,bt.width,bt.height,0,tt,et,bt.data)}}else{de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,0,0,tt,et,Re[ge]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,ct,tt,et,Re[ge]);for(let Be=0;Be<Me.length;Be++){const lt=Me[Be];de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,0,0,tt,et,lt.image[ge]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,ct,tt,et,lt.image[ge])}}}v(k)&&x(t.TEXTURE_CUBE_MAP),he.__version=ye.version,k.onUpdate&&k.onUpdate(k)}j.__version=k.version}function Pe(j,k,K,me,ye,he){const Ye=a.convert(K.format,K.colorSpace),Le=a.convert(K.type),qe=w(K.internalFormat,Ye,Le,K.colorSpace),rt=i.get(k),Ie=i.get(K);if(Ie.__renderTarget=k,!rt.__hasExternalTextures){const Re=Math.max(1,k.width>>he),ht=Math.max(1,k.height>>he);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,he,qe,Re,ht,k.depth,0,Ye,Le,null):n.texImage2D(ye,he,qe,Re,ht,0,Ye,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,j),oe(k)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,ye,Ie.__webglTexture,0,ee(k)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,me,ye,Ie.__webglTexture,he),n.bindFramebuffer(t.FRAMEBUFFER,null)}function pe(j,k,K){if(t.bindRenderbuffer(t.RENDERBUFFER,j),k.depthBuffer){const me=k.depthTexture,ye=me&&me.isDepthTexture?me.type:null,he=E(k.stencilBuffer,ye),Ye=k.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=ee(k);oe(k)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Le,he,k.width,k.height):K?t.renderbufferStorageMultisample(t.RENDERBUFFER,Le,he,k.width,k.height):t.renderbufferStorage(t.RENDERBUFFER,he,k.width,k.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Ye,t.RENDERBUFFER,j)}else{const me=k.textures;for(let ye=0;ye<me.length;ye++){const he=me[ye],Ye=a.convert(he.format,he.colorSpace),Le=a.convert(he.type),qe=w(he.internalFormat,Ye,Le,he.colorSpace),rt=ee(k);K&&oe(k)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,rt,qe,k.width,k.height):oe(k)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,rt,qe,k.width,k.height):t.renderbufferStorage(t.RENDERBUFFER,qe,k.width,k.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function we(j,k){if(k&&k.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,j),!(k.depthTexture&&k.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const me=i.get(k.depthTexture);me.__renderTarget=k,(!me.__webglTexture||k.depthTexture.image.width!==k.width||k.depthTexture.image.height!==k.height)&&(k.depthTexture.image.width=k.width,k.depthTexture.image.height=k.height,k.depthTexture.needsUpdate=!0),B(k.depthTexture,0);const ye=me.__webglTexture,he=ee(k);if(k.depthTexture.format===C0)oe(k)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,he):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(k.depthTexture.format===N0)oe(k)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,he):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function ze(j){const k=i.get(j),K=j.isWebGLCubeRenderTarget===!0;if(k.__boundDepthTexture!==j.depthTexture){const me=j.depthTexture;if(k.__depthDisposeCallback&&k.__depthDisposeCallback(),me){const ye=()=>{delete k.__boundDepthTexture,delete k.__depthDisposeCallback,me.removeEventListener("dispose",ye)};me.addEventListener("dispose",ye),k.__depthDisposeCallback=ye}k.__boundDepthTexture=me}if(j.depthTexture&&!k.__autoAllocateDepthBuffer){if(K)throw new Error("target.depthTexture not supported in Cube render targets");const me=j.texture.mipmaps;me&&me.length>0?we(k.__webglFramebuffer[0],j):we(k.__webglFramebuffer,j)}else if(K){k.__webglDepthbuffer=[];for(let me=0;me<6;me++)if(n.bindFramebuffer(t.FRAMEBUFFER,k.__webglFramebuffer[me]),k.__webglDepthbuffer[me]===void 0)k.__webglDepthbuffer[me]=t.createRenderbuffer(),pe(k.__webglDepthbuffer[me],j,!1);else{const ye=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,he=k.__webglDepthbuffer[me];t.bindRenderbuffer(t.RENDERBUFFER,he),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,he)}}else{const me=j.texture.mipmaps;if(me&&me.length>0?n.bindFramebuffer(t.FRAMEBUFFER,k.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer===void 0)k.__webglDepthbuffer=t.createRenderbuffer(),pe(k.__webglDepthbuffer,j,!1);else{const ye=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,he=k.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,he),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,he)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ce(j,k,K){const me=i.get(j);k!==void 0&&Pe(me.__webglFramebuffer,j,j.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),K!==void 0&&ze(j)}function ft(j){const k=j.texture,K=i.get(j),me=i.get(k);j.addEventListener("dispose",N);const ye=j.textures,he=j.isWebGLCubeRenderTarget===!0,Ye=ye.length>1;if(Ye||(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=k.version,s.memory.textures++),he){K.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(k.mipmaps&&k.mipmaps.length>0){K.__webglFramebuffer[Le]=[];for(let qe=0;qe<k.mipmaps.length;qe++)K.__webglFramebuffer[Le][qe]=t.createFramebuffer()}else K.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(k.mipmaps&&k.mipmaps.length>0){K.__webglFramebuffer=[];for(let Le=0;Le<k.mipmaps.length;Le++)K.__webglFramebuffer[Le]=t.createFramebuffer()}else K.__webglFramebuffer=t.createFramebuffer();if(Ye)for(let Le=0,qe=ye.length;Le<qe;Le++){const rt=i.get(ye[Le]);rt.__webglTexture===void 0&&(rt.__webglTexture=t.createTexture(),s.memory.textures++)}if(j.samples>0&&oe(j)===!1){K.__webglMultisampledFramebuffer=t.createFramebuffer(),K.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,K.__webglMultisampledFramebuffer);for(let Le=0;Le<ye.length;Le++){const qe=ye[Le];K.__webglColorRenderbuffer[Le]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,K.__webglColorRenderbuffer[Le]);const rt=a.convert(qe.format,qe.colorSpace),Ie=a.convert(qe.type),Re=w(qe.internalFormat,rt,Ie,qe.colorSpace,j.isXRRenderTarget===!0),ht=ee(j);t.renderbufferStorageMultisample(t.RENDERBUFFER,ht,Re,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Le,t.RENDERBUFFER,K.__webglColorRenderbuffer[Le])}t.bindRenderbuffer(t.RENDERBUFFER,null),j.depthBuffer&&(K.__webglDepthRenderbuffer=t.createRenderbuffer(),pe(K.__webglDepthRenderbuffer,j,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(he){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),Y(t.TEXTURE_CUBE_MAP,k);for(let Le=0;Le<6;Le++)if(k.mipmaps&&k.mipmaps.length>0)for(let qe=0;qe<k.mipmaps.length;qe++)Pe(K.__webglFramebuffer[Le][qe],j,k,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,qe);else Pe(K.__webglFramebuffer[Le],j,k,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);v(k)&&x(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Ye){for(let Le=0,qe=ye.length;Le<qe;Le++){const rt=ye[Le],Ie=i.get(rt);let Re=t.TEXTURE_2D;(j.isWebGL3DRenderTarget||j.isWebGLArrayRenderTarget)&&(Re=j.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Re,Ie.__webglTexture),Y(Re,rt),Pe(K.__webglFramebuffer,j,rt,t.COLOR_ATTACHMENT0+Le,Re,0),v(rt)&&x(Re)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((j.isWebGL3DRenderTarget||j.isWebGLArrayRenderTarget)&&(Le=j.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Le,me.__webglTexture),Y(Le,k),k.mipmaps&&k.mipmaps.length>0)for(let qe=0;qe<k.mipmaps.length;qe++)Pe(K.__webglFramebuffer[qe],j,k,t.COLOR_ATTACHMENT0,Le,qe);else Pe(K.__webglFramebuffer,j,k,t.COLOR_ATTACHMENT0,Le,0);v(k)&&x(Le),n.unbindTexture()}j.depthBuffer&&ze(j)}function F(j){const k=j.textures;for(let K=0,me=k.length;K<me;K++){const ye=k[K];if(v(ye)){const he=M(j),Ye=i.get(ye).__webglTexture;n.bindTexture(he,Ye),x(he),n.unbindTexture()}}}const $=[],ae=[];function J(j){if(j.samples>0){if(oe(j)===!1){const k=j.textures,K=j.width,me=j.height;let ye=t.COLOR_BUFFER_BIT;const he=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ye=i.get(j),Le=k.length>1;if(Le)for(let rt=0;rt<k.length;rt++)n.bindFramebuffer(t.FRAMEBUFFER,Ye.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ye.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ye.__webglMultisampledFramebuffer);const qe=j.texture.mipmaps;qe&&qe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ye.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ye.__webglFramebuffer);for(let rt=0;rt<k.length;rt++){if(j.resolveDepthBuffer&&(j.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),j.stencilBuffer&&j.resolveStencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Le){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ye.__webglColorRenderbuffer[rt]);const Ie=i.get(k[rt]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ie,0)}t.blitFramebuffer(0,0,K,me,0,0,K,me,ye,t.NEAREST),l===!0&&($.length=0,ae.length=0,$.push(t.COLOR_ATTACHMENT0+rt),j.depthBuffer&&j.resolveDepthBuffer===!1&&($.push(he),ae.push(he),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ae)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,$))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Le)for(let rt=0;rt<k.length;rt++){n.bindFramebuffer(t.FRAMEBUFFER,Ye.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.RENDERBUFFER,Ye.__webglColorRenderbuffer[rt]);const Ie=i.get(k[rt]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ye.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.TEXTURE_2D,Ie,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ye.__webglMultisampledFramebuffer)}else if(j.depthBuffer&&j.resolveDepthBuffer===!1&&l){const k=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[k])}}}function ee(j){return Math.min(r.maxSamples,j.samples)}function oe(j){const k=i.get(j);return j.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function De(j){const k=s.render.frame;d.get(j)!==k&&(d.set(j,k),j.update())}function Ne(j,k){const K=j.colorSpace,me=j.format,ye=j.type;return j.isCompressedTexture===!0||j.isVideoTexture===!0||K!==Op&&K!==yu&&(wn.getTransfer(K)===Fn?(me!==ho||ye!==Go)&&$t("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ri("WebGLTextures: Unsupported texture color space:",K)),k}function te(j){return typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement?(c.width=j.naturalWidth||j.width,c.height=j.naturalHeight||j.height):typeof VideoFrame<"u"&&j instanceof VideoFrame?(c.width=j.displayWidth,c.height=j.displayHeight):(c.width=j.width,c.height=j.height),c}this.allocateTextureUnit=G,this.resetTextureUnits=I,this.setTexture2D=B,this.setTexture2DArray=q,this.setTexture3D=W,this.setTextureCube=X,this.rebindTextures=ce,this.setupRenderTarget=ft,this.updateRenderTargetMipmap=F,this.updateMultisampleRenderTarget=J,this.setupDepthRenderbuffer=ze,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=oe}function Ife(t,e){function n(i,r=yu){let a;const s=wn.getTransfer(r);if(i===Go)return t.UNSIGNED_BYTE;if(i===oP)return t.UNSIGNED_SHORT_4_4_4_4;if(i===lP)return t.UNSIGNED_SHORT_5_5_5_1;if(i===eG)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===tG)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===Q$)return t.BYTE;if(i===J$)return t.SHORT;if(i===A0)return t.UNSIGNED_SHORT;if(i===sP)return t.INT;if(i===vf)return t.UNSIGNED_INT;if(i===Wl)return t.FLOAT;if(i===am)return t.HALF_FLOAT;if(i===nG)return t.ALPHA;if(i===iG)return t.RGB;if(i===ho)return t.RGBA;if(i===C0)return t.DEPTH_COMPONENT;if(i===N0)return t.DEPTH_STENCIL;if(i===rG)return t.RED;if(i===cP)return t.RED_INTEGER;if(i===uP)return t.RG;if(i===dP)return t.RG_INTEGER;if(i===fP)return t.RGBA_INTEGER;if(i===Gb||i===Wb||i===qb||i===Xb)if(s===Fn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===Gb)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Wb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===qb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Xb)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===Gb)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Wb)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===qb)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Xb)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===dN||i===fN||i===hN||i===pN)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===dN)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===fN)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===hN)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===pN)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===mN||i===gN||i===xN)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===mN||i===gN)return s===Fn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===xN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===vN||i===yN||i===bN||i===_N||i===SN||i===wN||i===MN||i===EN||i===AN||i===TN||i===CN||i===NN||i===RN||i===PN)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===vN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===yN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===bN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===_N)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===SN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===wN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===MN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===EN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===AN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===TN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===CN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===NN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===RN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===PN)return s===Fn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===DN||i===ON||i===kN)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===DN)return s===Fn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ON)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===kN)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===LN||i===IN||i===UN||i===jN)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===LN)return a.COMPRESSED_RED_RGTC1_EXT;if(i===IN)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===UN)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===jN)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===T0?t.UNSIGNED_INT_24_8:t[i]!==void 0?t[i]:null}return{convert:n}}const Ufe=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,jfe=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class Ffe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const i=new EG(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,i=new cc({vertexShader:Ufe,fragmentShader:jfe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Wo(new vP(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let zfe=class extends Uf{constructor(e,n){super();const i=this;let r=null,a=1,s=null,o="local-floor",l=1,c=null,d=null,f=null,p=null,m=null,_=null;const b=typeof XRWebGLBinding<"u",v=new Ffe,x={},M=n.getContextAttributes();let w=null,E=null;const T=[],P=[],N=new nn;let U=null;const R=new Os;R.viewport=new Bi;const O=new Os;O.viewport=new Bi;const z=[R,O],I=new ile;let G=null,L=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(re){let ve=T[re];return ve===void 0&&(ve=new EA,T[re]=ve),ve.getTargetRaySpace()},this.getControllerGrip=function(re){let ve=T[re];return ve===void 0&&(ve=new EA,T[re]=ve),ve.getGripSpace()},this.getHand=function(re){let ve=T[re];return ve===void 0&&(ve=new EA,T[re]=ve),ve.getHandSpace()};function B(re){const ve=P.indexOf(re.inputSource);if(ve===-1)return;const Pe=T[ve];Pe!==void 0&&(Pe.update(re.inputSource,re.frame,c||s),Pe.dispatchEvent({type:re.type,data:re.inputSource}))}function q(){r.removeEventListener("select",B),r.removeEventListener("selectstart",B),r.removeEventListener("selectend",B),r.removeEventListener("squeeze",B),r.removeEventListener("squeezestart",B),r.removeEventListener("squeezeend",B),r.removeEventListener("end",q),r.removeEventListener("inputsourceschange",W);for(let re=0;re<T.length;re++){const ve=P[re];ve!==null&&(P[re]=null,T[re].disconnect(ve))}G=null,L=null,v.reset();for(const re in x)delete x[re];e.setRenderTarget(w),m=null,p=null,f=null,r=null,E=null,xe.stop(),i.isPresenting=!1,e.setPixelRatio(U),e.setSize(N.width,N.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){a=re,i.isPresenting===!0&&$t("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){o=re,i.isPresenting===!0&&$t("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(re){c=re},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f===null&&b&&(f=new XRWebGLBinding(r,n)),f},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(re){if(r=re,r!==null){if(w=e.getRenderTarget(),r.addEventListener("select",B),r.addEventListener("selectstart",B),r.addEventListener("selectend",B),r.addEventListener("squeeze",B),r.addEventListener("squeezestart",B),r.addEventListener("squeezeend",B),r.addEventListener("end",q),r.addEventListener("inputsourceschange",W),M.xrCompatible!==!0&&await n.makeXRCompatible(),U=e.getPixelRatio(),e.getSize(N),b&&"createProjectionLayer"in XRWebGLBinding.prototype){let Pe=null,pe=null,we=null;M.depth&&(we=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Pe=M.stencil?N0:C0,pe=M.stencil?T0:vf);const ze={colorFormat:n.RGBA8,depthFormat:we,scaleFactor:a};f=this.getBinding(),p=f.createProjectionLayer(ze),r.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),E=new bf(p.textureWidth,p.textureHeight,{format:ho,type:Go,depthTexture:new MG(p.textureWidth,p.textureHeight,pe,void 0,void 0,void 0,void 0,void 0,void 0,Pe),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Pe={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(r,n,Pe),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),E=new bf(m.framebufferWidth,m.framebufferHeight,{format:ho,type:Go,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}E.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await r.requestReferenceSpace(o),xe.setContext(r),xe.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function W(re){for(let ve=0;ve<re.removed.length;ve++){const Pe=re.removed[ve],pe=P.indexOf(Pe);pe>=0&&(P[pe]=null,T[pe].disconnect(Pe))}for(let ve=0;ve<re.added.length;ve++){const Pe=re.added[ve];let pe=P.indexOf(Pe);if(pe===-1){for(let ze=0;ze<T.length;ze++)if(ze>=P.length){P.push(Pe),pe=ze;break}else if(P[ze]===null){P[ze]=Pe,pe=ze;break}if(pe===-1)break}const we=T[pe];we&&we.connect(Pe)}}const X=new $e,Q=new $e;function ie(re,ve,Pe){X.setFromMatrixPosition(ve.matrixWorld),Q.setFromMatrixPosition(Pe.matrixWorld);const pe=X.distanceTo(Q),we=ve.projectionMatrix.elements,ze=Pe.projectionMatrix.elements,ce=we[14]/(we[10]-1),ft=we[14]/(we[10]+1),F=(we[9]+1)/we[5],$=(we[9]-1)/we[5],ae=(we[8]-1)/we[0],J=(ze[8]+1)/ze[0],ee=ce*ae,oe=ce*J,De=pe/(-ae+J),Ne=De*-ae;if(ve.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(Ne),re.translateZ(De),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert(),we[10]===-1)re.projectionMatrix.copy(ve.projectionMatrix),re.projectionMatrixInverse.copy(ve.projectionMatrixInverse);else{const te=ce+De,j=ft+De,k=ee-Ne,K=oe+(pe-Ne),me=F*ft/j*te,ye=$*ft/j*te;re.projectionMatrix.makePerspective(k,K,me,ye,te,j),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}}function H(re,ve){ve===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(ve.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(r===null)return;let ve=re.near,Pe=re.far;v.texture!==null&&(v.depthNear>0&&(ve=v.depthNear),v.depthFar>0&&(Pe=v.depthFar)),I.near=O.near=R.near=ve,I.far=O.far=R.far=Pe,(G!==I.near||L!==I.far)&&(r.updateRenderState({depthNear:I.near,depthFar:I.far}),G=I.near,L=I.far),I.layers.mask=re.layers.mask|6,R.layers.mask=I.layers.mask&3,O.layers.mask=I.layers.mask&5;const pe=re.parent,we=I.cameras;H(I,pe);for(let ze=0;ze<we.length;ze++)H(we[ze],pe);we.length===2?ie(I,R,O):I.projectionMatrix.copy(R.projectionMatrix),Y(re,I,pe)};function Y(re,ve,Pe){Pe===null?re.matrix.copy(ve.matrixWorld):(re.matrix.copy(Pe.matrixWorld),re.matrix.invert(),re.matrix.multiply(ve.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(ve.projectionMatrix),re.projectionMatrixInverse.copy(ve.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=FN*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(p===null&&m===null))return l},this.setFoveation=function(re){l=re,p!==null&&(p.fixedFoveation=re),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=re)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(I)},this.getCameraTexture=function(re){return x[re]};let se=null;function ue(re,ve){if(d=ve.getViewerPose(c||s),_=ve,d!==null){const Pe=d.views;m!==null&&(e.setRenderTargetFramebuffer(E,m.framebuffer),e.setRenderTarget(E));let pe=!1;Pe.length!==I.cameras.length&&(I.cameras.length=0,pe=!0);for(let ft=0;ft<Pe.length;ft++){const F=Pe[ft];let $=null;if(m!==null)$=m.getViewport(F);else{const J=f.getViewSubImage(p,F);$=J.viewport,ft===0&&(e.setRenderTargetTextures(E,J.colorTexture,J.depthStencilTexture),e.setRenderTarget(E))}let ae=z[ft];ae===void 0&&(ae=new Os,ae.layers.enable(ft),ae.viewport=new Bi,z[ft]=ae),ae.matrix.fromArray(F.transform.matrix),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.projectionMatrix.fromArray(F.projectionMatrix),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert(),ae.viewport.set($.x,$.y,$.width,$.height),ft===0&&(I.matrix.copy(ae.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),pe===!0&&I.cameras.push(ae)}const we=r.enabledFeatures;if(we&&we.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&b){f=i.getBinding();const ft=f.getDepthInformation(Pe[0]);ft&&ft.isValid&&ft.texture&&v.init(ft,r.renderState)}if(we&&we.includes("camera-access")&&b){e.state.unbindTexture(),f=i.getBinding();for(let ft=0;ft<Pe.length;ft++){const F=Pe[ft].camera;if(F){let $=x[F];$||($=new EG,x[F]=$);const ae=f.getCameraImage(F);$.sourceTexture=ae}}}}for(let Pe=0;Pe<T.length;Pe++){const pe=P[Pe],we=T[Pe];pe!==null&&we!==void 0&&we.update(pe,ve,c||s)}se&&se(re,ve),ve.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ve}),_=null}const xe=new NG;xe.setAnimationLoop(ue),this.setAnimationLoop=function(re){se=re},this.dispose=function(){}}};const Nd=new Vu,Bfe=new Gi;function Hfe(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function i(v,x){x.color.getRGB(v.fogColor.value,bG(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function r(v,x,M,w,E){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),f(v,x)):x.isMeshPhongMaterial?(a(v,x),d(v,x)):x.isMeshStandardMaterial?(a(v,x),p(v,x),x.isMeshPhysicalMaterial&&m(v,x,E)):x.isMeshMatcapMaterial?(a(v,x),_(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),b(v,x)):x.isMeshNormalMaterial?a(v,x):x.isLineBasicMaterial?(s(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?l(v,x,M,w):x.isSpriteMaterial?c(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===Oa&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===Oa&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x),w=M.envMap,E=M.envMapRotation;w&&(v.envMap.value=w,Nd.copy(E),Nd.x*=-1,Nd.y*=-1,Nd.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(Nd.y*=-1,Nd.z*=-1),v.envMapRotation.value.setFromMatrix4(Bfe.makeRotationFromEuler(Nd)),v.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap&&(v.lightMap.value=x.lightMap,v.lightMapIntensity.value=x.lightMapIntensity,n(x.lightMap,v.lightMapTransform)),x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function s(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function l(v,x,M,w){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=w*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function c(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function d(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function f(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function p(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),x.envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===Oa&&v.clearcoatNormalScale.value.negate())),x.dispersion>0&&(v.dispersion.value=x.dispersion),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function _(v,x){x.matcap&&(v.matcap.value=x.matcap)}function b(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Vfe(t,e,n,i){let r={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,w){const E=w.program;i.uniformBlockBinding(M,E)}function c(M,w){let E=r[M.id];E===void 0&&(_(M),E=d(M),r[M.id]=E,M.addEventListener("dispose",v));const T=w.program;i.updateUBOMapping(M,T);const P=e.render.frame;a[M.id]!==P&&(p(M),a[M.id]=P)}function d(M){const w=f();M.__bindingPointIndex=w;const E=t.createBuffer(),T=M.__size,P=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,E),t.bufferData(t.UNIFORM_BUFFER,T,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,E),E}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return Ri("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(M){const w=r[M.id],E=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let P=0,N=E.length;P<N;P++){const U=Array.isArray(E[P])?E[P]:[E[P]];for(let R=0,O=U.length;R<O;R++){const z=U[R];if(m(z,P,R,T)===!0){const I=z.__offset,G=Array.isArray(z.value)?z.value:[z.value];let L=0;for(let B=0;B<G.length;B++){const q=G[B],W=b(q);typeof q=="number"||typeof q=="boolean"?(z.__data[0]=q,t.bufferSubData(t.UNIFORM_BUFFER,I+L,z.__data)):q.isMatrix3?(z.__data[0]=q.elements[0],z.__data[1]=q.elements[1],z.__data[2]=q.elements[2],z.__data[3]=0,z.__data[4]=q.elements[3],z.__data[5]=q.elements[4],z.__data[6]=q.elements[5],z.__data[7]=0,z.__data[8]=q.elements[6],z.__data[9]=q.elements[7],z.__data[10]=q.elements[8],z.__data[11]=0):(q.toArray(z.__data,L),L+=W.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,I,z.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,E,T){const P=M.value,N=w+"_"+E;if(T[N]===void 0)return typeof P=="number"||typeof P=="boolean"?T[N]=P:T[N]=P.clone(),!0;{const U=T[N];if(typeof P=="number"||typeof P=="boolean"){if(U!==P)return T[N]=P,!0}else if(U.equals(P)===!1)return U.copy(P),!0}return!1}function _(M){const w=M.uniforms;let E=0;const T=16;for(let N=0,U=w.length;N<U;N++){const R=Array.isArray(w[N])?w[N]:[w[N]];for(let O=0,z=R.length;O<z;O++){const I=R[O],G=Array.isArray(I.value)?I.value:[I.value];for(let L=0,B=G.length;L<B;L++){const q=G[L],W=b(q),X=E%T,Q=X%W.boundary,ie=X+Q;E+=Q,ie!==0&&T-ie<W.storage&&(E+=T-ie),I.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=E,E+=W.storage}}}const P=E%T;return P>0&&(E+=T-P),M.__size=E,M.__cache={},this}function b(M){const w={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?$t("WebGLRenderer: Texture samplers can not be part of an uniforms group."):$t("WebGLRenderer: Unsupported uniform value type.",M),w}function v(M){const w=M.target;w.removeEventListener("dispose",v);const E=s.indexOf(w.__bindingPointIndex);s.splice(E,1),t.deleteBuffer(r[w.id]),delete r[w.id],delete a[w.id]}function x(){for(const M in r)t.deleteBuffer(r[M]);s=[],r={},a={}}return{bind:l,update:c,dispose:x}}const $fe=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let El=null;function Gfe(){return El===null&&(El=new Goe($fe,32,32,uP,am),El.minFilter=js,El.magFilter=js,El.wrapS=Gl,El.wrapT=Gl,El.generateMipmaps=!1,El.needsUpdate=!0),El}let Wfe=class{constructor(e={}){const{canvas:n=goe(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=i.getContextAttributes().alpha}else m=s;const _=new Set([fP,dP,cP]),b=new Set([Go,vf,A0,T0,oP,lP]),v=new Uint32Array(4),x=new Int32Array(4);let M=null,w=null;const E=[],T=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ru,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let N=!1;this._outputColorSpace=Rs;let U=0,R=0,O=null,z=-1,I=null;const G=new Bi,L=new Bi;let B=null;const q=new xn(0);let W=0,X=n.width,Q=n.height,ie=1,H=null,Y=null;const se=new Bi(0,0,X,Q),ue=new Bi(0,0,X,Q);let xe=!1;const re=new xP;let ve=!1,Pe=!1;const pe=new Gi,we=new $e,ze=new Bi,ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ft=!1;function F(){return O===null?ie:1}let $=i;function ae(Z,be){return n.getContext(Z,be)}try{const Z={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${rP}`),n.addEventListener("webglcontextlost",Me,!1),n.addEventListener("webglcontextrestored",ge,!1),n.addEventListener("webglcontextcreationerror",Be,!1),$===null){const be="webgl2";if($=ae(be,Z),$===null)throw ae(be)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(Z){throw Z("WebGLRenderer: "+Z.message),Z}let J,ee,oe,De,Ne,te,j,k,K,me,ye,he,Ye,Le,qe,rt,Ie,Re,ht,tt,et,ct,de,nt;function fe(){J=new ede($),J.init(),ct=new Ife($,J),ee=new Gue($,J,e,ct),oe=new kfe($,J),ee.reversedDepthBuffer&&p&&oe.buffers.depth.setReversed(!0),De=new ide($),Ne=new _fe,te=new Lfe($,J,oe,Ne,ee,ct,De),j=new que(P),k=new Jue(P),K=new ole($),de=new Vue($,K),me=new tde($,K,De,de),ye=new ade($,me,K,De),ht=new rde($,ee,te),rt=new Wue(Ne),he=new bfe(P,j,k,J,ee,de,rt),Ye=new Hfe(P,Ne),Le=new wfe,qe=new Nfe(J),Re=new Hue(P,j,k,oe,ye,m,l),Ie=new Dfe(P,ye,ee),nt=new Vfe($,De,ee,oe),tt=new $ue($,J,De),et=new nde($,J,De),De.programs=he.programs,P.capabilities=ee,P.extensions=J,P.properties=Ne,P.renderLists=Le,P.shadowMap=Ie,P.state=oe,P.info=De}fe();const ke=new zfe(P,$);this.xr=ke,this.getContext=function(){return $},this.getContextAttributes=function(){return $.getContextAttributes()},this.forceContextLoss=function(){const Z=J.get("WEBGL_lose_context");Z&&Z.loseContext()},this.forceContextRestore=function(){const Z=J.get("WEBGL_lose_context");Z&&Z.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(Z){Z!==void 0&&(ie=Z,this.setSize(X,Q,!1))},this.getSize=function(Z){return Z.set(X,Q)},this.setSize=function(Z,be,Ce=!0){if(ke.isPresenting){$t("WebGLRenderer: Can't change size while VR device is presenting.");return}X=Z,Q=be,n.width=Math.floor(Z*ie),n.height=Math.floor(be*ie),Ce===!0&&(n.style.width=Z+"px",n.style.height=be+"px"),this.setViewport(0,0,Z,be)},this.getDrawingBufferSize=function(Z){return Z.set(X*ie,Q*ie).floor()},this.setDrawingBufferSize=function(Z,be,Ce){X=Z,Q=be,ie=Ce,n.width=Math.floor(Z*Ce),n.height=Math.floor(be*Ce),this.setViewport(0,0,Z,be)},this.getCurrentViewport=function(Z){return Z.copy(G)},this.getViewport=function(Z){return Z.copy(se)},this.setViewport=function(Z,be,Ce,Te){Z.isVector4?se.set(Z.x,Z.y,Z.z,Z.w):se.set(Z,be,Ce,Te),oe.viewport(G.copy(se).multiplyScalar(ie).round())},this.getScissor=function(Z){return Z.copy(ue)},this.setScissor=function(Z,be,Ce,Te){Z.isVector4?ue.set(Z.x,Z.y,Z.z,Z.w):ue.set(Z,be,Ce,Te),oe.scissor(L.copy(ue).multiplyScalar(ie).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(Z){oe.setScissorTest(xe=Z)},this.setOpaqueSort=function(Z){H=Z},this.setTransparentSort=function(Z){Y=Z},this.getClearColor=function(Z){return Z.copy(Re.getClearColor())},this.setClearColor=function(){Re.setClearColor(...arguments)},this.getClearAlpha=function(){return Re.getClearAlpha()},this.setClearAlpha=function(){Re.setClearAlpha(...arguments)},this.clear=function(Z=!0,be=!0,Ce=!0){let Te=0;if(Z){let Se=!1;if(O!==null){const Qe=O.texture.format;Se=_.has(Qe)}if(Se){const Qe=O.texture.type,ut=b.has(Qe),vt=Re.getClearColor(),xt=Re.getClearAlpha(),Rt=vt.r,wt=vt.g,pt=vt.b;ut?(v[0]=Rt,v[1]=wt,v[2]=pt,v[3]=xt,$.clearBufferuiv($.COLOR,0,v)):(x[0]=Rt,x[1]=wt,x[2]=pt,x[3]=xt,$.clearBufferiv($.COLOR,0,x))}else Te|=$.COLOR_BUFFER_BIT}be&&(Te|=$.DEPTH_BUFFER_BIT),Ce&&(Te|=$.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),$.clear(Te)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Me,!1),n.removeEventListener("webglcontextrestored",ge,!1),n.removeEventListener("webglcontextcreationerror",Be,!1),Re.dispose(),Le.dispose(),qe.dispose(),Ne.dispose(),j.dispose(),k.dispose(),ye.dispose(),de.dispose(),nt.dispose(),he.dispose(),ke.dispose(),ke.removeEventListener("sessionstart",Gn),ke.removeEventListener("sessionend",fr),Ki.stop()};function Me(Z){Z.preventDefault(),tj("WebGLRenderer: Context Lost."),N=!0}function ge(){tj("WebGLRenderer: Context Restored."),N=!1;const Z=De.autoReset,be=Ie.enabled,Ce=Ie.autoUpdate,Te=Ie.needsUpdate,Se=Ie.type;fe(),De.autoReset=Z,Ie.enabled=be,Ie.autoUpdate=Ce,Ie.needsUpdate=Te,Ie.type=Se}function Be(Z){Ri("WebGLRenderer: A WebGL context could not be created. Reason: ",Z.statusMessage)}function lt(Z){const be=Z.target;be.removeEventListener("dispose",lt),bt(be)}function bt(Z){Nt(Z),Ne.remove(Z)}function Nt(Z){const be=Ne.get(Z).programs;be!==void 0&&(be.forEach(function(Ce){he.releaseProgram(Ce)}),Z.isShaderMaterial&&he.releaseShaderCache(Z))}this.renderBufferDirect=function(Z,be,Ce,Te,Se,Qe){be===null&&(be=ce);const ut=Se.isMesh&&Se.matrixWorld.determinant()<0,vt=le(Z,be,Ce,Te,Se);oe.setMaterial(Te,ut);let xt=Ce.index,Rt=1;if(Te.wireframe===!0){if(xt=me.getWireframeAttribute(Ce),xt===void 0)return;Rt=2}const wt=Ce.drawRange,pt=Ce.attributes.position;let Vt=wt.start*Rt,kt=(wt.start+wt.count)*Rt;Qe!==null&&(Vt=Math.max(Vt,Qe.start*Rt),kt=Math.min(kt,(Qe.start+Qe.count)*Rt)),xt!==null?(Vt=Math.max(Vt,0),kt=Math.min(kt,xt.count)):pt!=null&&(Vt=Math.max(Vt,0),kt=Math.min(kt,pt.count));const Qt=kt-Vt;if(Qt<0||Qt===1/0)return;de.setup(Se,Te,vt,Ce,xt);let on,hn=tt;if(xt!==null&&(on=K.get(xt),hn=et,hn.setIndex(on)),Se.isMesh)Te.wireframe===!0?(oe.setLineWidth(Te.wireframeLinewidth*F()),hn.setMode($.LINES)):hn.setMode($.TRIANGLES);else if(Se.isLine){let Ot=Te.linewidth;Ot===void 0&&(Ot=1),oe.setLineWidth(Ot*F()),Se.isLineSegments?hn.setMode($.LINES):Se.isLineLoop?hn.setMode($.LINE_LOOP):hn.setMode($.LINE_STRIP)}else Se.isPoints?hn.setMode($.POINTS):Se.isSprite&&hn.setMode($.TRIANGLES);if(Se.isBatchedMesh)if(Se._multiDrawInstances!==null)R0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),hn.renderMultiDrawInstances(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount,Se._multiDrawInstances);else if(J.get("WEBGL_multi_draw"))hn.renderMultiDraw(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount);else{const Ot=Se._multiDrawStarts,Wt=Se._multiDrawCounts,Xt=Se._multiDrawCount,vi=xt?K.get(xt).bytesPerElement:1,Ai=Ne.get(Te).currentProgram.getUniforms();for(let Tn=0;Tn<Xt;Tn++)Ai.setValue($,"_gl_DrawID",Tn),hn.render(Ot[Tn]/vi,Wt[Tn])}else if(Se.isInstancedMesh)hn.renderInstances(Vt,Qt,Se.count);else if(Ce.isInstancedBufferGeometry){const Ot=Ce._maxInstanceCount!==void 0?Ce._maxInstanceCount:1/0,Wt=Math.min(Ce.instanceCount,Ot);hn.renderInstances(Vt,Qt,Wt)}else hn.render(Vt,Qt)};function an(Z,be,Ce){Z.transparent===!0&&Z.side===Io&&Z.forceSinglePass===!1?(Z.side=Oa,Z.needsUpdate=!0,Ei(Z,be,Ce),Z.side=Hu,Z.needsUpdate=!0,Ei(Z,be,Ce),Z.side=Io):Ei(Z,be,Ce)}this.compile=function(Z,be,Ce=null){Ce===null&&(Ce=Z),w=qe.get(Ce),w.init(be),T.push(w),Ce.traverseVisible(function(Se){Se.isLight&&Se.layers.test(be.layers)&&(w.pushLight(Se),Se.castShadow&&w.pushShadow(Se))}),Z!==Ce&&Z.traverseVisible(function(Se){Se.isLight&&Se.layers.test(be.layers)&&(w.pushLight(Se),Se.castShadow&&w.pushShadow(Se))}),w.setupLights();const Te=new Set;return Z.traverse(function(Se){if(!(Se.isMesh||Se.isPoints||Se.isLine||Se.isSprite))return;const Qe=Se.material;if(Qe)if(Array.isArray(Qe))for(let ut=0;ut<Qe.length;ut++){const vt=Qe[ut];an(vt,Ce,Se),Te.add(vt)}else an(Qe,Ce,Se),Te.add(Qe)}),w=T.pop(),Te},this.compileAsync=function(Z,be,Ce=null){const Te=this.compile(Z,be,Ce);return new Promise(Se=>{function Qe(){if(Te.forEach(function(ut){Ne.get(ut).currentProgram.isReady()&&Te.delete(ut)}),Te.size===0){Se(Z);return}setTimeout(Qe,10)}J.get("KHR_parallel_shader_compile")!==null?Qe():setTimeout(Qe,10)})};let Dt=null;function Nn(Z){Dt&&Dt(Z)}function Gn(){Ki.stop()}function fr(){Ki.start()}const Ki=new NG;Ki.setAnimationLoop(Nn),typeof self<"u"&&Ki.setContext(self),this.setAnimationLoop=function(Z){Dt=Z,ke.setAnimationLoop(Z),Z===null?Ki.stop():Ki.start()},ke.addEventListener("sessionstart",Gn),ke.addEventListener("sessionend",fr),this.render=function(Z,be){if(be!==void 0&&be.isCamera!==!0){Ri("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===!0)return;if(Z.matrixWorldAutoUpdate===!0&&Z.updateMatrixWorld(),be.parent===null&&be.matrixWorldAutoUpdate===!0&&be.updateMatrixWorld(),ke.enabled===!0&&ke.isPresenting===!0&&(ke.cameraAutoUpdate===!0&&ke.updateCamera(be),be=ke.getCamera()),Z.isScene===!0&&Z.onBeforeRender(P,Z,be,O),w=qe.get(Z,T.length),w.init(be),T.push(w),pe.multiplyMatrices(be.projectionMatrix,be.matrixWorldInverse),re.setFromProjectionMatrix(pe,jo,be.reversedDepth),Pe=this.localClippingEnabled,ve=rt.init(this.clippingPlanes,Pe),M=Le.get(Z,E.length),M.init(),E.push(M),ke.enabled===!0&&ke.isPresenting===!0){const Qe=P.xr.getDepthSensingMesh();Qe!==null&&hr(Qe,be,-1/0,P.sortObjects)}hr(Z,be,0,P.sortObjects),M.finish(),P.sortObjects===!0&&M.sort(H,Y),ft=ke.enabled===!1||ke.isPresenting===!1||ke.hasDepthSensing()===!1,ft&&Re.addToRenderList(M,Z),this.info.render.frame++,ve===!0&&rt.beginShadows();const Ce=w.state.shadowsArray;Ie.render(Ce,Z,be),ve===!0&&rt.endShadows(),this.info.autoReset===!0&&this.info.reset();const Te=M.opaque,Se=M.transmissive;if(w.setupLights(),be.isArrayCamera){const Qe=be.cameras;if(Se.length>0)for(let ut=0,vt=Qe.length;ut<vt;ut++){const xt=Qe[ut];$r(Te,Se,Z,xt)}ft&&Re.render(Z);for(let ut=0,vt=Qe.length;ut<vt;ut++){const xt=Qe[ut];Cr(M,Z,xt,xt.viewport)}}else Se.length>0&&$r(Te,Se,Z,be),ft&&Re.render(Z),Cr(M,Z,be);O!==null&&R===0&&(te.updateMultisampleRenderTarget(O),te.updateRenderTargetMipmap(O)),Z.isScene===!0&&Z.onAfterRender(P,Z,be),de.resetDefaultState(),z=-1,I=null,T.pop(),T.length>0?(w=T[T.length-1],ve===!0&&rt.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,E.pop(),E.length>0?M=E[E.length-1]:M=null};function hr(Z,be,Ce,Te){if(Z.visible===!1)return;if(Z.layers.test(be.layers)){if(Z.isGroup)Ce=Z.renderOrder;else if(Z.isLOD)Z.autoUpdate===!0&&Z.update(be);else if(Z.isLight)w.pushLight(Z),Z.castShadow&&w.pushShadow(Z);else if(Z.isSprite){if(!Z.frustumCulled||re.intersectsSprite(Z)){Te&&ze.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(pe);const ut=ye.update(Z),vt=Z.material;vt.visible&&M.push(Z,ut,vt,Ce,ze.z,null)}}else if((Z.isMesh||Z.isLine||Z.isPoints)&&(!Z.frustumCulled||re.intersectsObject(Z))){const ut=ye.update(Z),vt=Z.material;if(Te&&(Z.boundingSphere!==void 0?(Z.boundingSphere===null&&Z.computeBoundingSphere(),ze.copy(Z.boundingSphere.center)):(ut.boundingSphere===null&&ut.computeBoundingSphere(),ze.copy(ut.boundingSphere.center)),ze.applyMatrix4(Z.matrixWorld).applyMatrix4(pe)),Array.isArray(vt)){const xt=ut.groups;for(let Rt=0,wt=xt.length;Rt<wt;Rt++){const pt=xt[Rt],Vt=vt[pt.materialIndex];Vt&&Vt.visible&&M.push(Z,ut,Vt,Ce,ze.z,pt)}}else vt.visible&&M.push(Z,ut,vt,Ce,ze.z,null)}}const Qe=Z.children;for(let ut=0,vt=Qe.length;ut<vt;ut++)hr(Qe[ut],be,Ce,Te)}function Cr(Z,be,Ce,Te){const{opaque:Se,transmissive:Qe,transparent:ut}=Z;w.setupLightsView(Ce),ve===!0&&rt.setGlobalState(P.clippingPlanes,Ce),Te&&oe.viewport(G.copy(Te)),Se.length>0&&Oi(Se,be,Ce),Qe.length>0&&Oi(Qe,be,Ce),ut.length>0&&Oi(ut,be,Ce),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function $r(Z,be,Ce,Te){if((Ce.isScene===!0?Ce.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Te.id]===void 0&&(w.state.transmissionRenderTarget[Te.id]=new bf(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float")?am:Go,minFilter:qd,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:wn.workingColorSpace}));const Qe=w.state.transmissionRenderTarget[Te.id],ut=Te.viewport||G;Qe.setSize(ut.z*P.transmissionResolutionScale,ut.w*P.transmissionResolutionScale);const vt=P.getRenderTarget(),xt=P.getActiveCubeFace(),Rt=P.getActiveMipmapLevel();P.setRenderTarget(Qe),P.getClearColor(q),W=P.getClearAlpha(),W<1&&P.setClearColor(16777215,.5),P.clear(),ft&&Re.render(Ce);const wt=P.toneMapping;P.toneMapping=Ru;const pt=Te.viewport;if(Te.viewport!==void 0&&(Te.viewport=void 0),w.setupLightsView(Te),ve===!0&&rt.setGlobalState(P.clippingPlanes,Te),Oi(Z,Ce,Te),te.updateMultisampleRenderTarget(Qe),te.updateRenderTargetMipmap(Qe),J.has("WEBGL_multisampled_render_to_texture")===!1){let Vt=!1;for(let kt=0,Qt=be.length;kt<Qt;kt++){const on=be[kt],{object:hn,geometry:Ot,material:Wt,group:Xt}=on;if(Wt.side===Io&&hn.layers.test(Te.layers)){const vi=Wt.side;Wt.side=Oa,Wt.needsUpdate=!0,fi(hn,Ce,Te,Ot,Wt,Xt),Wt.side=vi,Wt.needsUpdate=!0,Vt=!0}}Vt===!0&&(te.updateMultisampleRenderTarget(Qe),te.updateRenderTargetMipmap(Qe))}P.setRenderTarget(vt,xt,Rt),P.setClearColor(q,W),pt!==void 0&&(Te.viewport=pt),P.toneMapping=wt}function Oi(Z,be,Ce){const Te=be.isScene===!0?be.overrideMaterial:null;for(let Se=0,Qe=Z.length;Se<Qe;Se++){const ut=Z[Se],{object:vt,geometry:xt,group:Rt}=ut;let wt=ut.material;wt.allowOverride===!0&&Te!==null&&(wt=Te),vt.layers.test(Ce.layers)&&fi(vt,be,Ce,xt,wt,Rt)}}function fi(Z,be,Ce,Te,Se,Qe){Z.onBeforeRender(P,be,Ce,Te,Se,Qe),Z.modelViewMatrix.multiplyMatrices(Ce.matrixWorldInverse,Z.matrixWorld),Z.normalMatrix.getNormalMatrix(Z.modelViewMatrix),Se.onBeforeRender(P,be,Ce,Te,Z,Qe),Se.transparent===!0&&Se.side===Io&&Se.forceSinglePass===!1?(Se.side=Oa,Se.needsUpdate=!0,P.renderBufferDirect(Ce,be,Te,Se,Z,Qe),Se.side=Hu,Se.needsUpdate=!0,P.renderBufferDirect(Ce,be,Te,Se,Z,Qe),Se.side=Io):P.renderBufferDirect(Ce,be,Te,Se,Z,Qe),Z.onAfterRender(P,be,Ce,Te,Se,Qe)}function Ei(Z,be,Ce){be.isScene!==!0&&(be=ce);const Te=Ne.get(Z),Se=w.state.lights,Qe=w.state.shadowsArray,ut=Se.state.version,vt=he.getParameters(Z,Se.state,Qe,be,Ce),xt=he.getProgramCacheKey(vt);let Rt=Te.programs;Te.environment=Z.isMeshStandardMaterial?be.environment:null,Te.fog=be.fog,Te.envMap=(Z.isMeshStandardMaterial?k:j).get(Z.envMap||Te.environment),Te.envMapRotation=Te.environment!==null&&Z.envMap===null?be.environmentRotation:Z.envMapRotation,Rt===void 0&&(Z.addEventListener("dispose",lt),Rt=new Map,Te.programs=Rt);let wt=Rt.get(xt);if(wt!==void 0){if(Te.currentProgram===wt&&Te.lightsStateVersion===ut)return Ac(Z,vt),wt}else vt.uniforms=he.getUniforms(Z),Z.onBeforeCompile(vt,P),wt=he.acquireProgram(vt,xt),Rt.set(xt,wt),Te.uniforms=vt.uniforms;const pt=Te.uniforms;return(!Z.isShaderMaterial&&!Z.isRawShaderMaterial||Z.clipping===!0)&&(pt.clippingPlanes=rt.uniform),Ac(Z,vt),Te.needsLights=We(Z),Te.lightsStateVersion=ut,Te.needsLights&&(pt.ambientLightColor.value=Se.state.ambient,pt.lightProbe.value=Se.state.probe,pt.directionalLights.value=Se.state.directional,pt.directionalLightShadows.value=Se.state.directionalShadow,pt.spotLights.value=Se.state.spot,pt.spotLightShadows.value=Se.state.spotShadow,pt.rectAreaLights.value=Se.state.rectArea,pt.ltc_1.value=Se.state.rectAreaLTC1,pt.ltc_2.value=Se.state.rectAreaLTC2,pt.pointLights.value=Se.state.point,pt.pointLightShadows.value=Se.state.pointShadow,pt.hemisphereLights.value=Se.state.hemi,pt.directionalShadowMap.value=Se.state.directionalShadowMap,pt.directionalShadowMatrix.value=Se.state.directionalShadowMatrix,pt.spotShadowMap.value=Se.state.spotShadowMap,pt.spotLightMatrix.value=Se.state.spotLightMatrix,pt.spotLightMap.value=Se.state.spotLightMap,pt.pointShadowMap.value=Se.state.pointShadowMap,pt.pointShadowMatrix.value=Se.state.pointShadowMatrix),Te.currentProgram=wt,Te.uniformsList=null,wt}function Ks(Z){if(Z.uniformsList===null){const be=Z.currentProgram.getUniforms();Z.uniformsList=Qb.seqWithValue(be.seq,Z.uniforms)}return Z.uniformsList}function Ac(Z,be){const Ce=Ne.get(Z);Ce.outputColorSpace=be.outputColorSpace,Ce.batching=be.batching,Ce.batchingColor=be.batchingColor,Ce.instancing=be.instancing,Ce.instancingColor=be.instancingColor,Ce.instancingMorph=be.instancingMorph,Ce.skinning=be.skinning,Ce.morphTargets=be.morphTargets,Ce.morphNormals=be.morphNormals,Ce.morphColors=be.morphColors,Ce.morphTargetsCount=be.morphTargetsCount,Ce.numClippingPlanes=be.numClippingPlanes,Ce.numIntersection=be.numClipIntersection,Ce.vertexAlphas=be.vertexAlphas,Ce.vertexTangents=be.vertexTangents,Ce.toneMapping=be.toneMapping}function le(Z,be,Ce,Te,Se){be.isScene!==!0&&(be=ce),te.resetTextureUnits();const Qe=be.fog,ut=Te.isMeshStandardMaterial?be.environment:null,vt=O===null?P.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:Op,xt=(Te.isMeshStandardMaterial?k:j).get(Te.envMap||ut),Rt=Te.vertexColors===!0&&!!Ce.attributes.color&&Ce.attributes.color.itemSize===4,wt=!!Ce.attributes.tangent&&(!!Te.normalMap||Te.anisotropy>0),pt=!!Ce.morphAttributes.position,Vt=!!Ce.morphAttributes.normal,kt=!!Ce.morphAttributes.color;let Qt=Ru;Te.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(Qt=P.toneMapping);const on=Ce.morphAttributes.position||Ce.morphAttributes.normal||Ce.morphAttributes.color,hn=on!==void 0?on.length:0,Ot=Ne.get(Te),Wt=w.state.lights;if(ve===!0&&(Pe===!0||Z!==I)){const mr=Z===I&&Te.id===z;rt.setState(Te,Z,mr)}let Xt=!1;Te.version===Ot.__version?(Ot.needsLights&&Ot.lightsStateVersion!==Wt.state.version||Ot.outputColorSpace!==vt||Se.isBatchedMesh&&Ot.batching===!1||!Se.isBatchedMesh&&Ot.batching===!0||Se.isBatchedMesh&&Ot.batchingColor===!0&&Se.colorTexture===null||Se.isBatchedMesh&&Ot.batchingColor===!1&&Se.colorTexture!==null||Se.isInstancedMesh&&Ot.instancing===!1||!Se.isInstancedMesh&&Ot.instancing===!0||Se.isSkinnedMesh&&Ot.skinning===!1||!Se.isSkinnedMesh&&Ot.skinning===!0||Se.isInstancedMesh&&Ot.instancingColor===!0&&Se.instanceColor===null||Se.isInstancedMesh&&Ot.instancingColor===!1&&Se.instanceColor!==null||Se.isInstancedMesh&&Ot.instancingMorph===!0&&Se.morphTexture===null||Se.isInstancedMesh&&Ot.instancingMorph===!1&&Se.morphTexture!==null||Ot.envMap!==xt||Te.fog===!0&&Ot.fog!==Qe||Ot.numClippingPlanes!==void 0&&(Ot.numClippingPlanes!==rt.numPlanes||Ot.numIntersection!==rt.numIntersection)||Ot.vertexAlphas!==Rt||Ot.vertexTangents!==wt||Ot.morphTargets!==pt||Ot.morphNormals!==Vt||Ot.morphColors!==kt||Ot.toneMapping!==Qt||Ot.morphTargetsCount!==hn)&&(Xt=!0):(Xt=!0,Ot.__version=Te.version);let vi=Ot.currentProgram;Xt===!0&&(vi=Ei(Te,be,Se));let Ai=!1,Tn=!1,Ys=!1;const Rn=vi.getUniforms(),pr=Ot.uniforms;if(oe.useProgram(vi.program)&&(Ai=!0,Tn=!0,Ys=!0),Te.id!==z&&(z=Te.id,Tn=!0),Ai||I!==Z){oe.buffers.depth.getReversed()&&Z.reversedDepth!==!0&&(Z._reversedDepth=!0,Z.updateProjectionMatrix()),Rn.setValue($,"projectionMatrix",Z.projectionMatrix),Rn.setValue($,"viewMatrix",Z.matrixWorldInverse);const Nr=Rn.map.cameraPosition;Nr!==void 0&&Nr.setValue($,we.setFromMatrixPosition(Z.matrixWorld)),ee.logarithmicDepthBuffer&&Rn.setValue($,"logDepthBufFC",2/(Math.log(Z.far+1)/Math.LN2)),(Te.isMeshPhongMaterial||Te.isMeshToonMaterial||Te.isMeshLambertMaterial||Te.isMeshBasicMaterial||Te.isMeshStandardMaterial||Te.isShaderMaterial)&&Rn.setValue($,"isOrthographic",Z.isOrthographicCamera===!0),I!==Z&&(I=Z,Tn=!0,Ys=!0)}if(Se.isSkinnedMesh){Rn.setOptional($,Se,"bindMatrix"),Rn.setOptional($,Se,"bindMatrixInverse");const mr=Se.skeleton;mr&&(mr.boneTexture===null&&mr.computeBoneTexture(),Rn.setValue($,"boneTexture",mr.boneTexture,te))}Se.isBatchedMesh&&(Rn.setOptional($,Se,"batchingTexture"),Rn.setValue($,"batchingTexture",Se._matricesTexture,te),Rn.setOptional($,Se,"batchingIdTexture"),Rn.setValue($,"batchingIdTexture",Se._indirectTexture,te),Rn.setOptional($,Se,"batchingColorTexture"),Se._colorsTexture!==null&&Rn.setValue($,"batchingColorTexture",Se._colorsTexture,te));const Yi=Ce.morphAttributes;if((Yi.position!==void 0||Yi.normal!==void 0||Yi.color!==void 0)&&ht.update(Se,Ce,vi),(Tn||Ot.receiveShadow!==Se.receiveShadow)&&(Ot.receiveShadow=Se.receiveShadow,Rn.setValue($,"receiveShadow",Se.receiveShadow)),Te.isMeshGouraudMaterial&&Te.envMap!==null&&(pr.envMap.value=xt,pr.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Te.isMeshStandardMaterial&&Te.envMap===null&&be.environment!==null&&(pr.envMapIntensity.value=be.environmentIntensity),pr.dfgLUT!==void 0&&(pr.dfgLUT.value=Gfe()),Tn&&(Rn.setValue($,"toneMappingExposure",P.toneMappingExposure),Ot.needsLights&&Ue(pr,Ys),Qe&&Te.fog===!0&&Ye.refreshFogUniforms(pr,Qe),Ye.refreshMaterialUniforms(pr,Te,ie,Q,w.state.transmissionRenderTarget[Z.id]),Qb.upload($,Ks(Ot),pr,te)),Te.isShaderMaterial&&Te.uniformsNeedUpdate===!0&&(Qb.upload($,Ks(Ot),pr,te),Te.uniformsNeedUpdate=!1),Te.isSpriteMaterial&&Rn.setValue($,"center",Se.center),Rn.setValue($,"modelViewMatrix",Se.modelViewMatrix),Rn.setValue($,"normalMatrix",Se.normalMatrix),Rn.setValue($,"modelMatrix",Se.matrixWorld),Te.isShaderMaterial||Te.isRawShaderMaterial){const mr=Te.uniformsGroups;for(let Nr=0,Mo=mr.length;Nr<Mo;Nr++){const nl=mr[Nr];nt.update(nl,vi),nt.bind(nl,vi)}}return vi}function Ue(Z,be){Z.ambientLightColor.needsUpdate=be,Z.lightProbe.needsUpdate=be,Z.directionalLights.needsUpdate=be,Z.directionalLightShadows.needsUpdate=be,Z.pointLights.needsUpdate=be,Z.pointLightShadows.needsUpdate=be,Z.spotLights.needsUpdate=be,Z.spotLightShadows.needsUpdate=be,Z.rectAreaLights.needsUpdate=be,Z.hemisphereLights.needsUpdate=be}function We(Z){return Z.isMeshLambertMaterial||Z.isMeshToonMaterial||Z.isMeshPhongMaterial||Z.isMeshStandardMaterial||Z.isShadowMaterial||Z.isShaderMaterial&&Z.lights===!0}this.getActiveCubeFace=function(){return U},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(Z,be,Ce){const Te=Ne.get(Z);Te.__autoAllocateDepthBuffer=Z.resolveDepthBuffer===!1,Te.__autoAllocateDepthBuffer===!1&&(Te.__useRenderToTexture=!1),Ne.get(Z.texture).__webglTexture=be,Ne.get(Z.depthTexture).__webglTexture=Te.__autoAllocateDepthBuffer?void 0:Ce,Te.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(Z,be){const Ce=Ne.get(Z);Ce.__webglFramebuffer=be,Ce.__useDefaultFramebuffer=be===void 0};const Xe=$.createFramebuffer();this.setRenderTarget=function(Z,be=0,Ce=0){O=Z,U=be,R=Ce;let Te=!0,Se=null,Qe=!1,ut=!1;if(Z){const xt=Ne.get(Z);if(xt.__useDefaultFramebuffer!==void 0)oe.bindFramebuffer($.FRAMEBUFFER,null),Te=!1;else if(xt.__webglFramebuffer===void 0)te.setupRenderTarget(Z);else if(xt.__hasExternalTextures)te.rebindTextures(Z,Ne.get(Z.texture).__webglTexture,Ne.get(Z.depthTexture).__webglTexture);else if(Z.depthBuffer){const pt=Z.depthTexture;if(xt.__boundDepthTexture!==pt){if(pt!==null&&Ne.has(pt)&&(Z.width!==pt.image.width||Z.height!==pt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");te.setupDepthRenderbuffer(Z)}}const Rt=Z.texture;(Rt.isData3DTexture||Rt.isDataArrayTexture||Rt.isCompressedArrayTexture)&&(ut=!0);const wt=Ne.get(Z).__webglFramebuffer;Z.isWebGLCubeRenderTarget?(Array.isArray(wt[be])?Se=wt[be][Ce]:Se=wt[be],Qe=!0):Z.samples>0&&te.useMultisampledRTT(Z)===!1?Se=Ne.get(Z).__webglMultisampledFramebuffer:Array.isArray(wt)?Se=wt[Ce]:Se=wt,G.copy(Z.viewport),L.copy(Z.scissor),B=Z.scissorTest}else G.copy(se).multiplyScalar(ie).floor(),L.copy(ue).multiplyScalar(ie).floor(),B=xe;if(Ce!==0&&(Se=Xe),oe.bindFramebuffer($.FRAMEBUFFER,Se)&&Te&&oe.drawBuffers(Z,Se),oe.viewport(G),oe.scissor(L),oe.setScissorTest(B),Qe){const xt=Ne.get(Z.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+be,xt.__webglTexture,Ce)}else if(ut){const xt=be;for(let Rt=0;Rt<Z.textures.length;Rt++){const wt=Ne.get(Z.textures[Rt]);$.framebufferTextureLayer($.FRAMEBUFFER,$.COLOR_ATTACHMENT0+Rt,wt.__webglTexture,Ce,xt)}}else if(Z!==null&&Ce!==0){const xt=Ne.get(Z.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,xt.__webglTexture,Ce)}z=-1},this.readRenderTargetPixels=function(Z,be,Ce,Te,Se,Qe,ut,vt=0){if(!(Z&&Z.isWebGLRenderTarget)){Ri("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ne.get(Z).__webglFramebuffer;if(Z.isWebGLCubeRenderTarget&&ut!==void 0&&(xt=xt[ut]),xt){oe.bindFramebuffer($.FRAMEBUFFER,xt);try{const Rt=Z.textures[vt],wt=Rt.format,pt=Rt.type;if(!ee.textureFormatReadable(wt)){Ri("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ee.textureTypeReadable(pt)){Ri("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}be>=0&&be<=Z.width-Te&&Ce>=0&&Ce<=Z.height-Se&&(Z.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+vt),$.readPixels(be,Ce,Te,Se,ct.convert(wt),ct.convert(pt),Qe))}finally{const Rt=O!==null?Ne.get(O).__webglFramebuffer:null;oe.bindFramebuffer($.FRAMEBUFFER,Rt)}}},this.readRenderTargetPixelsAsync=async function(Z,be,Ce,Te,Se,Qe,ut,vt=0){if(!(Z&&Z.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ne.get(Z).__webglFramebuffer;if(Z.isWebGLCubeRenderTarget&&ut!==void 0&&(xt=xt[ut]),xt)if(be>=0&&be<=Z.width-Te&&Ce>=0&&Ce<=Z.height-Se){oe.bindFramebuffer($.FRAMEBUFFER,xt);const Rt=Z.textures[vt],wt=Rt.format,pt=Rt.type;if(!ee.textureFormatReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ee.textureTypeReadable(pt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Vt=$.createBuffer();$.bindBuffer($.PIXEL_PACK_BUFFER,Vt),$.bufferData($.PIXEL_PACK_BUFFER,Qe.byteLength,$.STREAM_READ),Z.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+vt),$.readPixels(be,Ce,Te,Se,ct.convert(wt),ct.convert(pt),0);const kt=O!==null?Ne.get(O).__webglFramebuffer:null;oe.bindFramebuffer($.FRAMEBUFFER,kt);const Qt=$.fenceSync($.SYNC_GPU_COMMANDS_COMPLETE,0);return $.flush(),await xoe($,Qt,4),$.bindBuffer($.PIXEL_PACK_BUFFER,Vt),$.getBufferSubData($.PIXEL_PACK_BUFFER,0,Qe),$.deleteBuffer(Vt),$.deleteSync(Qt),Qe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(Z,be=null,Ce=0){const Te=Math.pow(2,-Ce),Se=Math.floor(Z.image.width*Te),Qe=Math.floor(Z.image.height*Te),ut=be!==null?be.x:0,vt=be!==null?be.y:0;te.setTexture2D(Z,0),$.copyTexSubImage2D($.TEXTURE_2D,Ce,0,0,ut,vt,Se,Qe),oe.unbindTexture()};const Ge=$.createFramebuffer(),_t=$.createFramebuffer();this.copyTextureToTexture=function(Z,be,Ce=null,Te=null,Se=0,Qe=null){Qe===null&&(Se!==0?(R0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Qe=Se,Se=0):Qe=0);let ut,vt,xt,Rt,wt,pt,Vt,kt,Qt;const on=Z.isCompressedTexture?Z.mipmaps[Qe]:Z.image;if(Ce!==null)ut=Ce.max.x-Ce.min.x,vt=Ce.max.y-Ce.min.y,xt=Ce.isBox3?Ce.max.z-Ce.min.z:1,Rt=Ce.min.x,wt=Ce.min.y,pt=Ce.isBox3?Ce.min.z:0;else{const Yi=Math.pow(2,-Se);ut=Math.floor(on.width*Yi),vt=Math.floor(on.height*Yi),Z.isDataArrayTexture?xt=on.depth:Z.isData3DTexture?xt=Math.floor(on.depth*Yi):xt=1,Rt=0,wt=0,pt=0}Te!==null?(Vt=Te.x,kt=Te.y,Qt=Te.z):(Vt=0,kt=0,Qt=0);const hn=ct.convert(be.format),Ot=ct.convert(be.type);let Wt;be.isData3DTexture?(te.setTexture3D(be,0),Wt=$.TEXTURE_3D):be.isDataArrayTexture||be.isCompressedArrayTexture?(te.setTexture2DArray(be,0),Wt=$.TEXTURE_2D_ARRAY):(te.setTexture2D(be,0),Wt=$.TEXTURE_2D),$.pixelStorei($.UNPACK_FLIP_Y_WEBGL,be.flipY),$.pixelStorei($.UNPACK_PREMULTIPLY_ALPHA_WEBGL,be.premultiplyAlpha),$.pixelStorei($.UNPACK_ALIGNMENT,be.unpackAlignment);const Xt=$.getParameter($.UNPACK_ROW_LENGTH),vi=$.getParameter($.UNPACK_IMAGE_HEIGHT),Ai=$.getParameter($.UNPACK_SKIP_PIXELS),Tn=$.getParameter($.UNPACK_SKIP_ROWS),Ys=$.getParameter($.UNPACK_SKIP_IMAGES);$.pixelStorei($.UNPACK_ROW_LENGTH,on.width),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,on.height),$.pixelStorei($.UNPACK_SKIP_PIXELS,Rt),$.pixelStorei($.UNPACK_SKIP_ROWS,wt),$.pixelStorei($.UNPACK_SKIP_IMAGES,pt);const Rn=Z.isDataArrayTexture||Z.isData3DTexture,pr=be.isDataArrayTexture||be.isData3DTexture;if(Z.isDepthTexture){const Yi=Ne.get(Z),mr=Ne.get(be),Nr=Ne.get(Yi.__renderTarget),Mo=Ne.get(mr.__renderTarget);oe.bindFramebuffer($.READ_FRAMEBUFFER,Nr.__webglFramebuffer),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,Mo.__webglFramebuffer);for(let nl=0;nl<xt;nl++)Rn&&($.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Ne.get(Z).__webglTexture,Se,pt+nl),$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Ne.get(be).__webglTexture,Qe,Qt+nl)),$.blitFramebuffer(Rt,wt,ut,vt,Vt,kt,ut,vt,$.DEPTH_BUFFER_BIT,$.NEAREST);oe.bindFramebuffer($.READ_FRAMEBUFFER,null),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else if(Se!==0||Z.isRenderTargetTexture||Ne.has(Z)){const Yi=Ne.get(Z),mr=Ne.get(be);oe.bindFramebuffer($.READ_FRAMEBUFFER,Ge),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,_t);for(let Nr=0;Nr<xt;Nr++)Rn?$.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Yi.__webglTexture,Se,pt+Nr):$.framebufferTexture2D($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,Yi.__webglTexture,Se),pr?$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,mr.__webglTexture,Qe,Qt+Nr):$.framebufferTexture2D($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,mr.__webglTexture,Qe),Se!==0?$.blitFramebuffer(Rt,wt,ut,vt,Vt,kt,ut,vt,$.COLOR_BUFFER_BIT,$.NEAREST):pr?$.copyTexSubImage3D(Wt,Qe,Vt,kt,Qt+Nr,Rt,wt,ut,vt):$.copyTexSubImage2D(Wt,Qe,Vt,kt,Rt,wt,ut,vt);oe.bindFramebuffer($.READ_FRAMEBUFFER,null),oe.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else pr?Z.isDataTexture||Z.isData3DTexture?$.texSubImage3D(Wt,Qe,Vt,kt,Qt,ut,vt,xt,hn,Ot,on.data):be.isCompressedArrayTexture?$.compressedTexSubImage3D(Wt,Qe,Vt,kt,Qt,ut,vt,xt,hn,on.data):$.texSubImage3D(Wt,Qe,Vt,kt,Qt,ut,vt,xt,hn,Ot,on):Z.isDataTexture?$.texSubImage2D($.TEXTURE_2D,Qe,Vt,kt,ut,vt,hn,Ot,on.data):Z.isCompressedTexture?$.compressedTexSubImage2D($.TEXTURE_2D,Qe,Vt,kt,on.width,on.height,hn,on.data):$.texSubImage2D($.TEXTURE_2D,Qe,Vt,kt,ut,vt,hn,Ot,on);$.pixelStorei($.UNPACK_ROW_LENGTH,Xt),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,vi),$.pixelStorei($.UNPACK_SKIP_PIXELS,Ai),$.pixelStorei($.UNPACK_SKIP_ROWS,Tn),$.pixelStorei($.UNPACK_SKIP_IMAGES,Ys),Qe===0&&be.generateMipmaps&&$.generateMipmap(Wt),oe.unbindTexture()},this.initRenderTarget=function(Z){Ne.get(Z).__webglFramebuffer===void 0&&te.setupRenderTarget(Z)},this.initTexture=function(Z){Z.isCubeTexture?te.setTextureCube(Z,0):Z.isData3DTexture?te.setTexture3D(Z,0):Z.isDataArrayTexture||Z.isCompressedArrayTexture?te.setTexture2DArray(Z,0):te.setTexture2D(Z,0),oe.unbindTexture()},this.resetState=function(){U=0,R=0,O=null,oe.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return jo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=wn._getDrawingBufferColorSpace(e),n.unpackColorSpace=wn._getUnpackColorSpace()}};const Yj={type:"change"},yP={type:"start"},kG={type:"end"},Oy=new pP,Zj=new du,qfe=Math.cos(70*yoe.DEG2RAD),Qi=new $e,Ca=2*Math.PI,Hn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},kA=1e-6;class Xfe extends ale{constructor(e,n=null){super(e,n),this.state=Hn.NONE,this.target=new $e,this.cursor=new $e,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:xp.ROTATE,MIDDLE:xp.DOLLY,RIGHT:xp.PAN},this.touches={ONE:up.ROTATE,TWO:up.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new $e,this._lastQuaternion=new yf,this._lastTargetPosition=new $e,this._quat=new yf().setFromUnitVectors(e.up,new $e(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ej,this._sphericalDelta=new Ej,this._scale=1,this._panOffset=new $e,this._rotateStart=new nn,this._rotateEnd=new nn,this._rotateDelta=new nn,this._panStart=new nn,this._panEnd=new nn,this._panDelta=new nn,this._dollyStart=new nn,this._dollyEnd=new nn,this._dollyDelta=new nn,this._dollyDirection=new $e,this._mouse=new nn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Yfe.bind(this),this._onPointerDown=Kfe.bind(this),this._onPointerUp=Zfe.bind(this),this._onContextMenu=rhe.bind(this),this._onMouseWheel=ehe.bind(this),this._onKeyDown=the.bind(this),this._onTouchStart=nhe.bind(this),this._onTouchMove=ihe.bind(this),this._onMouseDown=Qfe.bind(this),this._onMouseMove=Jfe.bind(this),this._interceptControlDown=ahe.bind(this),this._interceptControlUp=she.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Yj),this.update(),this.state=Hn.NONE}update(e=null){const n=this.object.position;Qi.copy(n).sub(this.target),Qi.applyQuaternion(this._quat),this._spherical.setFromVector3(Qi),this.autoRotate&&this.state===Hn.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(i)&&isFinite(r)&&(i<-Math.PI?i+=Ca:i>Math.PI&&(i-=Ca),r<-Math.PI?r+=Ca:r>Math.PI&&(r-=Ca),i<=r?this._spherical.theta=Math.max(i,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+r)/2?Math.max(i,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=s!=this._spherical.radius}if(Qi.setFromSpherical(this._spherical),Qi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Qi),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){const o=Qi.length();s=this._clampDistance(o*this._scale);const l=o-s;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),a=!!l}else if(this.object.isOrthographicCamera){const o=new $e(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=l!==this.object.zoom;const c=new $e(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=Qi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(Oy.origin.copy(this.object.position),Oy.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Oy.direction))<qfe?this.object.lookAt(this.target):(Zj.setFromNormalAndCoplanarPoint(this.object.up,this.target),Oy.intersectPlane(Zj,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>kA||8*(1-this._lastQuaternion.dot(this.object.quaternion))>kA||this._lastTargetPosition.distanceToSquared(this.target)>kA?(this.dispatchEvent(Yj),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ca/60*this.autoRotateSpeed*e:Ca/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){Qi.setFromMatrixColumn(n,0),Qi.multiplyScalar(-e),this._panOffset.add(Qi)}_panUp(e,n){this.screenSpacePanning===!0?Qi.setFromMatrixColumn(n,1):(Qi.setFromMatrixColumn(n,0),Qi.crossVectors(this.object.up,Qi)),Qi.multiplyScalar(e),this._panOffset.add(Qi)}_pan(e,n){const i=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;Qi.copy(r).sub(this.target);let a=Qi.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/i.clientHeight,this.object.matrix),this._panUp(2*n*a/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),r=e-i.left,a=n-i.top,s=i.width,o=i.height;this._mouse.x=r/s*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ca*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ca*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Ca*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Ca*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Ca*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Ca*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateStart.set(i,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._panStart.set(i,r)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),i=e.pageX-n.x,r=e.pageY-n.y,a=Math.sqrt(i*i+r*r);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),r=.5*(e.pageX+i.x),a=.5*(e.pageY+i.y);this._rotateEnd.set(r,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ca*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ca*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._panEnd.set(i,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),i=e.pageX-n.x,r=e.pageY-n.y,a=Math.sqrt(i*i+r*r);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const s=(e.pageX+n.x)*.5,o=(e.pageY+n.y)*.5;this._updateZoomParameters(s,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new nn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Kfe(t){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(t)&&(this._addPointer(t),t.pointerType==="touch"?this._onTouchStart(t):this._onMouseDown(t)))}function Yfe(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function Zfe(t){switch(this._removePointer(t),this._pointers.length){case 0:this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(kG),this.state=Hn.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function Qfe(t){let e;switch(t.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case xp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Hn.DOLLY;break;case xp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Hn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Hn.ROTATE}break;case xp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Hn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Hn.PAN}break;default:this.state=Hn.NONE}this.state!==Hn.NONE&&this.dispatchEvent(yP)}function Jfe(t){switch(this.state){case Hn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Hn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Hn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function ehe(t){this.enabled===!1||this.enableZoom===!1||this.state!==Hn.NONE||(t.preventDefault(),this.dispatchEvent(yP),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(kG))}function the(t){this.enabled!==!1&&this._handleKeyDown(t)}function nhe(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case up.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Hn.TOUCH_ROTATE;break;case up.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Hn.TOUCH_PAN;break;default:this.state=Hn.NONE}break;case 2:switch(this.touches.TWO){case up.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Hn.TOUCH_DOLLY_PAN;break;case up.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Hn.TOUCH_DOLLY_ROTATE;break;default:this.state=Hn.NONE}break;default:this.state=Hn.NONE}this.state!==Hn.NONE&&this.dispatchEvent(yP)}function ihe(t){switch(this._trackPointer(t),this.state){case Hn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Hn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Hn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Hn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Hn.NONE}}function rhe(t){this.enabled!==!1&&t.preventDefault()}function ahe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function she(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ohe(t,e=!1){const n=t[0].index!==null,i=new Set(Object.keys(t[0].attributes)),r=new Set(Object.keys(t[0].morphAttributes)),a={},s={},o=t[0].morphTargetsRelative,l=new tl;let c=0;for(let d=0;d<t.length;++d){const f=t[d];let p=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.attributes[m]),p++}if(p!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(o!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in f.morphAttributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;s[m]===void 0&&(s[m]=[]),s[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,m,d),c+=m}}if(n){let d=0;const f=[];for(let p=0;p<t.length;++p){const m=t[p].index;for(let _=0;_<m.count;++_)f.push(m.getX(_)+d);d+=t[p].attributes.position.count}l.setIndex(f)}for(const d in a){const f=Qj(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,f)}for(const d in s){const f=s[d][0].length;if(f===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let p=0;p<f;++p){const m=[];for(let b=0;b<s[d].length;++b)m.push(s[d][b][p]);const _=Qj(m);if(!_)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(_)}}return l}function Qj(t){let e,n,i,r=-1,a=0;for(let c=0;c<t.length;++c){const d=t[c];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=d.normalized),i!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=d.gpuType),r!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const s=new e(a),o=new zs(s,n,i);let l=0;for(let c=0;c<t.length;++c){const d=t[c];if(d.isInterleavedBufferAttribute){const f=l/n;for(let p=0,m=d.count;p<m;p++)for(let _=0;_<n;_++){const b=d.getComponent(p,_);o.setComponent(p+f,_,b)}}else s.set(d.array,l);l+=d.count*n}return r!==void 0&&(o.gpuType=r),o}function ky(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var LA={exports:{}};var Jj;function lhe(){return Jj||(Jj=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(i,r,a){function s(c,d){if(!r[c]){if(!i[c]){var f=typeof ky=="function"&&ky;if(!d&&f)return f(c,!0);if(o)return o(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var m=r[c]={exports:{}};i[c][0].call(m.exports,function(_){var b=i[c][1][_];return s(b||_)},m,m.exports,n,i,r,a)}return r[c].exports}for(var o=typeof ky=="function"&&ky,l=0;l<a.length;l++)s(a[l]);return s})({1:[function(n,i,r){var a=n("./utils"),s=n("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(l){for(var c,d,f,p,m,_,b,v=[],x=0,M=l.length,w=M,E=a.getTypeOf(l)!=="string";x<l.length;)w=M-x,f=E?(c=l[x++],d=x<M?l[x++]:0,x<M?l[x++]:0):(c=l.charCodeAt(x++),d=x<M?l.charCodeAt(x++):0,x<M?l.charCodeAt(x++):0),p=c>>2,m=(3&c)<<4|d>>4,_=1<w?(15&d)<<2|f>>6:64,b=2<w?63&f:64,v.push(o.charAt(p)+o.charAt(m)+o.charAt(_)+o.charAt(b));return v.join("")},r.decode=function(l){var c,d,f,p,m,_,b=0,v=0,x="data:";if(l.substr(0,x.length)===x)throw new Error("Invalid base64 input, it looks like a data url.");var M,w=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&w--,l.charAt(l.length-2)===o.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(M=s.uint8array?new Uint8Array(0|w):new Array(0|w);b<l.length;)c=o.indexOf(l.charAt(b++))<<2|(p=o.indexOf(l.charAt(b++)))>>4,d=(15&p)<<4|(m=o.indexOf(l.charAt(b++)))>>2,f=(3&m)<<6|(_=o.indexOf(l.charAt(b++))),M[v++]=c,m!==64&&(M[v++]=d),_!==64&&(M[v++]=f);return M}},{"./support":30,"./utils":32}],2:[function(n,i,r){var a=n("./external"),s=n("./stream/DataWorker"),o=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function c(d,f,p,m,_){this.compressedSize=d,this.uncompressedSize=f,this.crc32=p,this.compression=m,this.compressedContent=_}c.prototype={getContentWorker:function(){var d=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new s(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(d,f,p){return d.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,i,r){var a=n("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},r.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,i,r){var a=n("./utils"),s=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();i.exports=function(o,l){return o!==void 0&&o.length?a.getTypeOf(o)!=="string"?(function(c,d,f,p){var m=s,_=p+f;c^=-1;for(var b=p;b<_;b++)c=c>>>8^m[255&(c^d[b])];return-1^c})(0|l,o,o.length,0):(function(c,d,f,p){var m=s,_=p+f;c^=-1;for(var b=p;b<_;b++)c=c>>>8^m[255&(c^d.charCodeAt(b))];return-1^c})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(n,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(n,i,r){var a=null;a=typeof Promise<"u"?Promise:n("lie"),i.exports={Promise:a}},{lie:37}],7:[function(n,i,r){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),o=n("./utils"),l=n("./stream/GenericWorker"),c=a?"uint8array":"array";function d(f,p){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}r.magic="\b\0",o.inherits(d,l),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,f.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},r.compressWorker=function(f){return new d("Deflate",f)},r.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,i,r){function a(m,_){var b,v="";for(b=0;b<_;b++)v+=String.fromCharCode(255&m),m>>>=8;return v}function s(m,_,b,v,x,M){var w,E,T=m.file,P=m.compression,N=M!==c.utf8encode,U=o.transformTo("string",M(T.name)),R=o.transformTo("string",c.utf8encode(T.name)),O=T.comment,z=o.transformTo("string",M(O)),I=o.transformTo("string",c.utf8encode(O)),G=R.length!==T.name.length,L=I.length!==O.length,B="",q="",W="",X=T.dir,Q=T.date,ie={crc32:0,compressedSize:0,uncompressedSize:0};_&&!b||(ie.crc32=m.crc32,ie.compressedSize=m.compressedSize,ie.uncompressedSize=m.uncompressedSize);var H=0;_&&(H|=8),N||!G&&!L||(H|=2048);var Y=0,se=0;X&&(Y|=16),x==="UNIX"?(se=798,Y|=(function(xe,re){var ve=xe;return xe||(ve=re?16893:33204),(65535&ve)<<16})(T.unixPermissions,X)):(se=20,Y|=(function(xe){return 63&(xe||0)})(T.dosPermissions)),w=Q.getUTCHours(),w<<=6,w|=Q.getUTCMinutes(),w<<=5,w|=Q.getUTCSeconds()/2,E=Q.getUTCFullYear()-1980,E<<=4,E|=Q.getUTCMonth()+1,E<<=5,E|=Q.getUTCDate(),G&&(q=a(1,1)+a(d(U),4)+R,B+="up"+a(q.length,2)+q),L&&(W=a(1,1)+a(d(z),4)+I,B+="uc"+a(W.length,2)+W);var ue="";return ue+=`
- \0`,ue+=a(H,2),ue+=P.magic,ue+=a(w,2),ue+=a(E,2),ue+=a(ie.crc32,4),ue+=a(ie.compressedSize,4),ue+=a(ie.uncompressedSize,4),ue+=a(U.length,2),ue+=a(B.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ue+U+B,dirRecord:f.CENTRAL_FILE_HEADER+a(se,2)+ue+a(z.length,2)+"\0\0\0\0"+a(Y,4)+a(v,4)+U+B+z}}var o=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),d=n("../crc32"),f=n("../signature");function p(m,_,b,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=b,this.encodeFileName=v,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,l),p.prototype.push=function(m){var _=m.meta.percent||0,b=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,l.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:b?(_+100*(b-v-1))/b:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var _=this.streamFiles&&!m.file.dir;if(_){var b=s(m,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var _=this.streamFiles&&!m.file.dir,b=s(m,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),_)this.push({data:(function(v){return f.DATA_DESCRIPTOR+a(v.crc32,4)+a(v.compressedSize,4)+a(v.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var b=this.bytesWritten-m,v=(function(x,M,w,E,T){var P=o.transformTo("string",T(E));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(x,2)+a(x,2)+a(M,4)+a(w,4)+a(P.length,2)+P})(this.dirRecords.length,b,m,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(m){this._sources.push(m);var _=this;return m.on("data",function(b){_.processChunk(b)}),m.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),m.on("error",function(b){_.error(b)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(m){var _=this._sources;if(!l.prototype.error.call(this,m))return!1;for(var b=0;b<_.length;b++)try{_[b].error(m)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var m=this._sources,_=0;_<m.length;_++)m[_].lock()},i.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,i,r){var a=n("../compressions"),s=n("./ZipFileWorker");r.generateWorker=function(o,l,c){var d=new s(l.streamFiles,c,l.platform,l.encodeFileName),f=0;try{o.forEach(function(p,m){f++;var _=(function(M,w){var E=M||w,T=a[E];if(!T)throw new Error(E+" is not a valid compression method !");return T})(m.options.compression,l.compression),b=m.options.compressionOptions||l.compressionOptions||{},v=m.dir,x=m.date;m._compressWorker(_,b).withStreamInfo("file",{name:p,dir:v,date:x,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,i,r){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new a;for(var o in this)typeof this[o]!="function"&&(s[o]=this[o]);return s}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(s,o){return new a().loadAsync(s,o)},a.external=n("./external"),i.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,i,r){var a=n("./utils"),s=n("./external"),o=n("./utf8"),l=n("./zipEntries"),c=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(p){return new s.Promise(function(m,_){var b=p.decompressed.getContentWorker().pipe(new c);b.on("error",function(v){_(v)}).on("end",function(){b.streamInfo.crc32!==p.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}i.exports=function(p,m){var _=this;return m=a.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(p)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(b){var v=new l(m);return v.load(b),v}).then(function(b){var v=[s.Promise.resolve(b)],x=b.files;if(m.checkCRC32)for(var M=0;M<x.length;M++)v.push(f(x[M]));return s.Promise.all(v)}).then(function(b){for(var v=b.shift(),x=v.files,M=0;M<x.length;M++){var w=x[M],E=w.fileNameStr,T=a.resolve(w.fileNameStr);_.file(T,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:m.createFolders}),w.dir||(_.file(T).unsafeOriginalName=E)}return v.zipComment.length&&(_.comment=v.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,i,r){var a=n("../utils"),s=n("../stream/GenericWorker");function o(l,c){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}a.inherits(o,s),o.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(d){c.push({data:d,meta:{percent:0}})}).on("error",function(d){c.isPaused?this.generatedError=d:c.error(d)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},o.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,i,r){var a=n("readable-stream").Readable;function s(o,l,c){a.call(this,l),this._helper=o;var d=this;o.on("data",function(f,p){d.push(f)||d._helper.pause(),c&&c(p)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(s,a),s.prototype._read=function(){this._helper.resume()},i.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,s);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,s)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var s=new Buffer(a);return s.fill(0),s},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,i,r){function a(T,P,N){var U,R=o.getTypeOf(P),O=o.extend(N||{},d);O.date=O.date||new Date,O.compression!==null&&(O.compression=O.compression.toUpperCase()),typeof O.unixPermissions=="string"&&(O.unixPermissions=parseInt(O.unixPermissions,8)),O.unixPermissions&&16384&O.unixPermissions&&(O.dir=!0),O.dosPermissions&&16&O.dosPermissions&&(O.dir=!0),O.dir&&(T=x(T)),O.createFolders&&(U=v(T))&&M.call(this,U,!0);var z=R==="string"&&O.binary===!1&&O.base64===!1;N&&N.binary!==void 0||(O.binary=!z),(P instanceof f&&P.uncompressedSize===0||O.dir||!P||P.length===0)&&(O.base64=!1,O.binary=!0,P="",O.compression="STORE",R="string");var I=null;I=P instanceof f||P instanceof l?P:_.isNode&&_.isStream(P)?new b(T,P):o.prepareContent(T,P,O.binary,O.optimizedBinaryString,O.base64);var G=new p(T,I,O);this.files[T]=G}var s=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),_=n("./nodejsUtils"),b=n("./nodejs/NodejsStreamInputAdapter"),v=function(T){T.slice(-1)==="/"&&(T=T.substring(0,T.length-1));var P=T.lastIndexOf("/");return 0<P?T.substring(0,P):""},x=function(T){return T.slice(-1)!=="/"&&(T+="/"),T},M=function(T,P){return P=P!==void 0?P:d.createFolders,T=x(T),this.files[T]||a.call(this,T,null,{dir:!0,createFolders:P}),this.files[T]};function w(T){return Object.prototype.toString.call(T)==="[object RegExp]"}var E={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var P,N,U;for(P in this.files)U=this.files[P],(N=P.slice(this.root.length,P.length))&&P.slice(0,this.root.length)===this.root&&T(N,U)},filter:function(T){var P=[];return this.forEach(function(N,U){T(N,U)&&P.push(U)}),P},file:function(T,P,N){if(arguments.length!==1)return T=this.root+T,a.call(this,T,P,N),this;if(w(T)){var U=T;return this.filter(function(O,z){return!z.dir&&U.test(O)})}var R=this.files[this.root+T];return R&&!R.dir?R:null},folder:function(T){if(!T)return this;if(w(T))return this.filter(function(R,O){return O.dir&&T.test(R)});var P=this.root+T,N=M.call(this,P),U=this.clone();return U.root=N.name,U},remove:function(T){T=this.root+T;var P=this.files[T];if(P||(T.slice(-1)!=="/"&&(T+="/"),P=this.files[T]),P&&!P.dir)delete this.files[T];else for(var N=this.filter(function(R,O){return O.name.slice(0,T.length)===T}),U=0;U<N.length;U++)delete this.files[N[U].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(T){var P,N={};try{if((N=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");o.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var U=N.comment||this.comment||"";P=m.generateWorker(this,N,U)}catch(R){(P=new l("error")).error(R)}return new c(P,N.type||"string",N.mimeType)},generateAsync:function(T,P){return this.generateInternalStream(T).accumulate(P)},generateNodeStream:function(T,P){return(T=T||{}).type||(T.type="nodebuffer"),this.generateInternalStream(T).toNodejsStream(P)}};i.exports=E},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,i,r){i.exports=n("stream")},{stream:void 0}],17:[function(n,i,r){var a=n("./DataReader");function s(o){a.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data[this.zero+o]},s.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===c&&this.data[p+2]===d&&this.data[p+3]===f)return p-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),d=o.charCodeAt(2),f=o.charCodeAt(3),p=this.readData(4);return l===p[0]&&c===p[1]&&d===p[2]&&f===p[3]},s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,i,r){var a=n("../utils");function s(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,c=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return a.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=s},{"../utils":32}],19:[function(n,i,r){var a=n("./Uint8ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,i,r){var a=n("./DataReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},s.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},s.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},s.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,i,r){var a=n("./ArrayReader");function s(o){a.call(this,o)}n("../utils").inherits(s,a),s.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,i,r){var a=n("../utils"),s=n("../support"),o=n("./ArrayReader"),l=n("./StringReader"),c=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");i.exports=function(f){var p=a.getTypeOf(f);return a.checkSupport(p),p!=="string"||s.uint8array?p==="nodebuffer"?new c(f):s.uint8array?new d(a.transformTo("uint8array",f)):new o(a.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,i,r){var a=n("./GenericWorker"),s=n("../utils");function o(l){a.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(o,a),o.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(n,i,r){var a=n("./GenericWorker"),s=n("../crc32");function o(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(o,a),o.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,i,r){var a=n("../utils"),s=n("./GenericWorker");function o(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}a.inherits(o,s),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}s.prototype.processChunk.call(this,l)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(n,i,r){var a=n("../utils"),s=n("./GenericWorker");function o(l){s.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){c.dataIsReady=!0,c.data=d,c.max=d&&d.length||0,c.type=a.getTypeOf(d),c.isPaused||c._tickAndRepeat()},function(d){c.error(d)})}a.inherits(o,s),o.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(n,i,r){function a(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}a.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,o){return this._listeners[s].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,o){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,o)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var o=this;return s.on("data",function(l){o.processChunk(l)}),s.on("end",function(){o.end()}),s.on("error",function(l){o.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,o){return this.extraStreamInfo[s]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},i.exports=a},{}],29:[function(n,i,r){var a=n("../utils"),s=n("./ConvertWorker"),o=n("./GenericWorker"),l=n("../base64"),c=n("../support"),d=n("../external"),f=null;if(c.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(_,b){return new d.Promise(function(v,x){var M=[],w=_._internalType,E=_._outputType,T=_._mimeType;_.on("data",function(P,N){M.push(P),b&&b(N)}).on("error",function(P){M=[],x(P)}).on("end",function(){try{var P=(function(N,U,R){switch(N){case"blob":return a.newBlob(a.transformTo("arraybuffer",U),R);case"base64":return l.encode(U);default:return a.transformTo(N,U)}})(E,(function(N,U){var R,O=0,z=null,I=0;for(R=0;R<U.length;R++)I+=U[R].length;switch(N){case"string":return U.join("");case"array":return Array.prototype.concat.apply([],U);case"uint8array":for(z=new Uint8Array(I),R=0;R<U.length;R++)z.set(U[R],O),O+=U[R].length;return z;case"nodebuffer":return Buffer.concat(U);default:throw new Error("concat : unsupported type '"+N+"'")}})(w,M),T);v(P)}catch(N){x(N)}M=[]}).resume()})}function m(_,b,v){var x=b;switch(b){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=b,this._mimeType=v,a.checkSupport(x),this._worker=_.pipe(new s(x)),_.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}m.prototype={accumulate:function(_){return p(this,_)},on:function(_,b){var v=this;return _==="data"?this._worker.on(_,function(x){b.call(v,x.data,x.meta)}):this._worker.on(_,function(){a.delay(b,arguments,v)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},_)}},i.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var a=new ArrayBuffer(0);try{r.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(a),r.blob=s.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!n("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(n,i,r){for(var a=n("./utils"),s=n("./support"),o=n("./nodejsUtils"),l=n("./stream/GenericWorker"),c=new Array(256),d=0;d<256;d++)c[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;c[254]=c[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}r.utf8encode=function(m){return s.nodebuffer?o.newBufferFrom(m,"utf-8"):(function(_){var b,v,x,M,w,E=_.length,T=0;for(M=0;M<E;M++)(64512&(v=_.charCodeAt(M)))==55296&&M+1<E&&(64512&(x=_.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),T+=v<128?1:v<2048?2:v<65536?3:4;for(b=s.uint8array?new Uint8Array(T):new Array(T),M=w=0;w<T;M++)(64512&(v=_.charCodeAt(M)))==55296&&M+1<E&&(64512&(x=_.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),v<128?b[w++]=v:(v<2048?b[w++]=192|v>>>6:(v<65536?b[w++]=224|v>>>12:(b[w++]=240|v>>>18,b[w++]=128|v>>>12&63),b[w++]=128|v>>>6&63),b[w++]=128|63&v);return b})(m)},r.utf8decode=function(m){return s.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(_){var b,v,x,M,w=_.length,E=new Array(2*w);for(b=v=0;b<w;)if((x=_[b++])<128)E[v++]=x;else if(4<(M=c[x]))E[v++]=65533,b+=M-1;else{for(x&=M===2?31:M===3?15:7;1<M&&b<w;)x=x<<6|63&_[b++],M--;1<M?E[v++]=65533:x<65536?E[v++]=x:(x-=65536,E[v++]=55296|x>>10&1023,E[v++]=56320|1023&x)}return E.length!==v&&(E.subarray?E=E.subarray(0,v):E.length=v),a.applyFromCharCode(E)})(m=a.transformTo(s.uint8array?"uint8array":"array",m))},a.inherits(f,l),f.prototype.processChunk=function(m){var _=a.transformTo(s.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var b=_;(_=new Uint8Array(b.length+this.leftOver.length)).set(this.leftOver,0),_.set(b,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var v=(function(M,w){var E;for((w=w||M.length)>M.length&&(w=M.length),E=w-1;0<=E&&(192&M[E])==128;)E--;return E<0||E===0?w:E+c[M[E]]>w?E:w})(_),x=_;v!==_.length&&(s.uint8array?(x=_.subarray(0,v),this.leftOver=_.subarray(v,_.length)):(x=_.slice(0,v),this.leftOver=_.slice(v,_.length))),this.push({data:r.utf8decode(x),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=f,a.inherits(p,l),p.prototype.processChunk=function(m){this.push({data:r.utf8encode(m.data),meta:m.meta})},r.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,i,r){var a=n("./support"),s=n("./base64"),o=n("./nodejsUtils"),l=n("./external");function c(b){return b}function d(b,v){for(var x=0;x<b.length;++x)v[x]=255&b.charCodeAt(x);return v}n("setimmediate"),r.newBlob=function(b,v){r.checkSupport("blob");try{return new Blob([b],{type:v})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(b),x.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(b,v,x){var M=[],w=0,E=b.length;if(E<=x)return String.fromCharCode.apply(null,b);for(;w<E;)v==="array"||v==="nodebuffer"?M.push(String.fromCharCode.apply(null,b.slice(w,Math.min(w+x,E)))):M.push(String.fromCharCode.apply(null,b.subarray(w,Math.min(w+x,E)))),w+=x;return M.join("")},stringifyByChar:function(b){for(var v="",x=0;x<b.length;x++)v+=String.fromCharCode(b[x]);return v},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function p(b){var v=65536,x=r.getTypeOf(b),M=!0;if(x==="uint8array"?M=f.applyCanBeUsed.uint8array:x==="nodebuffer"&&(M=f.applyCanBeUsed.nodebuffer),M)for(;1<v;)try{return f.stringifyByChunk(b,x,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(b)}function m(b,v){for(var x=0;x<b.length;x++)v[x]=b[x];return v}r.applyFromCharCode=p;var _={};_.string={string:c,array:function(b){return d(b,new Array(b.length))},arraybuffer:function(b){return _.string.uint8array(b).buffer},uint8array:function(b){return d(b,new Uint8Array(b.length))},nodebuffer:function(b){return d(b,o.allocBuffer(b.length))}},_.array={string:p,array:c,arraybuffer:function(b){return new Uint8Array(b).buffer},uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return o.newBufferFrom(b)}},_.arraybuffer={string:function(b){return p(new Uint8Array(b))},array:function(b){return m(new Uint8Array(b),new Array(b.byteLength))},arraybuffer:c,uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return o.newBufferFrom(new Uint8Array(b))}},_.uint8array={string:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:c,nodebuffer:function(b){return o.newBufferFrom(b)}},_.nodebuffer={string:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return _.nodebuffer.uint8array(b).buffer},uint8array:function(b){return m(b,new Uint8Array(b.length))},nodebuffer:c},r.transformTo=function(b,v){if(v=v||"",!b)return v;r.checkSupport(b);var x=r.getTypeOf(v);return _[x][b](v)},r.resolve=function(b){for(var v=b.split("/"),x=[],M=0;M<v.length;M++){var w=v[M];w==="."||w===""&&M!==0&&M!==v.length-1||(w===".."?x.pop():x.push(w))}return x.join("/")},r.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(b)?"nodebuffer":a.uint8array&&b instanceof Uint8Array?"uint8array":a.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(b){if(!a[b.toLowerCase()])throw new Error(b+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(b){var v,x,M="";for(x=0;x<(b||"").length;x++)M+="\\x"+((v=b.charCodeAt(x))<16?"0":"")+v.toString(16).toUpperCase();return M},r.delay=function(b,v,x){setImmediate(function(){b.apply(x||null,v||[])})},r.inherits=function(b,v){function x(){}x.prototype=v.prototype,b.prototype=new x},r.extend=function(){var b,v,x={};for(b=0;b<arguments.length;b++)for(v in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],v)&&x[v]===void 0&&(x[v]=arguments[b][v]);return x},r.prepareContent=function(b,v,x,M,w){return l.Promise.resolve(v).then(function(E){return a.blob&&(E instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(E))!==-1)&&typeof FileReader<"u"?new l.Promise(function(T,P){var N=new FileReader;N.onload=function(U){T(U.target.result)},N.onerror=function(U){P(U.target.error)},N.readAsArrayBuffer(E)}):E}).then(function(E){var T=r.getTypeOf(E);return T?(T==="arraybuffer"?E=r.transformTo("uint8array",E):T==="string"&&(w?E=s.decode(E):x&&M!==!0&&(E=(function(P){return d(P,a.uint8array?new Uint8Array(P.length):new Array(P.length))})(E))),E):l.Promise.reject(new Error("Can't read the data of '"+b+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,i,r){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./signature"),l=n("./zipEntry"),c=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(p)+", expected "+s.pretty(f)+")")}},isSignature:function(f,p){var m=this.reader.index;this.reader.setIndex(f);var _=this.reader.readString(4)===p;return this.reader.setIndex(m),_},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=c.uint8array?"uint8array":"array",m=s.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,m,_=this.zip64EndOfCentralSize-44;0<_;)f=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var _=p-m;if(0<_)this.isSignature(p,o.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,i,r){var a=n("./reader/readerFor"),s=n("./utils"),o=n("./compressedObject"),l=n("./crc32"),c=n("./utf8"),d=n("./compressions"),f=n("./support");function p(m,_){this.options=m,this.loadOptions=_}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var _,b;if(m.skip(22),this.fileNameLength=m.readInt(2),b=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(b),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((_=(function(v){for(var x in d)if(Object.prototype.hasOwnProperty.call(d,x)&&d[x].magic===v)return d[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,_,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var _=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(_),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var _,b,v,x=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<x;)_=m.readInt(2),b=m.readInt(2),v=m.readData(b),this.extraFields[_]={id:_,length:b,value:v};m.setIndex(x)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(_!==null)this.fileNameStr=_;else{var b=s.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var x=s.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var _=a(m.value);return _.readInt(1)!==1||l(this.fileName)!==_.readInt(4)?null:c.utf8decode(_.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var _=a(m.value);return _.readInt(1)!==1||l(this.fileComment)!==_.readInt(4)?null:c.utf8decode(_.readData(m.length-5))}return null}},i.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,i,r){function a(_,b,v){this.name=_,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=b,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var s=n("./stream/StreamHelper"),o=n("./stream/DataWorker"),l=n("./utf8"),c=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(_){var b=null,v="string";try{if(!_)throw new Error("No output type specified.");var x=(v=_.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),b=this._decompressWorker();var M=!this._dataBinary;M&&!x&&(b=b.pipe(new l.Utf8EncodeWorker)),!M&&x&&(b=b.pipe(new l.Utf8DecodeWorker))}catch(w){(b=new d("error")).error(w)}return new s(b,v,"")},async:function(_,b){return this.internalStream(_).accumulate(b)},nodeStream:function(_,b){return this.internalStream(_||"nodebuffer").toNodejsStream(b)},_compressWorker:function(_,b){if(this._data instanceof c&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(v,_,b)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=p;i.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,i,r){(function(a){var s,o,l=a.MutationObserver||a.WebKitMutationObserver;if(l){var c=0,d=new l(_),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),s=function(){f.data=c=++c%2}}else if(a.setImmediate||a.MessageChannel===void 0)s="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){_(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(_,0)};else{var p=new a.MessageChannel;p.port1.onmessage=_,s=function(){p.port2.postMessage(0)}}var m=[];function _(){var b,v;o=!0;for(var x=m.length;x;){for(v=m,m=[],b=-1;++b<x;)v[b]();x=m.length}o=!1}i.exports=function(b){m.push(b)!==1||o||s()}}).call(this,typeof ly<"u"?ly:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,i,r){var a=n("immediate");function s(){}var o={},l=["REJECTED"],c=["FULFILLED"],d=["PENDING"];function f(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,x!==s&&b(this,x)}function p(x,M,w){this.promise=x,typeof M=="function"&&(this.onFulfilled=M,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function m(x,M,w){a(function(){var E;try{E=M(w)}catch(T){return o.reject(x,T)}E===x?o.reject(x,new TypeError("Cannot resolve promise with itself")):o.resolve(x,E)})}function _(x){var M=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof M=="function")return function(){M.apply(x,arguments)}}function b(x,M){var w=!1;function E(N){w||(w=!0,o.reject(x,N))}function T(N){w||(w=!0,o.resolve(x,N))}var P=v(function(){M(T,E)});P.status==="error"&&E(P.value)}function v(x,M){var w={};try{w.value=x(M),w.status="success"}catch(E){w.status="error",w.value=E}return w}(i.exports=f).prototype.finally=function(x){if(typeof x!="function")return this;var M=this.constructor;return this.then(function(w){return M.resolve(x()).then(function(){return w})},function(w){return M.resolve(x()).then(function(){throw w})})},f.prototype.catch=function(x){return this.then(null,x)},f.prototype.then=function(x,M){if(typeof x!="function"&&this.state===c||typeof M!="function"&&this.state===l)return this;var w=new this.constructor(s);return this.state!==d?m(w,this.state===c?x:M,this.outcome):this.queue.push(new p(w,x,M)),w},p.prototype.callFulfilled=function(x){o.resolve(this.promise,x)},p.prototype.otherCallFulfilled=function(x){m(this.promise,this.onFulfilled,x)},p.prototype.callRejected=function(x){o.reject(this.promise,x)},p.prototype.otherCallRejected=function(x){m(this.promise,this.onRejected,x)},o.resolve=function(x,M){var w=v(_,M);if(w.status==="error")return o.reject(x,w.value);var E=w.value;if(E)b(x,E);else{x.state=c,x.outcome=M;for(var T=-1,P=x.queue.length;++T<P;)x.queue[T].callFulfilled(M)}return x},o.reject=function(x,M){x.state=l,x.outcome=M;for(var w=-1,E=x.queue.length;++w<E;)x.queue[w].callRejected(M);return x},f.resolve=function(x){return x instanceof this?x:o.resolve(new this(s),x)},f.reject=function(x){var M=new this(s);return o.reject(M,x)},f.all=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,E=!1;if(!w)return this.resolve([]);for(var T=new Array(w),P=0,N=-1,U=new this(s);++N<w;)R(x[N],N);return U;function R(O,z){M.resolve(O).then(function(I){T[z]=I,++P!==w||E||(E=!0,o.resolve(U,T))},function(I){E||(E=!0,o.reject(U,I))})}},f.race=function(x){var M=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=x.length,E=!1;if(!w)return this.resolve([]);for(var T=-1,P=new this(s);++T<w;)N=x[T],M.resolve(N).then(function(U){E||(E=!0,o.resolve(P,U))},function(U){E||(E=!0,o.reject(P,U))});var N;return P}},{immediate:36}],38:[function(n,i,r){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),i.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,i,r){var a=n("./zlib/deflate"),s=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/messages"),c=n("./zlib/zstream"),d=Object.prototype.toString,f=0,p=-1,m=0,_=8;function b(x){if(!(this instanceof b))return new b(x);this.options=s.assign({level:p,method:_,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},x||{});var M=this.options;M.raw&&0<M.windowBits?M.windowBits=-M.windowBits:M.gzip&&0<M.windowBits&&M.windowBits<16&&(M.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,M.level,M.method,M.windowBits,M.memLevel,M.strategy);if(w!==f)throw new Error(l[w]);if(M.header&&a.deflateSetHeader(this.strm,M.header),M.dictionary){var E;if(E=typeof M.dictionary=="string"?o.string2buf(M.dictionary):d.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(w=a.deflateSetDictionary(this.strm,E))!==f)throw new Error(l[w]);this._dict_set=!0}}function v(x,M){var w=new b(M);if(w.push(x,!0),w.err)throw w.msg||l[w.err];return w.result}b.prototype.push=function(x,M){var w,E,T=this.strm,P=this.options.chunkSize;if(this.ended)return!1;E=M===~~M?M:M===!0?4:0,typeof x=="string"?T.input=o.string2buf(x):d.call(x)==="[object ArrayBuffer]"?T.input=new Uint8Array(x):T.input=x,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new s.Buf8(P),T.next_out=0,T.avail_out=P),(w=a.deflate(T,E))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||E!==4&&E!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(s.shrinkBuf(T.output,T.next_out))):this.onData(s.shrinkBuf(T.output,T.next_out)))}while((0<T.avail_in||T.avail_out===0)&&w!==1);return E===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):E!==2||(this.onEnd(f),!(T.avail_out=0))},b.prototype.onData=function(x){this.chunks.push(x)},b.prototype.onEnd=function(x){x===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},r.Deflate=b,r.deflate=v,r.deflateRaw=function(x,M){return(M=M||{}).raw=!0,v(x,M)},r.gzip=function(x,M){return(M=M||{}).gzip=!0,v(x,M)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,i,r){var a=n("./zlib/inflate"),s=n("./utils/common"),o=n("./utils/strings"),l=n("./zlib/constants"),c=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),p=Object.prototype.toString;function m(b){if(!(this instanceof m))return new m(b);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},b||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||b&&b.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var x=a.inflateInit2(this.strm,v.windowBits);if(x!==l.Z_OK)throw new Error(c[x]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function _(b,v){var x=new m(v);if(x.push(b,!0),x.err)throw x.msg||c[x.err];return x.result}m.prototype.push=function(b,v){var x,M,w,E,T,P,N=this.strm,U=this.options.chunkSize,R=this.options.dictionary,O=!1;if(this.ended)return!1;M=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof b=="string"?N.input=o.binstring2buf(b):p.call(b)==="[object ArrayBuffer]"?N.input=new Uint8Array(b):N.input=b,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new s.Buf8(U),N.next_out=0,N.avail_out=U),(x=a.inflate(N,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&R&&(P=typeof R=="string"?o.string2buf(R):p.call(R)==="[object ArrayBuffer]"?new Uint8Array(R):R,x=a.inflateSetDictionary(this.strm,P)),x===l.Z_BUF_ERROR&&O===!0&&(x=l.Z_OK,O=!1),x!==l.Z_STREAM_END&&x!==l.Z_OK)return this.onEnd(x),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&x!==l.Z_STREAM_END&&(N.avail_in!==0||M!==l.Z_FINISH&&M!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=o.utf8border(N.output,N.next_out),E=N.next_out-w,T=o.buf2string(N.output,w),N.next_out=E,N.avail_out=U-E,E&&s.arraySet(N.output,N.output,w,E,0),this.onData(T)):this.onData(s.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(O=!0)}while((0<N.avail_in||N.avail_out===0)&&x!==l.Z_STREAM_END);return x===l.Z_STREAM_END&&(M=l.Z_FINISH),M===l.Z_FINISH?(x=a.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===l.Z_OK):M!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(N.avail_out=0))},m.prototype.onData=function(b){this.chunks.push(b)},m.prototype.onEnd=function(b){b===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},r.Inflate=m,r.inflate=_,r.inflateRaw=function(b,v){return(v=v||{}).raw=!0,_(b,v)},r.ungzip=_},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,i,r){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var d=c.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(l[f]=d[f])}}return l},r.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var s={arraySet:function(l,c,d,f,p){if(c.subarray&&l.subarray)l.set(c.subarray(d,d+f),p);else for(var m=0;m<f;m++)l[p+m]=c[d+m]},flattenChunks:function(l){var c,d,f,p,m,_;for(c=f=0,d=l.length;c<d;c++)f+=l[c].length;for(_=new Uint8Array(f),c=p=0,d=l.length;c<d;c++)m=l[c],_.set(m,p),p+=m.length;return _}},o={arraySet:function(l,c,d,f,p){for(var m=0;m<f;m++)l[p+m]=c[d+m]},flattenChunks:function(l){return[].concat.apply([],l)}};r.setTyped=function(l){l?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,s)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,o))},r.setTyped(a)},{}],42:[function(n,i,r){var a=n("./common"),s=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new a.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function d(f,p){if(p<65537&&(f.subarray&&o||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,p));for(var m="",_=0;_<p;_++)m+=String.fromCharCode(f[_]);return m}l[254]=l[254]=1,r.string2buf=function(f){var p,m,_,b,v,x=f.length,M=0;for(b=0;b<x;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<x&&(64512&(_=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(_-56320),b++),M+=m<128?1:m<2048?2:m<65536?3:4;for(p=new a.Buf8(M),b=v=0;v<M;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<x&&(64512&(_=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(_-56320),b++),m<128?p[v++]=m:(m<2048?p[v++]=192|m>>>6:(m<65536?p[v++]=224|m>>>12:(p[v++]=240|m>>>18,p[v++]=128|m>>>12&63),p[v++]=128|m>>>6&63),p[v++]=128|63&m);return p},r.buf2binstring=function(f){return d(f,f.length)},r.binstring2buf=function(f){for(var p=new a.Buf8(f.length),m=0,_=p.length;m<_;m++)p[m]=f.charCodeAt(m);return p},r.buf2string=function(f,p){var m,_,b,v,x=p||f.length,M=new Array(2*x);for(m=_=0;m<x;)if((b=f[m++])<128)M[_++]=b;else if(4<(v=l[b]))M[_++]=65533,m+=v-1;else{for(b&=v===2?31:v===3?15:7;1<v&&m<x;)b=b<<6|63&f[m++],v--;1<v?M[_++]=65533:b<65536?M[_++]=b:(b-=65536,M[_++]=55296|b>>10&1023,M[_++]=56320|1023&b)}return d(M,_)},r.utf8border=function(f,p){var m;for((p=p||f.length)>f.length&&(p=f.length),m=p-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?p:m+l[f[m]]>p?m:p}},{"./common":41}],43:[function(n,i,r){i.exports=function(a,s,o,l){for(var c=65535&a|0,d=a>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;d=d+(c=c+s[l++]|0)|0,--f;);c%=65521,d%=65521}return c|d<<16|0}},{}],44:[function(n,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,i,r){var a=(function(){for(var s,o=[],l=0;l<256;l++){s=l;for(var c=0;c<8;c++)s=1&s?3988292384^s>>>1:s>>>1;o[l]=s}return o})();i.exports=function(s,o,l,c){var d=a,f=c+l;s^=-1;for(var p=c;p<f;p++)s=s>>>8^d[255&(s^o[p])];return-1^s}},{}],46:[function(n,i,r){var a,s=n("../utils/common"),o=n("./trees"),l=n("./adler32"),c=n("./crc32"),d=n("./messages"),f=0,p=4,m=0,_=-2,b=-1,v=4,x=2,M=8,w=9,E=286,T=30,P=19,N=2*E+1,U=15,R=3,O=258,z=O+R+1,I=42,G=113,L=1,B=2,q=3,W=4;function X(F,$){return F.msg=d[$],$}function Q(F){return(F<<1)-(4<F?9:0)}function ie(F){for(var $=F.length;0<=--$;)F[$]=0}function H(F){var $=F.state,ae=$.pending;ae>F.avail_out&&(ae=F.avail_out),ae!==0&&(s.arraySet(F.output,$.pending_buf,$.pending_out,ae,F.next_out),F.next_out+=ae,$.pending_out+=ae,F.total_out+=ae,F.avail_out-=ae,$.pending-=ae,$.pending===0&&($.pending_out=0))}function Y(F,$){o._tr_flush_block(F,0<=F.block_start?F.block_start:-1,F.strstart-F.block_start,$),F.block_start=F.strstart,H(F.strm)}function se(F,$){F.pending_buf[F.pending++]=$}function ue(F,$){F.pending_buf[F.pending++]=$>>>8&255,F.pending_buf[F.pending++]=255&$}function xe(F,$){var ae,J,ee=F.max_chain_length,oe=F.strstart,De=F.prev_length,Ne=F.nice_match,te=F.strstart>F.w_size-z?F.strstart-(F.w_size-z):0,j=F.window,k=F.w_mask,K=F.prev,me=F.strstart+O,ye=j[oe+De-1],he=j[oe+De];F.prev_length>=F.good_match&&(ee>>=2),Ne>F.lookahead&&(Ne=F.lookahead);do if(j[(ae=$)+De]===he&&j[ae+De-1]===ye&&j[ae]===j[oe]&&j[++ae]===j[oe+1]){oe+=2,ae++;do;while(j[++oe]===j[++ae]&&j[++oe]===j[++ae]&&j[++oe]===j[++ae]&&j[++oe]===j[++ae]&&j[++oe]===j[++ae]&&j[++oe]===j[++ae]&&j[++oe]===j[++ae]&&j[++oe]===j[++ae]&&oe<me);if(J=O-(me-oe),oe=me-O,De<J){if(F.match_start=$,Ne<=(De=J))break;ye=j[oe+De-1],he=j[oe+De]}}while(($=K[$&k])>te&&--ee!=0);return De<=F.lookahead?De:F.lookahead}function re(F){var $,ae,J,ee,oe,De,Ne,te,j,k,K=F.w_size;do{if(ee=F.window_size-F.lookahead-F.strstart,F.strstart>=K+(K-z)){for(s.arraySet(F.window,F.window,K,K,0),F.match_start-=K,F.strstart-=K,F.block_start-=K,$=ae=F.hash_size;J=F.head[--$],F.head[$]=K<=J?J-K:0,--ae;);for($=ae=K;J=F.prev[--$],F.prev[$]=K<=J?J-K:0,--ae;);ee+=K}if(F.strm.avail_in===0)break;if(De=F.strm,Ne=F.window,te=F.strstart+F.lookahead,j=ee,k=void 0,k=De.avail_in,j<k&&(k=j),ae=k===0?0:(De.avail_in-=k,s.arraySet(Ne,De.input,De.next_in,k,te),De.state.wrap===1?De.adler=l(De.adler,Ne,k,te):De.state.wrap===2&&(De.adler=c(De.adler,Ne,k,te)),De.next_in+=k,De.total_in+=k,k),F.lookahead+=ae,F.lookahead+F.insert>=R)for(oe=F.strstart-F.insert,F.ins_h=F.window[oe],F.ins_h=(F.ins_h<<F.hash_shift^F.window[oe+1])&F.hash_mask;F.insert&&(F.ins_h=(F.ins_h<<F.hash_shift^F.window[oe+R-1])&F.hash_mask,F.prev[oe&F.w_mask]=F.head[F.ins_h],F.head[F.ins_h]=oe,oe++,F.insert--,!(F.lookahead+F.insert<R)););}while(F.lookahead<z&&F.strm.avail_in!==0)}function ve(F,$){for(var ae,J;;){if(F.lookahead<z){if(re(F),F.lookahead<z&&$===f)return L;if(F.lookahead===0)break}if(ae=0,F.lookahead>=R&&(F.ins_h=(F.ins_h<<F.hash_shift^F.window[F.strstart+R-1])&F.hash_mask,ae=F.prev[F.strstart&F.w_mask]=F.head[F.ins_h],F.head[F.ins_h]=F.strstart),ae!==0&&F.strstart-ae<=F.w_size-z&&(F.match_length=xe(F,ae)),F.match_length>=R)if(J=o._tr_tally(F,F.strstart-F.match_start,F.match_length-R),F.lookahead-=F.match_length,F.match_length<=F.max_lazy_match&&F.lookahead>=R){for(F.match_length--;F.strstart++,F.ins_h=(F.ins_h<<F.hash_shift^F.window[F.strstart+R-1])&F.hash_mask,ae=F.prev[F.strstart&F.w_mask]=F.head[F.ins_h],F.head[F.ins_h]=F.strstart,--F.match_length!=0;);F.strstart++}else F.strstart+=F.match_length,F.match_length=0,F.ins_h=F.window[F.strstart],F.ins_h=(F.ins_h<<F.hash_shift^F.window[F.strstart+1])&F.hash_mask;else J=o._tr_tally(F,0,F.window[F.strstart]),F.lookahead--,F.strstart++;if(J&&(Y(F,!1),F.strm.avail_out===0))return L}return F.insert=F.strstart<R-1?F.strstart:R-1,$===p?(Y(F,!0),F.strm.avail_out===0?q:W):F.last_lit&&(Y(F,!1),F.strm.avail_out===0)?L:B}function Pe(F,$){for(var ae,J,ee;;){if(F.lookahead<z){if(re(F),F.lookahead<z&&$===f)return L;if(F.lookahead===0)break}if(ae=0,F.lookahead>=R&&(F.ins_h=(F.ins_h<<F.hash_shift^F.window[F.strstart+R-1])&F.hash_mask,ae=F.prev[F.strstart&F.w_mask]=F.head[F.ins_h],F.head[F.ins_h]=F.strstart),F.prev_length=F.match_length,F.prev_match=F.match_start,F.match_length=R-1,ae!==0&&F.prev_length<F.max_lazy_match&&F.strstart-ae<=F.w_size-z&&(F.match_length=xe(F,ae),F.match_length<=5&&(F.strategy===1||F.match_length===R&&4096<F.strstart-F.match_start)&&(F.match_length=R-1)),F.prev_length>=R&&F.match_length<=F.prev_length){for(ee=F.strstart+F.lookahead-R,J=o._tr_tally(F,F.strstart-1-F.prev_match,F.prev_length-R),F.lookahead-=F.prev_length-1,F.prev_length-=2;++F.strstart<=ee&&(F.ins_h=(F.ins_h<<F.hash_shift^F.window[F.strstart+R-1])&F.hash_mask,ae=F.prev[F.strstart&F.w_mask]=F.head[F.ins_h],F.head[F.ins_h]=F.strstart),--F.prev_length!=0;);if(F.match_available=0,F.match_length=R-1,F.strstart++,J&&(Y(F,!1),F.strm.avail_out===0))return L}else if(F.match_available){if((J=o._tr_tally(F,0,F.window[F.strstart-1]))&&Y(F,!1),F.strstart++,F.lookahead--,F.strm.avail_out===0)return L}else F.match_available=1,F.strstart++,F.lookahead--}return F.match_available&&(J=o._tr_tally(F,0,F.window[F.strstart-1]),F.match_available=0),F.insert=F.strstart<R-1?F.strstart:R-1,$===p?(Y(F,!0),F.strm.avail_out===0?q:W):F.last_lit&&(Y(F,!1),F.strm.avail_out===0)?L:B}function pe(F,$,ae,J,ee){this.good_length=F,this.max_lazy=$,this.nice_length=ae,this.max_chain=J,this.func=ee}function we(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=M,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*N),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*P+1)),ie(this.dyn_ltree),ie(this.dyn_dtree),ie(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(U+1),this.heap=new s.Buf16(2*E+1),ie(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*E+1),ie(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ze(F){var $;return F&&F.state?(F.total_in=F.total_out=0,F.data_type=x,($=F.state).pending=0,$.pending_out=0,$.wrap<0&&($.wrap=-$.wrap),$.status=$.wrap?I:G,F.adler=$.wrap===2?0:1,$.last_flush=f,o._tr_init($),m):X(F,_)}function ce(F){var $=ze(F);return $===m&&(function(ae){ae.window_size=2*ae.w_size,ie(ae.head),ae.max_lazy_match=a[ae.level].max_lazy,ae.good_match=a[ae.level].good_length,ae.nice_match=a[ae.level].nice_length,ae.max_chain_length=a[ae.level].max_chain,ae.strstart=0,ae.block_start=0,ae.lookahead=0,ae.insert=0,ae.match_length=ae.prev_length=R-1,ae.match_available=0,ae.ins_h=0})(F.state),$}function ft(F,$,ae,J,ee,oe){if(!F)return _;var De=1;if($===b&&($=6),J<0?(De=0,J=-J):15<J&&(De=2,J-=16),ee<1||w<ee||ae!==M||J<8||15<J||$<0||9<$||oe<0||v<oe)return X(F,_);J===8&&(J=9);var Ne=new we;return(F.state=Ne).strm=F,Ne.wrap=De,Ne.gzhead=null,Ne.w_bits=J,Ne.w_size=1<<Ne.w_bits,Ne.w_mask=Ne.w_size-1,Ne.hash_bits=ee+7,Ne.hash_size=1<<Ne.hash_bits,Ne.hash_mask=Ne.hash_size-1,Ne.hash_shift=~~((Ne.hash_bits+R-1)/R),Ne.window=new s.Buf8(2*Ne.w_size),Ne.head=new s.Buf16(Ne.hash_size),Ne.prev=new s.Buf16(Ne.w_size),Ne.lit_bufsize=1<<ee+6,Ne.pending_buf_size=4*Ne.lit_bufsize,Ne.pending_buf=new s.Buf8(Ne.pending_buf_size),Ne.d_buf=1*Ne.lit_bufsize,Ne.l_buf=3*Ne.lit_bufsize,Ne.level=$,Ne.strategy=oe,Ne.method=ae,ce(F)}a=[new pe(0,0,0,0,function(F,$){var ae=65535;for(ae>F.pending_buf_size-5&&(ae=F.pending_buf_size-5);;){if(F.lookahead<=1){if(re(F),F.lookahead===0&&$===f)return L;if(F.lookahead===0)break}F.strstart+=F.lookahead,F.lookahead=0;var J=F.block_start+ae;if((F.strstart===0||F.strstart>=J)&&(F.lookahead=F.strstart-J,F.strstart=J,Y(F,!1),F.strm.avail_out===0)||F.strstart-F.block_start>=F.w_size-z&&(Y(F,!1),F.strm.avail_out===0))return L}return F.insert=0,$===p?(Y(F,!0),F.strm.avail_out===0?q:W):(F.strstart>F.block_start&&(Y(F,!1),F.strm.avail_out),L)}),new pe(4,4,8,4,ve),new pe(4,5,16,8,ve),new pe(4,6,32,32,ve),new pe(4,4,16,16,Pe),new pe(8,16,32,32,Pe),new pe(8,16,128,128,Pe),new pe(8,32,128,256,Pe),new pe(32,128,258,1024,Pe),new pe(32,258,258,4096,Pe)],r.deflateInit=function(F,$){return ft(F,$,M,15,8,0)},r.deflateInit2=ft,r.deflateReset=ce,r.deflateResetKeep=ze,r.deflateSetHeader=function(F,$){return F&&F.state?F.state.wrap!==2?_:(F.state.gzhead=$,m):_},r.deflate=function(F,$){var ae,J,ee,oe;if(!F||!F.state||5<$||$<0)return F?X(F,_):_;if(J=F.state,!F.output||!F.input&&F.avail_in!==0||J.status===666&&$!==p)return X(F,F.avail_out===0?-5:_);if(J.strm=F,ae=J.last_flush,J.last_flush=$,J.status===I)if(J.wrap===2)F.adler=0,se(J,31),se(J,139),se(J,8),J.gzhead?(se(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(J.gzhead.extra?4:0)+(J.gzhead.name?8:0)+(J.gzhead.comment?16:0)),se(J,255&J.gzhead.time),se(J,J.gzhead.time>>8&255),se(J,J.gzhead.time>>16&255),se(J,J.gzhead.time>>24&255),se(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),se(J,255&J.gzhead.os),J.gzhead.extra&&J.gzhead.extra.length&&(se(J,255&J.gzhead.extra.length),se(J,J.gzhead.extra.length>>8&255)),J.gzhead.hcrc&&(F.adler=c(F.adler,J.pending_buf,J.pending,0)),J.gzindex=0,J.status=69):(se(J,0),se(J,0),se(J,0),se(J,0),se(J,0),se(J,J.level===9?2:2<=J.strategy||J.level<2?4:0),se(J,3),J.status=G);else{var De=M+(J.w_bits-8<<4)<<8;De|=(2<=J.strategy||J.level<2?0:J.level<6?1:J.level===6?2:3)<<6,J.strstart!==0&&(De|=32),De+=31-De%31,J.status=G,ue(J,De),J.strstart!==0&&(ue(J,F.adler>>>16),ue(J,65535&F.adler)),F.adler=1}if(J.status===69)if(J.gzhead.extra){for(ee=J.pending;J.gzindex<(65535&J.gzhead.extra.length)&&(J.pending!==J.pending_buf_size||(J.gzhead.hcrc&&J.pending>ee&&(F.adler=c(F.adler,J.pending_buf,J.pending-ee,ee)),H(F),ee=J.pending,J.pending!==J.pending_buf_size));)se(J,255&J.gzhead.extra[J.gzindex]),J.gzindex++;J.gzhead.hcrc&&J.pending>ee&&(F.adler=c(F.adler,J.pending_buf,J.pending-ee,ee)),J.gzindex===J.gzhead.extra.length&&(J.gzindex=0,J.status=73)}else J.status=73;if(J.status===73)if(J.gzhead.name){ee=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>ee&&(F.adler=c(F.adler,J.pending_buf,J.pending-ee,ee)),H(F),ee=J.pending,J.pending===J.pending_buf_size)){oe=1;break}oe=J.gzindex<J.gzhead.name.length?255&J.gzhead.name.charCodeAt(J.gzindex++):0,se(J,oe)}while(oe!==0);J.gzhead.hcrc&&J.pending>ee&&(F.adler=c(F.adler,J.pending_buf,J.pending-ee,ee)),oe===0&&(J.gzindex=0,J.status=91)}else J.status=91;if(J.status===91)if(J.gzhead.comment){ee=J.pending;do{if(J.pending===J.pending_buf_size&&(J.gzhead.hcrc&&J.pending>ee&&(F.adler=c(F.adler,J.pending_buf,J.pending-ee,ee)),H(F),ee=J.pending,J.pending===J.pending_buf_size)){oe=1;break}oe=J.gzindex<J.gzhead.comment.length?255&J.gzhead.comment.charCodeAt(J.gzindex++):0,se(J,oe)}while(oe!==0);J.gzhead.hcrc&&J.pending>ee&&(F.adler=c(F.adler,J.pending_buf,J.pending-ee,ee)),oe===0&&(J.status=103)}else J.status=103;if(J.status===103&&(J.gzhead.hcrc?(J.pending+2>J.pending_buf_size&&H(F),J.pending+2<=J.pending_buf_size&&(se(J,255&F.adler),se(J,F.adler>>8&255),F.adler=0,J.status=G)):J.status=G),J.pending!==0){if(H(F),F.avail_out===0)return J.last_flush=-1,m}else if(F.avail_in===0&&Q($)<=Q(ae)&&$!==p)return X(F,-5);if(J.status===666&&F.avail_in!==0)return X(F,-5);if(F.avail_in!==0||J.lookahead!==0||$!==f&&J.status!==666){var Ne=J.strategy===2?(function(te,j){for(var k;;){if(te.lookahead===0&&(re(te),te.lookahead===0)){if(j===f)return L;break}if(te.match_length=0,k=o._tr_tally(te,0,te.window[te.strstart]),te.lookahead--,te.strstart++,k&&(Y(te,!1),te.strm.avail_out===0))return L}return te.insert=0,j===p?(Y(te,!0),te.strm.avail_out===0?q:W):te.last_lit&&(Y(te,!1),te.strm.avail_out===0)?L:B})(J,$):J.strategy===3?(function(te,j){for(var k,K,me,ye,he=te.window;;){if(te.lookahead<=O){if(re(te),te.lookahead<=O&&j===f)return L;if(te.lookahead===0)break}if(te.match_length=0,te.lookahead>=R&&0<te.strstart&&(K=he[me=te.strstart-1])===he[++me]&&K===he[++me]&&K===he[++me]){ye=te.strstart+O;do;while(K===he[++me]&&K===he[++me]&&K===he[++me]&&K===he[++me]&&K===he[++me]&&K===he[++me]&&K===he[++me]&&K===he[++me]&&me<ye);te.match_length=O-(ye-me),te.match_length>te.lookahead&&(te.match_length=te.lookahead)}if(te.match_length>=R?(k=o._tr_tally(te,1,te.match_length-R),te.lookahead-=te.match_length,te.strstart+=te.match_length,te.match_length=0):(k=o._tr_tally(te,0,te.window[te.strstart]),te.lookahead--,te.strstart++),k&&(Y(te,!1),te.strm.avail_out===0))return L}return te.insert=0,j===p?(Y(te,!0),te.strm.avail_out===0?q:W):te.last_lit&&(Y(te,!1),te.strm.avail_out===0)?L:B})(J,$):a[J.level].func(J,$);if(Ne!==q&&Ne!==W||(J.status=666),Ne===L||Ne===q)return F.avail_out===0&&(J.last_flush=-1),m;if(Ne===B&&($===1?o._tr_align(J):$!==5&&(o._tr_stored_block(J,0,0,!1),$===3&&(ie(J.head),J.lookahead===0&&(J.strstart=0,J.block_start=0,J.insert=0))),H(F),F.avail_out===0))return J.last_flush=-1,m}return $!==p?m:J.wrap<=0?1:(J.wrap===2?(se(J,255&F.adler),se(J,F.adler>>8&255),se(J,F.adler>>16&255),se(J,F.adler>>24&255),se(J,255&F.total_in),se(J,F.total_in>>8&255),se(J,F.total_in>>16&255),se(J,F.total_in>>24&255)):(ue(J,F.adler>>>16),ue(J,65535&F.adler)),H(F),0<J.wrap&&(J.wrap=-J.wrap),J.pending!==0?m:1)},r.deflateEnd=function(F){var $;return F&&F.state?($=F.state.status)!==I&&$!==69&&$!==73&&$!==91&&$!==103&&$!==G&&$!==666?X(F,_):(F.state=null,$===G?X(F,-3):m):_},r.deflateSetDictionary=function(F,$){var ae,J,ee,oe,De,Ne,te,j,k=$.length;if(!F||!F.state||(oe=(ae=F.state).wrap)===2||oe===1&&ae.status!==I||ae.lookahead)return _;for(oe===1&&(F.adler=l(F.adler,$,k,0)),ae.wrap=0,k>=ae.w_size&&(oe===0&&(ie(ae.head),ae.strstart=0,ae.block_start=0,ae.insert=0),j=new s.Buf8(ae.w_size),s.arraySet(j,$,k-ae.w_size,ae.w_size,0),$=j,k=ae.w_size),De=F.avail_in,Ne=F.next_in,te=F.input,F.avail_in=k,F.next_in=0,F.input=$,re(ae);ae.lookahead>=R;){for(J=ae.strstart,ee=ae.lookahead-(R-1);ae.ins_h=(ae.ins_h<<ae.hash_shift^ae.window[J+R-1])&ae.hash_mask,ae.prev[J&ae.w_mask]=ae.head[ae.ins_h],ae.head[ae.ins_h]=J,J++,--ee;);ae.strstart=J,ae.lookahead=R-1,re(ae)}return ae.strstart+=ae.lookahead,ae.block_start=ae.strstart,ae.insert=ae.lookahead,ae.lookahead=0,ae.match_length=ae.prev_length=R-1,ae.match_available=0,F.next_in=Ne,F.input=te,F.avail_in=De,ae.wrap=oe,m},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,i,r){i.exports=function(a,s){var o,l,c,d,f,p,m,_,b,v,x,M,w,E,T,P,N,U,R,O,z,I,G,L,B;o=a.state,l=a.next_in,L=a.input,c=l+(a.avail_in-5),d=a.next_out,B=a.output,f=d-(s-a.avail_out),p=d+(a.avail_out-257),m=o.dmax,_=o.wsize,b=o.whave,v=o.wnext,x=o.window,M=o.hold,w=o.bits,E=o.lencode,T=o.distcode,P=(1<<o.lenbits)-1,N=(1<<o.distbits)-1;e:do{w<15&&(M+=L[l++]<<w,w+=8,M+=L[l++]<<w,w+=8),U=E[M&P];t:for(;;){if(M>>>=R=U>>>24,w-=R,(R=U>>>16&255)===0)B[d++]=65535&U;else{if(!(16&R)){if((64&R)==0){U=E[(65535&U)+(M&(1<<R)-1)];continue t}if(32&R){o.mode=12;break e}a.msg="invalid literal/length code",o.mode=30;break e}O=65535&U,(R&=15)&&(w<R&&(M+=L[l++]<<w,w+=8),O+=M&(1<<R)-1,M>>>=R,w-=R),w<15&&(M+=L[l++]<<w,w+=8,M+=L[l++]<<w,w+=8),U=T[M&N];n:for(;;){if(M>>>=R=U>>>24,w-=R,!(16&(R=U>>>16&255))){if((64&R)==0){U=T[(65535&U)+(M&(1<<R)-1)];continue n}a.msg="invalid distance code",o.mode=30;break e}if(z=65535&U,w<(R&=15)&&(M+=L[l++]<<w,(w+=8)<R&&(M+=L[l++]<<w,w+=8)),m<(z+=M&(1<<R)-1)){a.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=R,w-=R,(R=d-f)<z){if(b<(R=z-R)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break e}if(G=x,(I=0)===v){if(I+=_-R,R<O){for(O-=R;B[d++]=x[I++],--R;);I=d-z,G=B}}else if(v<R){if(I+=_+v-R,(R-=v)<O){for(O-=R;B[d++]=x[I++],--R;);if(I=0,v<O){for(O-=R=v;B[d++]=x[I++],--R;);I=d-z,G=B}}}else if(I+=v-R,R<O){for(O-=R;B[d++]=x[I++],--R;);I=d-z,G=B}for(;2<O;)B[d++]=G[I++],B[d++]=G[I++],B[d++]=G[I++],O-=3;O&&(B[d++]=G[I++],1<O&&(B[d++]=G[I++]))}else{for(I=d-z;B[d++]=B[I++],B[d++]=B[I++],B[d++]=B[I++],2<(O-=3););O&&(B[d++]=B[I++],1<O&&(B[d++]=B[I++]))}break}}break}}while(l<c&&d<p);l-=O=w>>3,M&=(1<<(w-=O<<3))-1,a.next_in=l,a.next_out=d,a.avail_in=l<c?c-l+5:5-(l-c),a.avail_out=d<p?p-d+257:257-(d-p),o.hold=M,o.bits=w}},{}],49:[function(n,i,r){var a=n("../utils/common"),s=n("./adler32"),o=n("./crc32"),l=n("./inffast"),c=n("./inftrees"),d=1,f=2,p=0,m=-2,_=1,b=852,v=592;function x(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function M(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(I){var G;return I&&I.state?(G=I.state,I.total_in=I.total_out=G.total=0,I.msg="",G.wrap&&(I.adler=1&G.wrap),G.mode=_,G.last=0,G.havedict=0,G.dmax=32768,G.head=null,G.hold=0,G.bits=0,G.lencode=G.lendyn=new a.Buf32(b),G.distcode=G.distdyn=new a.Buf32(v),G.sane=1,G.back=-1,p):m}function E(I){var G;return I&&I.state?((G=I.state).wsize=0,G.whave=0,G.wnext=0,w(I)):m}function T(I,G){var L,B;return I&&I.state?(B=I.state,G<0?(L=0,G=-G):(L=1+(G>>4),G<48&&(G&=15)),G&&(G<8||15<G)?m:(B.window!==null&&B.wbits!==G&&(B.window=null),B.wrap=L,B.wbits=G,E(I))):m}function P(I,G){var L,B;return I?(B=new M,(I.state=B).window=null,(L=T(I,G))!==p&&(I.state=null),L):m}var N,U,R=!0;function O(I){if(R){var G;for(N=new a.Buf32(512),U=new a.Buf32(32),G=0;G<144;)I.lens[G++]=8;for(;G<256;)I.lens[G++]=9;for(;G<280;)I.lens[G++]=7;for(;G<288;)I.lens[G++]=8;for(c(d,I.lens,0,288,N,0,I.work,{bits:9}),G=0;G<32;)I.lens[G++]=5;c(f,I.lens,0,32,U,0,I.work,{bits:5}),R=!1}I.lencode=N,I.lenbits=9,I.distcode=U,I.distbits=5}function z(I,G,L,B){var q,W=I.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new a.Buf8(W.wsize)),B>=W.wsize?(a.arraySet(W.window,G,L-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(B<(q=W.wsize-W.wnext)&&(q=B),a.arraySet(W.window,G,L-B,q,W.wnext),(B-=q)?(a.arraySet(W.window,G,L-B,B,0),W.wnext=B,W.whave=W.wsize):(W.wnext+=q,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=q))),0}r.inflateReset=E,r.inflateReset2=T,r.inflateResetKeep=w,r.inflateInit=function(I){return P(I,15)},r.inflateInit2=P,r.inflate=function(I,G){var L,B,q,W,X,Q,ie,H,Y,se,ue,xe,re,ve,Pe,pe,we,ze,ce,ft,F,$,ae,J,ee=0,oe=new a.Buf8(4),De=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return m;(L=I.state).mode===12&&(L.mode=13),X=I.next_out,q=I.output,ie=I.avail_out,W=I.next_in,B=I.input,Q=I.avail_in,H=L.hold,Y=L.bits,se=Q,ue=ie,$=p;e:for(;;)switch(L.mode){case _:if(L.wrap===0){L.mode=13;break}for(;Y<16;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(2&L.wrap&&H===35615){oe[L.check=0]=255&H,oe[1]=H>>>8&255,L.check=o(L.check,oe,2,0),Y=H=0,L.mode=2;break}if(L.flags=0,L.head&&(L.head.done=!1),!(1&L.wrap)||(((255&H)<<8)+(H>>8))%31){I.msg="incorrect header check",L.mode=30;break}if((15&H)!=8){I.msg="unknown compression method",L.mode=30;break}if(Y-=4,F=8+(15&(H>>>=4)),L.wbits===0)L.wbits=F;else if(F>L.wbits){I.msg="invalid window size",L.mode=30;break}L.dmax=1<<F,I.adler=L.check=1,L.mode=512&H?10:12,Y=H=0;break;case 2:for(;Y<16;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(L.flags=H,(255&L.flags)!=8){I.msg="unknown compression method",L.mode=30;break}if(57344&L.flags){I.msg="unknown header flags set",L.mode=30;break}L.head&&(L.head.text=H>>8&1),512&L.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,L.check=o(L.check,oe,2,0)),Y=H=0,L.mode=3;case 3:for(;Y<32;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}L.head&&(L.head.time=H),512&L.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,oe[2]=H>>>16&255,oe[3]=H>>>24&255,L.check=o(L.check,oe,4,0)),Y=H=0,L.mode=4;case 4:for(;Y<16;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}L.head&&(L.head.xflags=255&H,L.head.os=H>>8),512&L.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,L.check=o(L.check,oe,2,0)),Y=H=0,L.mode=5;case 5:if(1024&L.flags){for(;Y<16;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}L.length=H,L.head&&(L.head.extra_len=H),512&L.flags&&(oe[0]=255&H,oe[1]=H>>>8&255,L.check=o(L.check,oe,2,0)),Y=H=0}else L.head&&(L.head.extra=null);L.mode=6;case 6:if(1024&L.flags&&(Q<(xe=L.length)&&(xe=Q),xe&&(L.head&&(F=L.head.extra_len-L.length,L.head.extra||(L.head.extra=new Array(L.head.extra_len)),a.arraySet(L.head.extra,B,W,xe,F)),512&L.flags&&(L.check=o(L.check,B,xe,W)),Q-=xe,W+=xe,L.length-=xe),L.length))break e;L.length=0,L.mode=7;case 7:if(2048&L.flags){if(Q===0)break e;for(xe=0;F=B[W+xe++],L.head&&F&&L.length<65536&&(L.head.name+=String.fromCharCode(F)),F&&xe<Q;);if(512&L.flags&&(L.check=o(L.check,B,xe,W)),Q-=xe,W+=xe,F)break e}else L.head&&(L.head.name=null);L.length=0,L.mode=8;case 8:if(4096&L.flags){if(Q===0)break e;for(xe=0;F=B[W+xe++],L.head&&F&&L.length<65536&&(L.head.comment+=String.fromCharCode(F)),F&&xe<Q;);if(512&L.flags&&(L.check=o(L.check,B,xe,W)),Q-=xe,W+=xe,F)break e}else L.head&&(L.head.comment=null);L.mode=9;case 9:if(512&L.flags){for(;Y<16;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(H!==(65535&L.check)){I.msg="header crc mismatch",L.mode=30;break}Y=H=0}L.head&&(L.head.hcrc=L.flags>>9&1,L.head.done=!0),I.adler=L.check=0,L.mode=12;break;case 10:for(;Y<32;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}I.adler=L.check=x(H),Y=H=0,L.mode=11;case 11:if(L.havedict===0)return I.next_out=X,I.avail_out=ie,I.next_in=W,I.avail_in=Q,L.hold=H,L.bits=Y,2;I.adler=L.check=1,L.mode=12;case 12:if(G===5||G===6)break e;case 13:if(L.last){H>>>=7&Y,Y-=7&Y,L.mode=27;break}for(;Y<3;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}switch(L.last=1&H,Y-=1,3&(H>>>=1)){case 0:L.mode=14;break;case 1:if(O(L),L.mode=20,G!==6)break;H>>>=2,Y-=2;break e;case 2:L.mode=17;break;case 3:I.msg="invalid block type",L.mode=30}H>>>=2,Y-=2;break;case 14:for(H>>>=7&Y,Y-=7&Y;Y<32;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if((65535&H)!=(H>>>16^65535)){I.msg="invalid stored block lengths",L.mode=30;break}if(L.length=65535&H,Y=H=0,L.mode=15,G===6)break e;case 15:L.mode=16;case 16:if(xe=L.length){if(Q<xe&&(xe=Q),ie<xe&&(xe=ie),xe===0)break e;a.arraySet(q,B,W,xe,X),Q-=xe,W+=xe,ie-=xe,X+=xe,L.length-=xe;break}L.mode=12;break;case 17:for(;Y<14;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(L.nlen=257+(31&H),H>>>=5,Y-=5,L.ndist=1+(31&H),H>>>=5,Y-=5,L.ncode=4+(15&H),H>>>=4,Y-=4,286<L.nlen||30<L.ndist){I.msg="too many length or distance symbols",L.mode=30;break}L.have=0,L.mode=18;case 18:for(;L.have<L.ncode;){for(;Y<3;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}L.lens[De[L.have++]]=7&H,H>>>=3,Y-=3}for(;L.have<19;)L.lens[De[L.have++]]=0;if(L.lencode=L.lendyn,L.lenbits=7,ae={bits:L.lenbits},$=c(0,L.lens,0,19,L.lencode,0,L.work,ae),L.lenbits=ae.bits,$){I.msg="invalid code lengths set",L.mode=30;break}L.have=0,L.mode=19;case 19:for(;L.have<L.nlen+L.ndist;){for(;pe=(ee=L.lencode[H&(1<<L.lenbits)-1])>>>16&255,we=65535&ee,!((Pe=ee>>>24)<=Y);){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(we<16)H>>>=Pe,Y-=Pe,L.lens[L.have++]=we;else{if(we===16){for(J=Pe+2;Y<J;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(H>>>=Pe,Y-=Pe,L.have===0){I.msg="invalid bit length repeat",L.mode=30;break}F=L.lens[L.have-1],xe=3+(3&H),H>>>=2,Y-=2}else if(we===17){for(J=Pe+3;Y<J;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}Y-=Pe,F=0,xe=3+(7&(H>>>=Pe)),H>>>=3,Y-=3}else{for(J=Pe+7;Y<J;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}Y-=Pe,F=0,xe=11+(127&(H>>>=Pe)),H>>>=7,Y-=7}if(L.have+xe>L.nlen+L.ndist){I.msg="invalid bit length repeat",L.mode=30;break}for(;xe--;)L.lens[L.have++]=F}}if(L.mode===30)break;if(L.lens[256]===0){I.msg="invalid code -- missing end-of-block",L.mode=30;break}if(L.lenbits=9,ae={bits:L.lenbits},$=c(d,L.lens,0,L.nlen,L.lencode,0,L.work,ae),L.lenbits=ae.bits,$){I.msg="invalid literal/lengths set",L.mode=30;break}if(L.distbits=6,L.distcode=L.distdyn,ae={bits:L.distbits},$=c(f,L.lens,L.nlen,L.ndist,L.distcode,0,L.work,ae),L.distbits=ae.bits,$){I.msg="invalid distances set",L.mode=30;break}if(L.mode=20,G===6)break e;case 20:L.mode=21;case 21:if(6<=Q&&258<=ie){I.next_out=X,I.avail_out=ie,I.next_in=W,I.avail_in=Q,L.hold=H,L.bits=Y,l(I,ue),X=I.next_out,q=I.output,ie=I.avail_out,W=I.next_in,B=I.input,Q=I.avail_in,H=L.hold,Y=L.bits,L.mode===12&&(L.back=-1);break}for(L.back=0;pe=(ee=L.lencode[H&(1<<L.lenbits)-1])>>>16&255,we=65535&ee,!((Pe=ee>>>24)<=Y);){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(pe&&(240&pe)==0){for(ze=Pe,ce=pe,ft=we;pe=(ee=L.lencode[ft+((H&(1<<ze+ce)-1)>>ze)])>>>16&255,we=65535&ee,!(ze+(Pe=ee>>>24)<=Y);){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}H>>>=ze,Y-=ze,L.back+=ze}if(H>>>=Pe,Y-=Pe,L.back+=Pe,L.length=we,pe===0){L.mode=26;break}if(32&pe){L.back=-1,L.mode=12;break}if(64&pe){I.msg="invalid literal/length code",L.mode=30;break}L.extra=15&pe,L.mode=22;case 22:if(L.extra){for(J=L.extra;Y<J;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}L.length+=H&(1<<L.extra)-1,H>>>=L.extra,Y-=L.extra,L.back+=L.extra}L.was=L.length,L.mode=23;case 23:for(;pe=(ee=L.distcode[H&(1<<L.distbits)-1])>>>16&255,we=65535&ee,!((Pe=ee>>>24)<=Y);){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if((240&pe)==0){for(ze=Pe,ce=pe,ft=we;pe=(ee=L.distcode[ft+((H&(1<<ze+ce)-1)>>ze)])>>>16&255,we=65535&ee,!(ze+(Pe=ee>>>24)<=Y);){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}H>>>=ze,Y-=ze,L.back+=ze}if(H>>>=Pe,Y-=Pe,L.back+=Pe,64&pe){I.msg="invalid distance code",L.mode=30;break}L.offset=we,L.extra=15&pe,L.mode=24;case 24:if(L.extra){for(J=L.extra;Y<J;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}L.offset+=H&(1<<L.extra)-1,H>>>=L.extra,Y-=L.extra,L.back+=L.extra}if(L.offset>L.dmax){I.msg="invalid distance too far back",L.mode=30;break}L.mode=25;case 25:if(ie===0)break e;if(xe=ue-ie,L.offset>xe){if((xe=L.offset-xe)>L.whave&&L.sane){I.msg="invalid distance too far back",L.mode=30;break}re=xe>L.wnext?(xe-=L.wnext,L.wsize-xe):L.wnext-xe,xe>L.length&&(xe=L.length),ve=L.window}else ve=q,re=X-L.offset,xe=L.length;for(ie<xe&&(xe=ie),ie-=xe,L.length-=xe;q[X++]=ve[re++],--xe;);L.length===0&&(L.mode=21);break;case 26:if(ie===0)break e;q[X++]=L.length,ie--,L.mode=21;break;case 27:if(L.wrap){for(;Y<32;){if(Q===0)break e;Q--,H|=B[W++]<<Y,Y+=8}if(ue-=ie,I.total_out+=ue,L.total+=ue,ue&&(I.adler=L.check=L.flags?o(L.check,q,ue,X-ue):s(L.check,q,ue,X-ue)),ue=ie,(L.flags?H:x(H))!==L.check){I.msg="incorrect data check",L.mode=30;break}Y=H=0}L.mode=28;case 28:if(L.wrap&&L.flags){for(;Y<32;){if(Q===0)break e;Q--,H+=B[W++]<<Y,Y+=8}if(H!==(4294967295&L.total)){I.msg="incorrect length check",L.mode=30;break}Y=H=0}L.mode=29;case 29:$=1;break e;case 30:$=-3;break e;case 31:return-4;case 32:default:return m}return I.next_out=X,I.avail_out=ie,I.next_in=W,I.avail_in=Q,L.hold=H,L.bits=Y,(L.wsize||ue!==I.avail_out&&L.mode<30&&(L.mode<27||G!==4))&&z(I,I.output,I.next_out,ue-I.avail_out)?(L.mode=31,-4):(se-=I.avail_in,ue-=I.avail_out,I.total_in+=se,I.total_out+=ue,L.total+=ue,L.wrap&&ue&&(I.adler=L.check=L.flags?o(L.check,q,ue,I.next_out-ue):s(L.check,q,ue,I.next_out-ue)),I.data_type=L.bits+(L.last?64:0)+(L.mode===12?128:0)+(L.mode===20||L.mode===15?256:0),(se==0&&ue===0||G===4)&&$===p&&($=-5),$)},r.inflateEnd=function(I){if(!I||!I.state)return m;var G=I.state;return G.window&&(G.window=null),I.state=null,p},r.inflateGetHeader=function(I,G){var L;return I&&I.state?(2&(L=I.state).wrap)==0?m:((L.head=G).done=!1,p):m},r.inflateSetDictionary=function(I,G){var L,B=G.length;return I&&I.state?(L=I.state).wrap!==0&&L.mode!==11?m:L.mode===11&&s(1,G,B,0)!==L.check?-3:z(I,G,B,B)?(L.mode=31,-4):(L.havedict=1,p):m},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,i,r){var a=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(d,f,p,m,_,b,v,x){var M,w,E,T,P,N,U,R,O,z=x.bits,I=0,G=0,L=0,B=0,q=0,W=0,X=0,Q=0,ie=0,H=0,Y=null,se=0,ue=new a.Buf16(16),xe=new a.Buf16(16),re=null,ve=0;for(I=0;I<=15;I++)ue[I]=0;for(G=0;G<m;G++)ue[f[p+G]]++;for(q=z,B=15;1<=B&&ue[B]===0;B--);if(B<q&&(q=B),B===0)return _[b++]=20971520,_[b++]=20971520,x.bits=1,0;for(L=1;L<B&&ue[L]===0;L++);for(q<L&&(q=L),I=Q=1;I<=15;I++)if(Q<<=1,(Q-=ue[I])<0)return-1;if(0<Q&&(d===0||B!==1))return-1;for(xe[1]=0,I=1;I<15;I++)xe[I+1]=xe[I]+ue[I];for(G=0;G<m;G++)f[p+G]!==0&&(v[xe[f[p+G]]++]=G);if(N=d===0?(Y=re=v,19):d===1?(Y=s,se-=257,re=o,ve-=257,256):(Y=l,re=c,-1),I=L,P=b,X=G=H=0,E=-1,T=(ie=1<<(W=q))-1,d===1&&852<ie||d===2&&592<ie)return 1;for(;;){for(U=I-X,O=v[G]<N?(R=0,v[G]):v[G]>N?(R=re[ve+v[G]],Y[se+v[G]]):(R=96,0),M=1<<I-X,L=w=1<<W;_[P+(H>>X)+(w-=M)]=U<<24|R<<16|O|0,w!==0;);for(M=1<<I-1;H&M;)M>>=1;if(M!==0?(H&=M-1,H+=M):H=0,G++,--ue[I]==0){if(I===B)break;I=f[p+v[G]]}if(q<I&&(H&T)!==E){for(X===0&&(X=q),P+=L,Q=1<<(W=I-X);W+X<B&&!((Q-=ue[W+X])<=0);)W++,Q<<=1;if(ie+=1<<W,d===1&&852<ie||d===2&&592<ie)return 1;_[E=H&T]=q<<24|W<<16|P-b|0}}return H!==0&&(_[P+H]=I-X<<24|64<<16|0),x.bits=q,0}},{"../utils/common":41}],51:[function(n,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,i,r){var a=n("../utils/common"),s=0,o=1;function l(ee){for(var oe=ee.length;0<=--oe;)ee[oe]=0}var c=0,d=29,f=256,p=f+1+d,m=30,_=19,b=2*p+1,v=15,x=16,M=7,w=256,E=16,T=17,P=18,N=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],U=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],R=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(p+2));l(z);var I=new Array(2*m);l(I);var G=new Array(512);l(G);var L=new Array(256);l(L);var B=new Array(d);l(B);var q,W,X,Q=new Array(m);function ie(ee,oe,De,Ne,te){this.static_tree=ee,this.extra_bits=oe,this.extra_base=De,this.elems=Ne,this.max_length=te,this.has_stree=ee&&ee.length}function H(ee,oe){this.dyn_tree=ee,this.max_code=0,this.stat_desc=oe}function Y(ee){return ee<256?G[ee]:G[256+(ee>>>7)]}function se(ee,oe){ee.pending_buf[ee.pending++]=255&oe,ee.pending_buf[ee.pending++]=oe>>>8&255}function ue(ee,oe,De){ee.bi_valid>x-De?(ee.bi_buf|=oe<<ee.bi_valid&65535,se(ee,ee.bi_buf),ee.bi_buf=oe>>x-ee.bi_valid,ee.bi_valid+=De-x):(ee.bi_buf|=oe<<ee.bi_valid&65535,ee.bi_valid+=De)}function xe(ee,oe,De){ue(ee,De[2*oe],De[2*oe+1])}function re(ee,oe){for(var De=0;De|=1&ee,ee>>>=1,De<<=1,0<--oe;);return De>>>1}function ve(ee,oe,De){var Ne,te,j=new Array(v+1),k=0;for(Ne=1;Ne<=v;Ne++)j[Ne]=k=k+De[Ne-1]<<1;for(te=0;te<=oe;te++){var K=ee[2*te+1];K!==0&&(ee[2*te]=re(j[K]++,K))}}function Pe(ee){var oe;for(oe=0;oe<p;oe++)ee.dyn_ltree[2*oe]=0;for(oe=0;oe<m;oe++)ee.dyn_dtree[2*oe]=0;for(oe=0;oe<_;oe++)ee.bl_tree[2*oe]=0;ee.dyn_ltree[2*w]=1,ee.opt_len=ee.static_len=0,ee.last_lit=ee.matches=0}function pe(ee){8<ee.bi_valid?se(ee,ee.bi_buf):0<ee.bi_valid&&(ee.pending_buf[ee.pending++]=ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0}function we(ee,oe,De,Ne){var te=2*oe,j=2*De;return ee[te]<ee[j]||ee[te]===ee[j]&&Ne[oe]<=Ne[De]}function ze(ee,oe,De){for(var Ne=ee.heap[De],te=De<<1;te<=ee.heap_len&&(te<ee.heap_len&&we(oe,ee.heap[te+1],ee.heap[te],ee.depth)&&te++,!we(oe,Ne,ee.heap[te],ee.depth));)ee.heap[De]=ee.heap[te],De=te,te<<=1;ee.heap[De]=Ne}function ce(ee,oe,De){var Ne,te,j,k,K=0;if(ee.last_lit!==0)for(;Ne=ee.pending_buf[ee.d_buf+2*K]<<8|ee.pending_buf[ee.d_buf+2*K+1],te=ee.pending_buf[ee.l_buf+K],K++,Ne===0?xe(ee,te,oe):(xe(ee,(j=L[te])+f+1,oe),(k=N[j])!==0&&ue(ee,te-=B[j],k),xe(ee,j=Y(--Ne),De),(k=U[j])!==0&&ue(ee,Ne-=Q[j],k)),K<ee.last_lit;);xe(ee,w,oe)}function ft(ee,oe){var De,Ne,te,j=oe.dyn_tree,k=oe.stat_desc.static_tree,K=oe.stat_desc.has_stree,me=oe.stat_desc.elems,ye=-1;for(ee.heap_len=0,ee.heap_max=b,De=0;De<me;De++)j[2*De]!==0?(ee.heap[++ee.heap_len]=ye=De,ee.depth[De]=0):j[2*De+1]=0;for(;ee.heap_len<2;)j[2*(te=ee.heap[++ee.heap_len]=ye<2?++ye:0)]=1,ee.depth[te]=0,ee.opt_len--,K&&(ee.static_len-=k[2*te+1]);for(oe.max_code=ye,De=ee.heap_len>>1;1<=De;De--)ze(ee,j,De);for(te=me;De=ee.heap[1],ee.heap[1]=ee.heap[ee.heap_len--],ze(ee,j,1),Ne=ee.heap[1],ee.heap[--ee.heap_max]=De,ee.heap[--ee.heap_max]=Ne,j[2*te]=j[2*De]+j[2*Ne],ee.depth[te]=(ee.depth[De]>=ee.depth[Ne]?ee.depth[De]:ee.depth[Ne])+1,j[2*De+1]=j[2*Ne+1]=te,ee.heap[1]=te++,ze(ee,j,1),2<=ee.heap_len;);ee.heap[--ee.heap_max]=ee.heap[1],(function(he,Ye){var Le,qe,rt,Ie,Re,ht,tt=Ye.dyn_tree,et=Ye.max_code,ct=Ye.stat_desc.static_tree,de=Ye.stat_desc.has_stree,nt=Ye.stat_desc.extra_bits,fe=Ye.stat_desc.extra_base,ke=Ye.stat_desc.max_length,Me=0;for(Ie=0;Ie<=v;Ie++)he.bl_count[Ie]=0;for(tt[2*he.heap[he.heap_max]+1]=0,Le=he.heap_max+1;Le<b;Le++)ke<(Ie=tt[2*tt[2*(qe=he.heap[Le])+1]+1]+1)&&(Ie=ke,Me++),tt[2*qe+1]=Ie,et<qe||(he.bl_count[Ie]++,Re=0,fe<=qe&&(Re=nt[qe-fe]),ht=tt[2*qe],he.opt_len+=ht*(Ie+Re),de&&(he.static_len+=ht*(ct[2*qe+1]+Re)));if(Me!==0){do{for(Ie=ke-1;he.bl_count[Ie]===0;)Ie--;he.bl_count[Ie]--,he.bl_count[Ie+1]+=2,he.bl_count[ke]--,Me-=2}while(0<Me);for(Ie=ke;Ie!==0;Ie--)for(qe=he.bl_count[Ie];qe!==0;)et<(rt=he.heap[--Le])||(tt[2*rt+1]!==Ie&&(he.opt_len+=(Ie-tt[2*rt+1])*tt[2*rt],tt[2*rt+1]=Ie),qe--)}})(ee,oe),ve(j,ye,ee.bl_count)}function F(ee,oe,De){var Ne,te,j=-1,k=oe[1],K=0,me=7,ye=4;for(k===0&&(me=138,ye=3),oe[2*(De+1)+1]=65535,Ne=0;Ne<=De;Ne++)te=k,k=oe[2*(Ne+1)+1],++K<me&&te===k||(K<ye?ee.bl_tree[2*te]+=K:te!==0?(te!==j&&ee.bl_tree[2*te]++,ee.bl_tree[2*E]++):K<=10?ee.bl_tree[2*T]++:ee.bl_tree[2*P]++,j=te,ye=(K=0)===k?(me=138,3):te===k?(me=6,3):(me=7,4))}function $(ee,oe,De){var Ne,te,j=-1,k=oe[1],K=0,me=7,ye=4;for(k===0&&(me=138,ye=3),Ne=0;Ne<=De;Ne++)if(te=k,k=oe[2*(Ne+1)+1],!(++K<me&&te===k)){if(K<ye)for(;xe(ee,te,ee.bl_tree),--K!=0;);else te!==0?(te!==j&&(xe(ee,te,ee.bl_tree),K--),xe(ee,E,ee.bl_tree),ue(ee,K-3,2)):K<=10?(xe(ee,T,ee.bl_tree),ue(ee,K-3,3)):(xe(ee,P,ee.bl_tree),ue(ee,K-11,7));j=te,ye=(K=0)===k?(me=138,3):te===k?(me=6,3):(me=7,4)}}l(Q);var ae=!1;function J(ee,oe,De,Ne){ue(ee,(c<<1)+(Ne?1:0),3),(function(te,j,k,K){pe(te),se(te,k),se(te,~k),a.arraySet(te.pending_buf,te.window,j,k,te.pending),te.pending+=k})(ee,oe,De)}r._tr_init=function(ee){ae||((function(){var oe,De,Ne,te,j,k=new Array(v+1);for(te=Ne=0;te<d-1;te++)for(B[te]=Ne,oe=0;oe<1<<N[te];oe++)L[Ne++]=te;for(L[Ne-1]=te,te=j=0;te<16;te++)for(Q[te]=j,oe=0;oe<1<<U[te];oe++)G[j++]=te;for(j>>=7;te<m;te++)for(Q[te]=j<<7,oe=0;oe<1<<U[te]-7;oe++)G[256+j++]=te;for(De=0;De<=v;De++)k[De]=0;for(oe=0;oe<=143;)z[2*oe+1]=8,oe++,k[8]++;for(;oe<=255;)z[2*oe+1]=9,oe++,k[9]++;for(;oe<=279;)z[2*oe+1]=7,oe++,k[7]++;for(;oe<=287;)z[2*oe+1]=8,oe++,k[8]++;for(ve(z,p+1,k),oe=0;oe<m;oe++)I[2*oe+1]=5,I[2*oe]=re(oe,5);q=new ie(z,N,f+1,p,v),W=new ie(I,U,0,m,v),X=new ie(new Array(0),R,0,_,M)})(),ae=!0),ee.l_desc=new H(ee.dyn_ltree,q),ee.d_desc=new H(ee.dyn_dtree,W),ee.bl_desc=new H(ee.bl_tree,X),ee.bi_buf=0,ee.bi_valid=0,Pe(ee)},r._tr_stored_block=J,r._tr_flush_block=function(ee,oe,De,Ne){var te,j,k=0;0<ee.level?(ee.strm.data_type===2&&(ee.strm.data_type=(function(K){var me,ye=4093624447;for(me=0;me<=31;me++,ye>>>=1)if(1&ye&&K.dyn_ltree[2*me]!==0)return s;if(K.dyn_ltree[18]!==0||K.dyn_ltree[20]!==0||K.dyn_ltree[26]!==0)return o;for(me=32;me<f;me++)if(K.dyn_ltree[2*me]!==0)return o;return s})(ee)),ft(ee,ee.l_desc),ft(ee,ee.d_desc),k=(function(K){var me;for(F(K,K.dyn_ltree,K.l_desc.max_code),F(K,K.dyn_dtree,K.d_desc.max_code),ft(K,K.bl_desc),me=_-1;3<=me&&K.bl_tree[2*O[me]+1]===0;me--);return K.opt_len+=3*(me+1)+5+5+4,me})(ee),te=ee.opt_len+3+7>>>3,(j=ee.static_len+3+7>>>3)<=te&&(te=j)):te=j=De+5,De+4<=te&&oe!==-1?J(ee,oe,De,Ne):ee.strategy===4||j===te?(ue(ee,2+(Ne?1:0),3),ce(ee,z,I)):(ue(ee,4+(Ne?1:0),3),(function(K,me,ye,he){var Ye;for(ue(K,me-257,5),ue(K,ye-1,5),ue(K,he-4,4),Ye=0;Ye<he;Ye++)ue(K,K.bl_tree[2*O[Ye]+1],3);$(K,K.dyn_ltree,me-1),$(K,K.dyn_dtree,ye-1)})(ee,ee.l_desc.max_code+1,ee.d_desc.max_code+1,k+1),ce(ee,ee.dyn_ltree,ee.dyn_dtree)),Pe(ee),Ne&&pe(ee)},r._tr_tally=function(ee,oe,De){return ee.pending_buf[ee.d_buf+2*ee.last_lit]=oe>>>8&255,ee.pending_buf[ee.d_buf+2*ee.last_lit+1]=255&oe,ee.pending_buf[ee.l_buf+ee.last_lit]=255&De,ee.last_lit++,oe===0?ee.dyn_ltree[2*De]++:(ee.matches++,oe--,ee.dyn_ltree[2*(L[De]+f+1)]++,ee.dyn_dtree[2*Y(oe)]++),ee.last_lit===ee.lit_bufsize-1},r._tr_align=function(ee){ue(ee,2,3),xe(ee,w,z),(function(oe){oe.bi_valid===16?(se(oe,oe.bi_buf),oe.bi_buf=0,oe.bi_valid=0):8<=oe.bi_valid&&(oe.pending_buf[oe.pending++]=255&oe.bi_buf,oe.bi_buf>>=8,oe.bi_valid-=8)})(ee)}},{"../utils/common":41}],53:[function(n,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,i,r){(function(a){(function(s,o){if(!s.setImmediate){var l,c,d,f,p=1,m={},_=!1,b=s.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(s);v=v&&v.setTimeout?v:s,l={}.toString.call(s.process)==="[object process]"?function(E){process.nextTick(function(){M(E)})}:(function(){if(s.postMessage&&!s.importScripts){var E=!0,T=s.onmessage;return s.onmessage=function(){E=!1},s.postMessage("","*"),s.onmessage=T,E}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(E){s.postMessage(f+E,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(E){M(E.data)},function(E){d.port2.postMessage(E)}):b&&"onreadystatechange"in b.createElement("script")?(c=b.documentElement,function(E){var T=b.createElement("script");T.onreadystatechange=function(){M(E),T.onreadystatechange=null,c.removeChild(T),T=null},c.appendChild(T)}):function(E){setTimeout(M,0,E)},v.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var T=new Array(arguments.length-1),P=0;P<T.length;P++)T[P]=arguments[P+1];var N={callback:E,args:T};return m[p]=N,l(p),p++},v.clearImmediate=x}function x(E){delete m[E]}function M(E){if(_)setTimeout(M,0,E);else{var T=m[E];if(T){_=!0;try{(function(P){var N=P.callback,U=P.args;switch(U.length){case 0:N();break;case 1:N(U[0]);break;case 2:N(U[0],U[1]);break;case 3:N(U[0],U[1],U[2]);break;default:N.apply(o,U)}})(T)}finally{x(E),_=!1}}}}function w(E){E.source===s&&typeof E.data=="string"&&E.data.indexOf(f)===0&&M(+E.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof ly<"u"?ly:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(LA)),LA.exports}var che=lhe();const uhe=qs(che);function dhe(t){const e=new Gi;if(!t)return e;const n=t.trim().split(/\s+/).map(parseFloat);return n.length>=12&&e.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),e}const eF=dhe;async function tF(t){const e=[],n=t.getElementsByTagName("mesh");for(let i=0;i<n.length;i++){const r=n[i],a=[],s=[],o=r.getElementsByTagName("vertex");for(let c=0;c<o.length;c++){const d=o[c];a.push(parseFloat(d.getAttribute("x")||"0"),parseFloat(d.getAttribute("y")||"0"),parseFloat(d.getAttribute("z")||"0"))}const l=r.getElementsByTagName("triangle");for(let c=0;c<l.length;c++){const d=l[c];s.push(parseInt(d.getAttribute("v1")||"0"),parseInt(d.getAttribute("v2")||"0"),parseInt(d.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function fhe(t){const e=await uhe.loadAsync(t),n=new Map,i=[],r=new DOMParser;async function a(d){const f=d.startsWith("/")?d.slice(1):d,p=e.files[f];if(!p)return null;const m=await p.async("string");return r.parseFromString(m,"application/xml")}const s=Object.keys(e.files).find(d=>d==="3D/3dmodel.model"||d.endsWith("/3dmodel.model"));if(!s){const d=Object.keys(e.files).find(f=>f.endsWith(".model"));if(d){const f=await a(d);if(f){const p=await tF(f);p.length>0&&n.set("1",{id:"1",meshes:p})}}return{objects:n,buildItems:i}}const o=await a(s);if(!o)return{objects:n,buildItems:i};const l=o.getElementsByTagName("object");for(let d=0;d<l.length;d++){const f=l[d],p=f.getAttribute("id");if(!p)continue;const m=[],_=f.getElementsByTagName("mesh");for(let v=0;v<_.length;v++){const x=_[v],M=[],w=[],E=x.getElementsByTagName("vertex");for(let P=0;P<E.length;P++){const N=E[P];M.push(parseFloat(N.getAttribute("x")||"0"),parseFloat(N.getAttribute("y")||"0"),parseFloat(N.getAttribute("z")||"0"))}const T=x.getElementsByTagName("triangle");for(let P=0;P<T.length;P++){const N=T[P];w.push(parseInt(N.getAttribute("v1")||"0"),parseInt(N.getAttribute("v2")||"0"),parseInt(N.getAttribute("v3")||"0"))}M.length>0&&w.length>0&&m.push({vertices:M,triangles:w})}const b=f.getElementsByTagName("component");for(let v=0;v<b.length;v++){const x=b[v],M=x.getAttribute("p:path")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path");if(M){const w=await a(M);if(w){const E=await tF(w),T=x.getAttribute("transform"),P=eF(T);for(const N of E)if(T){const U=[];for(let R=0;R<N.vertices.length;R+=3){const O=new $e(N.vertices[R],N.vertices[R+1],N.vertices[R+2]);O.applyMatrix4(P),U.push(O.x,O.y,O.z)}m.push({vertices:U,triangles:N.triangles})}else m.push(N)}}}m.length>0&&n.set(p,{id:p,meshes:m})}const c=o.getElementsByTagName("build");if(c.length>0){const d=c[0].getElementsByTagName("item");for(let f=0;f<d.length;f++){const p=d[f],m=p.getAttribute("objectid");if(!m)continue;const _=eF(p.getAttribute("transform"));i.push({objectId:m,transform:_})}}return{objects:n,buildItems:i}}function nF(t){const e=new tl,n=new Float32Array(t.vertices.length);for(let i=0;i<t.vertices.length;i+=3)n[i]=t.vertices[i],n[i+1]=t.vertices[i+2],n[i+2]=t.vertices[i+1];return e.setAttribute("position",new zs(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function hhe({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const i=A.useRef(null),r=A.useRef(null),a=A.useRef(null),s=A.useRef(null),o=A.useRef(null),[l,c]=A.useState(!0),[d,f]=A.useState(null);A.useEffect(()=>{if(!i.current)return;const _=i.current,b=_.clientWidth,v=_.clientHeight,x=new $oe;x.background=new xn(1710618),a.current=x;const M=new Os(45,b/v,.1,1e4);M.position.set(150,150,150),s.current=M;const w=new Wfe({antialias:!0});w.setSize(b,v),w.setPixelRatio(window.devicePixelRatio),_.appendChild(w.domElement),r.current=w;const E=new Xfe(M,w.domElement);E.enableDamping=!0,E.dampingFactor=.05,o.current=E;const T=new nle(16777215,.6);x.add(T);const P=new Mj(16777215,.8);P.position.set(100,100,100),x.add(P);const N=new Mj(16777215,.4);N.position.set(-100,50,-100),x.add(N);const U=Math.max(e.x,e.y),R=Math.ceil(U/16),O=new rle(U,R,4473924,3355443);x.add(O);const z=new vP(e.x,e.y),I=new mP({color:44610,transparent:!0,opacity:.15,side:Io}),G=new Wo(z,I);G.rotation.x=-Math.PI/2,G.position.y=-.5,x.add(G);let L;const B=()=>{L=requestAnimationFrame(B),E.update(),w.render(x,M)};B(),fetch(t).then(W=>{if(!W.ok)throw new Error("Failed to load file");return W.arrayBuffer()}).then(fhe).then(({objects:W,buildItems:X})=>{if(W.size===0)throw new Error("No meshes found in 3MF file");const Q=new Zoe({color:44610,shininess:30,flatShading:!1}),ie=new Bg,H=[];if(X.length>0)for(const pe of X){const we=W.get(pe.objectId);if(we)for(const ze of we.meshes){const ce=[];for(let F=0;F<ze.vertices.length;F+=3){const $=new $e(ze.vertices[F],ze.vertices[F+1],ze.vertices[F+2]);$.applyMatrix4(pe.transform),ce.push($.x,$.y,$.z)}const ft=nF({vertices:ce,triangles:ze.triangles});H.push(ft)}}else for(const pe of W.values())for(const we of pe.meshes){const ze=nF(we);H.push(ze)}if(H.length>0){const pe=H.length===1?H[0]:ohe(H,!1);if(pe){const we=new Wo(pe,Q);ie.add(we)}if(H.length>1)for(const we of H)we.dispose()}const Y=new _f().setFromObject(ie),se=Y.getCenter(new $e);ie.position.y=-Y.min.y,X.length===0&&(ie.position.x=-se.x,ie.position.z=-se.z),x.add(ie);const ue=new _f().setFromObject(ie),xe=ue.getCenter(new $e),re=ue.getSize(new $e),Pe=Math.max(re.x,re.y,re.z)*1.8;M.position.set(xe.x+Pe*.7,xe.y+Pe*.5,xe.z+Pe*.7),E.target.copy(xe),E.update(),c(!1)}).catch(W=>{f(W.message),c(!1)});const q=()=>{if(!_)return;const W=_.clientWidth,X=_.clientHeight;M.aspect=W/X,M.updateProjectionMatrix(),w.setSize(W,X)};return window.addEventListener("resize",q),()=>{window.removeEventListener("resize",q),cancelAnimationFrame(L),E.dispose(),w.dispose(),_.removeChild(w.domElement)}},[t,e]);const p=()=>{s.current&&o.current&&(s.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},m=_=>{s.current&&s.current.position.multiplyScalar(_)};return g.jsxs("div",{className:`relative ${n}`,children:[g.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),l&&g.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),d&&g.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:g.jsx("p",{className:"text-red-400",children:d})}),!l&&!d&&g.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[g.jsx(ot,{variant:"secondary",size:"sm",onClick:()=>m(.8),children:g.jsx(Qae,{className:"w-4 h-4"})}),g.jsx(ot,{variant:"secondary",size:"sm",onClick:()=>m(1.25),children:g.jsx(tse,{className:"w-4 h-4"})}),g.jsx(ot,{variant:"secondary",size:"sm",onClick:p,children:g.jsx(wS,{className:"w-4 h-4"})})]})]})}const RS="159",Oh={ROTATE:0,DOLLY:1,PAN:2},kh={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},phe=0,iF=1,mhe=2,LG=1,ghe=2,Il=3,$u=0,ka=1,Bl=2,Pu=0,bp=1,rF=2,aF=3,sF=4,xhe=5,Hd=100,vhe=101,yhe=102,oF=103,lF=104,bhe=200,_he=201,She=202,whe=203,HN=204,VN=205,Mhe=206,Ehe=207,Ahe=208,The=209,Che=210,Nhe=211,Rhe=212,Phe=213,Dhe=214,Ohe=0,khe=1,Lhe=2,w_=3,Ihe=4,Uhe=5,jhe=6,Fhe=7,bP=0,zhe=1,Bhe=2,Du=0,Hhe=1,Vhe=2,$he=3,Ghe=4,Whe=5,IG=300,Lp=301,Ip=302,$N=303,GN=304,PS=306,WN=1e3,oo=1001,qN=1002,Fr=1003,cF=1004,IA=1005,ks=1006,qhe=1007,P0=1008,Ou=1009,Xhe=1010,Khe=1011,_P=1012,UG=1013,Mu=1014,ql=1015,D0=1016,jG=1017,FG=1018,tf=1020,Yhe=1021,Ls=1023,Zhe=1024,Qhe=1025,nf=1026,Up=1027,Jhe=1028,zG=1029,epe=1030,BG=1031,HG=1033,UA=33776,jA=33777,FA=33778,zA=33779,uF=35840,dF=35841,fF=35842,hF=35843,VG=36196,pF=37492,mF=37496,gF=37808,xF=37809,vF=37810,yF=37811,bF=37812,_F=37813,SF=37814,wF=37815,MF=37816,EF=37817,AF=37818,TF=37819,CF=37820,NF=37821,BA=36492,RF=36494,PF=36495,tpe=36283,DF=36284,OF=36285,kF=36286,$G=3e3,rf=3001,npe=3200,ipe=3201,GG=0,rpe=1,Is="",zr="srgb",uc="srgb-linear",SP="display-p3",DS="display-p3-linear",M_="linear",ti="srgb",E_="rec709",A_="p3",Lh=7680,LF=519,ape=512,spe=513,ope=514,WG=515,lpe=516,cpe=517,upe=518,dpe=519,XN=35044,IF="300 es",KN=1035,Fo=2e3,O0=2001;class jf{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(n)===-1&&i[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const a=r.indexOf(n);a!==-1&&r.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const i=this._listeners[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let a=0,s=r.length;a<s;a++)r[a].call(this,e);e.target=null}}}const Xr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let UF=1234567;const Zg=Math.PI/180,k0=180/Math.PI;function ec(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Xr[t&255]+Xr[t>>8&255]+Xr[t>>16&255]+Xr[t>>24&255]+"-"+Xr[e&255]+Xr[e>>8&255]+"-"+Xr[e>>16&15|64]+Xr[e>>24&255]+"-"+Xr[n&63|128]+Xr[n>>8&255]+"-"+Xr[n>>16&255]+Xr[n>>24&255]+Xr[i&255]+Xr[i>>8&255]+Xr[i>>16&255]+Xr[i>>24&255]).toLowerCase()}function Br(t,e,n){return Math.max(e,Math.min(n,t))}function wP(t,e){return(t%e+e)%e}function fpe(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)}function hpe(t,e,n){return t!==e?(n-t)/(e-t):0}function Qg(t,e,n){return(1-n)*t+n*e}function ppe(t,e,n,i){return Qg(t,e,1-Math.exp(-n*i))}function mpe(t,e=1){return e-Math.abs(wP(t,e*2)-e)}function gpe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function xpe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function vpe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function ype(t,e){return t+Math.random()*(e-t)}function bpe(t){return t*(.5-Math.random())}function _pe(t){t!==void 0&&(UF=t);let e=UF+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function Spe(t){return t*Zg}function wpe(t){return t*k0}function YN(t){return(t&t-1)===0&&t!==0}function Mpe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function T_(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Epe(t,e,n,i,r){const a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),c=a((e+i)/2),d=s((e+i)/2),f=a((e-i)/2),p=s((e-i)/2),m=a((i-e)/2),_=s((i-e)/2);switch(r){case"XYX":t.set(o*d,l*f,l*p,o*c);break;case"YZY":t.set(l*p,o*d,l*f,o*c);break;case"ZXZ":t.set(l*f,l*p,o*d,o*c);break;case"XZX":t.set(o*d,l*_,l*m,o*c);break;case"YXY":t.set(l*m,o*d,l*_,o*c);break;case"ZYZ":t.set(l*_,l*m,o*d,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Uo(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function zn(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const qG={DEG2RAD:Zg,RAD2DEG:k0,generateUUID:ec,clamp:Br,euclideanModulo:wP,mapLinear:fpe,inverseLerp:hpe,lerp:Qg,damp:ppe,pingpong:mpe,smoothstep:gpe,smootherstep:xpe,randInt:vpe,randFloat:ype,randFloatSpread:bpe,seededRandom:_pe,degToRad:Spe,radToDeg:wpe,isPowerOfTwo:YN,ceilPowerOfTwo:Mpe,floorPowerOfTwo:T_,setQuaternionFromProperEuler:Epe,normalize:zn,denormalize:Uo};class Gt{constructor(e=0,n=0){Gt.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,i=this.y,r=e.elements;return this.x=r[0]*n+r[3]*i+r[6],this.y=r[1]*n+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(e)/n;return Math.acos(Br(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y;return n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const i=Math.cos(n),r=Math.sin(n),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ln{constructor(e,n,i,r,a,s,o,l,c){ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,i,r,a,s,o,l,c)}set(e,n,i,r,a,s,o,l,c){const d=this.elements;return d[0]=e,d[1]=r,d[2]=o,d[3]=n,d[4]=a,d[5]=l,d[6]=i,d[7]=s,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],this}extractBasis(e,n,i){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[3],l=i[6],c=i[1],d=i[4],f=i[7],p=i[2],m=i[5],_=i[8],b=r[0],v=r[3],x=r[6],M=r[1],w=r[4],E=r[7],T=r[2],P=r[5],N=r[8];return a[0]=s*b+o*M+l*T,a[3]=s*v+o*w+l*P,a[6]=s*x+o*E+l*N,a[1]=c*b+d*M+f*T,a[4]=c*v+d*w+f*P,a[7]=c*x+d*E+f*N,a[2]=p*b+m*M+_*T,a[5]=p*v+m*w+_*P,a[8]=p*x+m*E+_*N,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],d=e[8];return n*s*d-n*o*c-i*a*d+i*o*l+r*a*c-r*s*l}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],d=e[8],f=d*s-o*c,p=o*l-d*a,m=c*a-s*l,_=n*f+i*p+r*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/_;return e[0]=f*b,e[1]=(r*c-d*i)*b,e[2]=(o*i-r*s)*b,e[3]=p*b,e[4]=(d*n-r*l)*b,e[5]=(r*a-o*n)*b,e[6]=m*b,e[7]=(i*l-c*n)*b,e[8]=(s*n-i*a)*b,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,i,r,a,s,o){const l=Math.cos(a),c=Math.sin(a);return this.set(i*l,i*c,-i*(l*s+c*o)+s+e,-r*c,r*l,-r*(-c*s+l*o)+o+n,0,0,1),this}scale(e,n){return this.premultiply(HA.makeScale(e,n)),this}rotate(e){return this.premultiply(HA.makeRotation(-e)),this}translate(e,n){return this.premultiply(HA.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,i,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,i=e.elements;for(let r=0;r<9;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<9;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const HA=new ln;function XG(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function C_(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Ape(){const t=C_("canvas");return t.style.display="block",t}const jF={};function Jg(t){t in jF||(jF[t]=!0,console.warn(t))}const FF=new ln().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),zF=new ln().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ly={[uc]:{transfer:M_,primaries:E_,toReference:t=>t,fromReference:t=>t},[zr]:{transfer:ti,primaries:E_,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[DS]:{transfer:M_,primaries:A_,toReference:t=>t.applyMatrix3(zF),fromReference:t=>t.applyMatrix3(FF)},[SP]:{transfer:ti,primaries:A_,toReference:t=>t.convertSRGBToLinear().applyMatrix3(zF),fromReference:t=>t.applyMatrix3(FF).convertLinearToSRGB()}},Tpe=new Set([uc,DS]),Bn={enabled:!0,_workingColorSpace:uc,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(t){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!t},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!Tpe.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(this.enabled===!1||e===n||!e||!n)return t;const i=Ly[e].toReference,r=Ly[n].fromReference;return r(i(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return Ly[t].primaries},getTransfer:function(t){return t===Is?M_:Ly[t].transfer}};function _p(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function VA(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Ih;class KG{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Ih===void 0&&(Ih=C_("canvas")),Ih.width=e.width,Ih.height=e.height;const i=Ih.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Ih}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=C_("canvas");n.width=e.width,n.height=e.height;const i=n.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=_p(a[s]/255)*255;return i.putImageData(r,0,0),n}else if(e.data){const n=e.data.slice(0);for(let i=0;i<n.length;i++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[i]=Math.floor(_p(n[i]/255)*255):n[i]=_p(n[i]);return{data:n,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Cpe=0;class YG{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Cpe++}),this.uuid=ec(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,o=r.length;s<o;s++)r[s].isDataTexture?a.push($A(r[s].image)):a.push($A(r[s]))}else a=$A(r);i.url=a}return n||(e.images[this.uuid]=i),i}}function $A(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?KG.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Npe=0;class La extends jf{constructor(e=La.DEFAULT_IMAGE,n=La.DEFAULT_MAPPING,i=oo,r=oo,a=ks,s=P0,o=Ls,l=Ou,c=La.DEFAULT_ANISOTROPY,d=Is){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Npe++}),this.uuid=ec(),this.name="",this.source=new YG(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Gt(0,0),this.repeat=new Gt(1,1),this.center=new Gt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ln,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Jg("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===rf?zr:Is),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),n||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==IG)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case WN:e.x=e.x-Math.floor(e.x);break;case oo:e.x=e.x<0?0:1;break;case qN:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case WN:e.y=e.y-Math.floor(e.y);break;case oo:e.y=e.y<0?0:1;break;case qN:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Jg("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===zr?rf:$G}set encoding(e){Jg("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===rf?zr:Is}}La.DEFAULT_IMAGE=null;La.DEFAULT_MAPPING=IG;La.DEFAULT_ANISOTROPY=1;class Vn{constructor(e=0,n=0,i=0,r=1){Vn.prototype.isVector4=!0,this.x=e,this.y=n,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,i,r){return this.x=e,this.y=n,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*n+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*n+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*n+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*n+s[7]*i+s[11]*r+s[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,i,r,a;const l=e.elements,c=l[0],d=l[4],f=l[8],p=l[1],m=l[5],_=l[9],b=l[2],v=l[6],x=l[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(_-v)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(_+v)<.1&&Math.abs(c+m+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,E=(m+1)/2,T=(x+1)/2,P=(d+p)/4,N=(f+b)/4,U=(_+v)/4;return w>E&&w>T?w<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(w),r=P/i,a=N/i):E>T?E<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(E),i=P/r,a=U/r):T<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(T),i=N/a,r=U/a),this.set(i,r,a,n),this}let M=Math.sqrt((v-_)*(v-_)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(M)<.001&&(M=1),this.x=(v-_)/M,this.y=(f-b)/M,this.z=(p-d)/M,this.w=Math.acos((c+m+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this.w=e.w+(n.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Rpe extends jf{constructor(e=1,n=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Vn(0,0,e,n),this.scissorTest=!1,this.viewport=new Vn(0,0,e,n);const r={width:e,height:n,depth:1};i.encoding!==void 0&&(Jg("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===rf?zr:Is),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ks,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new La(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(e,n,i=1){(this.width!==e||this.height!==n||this.depth!==i)&&(this.width=e,this.height=n,this.depth=i,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new YG(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Sf extends Rpe{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}}class ZG extends La{constructor(e=null,n=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=Fr,this.minFilter=Fr,this.wrapR=oo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ppe extends La{constructor(e=null,n=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:i,depth:r},this.magFilter=Fr,this.minFilter=Fr,this.wrapR=oo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class wf{constructor(e=0,n=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=i,this._w=r}static slerpFlat(e,n,i,r,a,s,o){let l=i[r+0],c=i[r+1],d=i[r+2],f=i[r+3];const p=a[s+0],m=a[s+1],_=a[s+2],b=a[s+3];if(o===0){e[n+0]=l,e[n+1]=c,e[n+2]=d,e[n+3]=f;return}if(o===1){e[n+0]=p,e[n+1]=m,e[n+2]=_,e[n+3]=b;return}if(f!==b||l!==p||c!==m||d!==_){let v=1-o;const x=l*p+c*m+d*_+f*b,M=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){const T=Math.sqrt(w),P=Math.atan2(T,x*M);v=Math.sin(v*P)/T,o=Math.sin(o*P)/T}const E=o*M;if(l=l*v+p*E,c=c*v+m*E,d=d*v+_*E,f=f*v+b*E,v===1-o){const T=1/Math.sqrt(l*l+c*c+d*d+f*f);l*=T,c*=T,d*=T,f*=T}}e[n]=l,e[n+1]=c,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,i,r,a,s){const o=i[r],l=i[r+1],c=i[r+2],d=i[r+3],f=a[s],p=a[s+1],m=a[s+2],_=a[s+3];return e[n]=o*_+d*f+l*m-c*p,e[n+1]=l*_+d*p+c*f-o*m,e[n+2]=c*_+d*m+o*p-l*f,e[n+3]=d*_-o*f-l*p-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,i,r){return this._x=e,this._y=n,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const i=e._x,r=e._y,a=e._z,s=e._order,o=Math.cos,l=Math.sin,c=o(i/2),d=o(r/2),f=o(a/2),p=l(i/2),m=l(r/2),_=l(a/2);switch(s){case"XYZ":this._x=p*d*f+c*m*_,this._y=c*m*f-p*d*_,this._z=c*d*_+p*m*f,this._w=c*d*f-p*m*_;break;case"YXZ":this._x=p*d*f+c*m*_,this._y=c*m*f-p*d*_,this._z=c*d*_-p*m*f,this._w=c*d*f+p*m*_;break;case"ZXY":this._x=p*d*f-c*m*_,this._y=c*m*f+p*d*_,this._z=c*d*_+p*m*f,this._w=c*d*f-p*m*_;break;case"ZYX":this._x=p*d*f-c*m*_,this._y=c*m*f+p*d*_,this._z=c*d*_-p*m*f,this._w=c*d*f+p*m*_;break;case"YZX":this._x=p*d*f+c*m*_,this._y=c*m*f+p*d*_,this._z=c*d*_-p*m*f,this._w=c*d*f-p*m*_;break;case"XZY":this._x=p*d*f-c*m*_,this._y=c*m*f-p*d*_,this._z=c*d*_+p*m*f,this._w=c*d*f+p*m*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const i=n/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,i=n[0],r=n[4],a=n[8],s=n[1],o=n[5],l=n[9],c=n[2],d=n[6],f=n[10],p=i+o+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-l)*m,this._y=(a-c)*m,this._z=(s-r)*m}else if(i>o&&i>f){const m=2*Math.sqrt(1+i-o-f);this._w=(d-l)/m,this._x=.25*m,this._y=(r+s)/m,this._z=(a+c)/m}else if(o>f){const m=2*Math.sqrt(1+o-i-f);this._w=(a-c)/m,this._x=(r+s)/m,this._y=.25*m,this._z=(l+d)/m}else{const m=2*Math.sqrt(1+f-i-o);this._w=(s-r)/m,this._x=(a+c)/m,this._y=(l+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let i=e.dot(n)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Br(this.dot(e),-1,1)))}rotateTowards(e,n){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,n/i);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const i=e._x,r=e._y,a=e._z,s=e._w,o=n._x,l=n._y,c=n._z,d=n._w;return this._x=i*d+s*o+r*c-a*l,this._y=r*d+s*l+a*o-i*c,this._z=a*d+s*c+i*l-r*o,this._w=s*d-i*o-r*l-a*c,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const i=this._x,r=this._y,a=this._z,s=this._w;let o=s*e._w+i*e._x+r*e._y+a*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=s,this._x=i,this._y=r,this._z=a,this;const l=1-o*o;if(l<=Number.EPSILON){const m=1-n;return this._w=m*s+n*this._w,this._x=m*i+n*this._x,this._y=m*r+n*this._y,this._z=m*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),d=Math.atan2(c,o),f=Math.sin((1-n)*d)/c,p=Math.sin(n*d)/c;return this._w=s*f+this._w*p,this._x=i*f+this._x*p,this._y=r*f+this._y*p,this._z=a*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,n,i){return this.copy(e).slerp(n,i)}random(){const e=Math.random(),n=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(r),i*Math.sin(a),i*Math.cos(a),n*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ae{constructor(e=0,n=0,i=0){Ae.prototype.isVector3=!0,this.x=e,this.y=n,this.z=i}set(e,n,i){return i===void 0&&(i=this.z),this.x=e,this.y=n,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(BF.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(BF.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[3]*i+a[6]*r,this.y=a[1]*n+a[4]*i+a[7]*r,this.z=a[2]*n+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*n+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*n+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*n+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*n+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){const n=this.x,i=this.y,r=this.z,a=e.x,s=e.y,o=e.z,l=e.w,c=2*(s*r-o*i),d=2*(o*n-a*r),f=2*(a*i-s*n);return this.x=n+l*c+s*f-o*d,this.y=i+l*d+o*c-a*f,this.z=r+l*f+a*d-s*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*n+a[4]*i+a[8]*r,this.y=a[1]*n+a[5]*i+a[9]*r,this.z=a[2]*n+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(n,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,i){return this.x=e.x+(n.x-e.x)*i,this.y=e.y+(n.y-e.y)*i,this.z=e.z+(n.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const i=e.x,r=e.y,a=e.z,s=n.x,o=n.y,l=n.z;return this.x=r*l-a*o,this.y=a*s-i*l,this.z=i*o-r*s,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const i=e.dot(this)/n;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return GA.copy(this).projectOnVector(e),this.sub(GA)}reflect(e){return this.sub(GA.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const i=this.dot(e)/n;return Math.acos(Br(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return n*n+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,i){const r=Math.sin(n)*e;return this.x=r*Math.sin(i),this.y=Math.cos(n)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,i){return this.x=e*Math.sin(n),this.y=i,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=i,this.z=r,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(n),this.y=i*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const GA=new Ae,BF=new wf;class Bs{constructor(e=new Ae(1/0,1/0,1/0),n=new Ae(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,i=e.length;n<i;n+=3)this.expandByPoint(io.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,i=e.count;n<i;n++)this.expandByPoint(io.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,i=e.length;n<i;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const i=io.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const i=e.geometry;if(i!==void 0){const a=i.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,o=a.count;s<o;s++)e.isMesh===!0?e.getVertexPosition(s,io):io.fromBufferAttribute(a,s),io.applyMatrix4(e.matrixWorld),this.expandByPoint(io);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Iy.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Iy.copy(i.boundingBox)),Iy.applyMatrix4(e.matrixWorld),this.union(Iy)}const r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,io),io.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,i;return e.normal.x>0?(n=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),n<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Mg),Uy.subVectors(this.max,Mg),Uh.subVectors(e.a,Mg),jh.subVectors(e.b,Mg),Fh.subVectors(e.c,Mg),nu.subVectors(jh,Uh),iu.subVectors(Fh,jh),Rd.subVectors(Uh,Fh);let n=[0,-nu.z,nu.y,0,-iu.z,iu.y,0,-Rd.z,Rd.y,nu.z,0,-nu.x,iu.z,0,-iu.x,Rd.z,0,-Rd.x,-nu.y,nu.x,0,-iu.y,iu.x,0,-Rd.y,Rd.x,0];return!WA(n,Uh,jh,Fh,Uy)||(n=[1,0,0,0,1,0,0,0,1],!WA(n,Uh,jh,Fh,Uy))?!1:(jy.crossVectors(nu,iu),n=[jy.x,jy.y,jy.z],WA(n,Uh,jh,Fh,Uy))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,io).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(io).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Al[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Al[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Al[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Al[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Al[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Al[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Al[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Al[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Al),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Al=[new Ae,new Ae,new Ae,new Ae,new Ae,new Ae,new Ae,new Ae],io=new Ae,Iy=new Bs,Uh=new Ae,jh=new Ae,Fh=new Ae,nu=new Ae,iu=new Ae,Rd=new Ae,Mg=new Ae,Uy=new Ae,jy=new Ae,Pd=new Ae;function WA(t,e,n,i,r){for(let a=0,s=t.length-3;a<=s;a+=3){Pd.fromArray(t,a);const o=r.x*Math.abs(Pd.x)+r.y*Math.abs(Pd.y)+r.z*Math.abs(Pd.z),l=e.dot(Pd),c=n.dot(Pd),d=i.dot(Pd);if(Math.max(-Math.max(l,c,d),Math.min(l,c,d))>o)return!1}return!0}const Dpe=new Bs,Eg=new Ae,qA=new Ae;class Bo{constructor(e=new Ae,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const i=this.center;n!==void 0?i.copy(n):Dpe.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const i=this.center.distanceToSquared(e);return n.copy(e),i>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Eg.subVectors(e,this.center);const n=Eg.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),r=(i-this.radius)*.5;this.center.addScaledVector(Eg,r/i),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(qA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Eg.copy(e.center).add(qA)),this.expandByPoint(Eg.copy(e.center).sub(qA))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Tl=new Ae,XA=new Ae,Fy=new Ae,ru=new Ae,KA=new Ae,zy=new Ae,YA=new Ae;class MP{constructor(e=new Ae,n=new Ae(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Tl)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=Tl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Tl.copy(this.origin).addScaledVector(this.direction,n),Tl.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){XA.copy(e).add(n).multiplyScalar(.5),Fy.copy(n).sub(e).normalize(),ru.copy(this.origin).sub(XA);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Fy),o=ru.dot(this.direction),l=-ru.dot(Fy),c=ru.lengthSq(),d=Math.abs(1-s*s);let f,p,m,_;if(d>0)if(f=s*l-o,p=s*o-l,_=a*d,f>=0)if(p>=-_)if(p<=_){const b=1/d;f*=b,p*=b,m=f*(f+s*p+2*o)+p*(s*f+p+2*l)+c}else p=a,f=Math.max(0,-(s*p+o)),m=-f*f+p*(p+2*l)+c;else p=-a,f=Math.max(0,-(s*p+o)),m=-f*f+p*(p+2*l)+c;else p<=-_?(f=Math.max(0,-(-s*a+o)),p=f>0?-a:Math.min(Math.max(-a,-l),a),m=-f*f+p*(p+2*l)+c):p<=_?(f=0,p=Math.min(Math.max(-a,-l),a),m=p*(p+2*l)+c):(f=Math.max(0,-(s*a+o)),p=f>0?a:Math.min(Math.max(-a,-l),a),m=-f*f+p*(p+2*l)+c);else p=s>0?-a:a,f=Math.max(0,-(s*p+o)),m=-f*f+p*(p+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(XA).addScaledVector(Fy,p),m}intersectSphere(e,n){Tl.subVectors(e.center,this.origin);const i=Tl.dot(this.direction),r=Tl.dot(Tl)-i*i,a=e.radius*e.radius;if(r>a)return null;const s=Math.sqrt(a-r),o=i-s,l=i+s;return l<0?null:o<0?this.at(l,n):this.at(o,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/n;return i>=0?i:null}intersectPlane(e,n){const i=this.distanceToPlane(e);return i===null?null:this.at(i,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let i,r,a,s,o,l;const c=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return c>=0?(i=(e.min.x-p.x)*c,r=(e.max.x-p.x)*c):(i=(e.max.x-p.x)*c,r=(e.min.x-p.x)*c),d>=0?(a=(e.min.y-p.y)*d,s=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,s=(e.min.y-p.y)*d),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-p.z)*f,l=(e.max.z-p.z)*f):(o=(e.max.z-p.z)*f,l=(e.min.z-p.z)*f),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,n)}intersectsBox(e){return this.intersectBox(e,Tl)!==null}intersectTriangle(e,n,i,r,a){KA.subVectors(n,e),zy.subVectors(i,e),YA.crossVectors(KA,zy);let s=this.direction.dot(YA),o;if(s>0){if(r)return null;o=1}else if(s<0)o=-1,s=-s;else return null;ru.subVectors(this.origin,e);const l=o*this.direction.dot(zy.crossVectors(ru,zy));if(l<0)return null;const c=o*this.direction.dot(KA.cross(ru));if(c<0||l+c>s)return null;const d=-o*ru.dot(YA);return d<0?null:this.at(d/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Zn{constructor(e,n,i,r,a,s,o,l,c,d,f,p,m,_,b,v){Zn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,i,r,a,s,o,l,c,d,f,p,m,_,b,v)}set(e,n,i,r,a,s,o,l,c,d,f,p,m,_,b,v){const x=this.elements;return x[0]=e,x[4]=n,x[8]=i,x[12]=r,x[1]=a,x[5]=s,x[9]=o,x[13]=l,x[2]=c,x[6]=d,x[10]=f,x[14]=p,x[3]=m,x[7]=_,x[11]=b,x[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Zn().fromArray(this.elements)}copy(e){const n=this.elements,i=e.elements;return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=i[3],n[4]=i[4],n[5]=i[5],n[6]=i[6],n[7]=i[7],n[8]=i[8],n[9]=i[9],n[10]=i[10],n[11]=i[11],n[12]=i[12],n[13]=i[13],n[14]=i[14],n[15]=i[15],this}copyPosition(e){const n=this.elements,i=e.elements;return n[12]=i[12],n[13]=i[13],n[14]=i[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,i){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,n,i){return this.set(e.x,n.x,i.x,0,e.y,n.y,i.y,0,e.z,n.z,i.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,i=e.elements,r=1/zh.setFromMatrixColumn(e,0).length(),a=1/zh.setFromMatrixColumn(e,1).length(),s=1/zh.setFromMatrixColumn(e,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*a,n[5]=i[5]*a,n[6]=i[6]*a,n[7]=0,n[8]=i[8]*s,n[9]=i[9]*s,n[10]=i[10]*s,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=s*d,m=s*f,_=o*d,b=o*f;n[0]=l*d,n[4]=-l*f,n[8]=c,n[1]=m+_*c,n[5]=p-b*c,n[9]=-o*l,n[2]=b-p*c,n[6]=_+m*c,n[10]=s*l}else if(e.order==="YXZ"){const p=l*d,m=l*f,_=c*d,b=c*f;n[0]=p+b*o,n[4]=_*o-m,n[8]=s*c,n[1]=s*f,n[5]=s*d,n[9]=-o,n[2]=m*o-_,n[6]=b+p*o,n[10]=s*l}else if(e.order==="ZXY"){const p=l*d,m=l*f,_=c*d,b=c*f;n[0]=p-b*o,n[4]=-s*f,n[8]=_+m*o,n[1]=m+_*o,n[5]=s*d,n[9]=b-p*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const p=s*d,m=s*f,_=o*d,b=o*f;n[0]=l*d,n[4]=_*c-m,n[8]=p*c+b,n[1]=l*f,n[5]=b*c+p,n[9]=m*c-_,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const p=s*l,m=s*c,_=o*l,b=o*c;n[0]=l*d,n[4]=b-p*f,n[8]=_*f+m,n[1]=f,n[5]=s*d,n[9]=-o*d,n[2]=-c*d,n[6]=m*f+_,n[10]=p-b*f}else if(e.order==="XZY"){const p=s*l,m=s*c,_=o*l,b=o*c;n[0]=l*d,n[4]=-f,n[8]=c*d,n[1]=p*f+b,n[5]=s*d,n[9]=m*f-_,n[2]=_*f-m,n[6]=o*d,n[10]=b*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ope,e,kpe)}lookAt(e,n,i){const r=this.elements;return Za.subVectors(e,n),Za.lengthSq()===0&&(Za.z=1),Za.normalize(),au.crossVectors(i,Za),au.lengthSq()===0&&(Math.abs(i.z)===1?Za.x+=1e-4:Za.z+=1e-4,Za.normalize(),au.crossVectors(i,Za)),au.normalize(),By.crossVectors(Za,au),r[0]=au.x,r[4]=By.x,r[8]=Za.x,r[1]=au.y,r[5]=By.y,r[9]=Za.y,r[2]=au.z,r[6]=By.z,r[10]=Za.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const i=e.elements,r=n.elements,a=this.elements,s=i[0],o=i[4],l=i[8],c=i[12],d=i[1],f=i[5],p=i[9],m=i[13],_=i[2],b=i[6],v=i[10],x=i[14],M=i[3],w=i[7],E=i[11],T=i[15],P=r[0],N=r[4],U=r[8],R=r[12],O=r[1],z=r[5],I=r[9],G=r[13],L=r[2],B=r[6],q=r[10],W=r[14],X=r[3],Q=r[7],ie=r[11],H=r[15];return a[0]=s*P+o*O+l*L+c*X,a[4]=s*N+o*z+l*B+c*Q,a[8]=s*U+o*I+l*q+c*ie,a[12]=s*R+o*G+l*W+c*H,a[1]=d*P+f*O+p*L+m*X,a[5]=d*N+f*z+p*B+m*Q,a[9]=d*U+f*I+p*q+m*ie,a[13]=d*R+f*G+p*W+m*H,a[2]=_*P+b*O+v*L+x*X,a[6]=_*N+b*z+v*B+x*Q,a[10]=_*U+b*I+v*q+x*ie,a[14]=_*R+b*G+v*W+x*H,a[3]=M*P+w*O+E*L+T*X,a[7]=M*N+w*z+E*B+T*Q,a[11]=M*U+w*I+E*q+T*ie,a[15]=M*R+w*G+E*W+T*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],i=e[4],r=e[8],a=e[12],s=e[1],o=e[5],l=e[9],c=e[13],d=e[2],f=e[6],p=e[10],m=e[14],_=e[3],b=e[7],v=e[11],x=e[15];return _*(+a*l*f-r*c*f-a*o*p+i*c*p+r*o*m-i*l*m)+b*(+n*l*m-n*c*p+a*s*p-r*s*m+r*c*d-a*l*d)+v*(+n*c*f-n*o*m-a*s*f+i*s*m+a*o*d-i*c*d)+x*(-r*o*d-n*l*f+n*o*p+r*s*f-i*s*p+i*l*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=n,r[14]=i),this}invert(){const e=this.elements,n=e[0],i=e[1],r=e[2],a=e[3],s=e[4],o=e[5],l=e[6],c=e[7],d=e[8],f=e[9],p=e[10],m=e[11],_=e[12],b=e[13],v=e[14],x=e[15],M=f*v*c-b*p*c+b*l*m-o*v*m-f*l*x+o*p*x,w=_*p*c-d*v*c-_*l*m+s*v*m+d*l*x-s*p*x,E=d*b*c-_*f*c+_*o*m-s*b*m-d*o*x+s*f*x,T=_*f*l-d*b*l-_*o*p+s*b*p+d*o*v-s*f*v,P=n*M+i*w+r*E+a*T;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/P;return e[0]=M*N,e[1]=(b*p*a-f*v*a-b*r*m+i*v*m+f*r*x-i*p*x)*N,e[2]=(o*v*a-b*l*a+b*r*c-i*v*c-o*r*x+i*l*x)*N,e[3]=(f*l*a-o*p*a-f*r*c+i*p*c+o*r*m-i*l*m)*N,e[4]=w*N,e[5]=(d*v*a-_*p*a+_*r*m-n*v*m-d*r*x+n*p*x)*N,e[6]=(_*l*a-s*v*a-_*r*c+n*v*c+s*r*x-n*l*x)*N,e[7]=(s*p*a-d*l*a+d*r*c-n*p*c-s*r*m+n*l*m)*N,e[8]=E*N,e[9]=(_*f*a-d*b*a-_*i*m+n*b*m+d*i*x-n*f*x)*N,e[10]=(s*b*a-_*o*a+_*i*c-n*b*c-s*i*x+n*o*x)*N,e[11]=(d*o*a-s*f*a-d*i*c+n*f*c+s*i*m-n*o*m)*N,e[12]=T*N,e[13]=(d*b*r-_*f*r+_*i*p-n*b*p-d*i*v+n*f*v)*N,e[14]=(_*o*r-s*b*r-_*i*l+n*b*l+s*i*v-n*o*v)*N,e[15]=(s*f*r-d*o*r+d*i*l-n*f*l-s*i*p+n*o*p)*N,this}scale(e){const n=this.elements,i=e.x,r=e.y,a=e.z;return n[0]*=i,n[4]*=r,n[8]*=a,n[1]*=i,n[5]*=r,n[9]*=a,n[2]*=i,n[6]*=r,n[10]*=a,n[3]*=i,n[7]*=r,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,i,r))}makeTranslation(e,n,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,i,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,n,-i,0,0,i,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,0,i,0,0,1,0,0,-i,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),i=Math.sin(e);return this.set(n,-i,0,0,i,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const i=Math.cos(n),r=Math.sin(n),a=1-i,s=e.x,o=e.y,l=e.z,c=a*s,d=a*o;return this.set(c*s+i,c*o-r*l,c*l+r*o,0,c*o+r*l,d*o+i,d*l-r*s,0,c*l-r*o,d*l+r*s,a*l*l+i,0,0,0,0,1),this}makeScale(e,n,i){return this.set(e,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,n,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,n,r,1,0,0,0,0,1),this}compose(e,n,i){const r=this.elements,a=n._x,s=n._y,o=n._z,l=n._w,c=a+a,d=s+s,f=o+o,p=a*c,m=a*d,_=a*f,b=s*d,v=s*f,x=o*f,M=l*c,w=l*d,E=l*f,T=i.x,P=i.y,N=i.z;return r[0]=(1-(b+x))*T,r[1]=(m+E)*T,r[2]=(_-w)*T,r[3]=0,r[4]=(m-E)*P,r[5]=(1-(p+x))*P,r[6]=(v+M)*P,r[7]=0,r[8]=(_+w)*N,r[9]=(v-M)*N,r[10]=(1-(p+b))*N,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,n,i){const r=this.elements;let a=zh.set(r[0],r[1],r[2]).length();const s=zh.set(r[4],r[5],r[6]).length(),o=zh.set(r[8],r[9],r[10]).length();this.determinant()<0&&(a=-a),e.x=r[12],e.y=r[13],e.z=r[14],ro.copy(this);const c=1/a,d=1/s,f=1/o;return ro.elements[0]*=c,ro.elements[1]*=c,ro.elements[2]*=c,ro.elements[4]*=d,ro.elements[5]*=d,ro.elements[6]*=d,ro.elements[8]*=f,ro.elements[9]*=f,ro.elements[10]*=f,n.setFromRotationMatrix(ro),i.x=a,i.y=s,i.z=o,this}makePerspective(e,n,i,r,a,s,o=Fo){const l=this.elements,c=2*a/(n-e),d=2*a/(i-r),f=(n+e)/(n-e),p=(i+r)/(i-r);let m,_;if(o===Fo)m=-(s+a)/(s-a),_=-2*s*a/(s-a);else if(o===O0)m=-s/(s-a),_=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=d,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,i,r,a,s,o=Fo){const l=this.elements,c=1/(n-e),d=1/(i-r),f=1/(s-a),p=(n+e)*c,m=(i+r)*d;let _,b;if(o===Fo)_=(s+a)*f,b=-2*f;else if(o===O0)_=a*f,b=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*d,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=b,l[14]=-_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const n=this.elements,i=e.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])return!1;return!0}fromArray(e,n=0){for(let i=0;i<16;i++)this.elements[i]=e[i+n];return this}toArray(e=[],n=0){const i=this.elements;return e[n]=i[0],e[n+1]=i[1],e[n+2]=i[2],e[n+3]=i[3],e[n+4]=i[4],e[n+5]=i[5],e[n+6]=i[6],e[n+7]=i[7],e[n+8]=i[8],e[n+9]=i[9],e[n+10]=i[10],e[n+11]=i[11],e[n+12]=i[12],e[n+13]=i[13],e[n+14]=i[14],e[n+15]=i[15],e}}const zh=new Ae,ro=new Zn,Ope=new Ae(0,0,0),kpe=new Ae(1,1,1),au=new Ae,By=new Ae,Za=new Ae,HF=new Zn,VF=new wf;class xx{constructor(e=0,n=0,i=0,r=xx.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,i,r=this._order){return this._x=e,this._y=n,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,i=!0){const r=e.elements,a=r[0],s=r[4],o=r[8],l=r[1],c=r[5],d=r[9],f=r[2],p=r[6],m=r[10];switch(n){case"XYZ":this._y=Math.asin(Br(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Br(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Br(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Br(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(Br(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Br(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,i){return HF.makeRotationFromQuaternion(e),this.setFromRotationMatrix(HF,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return VF.setFromEuler(this),this.setFromQuaternion(VF,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xx.DEFAULT_ORDER="XYZ";class QG{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Lpe=0;const $F=new Ae,Bh=new wf,Cl=new Zn,Hy=new Ae,Ag=new Ae,Ipe=new Ae,Upe=new wf,GF=new Ae(1,0,0),WF=new Ae(0,1,0),qF=new Ae(0,0,1),jpe={type:"added"},Fpe={type:"removed"};class ma extends jf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Lpe++}),this.uuid=ec(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ma.DEFAULT_UP.clone();const e=new Ae,n=new xx,i=new wf,r=new Ae(1,1,1);function a(){i.setFromEuler(n,!1)}function s(){n.setFromQuaternion(i,void 0,!1)}n._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Zn},normalMatrix:{value:new ln}}),this.matrix=new Zn,this.matrixWorld=new Zn,this.matrixAutoUpdate=ma.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ma.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new QG,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return Bh.setFromAxisAngle(e,n),this.quaternion.multiply(Bh),this}rotateOnWorldAxis(e,n){return Bh.setFromAxisAngle(e,n),this.quaternion.premultiply(Bh),this}rotateX(e){return this.rotateOnAxis(GF,e)}rotateY(e){return this.rotateOnAxis(WF,e)}rotateZ(e){return this.rotateOnAxis(qF,e)}translateOnAxis(e,n){return $F.copy(e).applyQuaternion(this.quaternion),this.position.add($F.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(GF,e)}translateY(e){return this.translateOnAxis(WF,e)}translateZ(e){return this.translateOnAxis(qF,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Cl.copy(this.matrixWorld).invert())}lookAt(e,n,i){e.isVector3?Hy.copy(e):Hy.set(e,n,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Ag.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Cl.lookAt(Ag,Hy,this.up):Cl.lookAt(Hy,Ag,this.up),this.quaternion.setFromRotationMatrix(Cl),r&&(Cl.extractRotation(r.matrixWorld),Bh.setFromRotationMatrix(Cl),this.quaternion.premultiply(Bh.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(jpe)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(Fpe)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Cl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Cl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Cl),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let i=0,r=this.children.length;i<r;i++){const s=this.children[i].getObjectByProperty(e,n);if(s!==void 0)return s}}getObjectsByProperty(e,n,i=[]){this[e]===n&&i.push(this);const r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,n,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ag,e,Ipe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ag,Upe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let i=0,r=n.length;i<r;i++)n[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let i=0,r=n.length;i<r;i++)n[i].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let i=0,r=n.length;i<r;i++){const a=n[i];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const r=this.children;for(let a=0,s=r.length;a<s;a++){const o=r[a];o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",i={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function a(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,d=l.length;c<d;c++){const f=l[c];a(e.shapes,f)}else a(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(e.materials,this.material[l]));r.material=o}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(a(e.animations,l))}}if(n){const o=s(e.geometries),l=s(e.materials),c=s(e.textures),d=s(e.images),f=s(e.shapes),p=s(e.skeletons),m=s(e.animations),_=s(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),d.length>0&&(i.images=d),f.length>0&&(i.shapes=f),p.length>0&&(i.skeletons=p),m.length>0&&(i.animations=m),_.length>0&&(i.nodes=_)}return i.object=r,i;function s(o){const l=[];for(const c in o){const d=o[c];delete d.metadata,l.push(d)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}ma.DEFAULT_UP=new Ae(0,1,0);ma.DEFAULT_MATRIX_AUTO_UPDATE=!0;ma.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ao=new Ae,Nl=new Ae,ZA=new Ae,Rl=new Ae,Hh=new Ae,Vh=new Ae,XF=new Ae,QA=new Ae,JA=new Ae,eT=new Ae;let Vy=!1;class so{constructor(e=new Ae,n=new Ae,i=new Ae){this.a=e,this.b=n,this.c=i}static getNormal(e,n,i,r){r.subVectors(i,n),ao.subVectors(e,n),r.cross(ao);const a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,n,i,r,a){ao.subVectors(r,n),Nl.subVectors(i,n),ZA.subVectors(e,n);const s=ao.dot(ao),o=ao.dot(Nl),l=ao.dot(ZA),c=Nl.dot(Nl),d=Nl.dot(ZA),f=s*c-o*o;if(f===0)return a.set(-2,-1,-1);const p=1/f,m=(c*l-o*d)*p,_=(s*d-o*l)*p;return a.set(1-m-_,_,m)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,Rl),Rl.x>=0&&Rl.y>=0&&Rl.x+Rl.y<=1}static getUV(e,n,i,r,a,s,o,l){return Vy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Vy=!0),this.getInterpolation(e,n,i,r,a,s,o,l)}static getInterpolation(e,n,i,r,a,s,o,l){return this.getBarycoord(e,n,i,r,Rl),l.setScalar(0),l.addScaledVector(a,Rl.x),l.addScaledVector(s,Rl.y),l.addScaledVector(o,Rl.z),l}static isFrontFacing(e,n,i,r){return ao.subVectors(i,n),Nl.subVectors(e,n),ao.cross(Nl).dot(r)<0}set(e,n,i){return this.a.copy(e),this.b.copy(n),this.c.copy(i),this}setFromPointsAndIndices(e,n,i,r){return this.a.copy(e[n]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,n,i,r){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ao.subVectors(this.c,this.b),Nl.subVectors(this.a,this.b),ao.cross(Nl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return so.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return so.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,i,r,a){return Vy===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Vy=!0),so.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}getInterpolation(e,n,i,r,a){return so.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}containsPoint(e){return so.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return so.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const i=this.a,r=this.b,a=this.c;let s,o;Hh.subVectors(r,i),Vh.subVectors(a,i),QA.subVectors(e,i);const l=Hh.dot(QA),c=Vh.dot(QA);if(l<=0&&c<=0)return n.copy(i);JA.subVectors(e,r);const d=Hh.dot(JA),f=Vh.dot(JA);if(d>=0&&f<=d)return n.copy(r);const p=l*f-d*c;if(p<=0&&l>=0&&d<=0)return s=l/(l-d),n.copy(i).addScaledVector(Hh,s);eT.subVectors(e,a);const m=Hh.dot(eT),_=Vh.dot(eT);if(_>=0&&m<=_)return n.copy(a);const b=m*c-l*_;if(b<=0&&c>=0&&_<=0)return o=c/(c-_),n.copy(i).addScaledVector(Vh,o);const v=d*_-m*f;if(v<=0&&f-d>=0&&m-_>=0)return XF.subVectors(a,r),o=(f-d)/(f-d+(m-_)),n.copy(r).addScaledVector(XF,o);const x=1/(v+b+p);return s=b*x,o=p*x,n.copy(i).addScaledVector(Hh,s).addScaledVector(Vh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const JG={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},su={h:0,s:0,l:0},$y={h:0,s:0,l:0};function tT(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Ft=class{constructor(e,n,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,i)}set(e,n,i){if(n===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,n,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=zr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Bn.toWorkingColorSpace(this,n),this}setRGB(e,n,i,r=Bn.workingColorSpace){return this.r=e,this.g=n,this.b=i,Bn.toWorkingColorSpace(this,r),this}setHSL(e,n,i,r=Bn.workingColorSpace){if(e=wP(e,1),n=Br(n,0,1),i=Br(i,0,1),n===0)this.r=this.g=this.b=i;else{const a=i<=.5?i*(1+n):i+n-i*n,s=2*i-a;this.r=tT(s,a,e+1/3),this.g=tT(s,a,e),this.b=tT(s,a,e-1/3)}return Bn.toWorkingColorSpace(this,r),this}setStyle(e,n=zr){function i(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=r[1],o=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(s===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=zr){const i=JG[e.toLowerCase()];return i!==void 0?this.setHex(i,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=_p(e.r),this.g=_p(e.g),this.b=_p(e.b),this}copyLinearToSRGB(e){return this.r=VA(e.r),this.g=VA(e.g),this.b=VA(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=zr){return Bn.fromWorkingColorSpace(Kr.copy(this),e),Math.round(Br(Kr.r*255,0,255))*65536+Math.round(Br(Kr.g*255,0,255))*256+Math.round(Br(Kr.b*255,0,255))}getHexString(e=zr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Bn.workingColorSpace){Bn.fromWorkingColorSpace(Kr.copy(this),n);const i=Kr.r,r=Kr.g,a=Kr.b,s=Math.max(i,r,a),o=Math.min(i,r,a);let l,c;const d=(o+s)/2;if(o===s)l=0,c=0;else{const f=s-o;switch(c=d<=.5?f/(s+o):f/(2-s-o),s){case i:l=(r-a)/f+(r<a?6:0);break;case r:l=(a-i)/f+2;break;case a:l=(i-r)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=d,e}getRGB(e,n=Bn.workingColorSpace){return Bn.fromWorkingColorSpace(Kr.copy(this),n),e.r=Kr.r,e.g=Kr.g,e.b=Kr.b,e}getStyle(e=zr){Bn.fromWorkingColorSpace(Kr.copy(this),e);const n=Kr.r,i=Kr.g,r=Kr.b;return e!==zr?`color(${e} ${n.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,n,i){return this.getHSL(su),this.setHSL(su.h+e,su.s+n,su.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,i){return this.r=e.r+(n.r-e.r)*i,this.g=e.g+(n.g-e.g)*i,this.b=e.b+(n.b-e.b)*i,this}lerpHSL(e,n){this.getHSL(su),e.getHSL($y);const i=Qg(su.h,$y.h,n),r=Qg(su.s,$y.s,n),a=Qg(su.l,$y.l,n);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*n+a[3]*i+a[6]*r,this.g=a[1]*n+a[4]*i+a[7]*r,this.b=a[2]*n+a[5]*i+a[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Kr=new Ft;Ft.NAMES=JG;let zpe=0;class lm extends jf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zpe++}),this.uuid=ec(),this.name="",this.type="Material",this.blending=bp,this.side=$u,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=HN,this.blendDst=VN,this.blendEquation=Hd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ft(0,0,0),this.blendAlpha=0,this.depthFunc=w_,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=LF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lh,this.stencilZFail=Lh,this.stencilZPass=Lh,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const i=e[n];if(i===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[n]=i}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==bp&&(i.blending=this.blending),this.side!==$u&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==HN&&(i.blendSrc=this.blendSrc),this.blendDst!==VN&&(i.blendDst=this.blendDst),this.blendEquation!==Hd&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==w_&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==LF&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lh&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Lh&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Lh&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){const s=[];for(const o in a){const l=a[o];delete l.metadata,s.push(l)}return s}if(n){const a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let i=null;if(n!==null){const r=n.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=n[a].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class e9 extends lm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ft(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=bP,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Fi=new Ae,Gy=new Gt;class ss{constructor(e,n,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=i,this.usage=XN,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=ql,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,i){e*=this.itemSize,i*=n.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=n.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,i=this.count;n<i;n++)Gy.fromBufferAttribute(this,n),Gy.applyMatrix3(e),this.setXY(n,Gy.x,Gy.y);else if(this.itemSize===3)for(let n=0,i=this.count;n<i;n++)Fi.fromBufferAttribute(this,n),Fi.applyMatrix3(e),this.setXYZ(n,Fi.x,Fi.y,Fi.z);return this}applyMatrix4(e){for(let n=0,i=this.count;n<i;n++)Fi.fromBufferAttribute(this,n),Fi.applyMatrix4(e),this.setXYZ(n,Fi.x,Fi.y,Fi.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)Fi.fromBufferAttribute(this,n),Fi.applyNormalMatrix(e),this.setXYZ(n,Fi.x,Fi.y,Fi.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)Fi.fromBufferAttribute(this,n),Fi.transformDirection(e),this.setXYZ(n,Fi.x,Fi.y,Fi.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let i=this.array[e*this.itemSize+n];return this.normalized&&(i=Uo(i,this.array)),i}setComponent(e,n,i){return this.normalized&&(i=zn(i,this.array)),this.array[e*this.itemSize+n]=i,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Uo(n,this.array)),n}setX(e,n){return this.normalized&&(n=zn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Uo(n,this.array)),n}setY(e,n){return this.normalized&&(n=zn(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=Uo(n,this.array)),n}setZ(e,n){return this.normalized&&(n=zn(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=Uo(n,this.array)),n}setW(e,n){return this.normalized&&(n=zn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,i){return e*=this.itemSize,this.normalized&&(n=zn(n,this.array),i=zn(i,this.array)),this.array[e+0]=n,this.array[e+1]=i,this}setXYZ(e,n,i,r){return e*=this.itemSize,this.normalized&&(n=zn(n,this.array),i=zn(i,this.array),r=zn(r,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,n,i,r,a){return e*=this.itemSize,this.normalized&&(n=zn(n,this.array),i=zn(i,this.array),r=zn(r,this.array),a=zn(a,this.array)),this.array[e+0]=n,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==XN&&(e.usage=this.usage),e}}class t9 extends ss{constructor(e,n,i){super(new Uint16Array(e),n,i)}}class n9 extends ss{constructor(e,n,i){super(new Uint32Array(e),n,i)}}class Pi extends ss{constructor(e,n,i){super(new Float32Array(e),n,i)}}let Bpe=0;const Ss=new Zn,nT=new ma,$h=new Ae,Qa=new Bs,Tg=new Bs,vr=new Ae;class ia extends jf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Bpe++}),this.uuid=ec(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(XG(e)?n9:t9)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,i=0){this.groups.push({start:e,count:n,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const a=new ln().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ss.makeRotationFromQuaternion(e),this.applyMatrix4(Ss),this}rotateX(e){return Ss.makeRotationX(e),this.applyMatrix4(Ss),this}rotateY(e){return Ss.makeRotationY(e),this.applyMatrix4(Ss),this}rotateZ(e){return Ss.makeRotationZ(e),this.applyMatrix4(Ss),this}translate(e,n,i){return Ss.makeTranslation(e,n,i),this.applyMatrix4(Ss),this}scale(e,n,i){return Ss.makeScale(e,n,i),this.applyMatrix4(Ss),this}lookAt(e){return nT.lookAt(e),nT.updateMatrix(),this.applyMatrix4(nT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($h).negate(),this.translate($h.x,$h.y,$h.z),this}setFromPoints(e){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new Pi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bs);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Ae(-1/0,-1/0,-1/0),new Ae(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let i=0,r=n.length;i<r;i++){const a=n[i];Qa.setFromBufferAttribute(a),this.morphTargetsRelative?(vr.addVectors(this.boundingBox.min,Qa.min),this.boundingBox.expandByPoint(vr),vr.addVectors(this.boundingBox.max,Qa.max),this.boundingBox.expandByPoint(vr)):(this.boundingBox.expandByPoint(Qa.min),this.boundingBox.expandByPoint(Qa.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Bo);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Ae,1/0);return}if(e){const i=this.boundingSphere.center;if(Qa.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Tg.setFromBufferAttribute(o),this.morphTargetsRelative?(vr.addVectors(Qa.min,Tg.min),Qa.expandByPoint(vr),vr.addVectors(Qa.max,Tg.max),Qa.expandByPoint(vr)):(Qa.expandByPoint(Tg.min),Qa.expandByPoint(Tg.max))}Qa.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)vr.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(vr));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,d=o.count;c<d;c++)vr.fromBufferAttribute(o,c),l&&($h.fromBufferAttribute(e,c),vr.add($h)),r=Math.max(r,i.distanceToSquared(vr))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.array,r=n.position.array,a=n.normal.array,s=n.uv.array,o=r.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ss(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],d=[];for(let O=0;O<o;O++)c[O]=new Ae,d[O]=new Ae;const f=new Ae,p=new Ae,m=new Ae,_=new Gt,b=new Gt,v=new Gt,x=new Ae,M=new Ae;function w(O,z,I){f.fromArray(r,O*3),p.fromArray(r,z*3),m.fromArray(r,I*3),_.fromArray(s,O*2),b.fromArray(s,z*2),v.fromArray(s,I*2),p.sub(f),m.sub(f),b.sub(_),v.sub(_);const G=1/(b.x*v.y-v.x*b.y);isFinite(G)&&(x.copy(p).multiplyScalar(v.y).addScaledVector(m,-b.y).multiplyScalar(G),M.copy(m).multiplyScalar(b.x).addScaledVector(p,-v.x).multiplyScalar(G),c[O].add(x),c[z].add(x),c[I].add(x),d[O].add(M),d[z].add(M),d[I].add(M))}let E=this.groups;E.length===0&&(E=[{start:0,count:i.length}]);for(let O=0,z=E.length;O<z;++O){const I=E[O],G=I.start,L=I.count;for(let B=G,q=G+L;B<q;B+=3)w(i[B+0],i[B+1],i[B+2])}const T=new Ae,P=new Ae,N=new Ae,U=new Ae;function R(O){N.fromArray(a,O*3),U.copy(N);const z=c[O];T.copy(z),T.sub(N.multiplyScalar(N.dot(z))).normalize(),P.crossVectors(U,z);const G=P.dot(d[O])<0?-1:1;l[O*4]=T.x,l[O*4+1]=T.y,l[O*4+2]=T.z,l[O*4+3]=G}for(let O=0,z=E.length;O<z;++O){const I=E[O],G=I.start,L=I.count;for(let B=G,q=G+L;B<q;B+=3)R(i[B+0]),R(i[B+1]),R(i[B+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new ss(new Float32Array(n.count*3),3),this.setAttribute("normal",i);else for(let p=0,m=i.count;p<m;p++)i.setXYZ(p,0,0,0);const r=new Ae,a=new Ae,s=new Ae,o=new Ae,l=new Ae,c=new Ae,d=new Ae,f=new Ae;if(e)for(let p=0,m=e.count;p<m;p+=3){const _=e.getX(p+0),b=e.getX(p+1),v=e.getX(p+2);r.fromBufferAttribute(n,_),a.fromBufferAttribute(n,b),s.fromBufferAttribute(n,v),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),o.fromBufferAttribute(i,_),l.fromBufferAttribute(i,b),c.fromBufferAttribute(i,v),o.add(d),l.add(d),c.add(d),i.setXYZ(_,o.x,o.y,o.z),i.setXYZ(b,l.x,l.y,l.z),i.setXYZ(v,c.x,c.y,c.z)}else for(let p=0,m=n.count;p<m;p+=3)r.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),s.fromBufferAttribute(n,p+2),d.subVectors(s,a),f.subVectors(r,a),d.cross(f),i.setXYZ(p+0,d.x,d.y,d.z),i.setXYZ(p+1,d.x,d.y,d.z),i.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,i=e.count;n<i;n++)vr.fromBufferAttribute(e,n),vr.normalize(),e.setXYZ(n,vr.x,vr.y,vr.z)}toNonIndexed(){function e(o,l){const c=o.array,d=o.itemSize,f=o.normalized,p=new c.constructor(l.length*d);let m=0,_=0;for(let b=0,v=l.length;b<v;b++){o.isInterleavedBufferAttribute?m=l[b]*o.data.stride+o.offset:m=l[b]*d;for(let x=0;x<d;x++)p[_++]=c[m++]}return new ss(p,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ia,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);n.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let d=0,f=c.length;d<f;d++){const p=c[d],m=e(p,i);l.push(m)}n.morphAttributes[o]=l}n.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let o=0,l=s.length;o<l;o++){const c=s[o];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const r={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],d=[];for(let f=0,p=c.length;f<p;f++){const m=c[f];d.push(m.toJSON(e.data))}d.length>0&&(r[l]=d,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone(n));const r=e.attributes;for(const c in r){const d=r[c];this.setAttribute(c,d.clone(n))}const a=e.morphAttributes;for(const c in a){const d=[],f=a[c];for(let p=0,m=f.length;p<m;p++)d.push(f[p].clone(n));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,d=s.length;c<d;c++){const f=s[c];this.addGroup(f.start,f.count,f.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const KF=new Zn,Dd=new MP,Wy=new Bo,YF=new Ae,Gh=new Ae,Wh=new Ae,qh=new Ae,iT=new Ae,qy=new Ae,Xy=new Gt,Ky=new Gt,Yy=new Gt,ZF=new Ae,QF=new Ae,JF=new Ae,Zy=new Ae,Qy=new Ae;class po extends ma{constructor(e=new ia,n=new e9){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,i=Object.keys(n);if(i.length>0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){const o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(e,n){const i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;n.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(a&&o){qy.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const d=o[l],f=a[l];d!==0&&(iT.fromBufferAttribute(f,e),s?qy.addScaledVector(iT,d):qy.addScaledVector(iT.sub(n),d))}n.add(qy)}return n}raycast(e,n){const i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Wy.copy(i.boundingSphere),Wy.applyMatrix4(a),Dd.copy(e.ray).recast(e.near),!(Wy.containsPoint(Dd.origin)===!1&&(Dd.intersectSphere(Wy,YF)===null||Dd.origin.distanceToSquared(YF)>(e.far-e.near)**2))&&(KF.copy(a).invert(),Dd.copy(e.ray).applyMatrix4(KF),!(i.boundingBox!==null&&Dd.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,n,Dd)))}_computeIntersections(e,n,i){let r;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(o!==null)if(Array.isArray(s))for(let _=0,b=p.length;_<b;_++){const v=p[_],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(o.count,Math.min(v.start+v.count,m.start+m.count));for(let E=M,T=w;E<T;E+=3){const P=o.getX(E),N=o.getX(E+1),U=o.getX(E+2);r=Jy(this,x,e,i,c,d,f,P,N,U),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const _=Math.max(0,m.start),b=Math.min(o.count,m.start+m.count);for(let v=_,x=b;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),E=o.getX(v+2);r=Jy(this,s,e,i,c,d,f,M,w,E),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}else if(l!==void 0)if(Array.isArray(s))for(let _=0,b=p.length;_<b;_++){const v=p[_],x=s[v.materialIndex],M=Math.max(v.start,m.start),w=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let E=M,T=w;E<T;E+=3){const P=E,N=E+1,U=E+2;r=Jy(this,x,e,i,c,d,f,P,N,U),r&&(r.faceIndex=Math.floor(E/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const _=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let v=_,x=b;v<x;v+=3){const M=v,w=v+1,E=v+2;r=Jy(this,s,e,i,c,d,f,M,w,E),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}}}function Hpe(t,e,n,i,r,a,s,o){let l;if(e.side===ka?l=i.intersectTriangle(s,a,r,!0,o):l=i.intersectTriangle(r,a,s,e.side===$u,o),l===null)return null;Qy.copy(o),Qy.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Qy);return c<n.near||c>n.far?null:{distance:c,point:Qy.clone(),object:t}}function Jy(t,e,n,i,r,a,s,o,l,c){t.getVertexPosition(o,Gh),t.getVertexPosition(l,Wh),t.getVertexPosition(c,qh);const d=Hpe(t,e,n,i,Gh,Wh,qh,Zy);if(d){r&&(Xy.fromBufferAttribute(r,o),Ky.fromBufferAttribute(r,l),Yy.fromBufferAttribute(r,c),d.uv=so.getInterpolation(Zy,Gh,Wh,qh,Xy,Ky,Yy,new Gt)),a&&(Xy.fromBufferAttribute(a,o),Ky.fromBufferAttribute(a,l),Yy.fromBufferAttribute(a,c),d.uv1=so.getInterpolation(Zy,Gh,Wh,qh,Xy,Ky,Yy,new Gt),d.uv2=d.uv1),s&&(ZF.fromBufferAttribute(s,o),QF.fromBufferAttribute(s,l),JF.fromBufferAttribute(s,c),d.normal=so.getInterpolation(Zy,Gh,Wh,qh,ZF,QF,JF,new Ae),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));const f={a:o,b:l,c,normal:new Ae,materialIndex:0};so.getNormal(Gh,Wh,qh,f.normal),d.face=f}return d}class vx extends ia{constructor(e=1,n=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};const o=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);const l=[],c=[],d=[],f=[];let p=0,m=0;_("z","y","x",-1,-1,i,n,e,s,a,0),_("z","y","x",1,-1,i,n,-e,s,a,1),_("x","z","y",1,1,e,i,n,r,s,2),_("x","z","y",1,-1,e,i,-n,r,s,3),_("x","y","z",1,-1,e,n,i,r,a,4),_("x","y","z",-1,-1,e,n,-i,r,a,5),this.setIndex(l),this.setAttribute("position",new Pi(c,3)),this.setAttribute("normal",new Pi(d,3)),this.setAttribute("uv",new Pi(f,2));function _(b,v,x,M,w,E,T,P,N,U,R){const O=E/N,z=T/U,I=E/2,G=T/2,L=P/2,B=N+1,q=U+1;let W=0,X=0;const Q=new Ae;for(let ie=0;ie<q;ie++){const H=ie*z-G;for(let Y=0;Y<B;Y++){const se=Y*O-I;Q[b]=se*M,Q[v]=H*w,Q[x]=L,c.push(Q.x,Q.y,Q.z),Q[b]=0,Q[v]=0,Q[x]=P>0?1:-1,d.push(Q.x,Q.y,Q.z),f.push(Y/N),f.push(1-ie/U),W+=1}}for(let ie=0;ie<U;ie++)for(let H=0;H<N;H++){const Y=p+H+B*ie,se=p+H+B*(ie+1),ue=p+(H+1)+B*(ie+1),xe=p+(H+1)+B*ie;l.push(Y,se,xe),l.push(se,ue,xe),X+=6}o.addGroup(m,X,R),m+=X,p+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vx(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function jp(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}function ca(t){const e={};for(let n=0;n<t.length;n++){const i=jp(t[n]);for(const r in i)e[r]=i[r]}return e}function Vpe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function i9(t){return t.getRenderTarget()===null?t.outputColorSpace:Bn.workingColorSpace}const EP={clone:jp,merge:ca};var $pe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Gpe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Gu extends lm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=$pe,this.fragmentShader=Gpe,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=jp(e.uniforms),this.uniformsGroups=Vpe(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const r in this.uniforms){const s=this.uniforms[r].value;s&&s.isTexture?n.uniforms[r]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?n.uniforms[r]={type:"c",value:s.getHex()}:s&&s.isVector2?n.uniforms[r]={type:"v2",value:s.toArray()}:s&&s.isVector3?n.uniforms[r]={type:"v3",value:s.toArray()}:s&&s.isVector4?n.uniforms[r]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?n.uniforms[r]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?n.uniforms[r]={type:"m4",value:s.toArray()}:n.uniforms[r]={value:s}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader,n.lights=this.lights,n.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(n.extensions=i),n}}class r9 extends ma{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Zn,this.projectionMatrix=new Zn,this.projectionMatrixInverse=new Zn,this.coordinateSystem=Fo}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class ts extends r9{constructor(e=50,n=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=k0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Zg*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return k0*2*Math.atan(Math.tan(Zg*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,i,r,a,s){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Zg*.5*this.fov)/this.zoom,i=2*n,r=this.aspect*i,a=-.5*r;const s=this.view;if(this.view!==null&&this.view.enabled){const l=s.fullWidth,c=s.fullHeight;a+=s.offsetX*r/l,n-=s.offsetY*i/c,r*=s.width/l,i*=s.height/c}const o=this.filmOffset;o!==0&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,n,n-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const Xh=-90,Kh=1;class Wpe extends ma{constructor(e,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new ts(Xh,Kh,e,n);r.layers=this.layers,this.add(r);const a=new ts(Xh,Kh,e,n);a.layers=this.layers,this.add(a);const s=new ts(Xh,Kh,e,n);s.layers=this.layers,this.add(s);const o=new ts(Xh,Kh,e,n);o.layers=this.layers,this.add(o);const l=new ts(Xh,Kh,e,n);l.layers=this.layers,this.add(l);const c=new ts(Xh,Kh,e,n);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[i,r,a,s,o,l]=n;for(const c of n)this.remove(c);if(e===Fo)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===O0)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of n)this.add(c),c.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,o,l,c,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const b=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(n,a),e.setRenderTarget(i,1,r),e.render(n,s),e.setRenderTarget(i,2,r),e.render(n,o),e.setRenderTarget(i,3,r),e.render(n,l),e.setRenderTarget(i,4,r),e.render(n,c),i.texture.generateMipmaps=b,e.setRenderTarget(i,5,r),e.render(n,d),e.setRenderTarget(f,p,m),e.xr.enabled=_,i.texture.needsPMREMUpdate=!0}}class a9 extends La{constructor(e,n,i,r,a,s,o,l,c,d){e=e!==void 0?e:[],n=n!==void 0?n:Lp,super(e,n,i,r,a,s,o,l,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class qpe extends Sf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];n.encoding!==void 0&&(Jg("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===rf?zr:Is),this.texture=new a9(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:ks}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},r=new vx(5,5,5),a=new Gu({name:"CubemapFromEquirect",uniforms:jp(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:ka,blending:Pu});a.uniforms.tEquirect.value=n;const s=new po(r,a),o=n.minFilter;return n.minFilter===P0&&(n.minFilter=ks),new Wpe(1,10,this).update(e,s),n.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,n,i,r){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(n,i,r);e.setRenderTarget(a)}}const rT=new Ae,Xpe=new Ae,Kpe=new ln;class fu{constructor(e=new Ae(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,i,r){return this.normal.set(e,n,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,i){const r=rT.subVectors(i,n).cross(Xpe.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,n){const i=e.delta(rT),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return a<0||a>1?null:n.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return n<0&&i>0||i<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const i=n||Kpe.getNormalMatrix(e),r=this.coplanarPoint(rT).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Od=new Bo,eb=new Ae;class OS{constructor(e=new fu,n=new fu,i=new fu,r=new fu,a=new fu,s=new fu){this.planes=[e,n,i,r,a,s]}set(e,n,i,r,a,s){const o=this.planes;return o[0].copy(e),o[1].copy(n),o[2].copy(i),o[3].copy(r),o[4].copy(a),o[5].copy(s),this}copy(e){const n=this.planes;for(let i=0;i<6;i++)n[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,n=Fo){const i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],c=r[4],d=r[5],f=r[6],p=r[7],m=r[8],_=r[9],b=r[10],v=r[11],x=r[12],M=r[13],w=r[14],E=r[15];if(i[0].setComponents(l-a,p-c,v-m,E-x).normalize(),i[1].setComponents(l+a,p+c,v+m,E+x).normalize(),i[2].setComponents(l+s,p+d,v+_,E+M).normalize(),i[3].setComponents(l-s,p-d,v-_,E-M).normalize(),i[4].setComponents(l-o,p-f,v-b,E-w).normalize(),n===Fo)i[5].setComponents(l+o,p+f,v+b,E+w).normalize();else if(n===O0)i[5].setComponents(o,f,b,w).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+n);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Od.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Od.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Od)}intersectsSprite(e){return Od.center.set(0,0,0),Od.radius=.7071067811865476,Od.applyMatrix4(e.matrixWorld),this.intersectsSphere(Od)}intersectsSphere(e){const n=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const n=this.planes;for(let i=0;i<6;i++){const r=n[i];if(eb.x=r.normal.x>0?e.max.x:e.min.x,eb.y=r.normal.y>0?e.max.y:e.min.y,eb.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(eb)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let i=0;i<6;i++)if(n[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function s9(){let t=null,e=!1,n=null,i=null;function r(a,s){n(a,s),i=t.requestAnimationFrame(r)}return{start:function(){e!==!0&&n!==null&&(i=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function Ype(t,e){const n=e.isWebGL2,i=new WeakMap;function r(c,d){const f=c.array,p=c.usage,m=f.byteLength,_=t.createBuffer();t.bindBuffer(d,_),t.bufferData(d,f,p),c.onUploadCallback();let b;if(f instanceof Float32Array)b=t.FLOAT;else if(f instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(n)b=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else b=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)b=t.SHORT;else if(f instanceof Uint32Array)b=t.UNSIGNED_INT;else if(f instanceof Int32Array)b=t.INT;else if(f instanceof Int8Array)b=t.BYTE;else if(f instanceof Uint8Array)b=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)b=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:_,type:b,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version,size:m}}function a(c,d,f){const p=d.array,m=d._updateRange,_=d.updateRanges;if(t.bindBuffer(f,c),m.count===-1&&_.length===0&&t.bufferSubData(f,0,p),_.length!==0){for(let b=0,v=_.length;b<v;b++){const x=_[b];n?t.bufferSubData(f,x.start*p.BYTES_PER_ELEMENT,p,x.start,x.count):t.bufferSubData(f,x.start*p.BYTES_PER_ELEMENT,p.subarray(x.start,x.start+x.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.count=-1),d.onUploadCallback()}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const d=i.get(c);d&&(t.deleteBuffer(d.buffer),i.delete(c))}function l(c,d){if(c.isGLBufferAttribute){const p=i.get(c);(!p||p.version<c.version)&&i.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const f=i.get(c);if(f===void 0)i.set(c,r(c,d));else if(f.version<c.version){if(f.size!==c.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,c,d),f.version=c.version}}return{get:s,remove:o,update:l}}class AP extends ia{constructor(e=1,n=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:i,heightSegments:r};const a=e/2,s=n/2,o=Math.floor(i),l=Math.floor(r),c=o+1,d=l+1,f=e/o,p=n/l,m=[],_=[],b=[],v=[];for(let x=0;x<d;x++){const M=x*p-s;for(let w=0;w<c;w++){const E=w*f-a;_.push(E,-M,0),b.push(0,0,1),v.push(w/o),v.push(1-x/l)}}for(let x=0;x<l;x++)for(let M=0;M<o;M++){const w=M+c*x,E=M+c*(x+1),T=M+1+c*(x+1),P=M+1+c*x;m.push(w,E,P),m.push(E,T,P)}this.setIndex(m),this.setAttribute("position",new Pi(_,3)),this.setAttribute("normal",new Pi(b,3)),this.setAttribute("uv",new Pi(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new AP(e.width,e.height,e.widthSegments,e.heightSegments)}}var Zpe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Qpe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,Jpe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,eme=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,tme=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,nme=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,ime=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,rme=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,ame=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,sme=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,ome=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,lme=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,cme=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,ume=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,dme=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,fme=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,hme=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,pme=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,mme=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,gme=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,xme=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,vme=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,yme=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,bme=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,_me=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,Sme=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,wme=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Mme=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,Eme=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,Ame=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,Tme="gl_FragColor = linearToOutputTexel( gl_FragColor );",Cme=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,Nme=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,Rme=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,Pme=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,Dme=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,Ome=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,kme=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,Lme=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,Ime=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,Ume=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,jme=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,Fme=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,zme=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,Bme=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,Hme=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Vme=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,$me=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,Gme=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,Wme=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qme=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,Xme=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Kme=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,Yme=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,Zme=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,Qme=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,Jme=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,ege=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,tge=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,nge=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,ige=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,rge=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,age=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,sge=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,oge=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,lge=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,cge=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,uge=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,dge=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,fge=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,hge=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,pge=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,mge=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,gge=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,xge=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,vge=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,yge=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,bge=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,_ge=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Sge=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,wge=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Mge=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ege=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,Age=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,Tge=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,Cge=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,Nge=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,Rge=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Pge=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Dge=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,Oge=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,kge=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,Lge=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,Ige=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,Uge=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,jge=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,Fge=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,zge=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,Bge=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,Hge=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,Vge=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,$ge=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,Gge=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,Wge=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,qge=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,Xge=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,Kge=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const Yge=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Zge=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Qge=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Jge=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,e0e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,t0e=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,n0e=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,i0e=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,r0e=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,a0e=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,s0e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,o0e=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,l0e=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,c0e=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,u0e=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,d0e=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,f0e=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,h0e=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,p0e=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,m0e=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,g0e=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,x0e=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,v0e=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,y0e=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,b0e=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,_0e=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,S0e=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,w0e=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,M0e=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,E0e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,A0e=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,T0e=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,C0e=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,N0e=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,tn={alphahash_fragment:Zpe,alphahash_pars_fragment:Qpe,alphamap_fragment:Jpe,alphamap_pars_fragment:eme,alphatest_fragment:tme,alphatest_pars_fragment:nme,aomap_fragment:ime,aomap_pars_fragment:rme,batching_pars_vertex:ame,batching_vertex:sme,begin_vertex:ome,beginnormal_vertex:lme,bsdfs:cme,iridescence_fragment:ume,bumpmap_pars_fragment:dme,clipping_planes_fragment:fme,clipping_planes_pars_fragment:hme,clipping_planes_pars_vertex:pme,clipping_planes_vertex:mme,color_fragment:gme,color_pars_fragment:xme,color_pars_vertex:vme,color_vertex:yme,common:bme,cube_uv_reflection_fragment:_me,defaultnormal_vertex:Sme,displacementmap_pars_vertex:wme,displacementmap_vertex:Mme,emissivemap_fragment:Eme,emissivemap_pars_fragment:Ame,colorspace_fragment:Tme,colorspace_pars_fragment:Cme,envmap_fragment:Nme,envmap_common_pars_fragment:Rme,envmap_pars_fragment:Pme,envmap_pars_vertex:Dme,envmap_physical_pars_fragment:$me,envmap_vertex:Ome,fog_vertex:kme,fog_pars_vertex:Lme,fog_fragment:Ime,fog_pars_fragment:Ume,gradientmap_pars_fragment:jme,lightmap_fragment:Fme,lightmap_pars_fragment:zme,lights_lambert_fragment:Bme,lights_lambert_pars_fragment:Hme,lights_pars_begin:Vme,lights_toon_fragment:Gme,lights_toon_pars_fragment:Wme,lights_phong_fragment:qme,lights_phong_pars_fragment:Xme,lights_physical_fragment:Kme,lights_physical_pars_fragment:Yme,lights_fragment_begin:Zme,lights_fragment_maps:Qme,lights_fragment_end:Jme,logdepthbuf_fragment:ege,logdepthbuf_pars_fragment:tge,logdepthbuf_pars_vertex:nge,logdepthbuf_vertex:ige,map_fragment:rge,map_pars_fragment:age,map_particle_fragment:sge,map_particle_pars_fragment:oge,metalnessmap_fragment:lge,metalnessmap_pars_fragment:cge,morphcolor_vertex:uge,morphnormal_vertex:dge,morphtarget_pars_vertex:fge,morphtarget_vertex:hge,normal_fragment_begin:pge,normal_fragment_maps:mge,normal_pars_fragment:gge,normal_pars_vertex:xge,normal_vertex:vge,normalmap_pars_fragment:yge,clearcoat_normal_fragment_begin:bge,clearcoat_normal_fragment_maps:_ge,clearcoat_pars_fragment:Sge,iridescence_pars_fragment:wge,opaque_fragment:Mge,packing:Ege,premultiplied_alpha_fragment:Age,project_vertex:Tge,dithering_fragment:Cge,dithering_pars_fragment:Nge,roughnessmap_fragment:Rge,roughnessmap_pars_fragment:Pge,shadowmap_pars_fragment:Dge,shadowmap_pars_vertex:Oge,shadowmap_vertex:kge,shadowmask_pars_fragment:Lge,skinbase_vertex:Ige,skinning_pars_vertex:Uge,skinning_vertex:jge,skinnormal_vertex:Fge,specularmap_fragment:zge,specularmap_pars_fragment:Bge,tonemapping_fragment:Hge,tonemapping_pars_fragment:Vge,transmission_fragment:$ge,transmission_pars_fragment:Gge,uv_pars_fragment:Wge,uv_pars_vertex:qge,uv_vertex:Xge,worldpos_vertex:Kge,background_vert:Yge,background_frag:Zge,backgroundCube_vert:Qge,backgroundCube_frag:Jge,cube_vert:e0e,cube_frag:t0e,depth_vert:n0e,depth_frag:i0e,distanceRGBA_vert:r0e,distanceRGBA_frag:a0e,equirect_vert:s0e,equirect_frag:o0e,linedashed_vert:l0e,linedashed_frag:c0e,meshbasic_vert:u0e,meshbasic_frag:d0e,meshlambert_vert:f0e,meshlambert_frag:h0e,meshmatcap_vert:p0e,meshmatcap_frag:m0e,meshnormal_vert:g0e,meshnormal_frag:x0e,meshphong_vert:v0e,meshphong_frag:y0e,meshphysical_vert:b0e,meshphysical_frag:_0e,meshtoon_vert:S0e,meshtoon_frag:w0e,points_vert:M0e,points_frag:E0e,shadow_vert:A0e,shadow_frag:T0e,sprite_vert:C0e,sprite_frag:N0e},yt={common:{diffuse:{value:new Ft(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ln},alphaMap:{value:null},alphaMapTransform:{value:new ln},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ln}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ln}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ln}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ln},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ln},normalScale:{value:new Gt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ln},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ln}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ln}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ln}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ft(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ft(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ln},alphaTest:{value:0},uvTransform:{value:new ln}},sprite:{diffuse:{value:new Ft(16777215)},opacity:{value:1},center:{value:new Gt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ln},alphaMap:{value:null},alphaMapTransform:{value:new ln},alphaTest:{value:0}}},Ra={basic:{uniforms:ca([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.fog]),vertexShader:tn.meshbasic_vert,fragmentShader:tn.meshbasic_frag},lambert:{uniforms:ca([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new Ft(0)}}]),vertexShader:tn.meshlambert_vert,fragmentShader:tn.meshlambert_frag},phong:{uniforms:ca([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,yt.lights,{emissive:{value:new Ft(0)},specular:{value:new Ft(1118481)},shininess:{value:30}}]),vertexShader:tn.meshphong_vert,fragmentShader:tn.meshphong_frag},standard:{uniforms:ca([yt.common,yt.envmap,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.roughnessmap,yt.metalnessmap,yt.fog,yt.lights,{emissive:{value:new Ft(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:tn.meshphysical_vert,fragmentShader:tn.meshphysical_frag},toon:{uniforms:ca([yt.common,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.gradientmap,yt.fog,yt.lights,{emissive:{value:new Ft(0)}}]),vertexShader:tn.meshtoon_vert,fragmentShader:tn.meshtoon_frag},matcap:{uniforms:ca([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,{matcap:{value:null}}]),vertexShader:tn.meshmatcap_vert,fragmentShader:tn.meshmatcap_frag},points:{uniforms:ca([yt.points,yt.fog]),vertexShader:tn.points_vert,fragmentShader:tn.points_frag},dashed:{uniforms:ca([yt.common,yt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:tn.linedashed_vert,fragmentShader:tn.linedashed_frag},depth:{uniforms:ca([yt.common,yt.displacementmap]),vertexShader:tn.depth_vert,fragmentShader:tn.depth_frag},normal:{uniforms:ca([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,{opacity:{value:1}}]),vertexShader:tn.meshnormal_vert,fragmentShader:tn.meshnormal_frag},sprite:{uniforms:ca([yt.sprite,yt.fog]),vertexShader:tn.sprite_vert,fragmentShader:tn.sprite_frag},background:{uniforms:{uvTransform:{value:new ln},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:tn.background_vert,fragmentShader:tn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:tn.backgroundCube_vert,fragmentShader:tn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:tn.cube_vert,fragmentShader:tn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:tn.equirect_vert,fragmentShader:tn.equirect_frag},distanceRGBA:{uniforms:ca([yt.common,yt.displacementmap,{referencePosition:{value:new Ae},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:tn.distanceRGBA_vert,fragmentShader:tn.distanceRGBA_frag},shadow:{uniforms:ca([yt.lights,yt.fog,{color:{value:new Ft(0)},opacity:{value:1}}]),vertexShader:tn.shadow_vert,fragmentShader:tn.shadow_frag}};Ra.physical={uniforms:ca([Ra.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ln},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ln},clearcoatNormalScale:{value:new Gt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ln},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ln},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ln},sheen:{value:0},sheenColor:{value:new Ft(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ln},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ln},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ln},transmissionSamplerSize:{value:new Gt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ln},attenuationDistance:{value:0},attenuationColor:{value:new Ft(0)},specularColor:{value:new Ft(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ln},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ln},anisotropyVector:{value:new Gt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ln}}]),vertexShader:tn.meshphysical_vert,fragmentShader:tn.meshphysical_frag};const tb={r:0,b:0,g:0};function R0e(t,e,n,i,r,a,s){const o=new Ft(0);let l=a===!0?0:1,c,d,f=null,p=0,m=null;function _(v,x){let M=!1,w=x.isScene===!0?x.background:null;w&&w.isTexture&&(w=(x.backgroundBlurriness>0?n:e).get(w)),w===null?b(o,l):w&&w.isColor&&(b(w,1),M=!0);const E=t.xr.getEnvironmentBlendMode();E==="additive"?i.buffers.color.setClear(0,0,0,1,s):E==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,s),(t.autoClear||M)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===PS)?(d===void 0&&(d=new po(new vx(1,1,1),new Gu({name:"BackgroundCubeMaterial",uniforms:jp(Ra.backgroundCube.uniforms),vertexShader:Ra.backgroundCube.vertexShader,fragmentShader:Ra.backgroundCube.fragmentShader,side:ka,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(T,P,N){this.matrixWorld.copyPosition(N.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(d)),d.material.uniforms.envMap.value=w,d.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,d.material.toneMapped=Bn.getTransfer(w.colorSpace)!==ti,(f!==w||p!==w.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,p=w.version,m=t.toneMapping),d.layers.enableAll(),v.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new po(new AP(2,2),new Gu({name:"BackgroundMaterial",uniforms:jp(Ra.background.uniforms),vertexShader:Ra.background.vertexShader,fragmentShader:Ra.background.fragmentShader,side:$u,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=w,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=Bn.getTransfer(w.colorSpace)!==ti,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||p!==w.version||m!==t.toneMapping)&&(c.material.needsUpdate=!0,f=w,p=w.version,m=t.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function b(v,x){v.getRGB(tb,i9(t)),i.buffers.color.setClear(tb.r,tb.g,tb.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),l=x,b(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,b(o,l)},render:_}}function P0e(t,e,n,i){const r=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:e.get("OES_vertex_array_object"),s=i.isWebGL2||a!==null,o={},l=v(null);let c=l,d=!1;function f(L,B,q,W,X){let Q=!1;if(s){const ie=b(W,q,B);c!==ie&&(c=ie,m(c.object)),Q=x(L,W,q,X),Q&&M(L,W,q,X)}else{const ie=B.wireframe===!0;(c.geometry!==W.id||c.program!==q.id||c.wireframe!==ie)&&(c.geometry=W.id,c.program=q.id,c.wireframe=ie,Q=!0)}X!==null&&n.update(X,t.ELEMENT_ARRAY_BUFFER),(Q||d)&&(d=!1,U(L,B,q,W),X!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(X).buffer))}function p(){return i.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(L){return i.isWebGL2?t.bindVertexArray(L):a.bindVertexArrayOES(L)}function _(L){return i.isWebGL2?t.deleteVertexArray(L):a.deleteVertexArrayOES(L)}function b(L,B,q){const W=q.wireframe===!0;let X=o[L.id];X===void 0&&(X={},o[L.id]=X);let Q=X[B.id];Q===void 0&&(Q={},X[B.id]=Q);let ie=Q[W];return ie===void 0&&(ie=v(p()),Q[W]=ie),ie}function v(L){const B=[],q=[],W=[];for(let X=0;X<r;X++)B[X]=0,q[X]=0,W[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:q,attributeDivisors:W,object:L,attributes:{},index:null}}function x(L,B,q,W){const X=c.attributes,Q=B.attributes;let ie=0;const H=q.getAttributes();for(const Y in H)if(H[Y].location>=0){const ue=X[Y];let xe=Q[Y];if(xe===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(xe=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(xe=L.instanceColor)),ue===void 0||ue.attribute!==xe||xe&&ue.data!==xe.data)return!0;ie++}return c.attributesNum!==ie||c.index!==W}function M(L,B,q,W){const X={},Q=B.attributes;let ie=0;const H=q.getAttributes();for(const Y in H)if(H[Y].location>=0){let ue=Q[Y];ue===void 0&&(Y==="instanceMatrix"&&L.instanceMatrix&&(ue=L.instanceMatrix),Y==="instanceColor"&&L.instanceColor&&(ue=L.instanceColor));const xe={};xe.attribute=ue,ue&&ue.data&&(xe.data=ue.data),X[Y]=xe,ie++}c.attributes=X,c.attributesNum=ie,c.index=W}function w(){const L=c.newAttributes;for(let B=0,q=L.length;B<q;B++)L[B]=0}function E(L){T(L,0)}function T(L,B){const q=c.newAttributes,W=c.enabledAttributes,X=c.attributeDivisors;q[L]=1,W[L]===0&&(t.enableVertexAttribArray(L),W[L]=1),X[L]!==B&&((i.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](L,B),X[L]=B)}function P(){const L=c.newAttributes,B=c.enabledAttributes;for(let q=0,W=B.length;q<W;q++)B[q]!==L[q]&&(t.disableVertexAttribArray(q),B[q]=0)}function N(L,B,q,W,X,Q,ie){ie===!0?t.vertexAttribIPointer(L,B,q,X,Q):t.vertexAttribPointer(L,B,q,W,X,Q)}function U(L,B,q,W){if(i.isWebGL2===!1&&(L.isInstancedMesh||W.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const X=W.attributes,Q=q.getAttributes(),ie=B.defaultAttributeValues;for(const H in Q){const Y=Q[H];if(Y.location>=0){let se=X[H];if(se===void 0&&(H==="instanceMatrix"&&L.instanceMatrix&&(se=L.instanceMatrix),H==="instanceColor"&&L.instanceColor&&(se=L.instanceColor)),se!==void 0){const ue=se.normalized,xe=se.itemSize,re=n.get(se);if(re===void 0)continue;const ve=re.buffer,Pe=re.type,pe=re.bytesPerElement,we=i.isWebGL2===!0&&(Pe===t.INT||Pe===t.UNSIGNED_INT||se.gpuType===UG);if(se.isInterleavedBufferAttribute){const ze=se.data,ce=ze.stride,ft=se.offset;if(ze.isInstancedInterleavedBuffer){for(let F=0;F<Y.locationSize;F++)T(Y.location+F,ze.meshPerAttribute);L.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ze.meshPerAttribute*ze.count)}else for(let F=0;F<Y.locationSize;F++)E(Y.location+F);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let F=0;F<Y.locationSize;F++)N(Y.location+F,xe/Y.locationSize,Pe,ue,ce*pe,(ft+xe/Y.locationSize*F)*pe,we)}else{if(se.isInstancedBufferAttribute){for(let ze=0;ze<Y.locationSize;ze++)T(Y.location+ze,se.meshPerAttribute);L.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let ze=0;ze<Y.locationSize;ze++)E(Y.location+ze);t.bindBuffer(t.ARRAY_BUFFER,ve);for(let ze=0;ze<Y.locationSize;ze++)N(Y.location+ze,xe/Y.locationSize,Pe,ue,xe*pe,xe/Y.locationSize*ze*pe,we)}}else if(ie!==void 0){const ue=ie[H];if(ue!==void 0)switch(ue.length){case 2:t.vertexAttrib2fv(Y.location,ue);break;case 3:t.vertexAttrib3fv(Y.location,ue);break;case 4:t.vertexAttrib4fv(Y.location,ue);break;default:t.vertexAttrib1fv(Y.location,ue)}}}}P()}function R(){I();for(const L in o){const B=o[L];for(const q in B){const W=B[q];for(const X in W)_(W[X].object),delete W[X];delete B[q]}delete o[L]}}function O(L){if(o[L.id]===void 0)return;const B=o[L.id];for(const q in B){const W=B[q];for(const X in W)_(W[X].object),delete W[X];delete B[q]}delete o[L.id]}function z(L){for(const B in o){const q=o[B];if(q[L.id]===void 0)continue;const W=q[L.id];for(const X in W)_(W[X].object),delete W[X];delete q[L.id]}}function I(){G(),d=!0,c!==l&&(c=l,m(c.object))}function G(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:f,reset:I,resetDefaultState:G,dispose:R,releaseStatesOfGeometry:O,releaseStatesOfProgram:z,initAttributes:w,enableAttribute:E,disableUnusedAttributes:P}}function D0e(t,e,n,i){const r=i.isWebGL2;let a;function s(d){a=d}function o(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function l(d,f,p){if(p===0)return;let m,_;if(r)m=t,_="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),_="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[_](a,d,f,p),n.update(f,a,p)}function c(d,f,p){if(p===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let _=0;_<p;_++)this.render(d[_],f[_]);else{m.multiDrawArraysWEBGL(a,d,0,f,0,p);let _=0;for(let b=0;b<p;b++)_+=f[b];n.update(_,a,1)}}this.setMode=s,this.render=o,this.renderInstances=l,this.renderMultiDraw=c}function O0e(t,e,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const N=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(N.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(N){if(N==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";N="mediump"}return N==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let o=n.precision!==void 0?n.precision:"highp";const l=a(o);l!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",l,"instead."),o=l);const c=s||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),_=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),x=t.getParameter(t.MAX_VARYING_VECTORS),M=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=p>0,E=s||e.has("OES_texture_float"),T=w&&E,P=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:c,getMaxAnisotropy:r,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:_,maxAttributes:b,maxVertexUniforms:v,maxVaryings:x,maxFragmentUniforms:M,vertexTextures:w,floatFragmentTextures:E,floatVertexTextures:T,maxSamples:P}}function k0e(t){const e=this;let n=null,i=0,r=!1,a=!1;const s=new fu,o=new ln,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||i!==0||r;return r=p,i=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const _=f.clippingPlanes,b=f.clipIntersection,v=f.clipShadows,x=t.get(f);if(!r||_===null||_.length===0||a&&!v)a?d(null):c();else{const M=a?0:i,w=M*4;let E=x.clippingState||null;l.value=E,E=d(_,p,w,m);for(let T=0;T!==w;++T)E[T]=n[T];x.clippingState=E,this.numIntersection=b?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(f,p,m,_){const b=f!==null?f.length:0;let v=null;if(b!==0){if(v=l.value,_!==!0||v===null){const x=m+b*4,M=p.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,E=m;w!==b;++w,E+=4)s.copy(f[w]).applyMatrix4(M,o),s.normal.toArray(v,E),v[E+3]=s.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,v}}function L0e(t){let e=new WeakMap;function n(s,o){return o===$N?s.mapping=Lp:o===GN&&(s.mapping=Ip),s}function i(s){if(s&&s.isTexture){const o=s.mapping;if(o===$N||o===GN)if(e.has(s)){const l=e.get(s).texture;return n(l,s.mapping)}else{const l=s.image;if(l&&l.height>0){const c=new qpe(l.height/2);return c.fromEquirectangularTexture(t,s),e.set(s,c),s.addEventListener("dispose",r),n(c.texture,s.mapping)}else return null}}return s}function r(s){const o=s.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function a(){e=new WeakMap}return{get:i,dispose:a}}class I0e extends r9{constructor(e=-1,n=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=i,this.bottom=r,this.near=a,this.far=s,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,i,r,a,s){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let a=i-e,s=i+e,o=r+n,l=r-n;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=d*this.view.offsetY,l=o-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const dp=4,ez=[.125,.215,.35,.446,.526,.582],Vd=20,aT=new I0e,tz=new Ft;let sT=null,oT=0,lT=0;const Id=(1+Math.sqrt(5))/2,Yh=1/Id,nz=[new Ae(1,1,1),new Ae(-1,1,1),new Ae(1,1,-1),new Ae(-1,1,-1),new Ae(0,Id,Yh),new Ae(0,Id,-Yh),new Ae(Yh,0,Id),new Ae(-Yh,0,Id),new Ae(Id,Yh,0),new Ae(-Id,Yh,0)];class iz{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,i=.1,r=100){sT=this._renderer.getRenderTarget(),oT=this._renderer.getActiveCubeFace(),lT=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,i,r,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=sz(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=az(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(sT,oT,lT),e.scissorTest=!1,nb(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Lp||e.mapping===Ip?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),sT=this._renderer.getRenderTarget(),oT=this._renderer.getActiveCubeFace(),lT=this._renderer.getActiveMipmapLevel();const i=n||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,i={magFilter:ks,minFilter:ks,generateMipmaps:!1,type:D0,format:Ls,colorSpace:uc,depthBuffer:!1},r=rz(e,n,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=rz(e,n,i);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=U0e(a)),this._blurMaterial=j0e(a,e,n)}return r}_compileMaterial(e){const n=new po(this._lodPlanes[0],e);this._renderer.compile(n,aT)}_sceneToCubeUV(e,n,i,r){const o=new ts(90,1,n,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,p=d.toneMapping;d.getClearColor(tz),d.toneMapping=Du,d.autoClear=!1;const m=new e9({name:"PMREM.Background",side:ka,depthWrite:!1,depthTest:!1}),_=new po(new vx,m);let b=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,b=!0):(m.color.copy(tz),b=!0);for(let x=0;x<6;x++){const M=x%3;M===0?(o.up.set(0,l[x],0),o.lookAt(c[x],0,0)):M===1?(o.up.set(0,0,l[x]),o.lookAt(0,c[x],0)):(o.up.set(0,l[x],0),o.lookAt(0,0,c[x]));const w=this._cubeSize;nb(r,M*w,x>2?w:0,w,w),d.setRenderTarget(r),b&&d.render(_,o),d.render(e,o)}_.geometry.dispose(),_.material.dispose(),d.toneMapping=p,d.autoClear=f,e.background=v}_textureToCubeUV(e,n){const i=this._renderer,r=e.mapping===Lp||e.mapping===Ip;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=sz()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=az());const a=r?this._cubemapMaterial:this._equirectMaterial,s=new po(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;nb(n,0,0,3*l,2*l),i.setRenderTarget(n),i.render(s,aT)}_applyPMREM(e){const n=this._renderer,i=n.autoClear;n.autoClear=!1;for(let r=1;r<this._lodPlanes.length;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),s=nz[(r-1)%nz.length];this._blur(e,r-1,r,a,s)}n.autoClear=i}_blur(e,n,i,r,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,n,i,r,"latitudinal",a),this._halfBlur(s,e,i,i,r,"longitudinal",a)}_halfBlur(e,n,i,r,a,s,o){const l=this._renderer,c=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new po(this._lodPlanes[r],c),p=c.uniforms,m=this._sizeLods[i]-1,_=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Vd-1),b=a/_,v=isFinite(a)?1+Math.floor(d*b):Vd;v>Vd&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Vd}`);const x=[];let M=0;for(let N=0;N<Vd;++N){const U=N/b,R=Math.exp(-U*U/2);x.push(R),N===0?M+=R:N<v&&(M+=2*R)}for(let N=0;N<x.length;N++)x[N]=x[N]/M;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=x,p.latitudinal.value=s==="latitudinal",o&&(p.poleAxis.value=o);const{_lodMax:w}=this;p.dTheta.value=_,p.mipInt.value=w-i;const E=this._sizeLods[r],T=3*E*(r>w-dp?r-w+dp:0),P=4*(this._cubeSize-E);nb(n,T,P,3*E,2*E),l.setRenderTarget(n),l.render(f,aT)}}function U0e(t){const e=[],n=[],i=[];let r=t;const a=t-dp+1+ez.length;for(let s=0;s<a;s++){const o=Math.pow(2,r);n.push(o);let l=1/o;s>t-dp?l=ez[s-t+dp-1]:s===0&&(l=0),i.push(l);const c=1/(o-2),d=-c,f=1+c,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,_=6,b=3,v=2,x=1,M=new Float32Array(b*_*m),w=new Float32Array(v*_*m),E=new Float32Array(x*_*m);for(let P=0;P<m;P++){const N=P%3*2/3-1,U=P>2?0:-1,R=[N,U,0,N+2/3,U,0,N+2/3,U+1,0,N,U,0,N+2/3,U+1,0,N,U+1,0];M.set(R,b*_*P),w.set(p,v*_*P);const O=[P,P,P,P,P,P];E.set(O,x*_*P)}const T=new ia;T.setAttribute("position",new ss(M,b)),T.setAttribute("uv",new ss(w,v)),T.setAttribute("faceIndex",new ss(E,x)),e.push(T),r>dp&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}function rz(t,e,n){const i=new Sf(t,e,n);return i.texture.mapping=PS,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function nb(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function j0e(t,e,n){const i=new Float32Array(Vd),r=new Ae(0,1,0);return new Gu({name:"SphericalGaussianBlur",defines:{n:Vd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:TP(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Pu,depthTest:!1,depthWrite:!1})}function az(){return new Gu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:TP(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Pu,depthTest:!1,depthWrite:!1})}function sz(){return new Gu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:TP(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Pu,depthTest:!1,depthWrite:!1})}function TP(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function F0e(t){let e=new WeakMap,n=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===$N||l===GN,d=l===Lp||l===Ip;if(c||d)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new iz(t)),f=c?n.fromEquirectangular(o,f):n.fromCubemap(o,f),e.set(o,f),f.texture}else{if(e.has(o))return e.get(o).texture;{const f=o.image;if(c&&f&&f.height>0||d&&f&&r(f)){n===null&&(n=new iz(t));const p=c?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,p),o.addEventListener("dispose",a),p.texture}else return null}}}return o}function r(o){let l=0;const c=6;for(let d=0;d<c;d++)o[d]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function s(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:s}}function z0e(t){const e={};function n(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(i)}return e[i]=r,r}return{has:function(i){return n(i)!==null},init:function(i){i.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(i){const r=n(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function B0e(t,e,n,i){const r={},a=new WeakMap;function s(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const _ in p.attributes)e.remove(p.attributes[_]);for(const _ in p.morphAttributes){const b=p.morphAttributes[_];for(let v=0,x=b.length;v<x;v++)e.remove(b[v])}p.removeEventListener("dispose",s),delete r[p.id];const m=a.get(p);m&&(e.remove(m),a.delete(p)),i.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function o(f,p){return r[p.id]===!0||(p.addEventListener("dispose",s),r[p.id]=!0,n.memory.geometries++),p}function l(f){const p=f.attributes;for(const _ in p)e.update(p[_],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const _ in m){const b=m[_];for(let v=0,x=b.length;v<x;v++)e.update(b[v],t.ARRAY_BUFFER)}}function c(f){const p=[],m=f.index,_=f.attributes.position;let b=0;if(m!==null){const M=m.array;b=m.version;for(let w=0,E=M.length;w<E;w+=3){const T=M[w+0],P=M[w+1],N=M[w+2];p.push(T,P,P,N,N,T)}}else if(_!==void 0){const M=_.array;b=_.version;for(let w=0,E=M.length/3-1;w<E;w+=3){const T=w+0,P=w+1,N=w+2;p.push(T,P,P,N,N,T)}}else return;const v=new(XG(p)?n9:t9)(p,1);v.version=b;const x=a.get(f);x&&e.remove(x),a.set(f,v)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&c(f)}else c(f);return a.get(f)}return{get:o,update:l,getWireframeAttribute:d}}function H0e(t,e,n,i){const r=i.isWebGL2;let a;function s(m){a=m}let o,l;function c(m){o=m.type,l=m.bytesPerElement}function d(m,_){t.drawElements(a,_,o,m*l),n.update(_,a,1)}function f(m,_,b){if(b===0)return;let v,x;if(r)v=t,x="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[x](a,_,o,m*l,b),n.update(_,a,b)}function p(m,_,b){if(b===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<b;x++)this.render(m[x]/l,_[x]);else{v.multiDrawElementsWEBGL(a,_,0,o,m,0,b);let x=0;for(let M=0;M<b;M++)x+=_[M];n.update(x,a,1)}}this.setMode=s,this.setIndex=c,this.render=d,this.renderInstances=f,this.renderMultiDraw=p}function V0e(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function i(a,s,o){switch(n.calls++,s){case t.TRIANGLES:n.triangles+=o*(a/3);break;case t.LINES:n.lines+=o*(a/2);break;case t.LINE_STRIP:n.lines+=o*(a-1);break;case t.LINE_LOOP:n.lines+=o*a;break;case t.POINTS:n.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function r(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:r,update:i}}function $0e(t,e){return t[0]-e[0]}function G0e(t,e){return Math.abs(e[1])-Math.abs(t[1])}function W0e(t,e,n){const i={},r=new Float32Array(8),a=new WeakMap,s=new Vn,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,d,f){const p=c.morphTargetInfluences;if(e.isWebGL2===!0){const _=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,b=_!==void 0?_.length:0;let v=a.get(d);if(v===void 0||v.count!==b){let B=function(){G.dispose(),a.delete(d),d.removeEventListener("dispose",B)};var m=B;v!==void 0&&v.texture.dispose();const w=d.morphAttributes.position!==void 0,E=d.morphAttributes.normal!==void 0,T=d.morphAttributes.color!==void 0,P=d.morphAttributes.position||[],N=d.morphAttributes.normal||[],U=d.morphAttributes.color||[];let R=0;w===!0&&(R=1),E===!0&&(R=2),T===!0&&(R=3);let O=d.attributes.position.count*R,z=1;O>e.maxTextureSize&&(z=Math.ceil(O/e.maxTextureSize),O=e.maxTextureSize);const I=new Float32Array(O*z*4*b),G=new ZG(I,O,z,b);G.type=ql,G.needsUpdate=!0;const L=R*4;for(let q=0;q<b;q++){const W=P[q],X=N[q],Q=U[q],ie=O*z*4*q;for(let H=0;H<W.count;H++){const Y=H*L;w===!0&&(s.fromBufferAttribute(W,H),I[ie+Y+0]=s.x,I[ie+Y+1]=s.y,I[ie+Y+2]=s.z,I[ie+Y+3]=0),E===!0&&(s.fromBufferAttribute(X,H),I[ie+Y+4]=s.x,I[ie+Y+5]=s.y,I[ie+Y+6]=s.z,I[ie+Y+7]=0),T===!0&&(s.fromBufferAttribute(Q,H),I[ie+Y+8]=s.x,I[ie+Y+9]=s.y,I[ie+Y+10]=s.z,I[ie+Y+11]=Q.itemSize===4?s.w:1)}}v={count:b,texture:G,size:new Gt(O,z)},a.set(d,v),d.addEventListener("dispose",B)}let x=0;for(let w=0;w<p.length;w++)x+=p[w];const M=d.morphTargetsRelative?1:1-x;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",p),f.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const _=p===void 0?0:p.length;let b=i[d.id];if(b===void 0||b.length!==_){b=[];for(let E=0;E<_;E++)b[E]=[E,0];i[d.id]=b}for(let E=0;E<_;E++){const T=b[E];T[0]=E,T[1]=p[E]}b.sort(G0e);for(let E=0;E<8;E++)E<_&&b[E][1]?(o[E][0]=b[E][0],o[E][1]=b[E][1]):(o[E][0]=Number.MAX_SAFE_INTEGER,o[E][1]=0);o.sort($0e);const v=d.morphAttributes.position,x=d.morphAttributes.normal;let M=0;for(let E=0;E<8;E++){const T=o[E],P=T[0],N=T[1];P!==Number.MAX_SAFE_INTEGER&&N?(v&&d.getAttribute("morphTarget"+E)!==v[P]&&d.setAttribute("morphTarget"+E,v[P]),x&&d.getAttribute("morphNormal"+E)!==x[P]&&d.setAttribute("morphNormal"+E,x[P]),r[E]=N,M+=N):(v&&d.hasAttribute("morphTarget"+E)===!0&&d.deleteAttribute("morphTarget"+E),x&&d.hasAttribute("morphNormal"+E)===!0&&d.deleteAttribute("morphNormal"+E),r[E]=0)}const w=d.morphTargetsRelative?1:1-M;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",r)}}return{update:l}}function q0e(t,e,n,i){let r=new WeakMap;function a(l){const c=i.render.frame,d=l.geometry,f=e.get(l,d);if(r.get(f)!==c&&(e.update(f),r.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(n.update(l.instanceMatrix,t.ARRAY_BUFFER),l.instanceColor!==null&&n.update(l.instanceColor,t.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;r.get(p)!==c&&(p.update(),r.set(p,c))}return f}function s(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),n.remove(c.instanceMatrix),c.instanceColor!==null&&n.remove(c.instanceColor)}return{update:a,dispose:s}}class o9 extends La{constructor(e,n,i,r,a,s,o,l,c,d){if(d=d!==void 0?d:nf,d!==nf&&d!==Up)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&d===nf&&(i=Mu),i===void 0&&d===Up&&(i=tf),super(null,r,a,s,o,l,d,i,c),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Fr,this.minFilter=l!==void 0?l:Fr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const n=super.toJSON(e);return this.compareFunction!==null&&(n.compareFunction=this.compareFunction),n}}const l9=new La,c9=new o9(1,1);c9.compareFunction=WG;const u9=new ZG,d9=new Ppe,f9=new a9,oz=[],lz=[],cz=new Float32Array(16),uz=new Float32Array(9),dz=new Float32Array(4);function cm(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let a=oz[r];if(a===void 0&&(a=new Float32Array(r),oz[r]=a),e!==0){i.toArray(a,0);for(let s=1,o=0;s!==e;++s)o+=n,t[s].toArray(a,o)}return a}function ar(t,e){if(t.length!==e.length)return!1;for(let n=0,i=t.length;n<i;n++)if(t[n]!==e[n])return!1;return!0}function sr(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function kS(t,e){let n=lz[e];n===void 0&&(n=new Int32Array(e),lz[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function X0e(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function K0e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ar(n,e))return;t.uniform2fv(this.addr,e),sr(n,e)}}function Y0e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(ar(n,e))return;t.uniform3fv(this.addr,e),sr(n,e)}}function Z0e(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ar(n,e))return;t.uniform4fv(this.addr,e),sr(n,e)}}function Q0e(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(ar(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),sr(n,e)}else{if(ar(n,i))return;dz.set(i),t.uniformMatrix2fv(this.addr,!1,dz),sr(n,i)}}function J0e(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(ar(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),sr(n,e)}else{if(ar(n,i))return;uz.set(i),t.uniformMatrix3fv(this.addr,!1,uz),sr(n,i)}}function exe(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(ar(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),sr(n,e)}else{if(ar(n,i))return;cz.set(i),t.uniformMatrix4fv(this.addr,!1,cz),sr(n,i)}}function txe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function nxe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ar(n,e))return;t.uniform2iv(this.addr,e),sr(n,e)}}function ixe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ar(n,e))return;t.uniform3iv(this.addr,e),sr(n,e)}}function rxe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ar(n,e))return;t.uniform4iv(this.addr,e),sr(n,e)}}function axe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function sxe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(ar(n,e))return;t.uniform2uiv(this.addr,e),sr(n,e)}}function oxe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(ar(n,e))return;t.uniform3uiv(this.addr,e),sr(n,e)}}function lxe(t,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(ar(n,e))return;t.uniform4uiv(this.addr,e),sr(n,e)}}function cxe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r);const a=this.type===t.SAMPLER_2D_SHADOW?c9:l9;n.setTexture2D(e||a,r)}function uxe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||d9,r)}function dxe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||f9,r)}function fxe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||u9,r)}function hxe(t){switch(t){case 5126:return X0e;case 35664:return K0e;case 35665:return Y0e;case 35666:return Z0e;case 35674:return Q0e;case 35675:return J0e;case 35676:return exe;case 5124:case 35670:return txe;case 35667:case 35671:return nxe;case 35668:case 35672:return ixe;case 35669:case 35673:return rxe;case 5125:return axe;case 36294:return sxe;case 36295:return oxe;case 36296:return lxe;case 35678:case 36198:case 36298:case 36306:case 35682:return cxe;case 35679:case 36299:case 36307:return uxe;case 35680:case 36300:case 36308:case 36293:return dxe;case 36289:case 36303:case 36311:case 36292:return fxe}}function pxe(t,e){t.uniform1fv(this.addr,e)}function mxe(t,e){const n=cm(e,this.size,2);t.uniform2fv(this.addr,n)}function gxe(t,e){const n=cm(e,this.size,3);t.uniform3fv(this.addr,n)}function xxe(t,e){const n=cm(e,this.size,4);t.uniform4fv(this.addr,n)}function vxe(t,e){const n=cm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function yxe(t,e){const n=cm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function bxe(t,e){const n=cm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function _xe(t,e){t.uniform1iv(this.addr,e)}function Sxe(t,e){t.uniform2iv(this.addr,e)}function wxe(t,e){t.uniform3iv(this.addr,e)}function Mxe(t,e){t.uniform4iv(this.addr,e)}function Exe(t,e){t.uniform1uiv(this.addr,e)}function Axe(t,e){t.uniform2uiv(this.addr,e)}function Txe(t,e){t.uniform3uiv(this.addr,e)}function Cxe(t,e){t.uniform4uiv(this.addr,e)}function Nxe(t,e,n){const i=this.cache,r=e.length,a=kS(n,r);ar(i,a)||(t.uniform1iv(this.addr,a),sr(i,a));for(let s=0;s!==r;++s)n.setTexture2D(e[s]||l9,a[s])}function Rxe(t,e,n){const i=this.cache,r=e.length,a=kS(n,r);ar(i,a)||(t.uniform1iv(this.addr,a),sr(i,a));for(let s=0;s!==r;++s)n.setTexture3D(e[s]||d9,a[s])}function Pxe(t,e,n){const i=this.cache,r=e.length,a=kS(n,r);ar(i,a)||(t.uniform1iv(this.addr,a),sr(i,a));for(let s=0;s!==r;++s)n.setTextureCube(e[s]||f9,a[s])}function Dxe(t,e,n){const i=this.cache,r=e.length,a=kS(n,r);ar(i,a)||(t.uniform1iv(this.addr,a),sr(i,a));for(let s=0;s!==r;++s)n.setTexture2DArray(e[s]||u9,a[s])}function Oxe(t){switch(t){case 5126:return pxe;case 35664:return mxe;case 35665:return gxe;case 35666:return xxe;case 35674:return vxe;case 35675:return yxe;case 35676:return bxe;case 5124:case 35670:return _xe;case 35667:case 35671:return Sxe;case 35668:case 35672:return wxe;case 35669:case 35673:return Mxe;case 5125:return Exe;case 36294:return Axe;case 36295:return Txe;case 36296:return Cxe;case 35678:case 36198:case 36298:case 36306:case 35682:return Nxe;case 35679:case 36299:case 36307:return Rxe;case 35680:case 36300:case 36308:case 36293:return Pxe;case 36289:case 36303:case 36311:case 36292:return Dxe}}class kxe{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.setValue=hxe(n.type)}}class Lxe{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Oxe(n.type)}}class Ixe{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,i){const r=this.seq;for(let a=0,s=r.length;a!==s;++a){const o=r[a];o.setValue(e,n[o.id],i)}}}const cT=/(\w+)(\])?(\[|\.)?/g;function fz(t,e){t.seq.push(e),t.map[e.id]=e}function Uxe(t,e,n){const i=t.name,r=i.length;for(cT.lastIndex=0;;){const a=cT.exec(i),s=cT.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===r){fz(n,c===void 0?new kxe(o,t,e):new Lxe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new Ixe(o),fz(n,f)),n=f}}}class Jb{constructor(e,n){this.seq=[],this.map={};const i=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const a=e.getActiveUniform(n,r),s=e.getUniformLocation(n,a.name);Uxe(a,s,this)}}setValue(e,n,i,r){const a=this.map[n];a!==void 0&&a.setValue(e,i,r)}setOptional(e,n,i){const r=n[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,n,i,r){for(let a=0,s=n.length;a!==s;++a){const o=n[a],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,n){const i=[];for(let r=0,a=e.length;r!==a;++r){const s=e[r];s.id in n&&i.push(s)}return i}}function hz(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const jxe=37297;let Fxe=0;function zxe(t,e){const n=t.split(`
- `),i=[],r=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let s=r;s<a;s++){const o=s+1;i.push(`${o===e?">":" "} ${o}: ${n[s]}`)}return i.join(`
- `)}function Bxe(t){const e=Bn.getPrimaries(Bn.workingColorSpace),n=Bn.getPrimaries(t);let i;switch(e===n?i="":e===A_&&n===E_?i="LinearDisplayP3ToLinearSRGB":e===E_&&n===A_&&(i="LinearSRGBToLinearDisplayP3"),t){case uc:case DS:return[i,"LinearTransferOETF"];case zr:case SP:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[i,"LinearTransferOETF"]}}function pz(t,e,n){const i=t.getShaderParameter(e,t.COMPILE_STATUS),r=t.getShaderInfoLog(e).trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const s=parseInt(a[1]);return n.toUpperCase()+`
- `+r+`
- `+zxe(t.getShaderSource(e),s)}else return r}function Hxe(t,e){const n=Bxe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function Vxe(t,e){let n;switch(e){case Hhe:n="Linear";break;case Vhe:n="Reinhard";break;case $he:n="OptimizedCineon";break;case Ghe:n="ACESFilmic";break;case Whe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function $xe(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.normalMapTangentSpace||t.clearcoatNormalMap||t.flatShading||t.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Vg).join(`
- `)}function Gxe(t){const e=[];for(const n in t){const i=t[n];i!==!1&&e.push("#define "+n+" "+i)}return e.join(`
- `)}function Wxe(t,e){const n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const a=t.getActiveAttrib(e,r),s=a.name;let o=1;a.type===t.FLOAT_MAT2&&(o=2),a.type===t.FLOAT_MAT3&&(o=3),a.type===t.FLOAT_MAT4&&(o=4),n[s]={type:a.type,location:t.getAttribLocation(e,s),locationSize:o}}return n}function Vg(t){return t!==""}function mz(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function gz(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const qxe=/^[ \t]*#include +<([\w\d./]+)>/gm;function ZN(t){return t.replace(qxe,Kxe)}const Xxe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Kxe(t,e){let n=tn[e];if(n===void 0){const i=Xxe.get(e);if(i!==void 0)n=tn[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return ZN(n)}const Yxe=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function xz(t){return t.replace(Yxe,Zxe)}function Zxe(t,e,n,i){let r="";for(let a=parseInt(e);a<parseInt(n);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function vz(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function Qxe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===LG?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===ghe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Il&&(e="SHADOWMAP_TYPE_VSM"),e}function Jxe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Lp:case Ip:e="ENVMAP_TYPE_CUBE";break;case PS:e="ENVMAP_TYPE_CUBE_UV";break}return e}function eve(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Ip:e="ENVMAP_MODE_REFRACTION";break}return e}function tve(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case bP:e="ENVMAP_BLENDING_MULTIPLY";break;case zhe:e="ENVMAP_BLENDING_MIX";break;case Bhe:e="ENVMAP_BLENDING_ADD";break}return e}function nve(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}function ive(t,e,n,i){const r=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=Qxe(n),c=Jxe(n),d=eve(n),f=tve(n),p=nve(n),m=n.isWebGL2?"":$xe(n),_=Gxe(a),b=r.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(Vg).join(`
- `),v.length>0&&(v+=`
- `),x=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_].filter(Vg).join(`
- `),x.length>0&&(x+=`
- `)):(v=[vz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(Vg).join(`
- `),x=[m,vz(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,_,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Du?"#define TONE_MAPPING":"",n.toneMapping!==Du?tn.tonemapping_pars_fragment:"",n.toneMapping!==Du?Vxe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",tn.colorspace_pars_fragment,Hxe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(Vg).join(`
- `)),s=ZN(s),s=mz(s,n),s=gz(s,n),o=ZN(o),o=mz(o,n),o=gz(o,n),s=xz(s),o=xz(o),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,x=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===IF?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===IF?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
- `)+`
- `+x);const w=M+v+s,E=M+x+o,T=hz(r,r.VERTEX_SHADER,w),P=hz(r,r.FRAGMENT_SHADER,E);r.attachShader(b,T),r.attachShader(b,P),n.index0AttributeName!==void 0?r.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&r.bindAttribLocation(b,0,"position"),r.linkProgram(b);function N(z){if(t.debug.checkShaderErrors){const I=r.getProgramInfoLog(b).trim(),G=r.getShaderInfoLog(T).trim(),L=r.getShaderInfoLog(P).trim();let B=!0,q=!0;if(r.getProgramParameter(b,r.LINK_STATUS)===!1)if(B=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(r,b,T,P);else{const W=pz(r,T,"vertex"),X=pz(r,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(b,r.VALIDATE_STATUS)+`
- Program Info Log: `+I+`
- `+W+`
- `+X)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(G===""||L==="")&&(q=!1);q&&(z.diagnostics={runnable:B,programLog:I,vertexShader:{log:G,prefix:v},fragmentShader:{log:L,prefix:x}})}r.deleteShader(T),r.deleteShader(P),U=new Jb(r,b),R=Wxe(r,b)}let U;this.getUniforms=function(){return U===void 0&&N(this),U};let R;this.getAttributes=function(){return R===void 0&&N(this),R};let O=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return O===!1&&(O=r.getProgramParameter(b,jxe)),O},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Fxe++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=T,this.fragmentShader=P,this}let rve=0;class ave{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(n),a=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(r)===!1&&(s.add(r),r.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const i of n)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let i=n.get(e);return i===void 0&&(i=new Set,n.set(e,i)),i}_getShaderStage(e){const n=this.shaderCache;let i=n.get(e);return i===void 0&&(i=new sve(e),n.set(e,i)),i}}class sve{constructor(e){this.id=rve++,this.code=e,this.usedTimes=0}}function ove(t,e,n,i,r,a,s){const o=new QG,l=new ave,c=[],d=r.isWebGL2,f=r.logarithmicDepthBuffer,p=r.vertexTextures;let m=r.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function b(R){return R===0?"uv":`uv${R}`}function v(R,O,z,I,G){const L=I.fog,B=G.geometry,q=R.isMeshStandardMaterial?I.environment:null,W=(R.isMeshStandardMaterial?n:e).get(R.envMap||q),X=W&&W.mapping===PS?W.image.height:null,Q=_[R.type];R.precision!==null&&(m=r.getMaxPrecision(R.precision),m!==R.precision&&console.warn("THREE.WebGLProgram.getParameters:",R.precision,"not supported, using",m,"instead."));const ie=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,H=ie!==void 0?ie.length:0;let Y=0;B.morphAttributes.position!==void 0&&(Y=1),B.morphAttributes.normal!==void 0&&(Y=2),B.morphAttributes.color!==void 0&&(Y=3);let se,ue,xe,re;if(Q){const an=Ra[Q];se=an.vertexShader,ue=an.fragmentShader}else se=R.vertexShader,ue=R.fragmentShader,l.update(R),xe=l.getVertexShaderID(R),re=l.getFragmentShaderID(R);const ve=t.getRenderTarget(),Pe=G.isInstancedMesh===!0,pe=G.isBatchedMesh===!0,we=!!R.map,ze=!!R.matcap,ce=!!W,ft=!!R.aoMap,F=!!R.lightMap,$=!!R.bumpMap,ae=!!R.normalMap,J=!!R.displacementMap,ee=!!R.emissiveMap,oe=!!R.metalnessMap,De=!!R.roughnessMap,Ne=R.anisotropy>0,te=R.clearcoat>0,j=R.iridescence>0,k=R.sheen>0,K=R.transmission>0,me=Ne&&!!R.anisotropyMap,ye=te&&!!R.clearcoatMap,he=te&&!!R.clearcoatNormalMap,Ye=te&&!!R.clearcoatRoughnessMap,Le=j&&!!R.iridescenceMap,qe=j&&!!R.iridescenceThicknessMap,rt=k&&!!R.sheenColorMap,Ie=k&&!!R.sheenRoughnessMap,Re=!!R.specularMap,ht=!!R.specularColorMap,tt=!!R.specularIntensityMap,et=K&&!!R.transmissionMap,ct=K&&!!R.thicknessMap,de=!!R.gradientMap,nt=!!R.alphaMap,fe=R.alphaTest>0,ke=!!R.alphaHash,Me=!!R.extensions,ge=!!B.attributes.uv1,Be=!!B.attributes.uv2,lt=!!B.attributes.uv3;let bt=Du;return R.toneMapped&&(ve===null||ve.isXRRenderTarget===!0)&&(bt=t.toneMapping),{isWebGL2:d,shaderID:Q,shaderType:R.type,shaderName:R.name,vertexShader:se,fragmentShader:ue,defines:R.defines,customVertexShaderID:xe,customFragmentShaderID:re,isRawShaderMaterial:R.isRawShaderMaterial===!0,glslVersion:R.glslVersion,precision:m,batching:pe,instancing:Pe,instancingColor:Pe&&G.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:ve===null?t.outputColorSpace:ve.isXRRenderTarget===!0?ve.texture.colorSpace:uc,map:we,matcap:ze,envMap:ce,envMapMode:ce&&W.mapping,envMapCubeUVHeight:X,aoMap:ft,lightMap:F,bumpMap:$,normalMap:ae,displacementMap:p&&J,emissiveMap:ee,normalMapObjectSpace:ae&&R.normalMapType===rpe,normalMapTangentSpace:ae&&R.normalMapType===GG,metalnessMap:oe,roughnessMap:De,anisotropy:Ne,anisotropyMap:me,clearcoat:te,clearcoatMap:ye,clearcoatNormalMap:he,clearcoatRoughnessMap:Ye,iridescence:j,iridescenceMap:Le,iridescenceThicknessMap:qe,sheen:k,sheenColorMap:rt,sheenRoughnessMap:Ie,specularMap:Re,specularColorMap:ht,specularIntensityMap:tt,transmission:K,transmissionMap:et,thicknessMap:ct,gradientMap:de,opaque:R.transparent===!1&&R.blending===bp,alphaMap:nt,alphaTest:fe,alphaHash:ke,combine:R.combine,mapUv:we&&b(R.map.channel),aoMapUv:ft&&b(R.aoMap.channel),lightMapUv:F&&b(R.lightMap.channel),bumpMapUv:$&&b(R.bumpMap.channel),normalMapUv:ae&&b(R.normalMap.channel),displacementMapUv:J&&b(R.displacementMap.channel),emissiveMapUv:ee&&b(R.emissiveMap.channel),metalnessMapUv:oe&&b(R.metalnessMap.channel),roughnessMapUv:De&&b(R.roughnessMap.channel),anisotropyMapUv:me&&b(R.anisotropyMap.channel),clearcoatMapUv:ye&&b(R.clearcoatMap.channel),clearcoatNormalMapUv:he&&b(R.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ye&&b(R.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&b(R.iridescenceMap.channel),iridescenceThicknessMapUv:qe&&b(R.iridescenceThicknessMap.channel),sheenColorMapUv:rt&&b(R.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&b(R.sheenRoughnessMap.channel),specularMapUv:Re&&b(R.specularMap.channel),specularColorMapUv:ht&&b(R.specularColorMap.channel),specularIntensityMapUv:tt&&b(R.specularIntensityMap.channel),transmissionMapUv:et&&b(R.transmissionMap.channel),thicknessMapUv:ct&&b(R.thicknessMap.channel),alphaMapUv:nt&&b(R.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(ae||Ne),vertexColors:R.vertexColors,vertexAlphas:R.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,vertexUv1s:ge,vertexUv2s:Be,vertexUv3s:lt,pointsUvs:G.isPoints===!0&&!!B.attributes.uv&&(we||nt),fog:!!L,useFog:R.fog===!0,fogExp2:L&&L.isFogExp2,flatShading:R.flatShading===!0,sizeAttenuation:R.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:G.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:Y,numDirLights:O.directional.length,numPointLights:O.point.length,numSpotLights:O.spot.length,numSpotLightMaps:O.spotLightMap.length,numRectAreaLights:O.rectArea.length,numHemiLights:O.hemi.length,numDirLightShadows:O.directionalShadowMap.length,numPointLightShadows:O.pointShadowMap.length,numSpotLightShadows:O.spotShadowMap.length,numSpotLightShadowsWithMaps:O.numSpotLightShadowsWithMaps,numLightProbes:O.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:R.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:bt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:we&&R.map.isVideoTexture===!0&&Bn.getTransfer(R.map.colorSpace)===ti,premultipliedAlpha:R.premultipliedAlpha,doubleSided:R.side===Bl,flipSided:R.side===ka,useDepthPacking:R.depthPacking>=0,depthPacking:R.depthPacking||0,index0AttributeName:R.index0AttributeName,extensionDerivatives:Me&&R.extensions.derivatives===!0,extensionFragDepth:Me&&R.extensions.fragDepth===!0,extensionDrawBuffers:Me&&R.extensions.drawBuffers===!0,extensionShaderTextureLOD:Me&&R.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:R.customProgramCacheKey()}}function x(R){const O=[];if(R.shaderID?O.push(R.shaderID):(O.push(R.customVertexShaderID),O.push(R.customFragmentShaderID)),R.defines!==void 0)for(const z in R.defines)O.push(z),O.push(R.defines[z]);return R.isRawShaderMaterial===!1&&(M(O,R),w(O,R),O.push(t.outputColorSpace)),O.push(R.customProgramCacheKey),O.join()}function M(R,O){R.push(O.precision),R.push(O.outputColorSpace),R.push(O.envMapMode),R.push(O.envMapCubeUVHeight),R.push(O.mapUv),R.push(O.alphaMapUv),R.push(O.lightMapUv),R.push(O.aoMapUv),R.push(O.bumpMapUv),R.push(O.normalMapUv),R.push(O.displacementMapUv),R.push(O.emissiveMapUv),R.push(O.metalnessMapUv),R.push(O.roughnessMapUv),R.push(O.anisotropyMapUv),R.push(O.clearcoatMapUv),R.push(O.clearcoatNormalMapUv),R.push(O.clearcoatRoughnessMapUv),R.push(O.iridescenceMapUv),R.push(O.iridescenceThicknessMapUv),R.push(O.sheenColorMapUv),R.push(O.sheenRoughnessMapUv),R.push(O.specularMapUv),R.push(O.specularColorMapUv),R.push(O.specularIntensityMapUv),R.push(O.transmissionMapUv),R.push(O.thicknessMapUv),R.push(O.combine),R.push(O.fogExp2),R.push(O.sizeAttenuation),R.push(O.morphTargetsCount),R.push(O.morphAttributeCount),R.push(O.numDirLights),R.push(O.numPointLights),R.push(O.numSpotLights),R.push(O.numSpotLightMaps),R.push(O.numHemiLights),R.push(O.numRectAreaLights),R.push(O.numDirLightShadows),R.push(O.numPointLightShadows),R.push(O.numSpotLightShadows),R.push(O.numSpotLightShadowsWithMaps),R.push(O.numLightProbes),R.push(O.shadowMapType),R.push(O.toneMapping),R.push(O.numClippingPlanes),R.push(O.numClipIntersection),R.push(O.depthPacking)}function w(R,O){o.disableAll(),O.isWebGL2&&o.enable(0),O.supportsVertexTextures&&o.enable(1),O.instancing&&o.enable(2),O.instancingColor&&o.enable(3),O.matcap&&o.enable(4),O.envMap&&o.enable(5),O.normalMapObjectSpace&&o.enable(6),O.normalMapTangentSpace&&o.enable(7),O.clearcoat&&o.enable(8),O.iridescence&&o.enable(9),O.alphaTest&&o.enable(10),O.vertexColors&&o.enable(11),O.vertexAlphas&&o.enable(12),O.vertexUv1s&&o.enable(13),O.vertexUv2s&&o.enable(14),O.vertexUv3s&&o.enable(15),O.vertexTangents&&o.enable(16),O.anisotropy&&o.enable(17),O.alphaHash&&o.enable(18),O.batching&&o.enable(19),R.push(o.mask),o.disableAll(),O.fog&&o.enable(0),O.useFog&&o.enable(1),O.flatShading&&o.enable(2),O.logarithmicDepthBuffer&&o.enable(3),O.skinning&&o.enable(4),O.morphTargets&&o.enable(5),O.morphNormals&&o.enable(6),O.morphColors&&o.enable(7),O.premultipliedAlpha&&o.enable(8),O.shadowMapEnabled&&o.enable(9),O.useLegacyLights&&o.enable(10),O.doubleSided&&o.enable(11),O.flipSided&&o.enable(12),O.useDepthPacking&&o.enable(13),O.dithering&&o.enable(14),O.transmission&&o.enable(15),O.sheen&&o.enable(16),O.opaque&&o.enable(17),O.pointsUvs&&o.enable(18),O.decodeVideoTexture&&o.enable(19),R.push(o.mask)}function E(R){const O=_[R.type];let z;if(O){const I=Ra[O];z=EP.clone(I.uniforms)}else z=R.uniforms;return z}function T(R,O){let z;for(let I=0,G=c.length;I<G;I++){const L=c[I];if(L.cacheKey===O){z=L,++z.usedTimes;break}}return z===void 0&&(z=new ive(t,O,R,a),c.push(z)),z}function P(R){if(--R.usedTimes===0){const O=c.indexOf(R);c[O]=c[c.length-1],c.pop(),R.destroy()}}function N(R){l.remove(R)}function U(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:E,acquireProgram:T,releaseProgram:P,releaseShaderCache:N,programs:c,dispose:U}}function lve(){let t=new WeakMap;function e(a){let s=t.get(a);return s===void 0&&(s={},t.set(a,s)),s}function n(a){t.delete(a)}function i(a,s,o){t.get(a)[s]=o}function r(){t=new WeakMap}return{get:e,remove:n,update:i,dispose:r}}function cve(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function yz(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function bz(){const t=[];let e=0;const n=[],i=[],r=[];function a(){e=0,n.length=0,i.length=0,r.length=0}function s(f,p,m,_,b,v){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:p,material:m,groupOrder:_,renderOrder:f.renderOrder,z:b,group:v},t[e]=x):(x.id=f.id,x.object=f,x.geometry=p,x.material=m,x.groupOrder=_,x.renderOrder=f.renderOrder,x.z=b,x.group=v),e++,x}function o(f,p,m,_,b,v){const x=s(f,p,m,_,b,v);m.transmission>0?i.push(x):m.transparent===!0?r.push(x):n.push(x)}function l(f,p,m,_,b,v){const x=s(f,p,m,_,b,v);m.transmission>0?i.unshift(x):m.transparent===!0?r.unshift(x):n.unshift(x)}function c(f,p){n.length>1&&n.sort(f||cve),i.length>1&&i.sort(p||yz),r.length>1&&r.sort(p||yz)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:i,transparent:r,init:a,push:o,unshift:l,finish:d,sort:c}}function uve(){let t=new WeakMap;function e(i,r){const a=t.get(i);let s;return a===void 0?(s=new bz,t.set(i,[s])):r>=a.length?(s=new bz,a.push(s)):s=a[r],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function dve(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Ae,color:new Ft};break;case"SpotLight":n={position:new Ae,direction:new Ae,color:new Ft,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ae,color:new Ft,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ae,skyColor:new Ft,groundColor:new Ft};break;case"RectAreaLight":n={color:new Ft,position:new Ae,halfWidth:new Ae,halfHeight:new Ae};break}return t[e.id]=n,n}}}function fve(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Gt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Gt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Gt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let hve=0;function pve(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function mve(t,e){const n=new dve,i=fve(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)r.probe.push(new Ae);const a=new Ae,s=new Zn,o=new Zn;function l(d,f){let p=0,m=0,_=0;for(let I=0;I<9;I++)r.probe[I].set(0,0,0);let b=0,v=0,x=0,M=0,w=0,E=0,T=0,P=0,N=0,U=0,R=0;d.sort(pve);const O=f===!0?Math.PI:1;for(let I=0,G=d.length;I<G;I++){const L=d[I],B=L.color,q=L.intensity,W=L.distance,X=L.shadow&&L.shadow.map?L.shadow.map.texture:null;if(L.isAmbientLight)p+=B.r*q*O,m+=B.g*q*O,_+=B.b*q*O;else if(L.isLightProbe){for(let Q=0;Q<9;Q++)r.probe[Q].addScaledVector(L.sh.coefficients[Q],q);R++}else if(L.isDirectionalLight){const Q=n.get(L);if(Q.color.copy(L.color).multiplyScalar(L.intensity*O),L.castShadow){const ie=L.shadow,H=i.get(L);H.shadowBias=ie.bias,H.shadowNormalBias=ie.normalBias,H.shadowRadius=ie.radius,H.shadowMapSize=ie.mapSize,r.directionalShadow[b]=H,r.directionalShadowMap[b]=X,r.directionalShadowMatrix[b]=L.shadow.matrix,E++}r.directional[b]=Q,b++}else if(L.isSpotLight){const Q=n.get(L);Q.position.setFromMatrixPosition(L.matrixWorld),Q.color.copy(B).multiplyScalar(q*O),Q.distance=W,Q.coneCos=Math.cos(L.angle),Q.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),Q.decay=L.decay,r.spot[x]=Q;const ie=L.shadow;if(L.map&&(r.spotLightMap[N]=L.map,N++,ie.updateMatrices(L),L.castShadow&&U++),r.spotLightMatrix[x]=ie.matrix,L.castShadow){const H=i.get(L);H.shadowBias=ie.bias,H.shadowNormalBias=ie.normalBias,H.shadowRadius=ie.radius,H.shadowMapSize=ie.mapSize,r.spotShadow[x]=H,r.spotShadowMap[x]=X,P++}x++}else if(L.isRectAreaLight){const Q=n.get(L);Q.color.copy(B).multiplyScalar(q),Q.halfWidth.set(L.width*.5,0,0),Q.halfHeight.set(0,L.height*.5,0),r.rectArea[M]=Q,M++}else if(L.isPointLight){const Q=n.get(L);if(Q.color.copy(L.color).multiplyScalar(L.intensity*O),Q.distance=L.distance,Q.decay=L.decay,L.castShadow){const ie=L.shadow,H=i.get(L);H.shadowBias=ie.bias,H.shadowNormalBias=ie.normalBias,H.shadowRadius=ie.radius,H.shadowMapSize=ie.mapSize,H.shadowCameraNear=ie.camera.near,H.shadowCameraFar=ie.camera.far,r.pointShadow[v]=H,r.pointShadowMap[v]=X,r.pointShadowMatrix[v]=L.shadow.matrix,T++}r.point[v]=Q,v++}else if(L.isHemisphereLight){const Q=n.get(L);Q.skyColor.copy(L.color).multiplyScalar(q*O),Q.groundColor.copy(L.groundColor).multiplyScalar(q*O),r.hemi[w]=Q,w++}}M>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=yt.LTC_FLOAT_1,r.rectAreaLTC2=yt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=yt.LTC_HALF_1,r.rectAreaLTC2=yt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=p,r.ambient[1]=m,r.ambient[2]=_;const z=r.hash;(z.directionalLength!==b||z.pointLength!==v||z.spotLength!==x||z.rectAreaLength!==M||z.hemiLength!==w||z.numDirectionalShadows!==E||z.numPointShadows!==T||z.numSpotShadows!==P||z.numSpotMaps!==N||z.numLightProbes!==R)&&(r.directional.length=b,r.spot.length=x,r.rectArea.length=M,r.point.length=v,r.hemi.length=w,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=T,r.pointShadowMap.length=T,r.spotShadow.length=P,r.spotShadowMap.length=P,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=T,r.spotLightMatrix.length=P+N-U,r.spotLightMap.length=N,r.numSpotLightShadowsWithMaps=U,r.numLightProbes=R,z.directionalLength=b,z.pointLength=v,z.spotLength=x,z.rectAreaLength=M,z.hemiLength=w,z.numDirectionalShadows=E,z.numPointShadows=T,z.numSpotShadows=P,z.numSpotMaps=N,z.numLightProbes=R,r.version=hve++)}function c(d,f){let p=0,m=0,_=0,b=0,v=0;const x=f.matrixWorldInverse;for(let M=0,w=d.length;M<w;M++){const E=d[M];if(E.isDirectionalLight){const T=r.directional[p];T.direction.setFromMatrixPosition(E.matrixWorld),a.setFromMatrixPosition(E.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),p++}else if(E.isSpotLight){const T=r.spot[_];T.position.setFromMatrixPosition(E.matrixWorld),T.position.applyMatrix4(x),T.direction.setFromMatrixPosition(E.matrixWorld),a.setFromMatrixPosition(E.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),_++}else if(E.isRectAreaLight){const T=r.rectArea[b];T.position.setFromMatrixPosition(E.matrixWorld),T.position.applyMatrix4(x),o.identity(),s.copy(E.matrixWorld),s.premultiply(x),o.extractRotation(s),T.halfWidth.set(E.width*.5,0,0),T.halfHeight.set(0,E.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),b++}else if(E.isPointLight){const T=r.point[m];T.position.setFromMatrixPosition(E.matrixWorld),T.position.applyMatrix4(x),m++}else if(E.isHemisphereLight){const T=r.hemi[v];T.direction.setFromMatrixPosition(E.matrixWorld),T.direction.transformDirection(x),v++}}}return{setup:l,setupView:c,state:r}}function _z(t,e){const n=new mve(t,e),i=[],r=[];function a(){i.length=0,r.length=0}function s(f){i.push(f)}function o(f){r.push(f)}function l(f){n.setup(i,f)}function c(f){n.setupView(i,f)}return{init:a,state:{lightsArray:i,shadowsArray:r,lights:n},setupLights:l,setupLightsView:c,pushLight:s,pushShadow:o}}function gve(t,e){let n=new WeakMap;function i(a,s=0){const o=n.get(a);let l;return o===void 0?(l=new _z(t,e),n.set(a,[l])):s>=o.length?(l=new _z(t,e),o.push(l)):l=o[s],l}function r(){n=new WeakMap}return{get:i,dispose:r}}class xve extends lm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=npe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class vve extends lm{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const yve=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,bve=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function _ve(t,e,n){let i=new OS;const r=new Gt,a=new Gt,s=new Vn,o=new xve({depthPacking:ipe}),l=new vve,c={},d=n.maxTextureSize,f={[$u]:ka,[ka]:$u,[Bl]:Bl},p=new Gu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Gt},radius:{value:4}},vertexShader:yve,fragmentShader:bve}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const _=new ia;_.setAttribute("position",new ss(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new po(_,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=LG;let x=this.type;this.render=function(T,P,N){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const U=t.getRenderTarget(),R=t.getActiveCubeFace(),O=t.getActiveMipmapLevel(),z=t.state;z.setBlending(Pu),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const I=x!==Il&&this.type===Il,G=x===Il&&this.type!==Il;for(let L=0,B=T.length;L<B;L++){const q=T[L],W=q.shadow;if(W===void 0){console.warn("THREE.WebGLShadowMap:",q,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;r.copy(W.mapSize);const X=W.getFrameExtents();if(r.multiply(X),a.copy(W.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/X.x),r.x=a.x*X.x,W.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/X.y),r.y=a.y*X.y,W.mapSize.y=a.y)),W.map===null||I===!0||G===!0){const ie=this.type!==Il?{minFilter:Fr,magFilter:Fr}:{};W.map!==null&&W.map.dispose(),W.map=new Sf(r.x,r.y,ie),W.map.texture.name=q.name+".shadowMap",W.camera.updateProjectionMatrix()}t.setRenderTarget(W.map),t.clear();const Q=W.getViewportCount();for(let ie=0;ie<Q;ie++){const H=W.getViewport(ie);s.set(a.x*H.x,a.y*H.y,a.x*H.z,a.y*H.w),z.viewport(s),W.updateMatrices(q,ie),i=W.getFrustum(),E(P,N,W.camera,q,this.type)}W.isPointLightShadow!==!0&&this.type===Il&&M(W,N),W.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(U,R,O)};function M(T,P){const N=e.update(b);p.defines.VSM_SAMPLES!==T.blurSamples&&(p.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Sf(r.x,r.y)),p.uniforms.shadow_pass.value=T.map.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(P,null,N,p,b,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(P,null,N,m,b,null)}function w(T,P,N,U){let R=null;const O=N.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(O!==void 0)R=O;else if(R=N.isPointLight===!0?l:o,t.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0){const z=R.uuid,I=P.uuid;let G=c[z];G===void 0&&(G={},c[z]=G);let L=G[I];L===void 0&&(L=R.clone(),G[I]=L),R=L}if(R.visible=P.visible,R.wireframe=P.wireframe,U===Il?R.side=P.shadowSide!==null?P.shadowSide:P.side:R.side=P.shadowSide!==null?P.shadowSide:f[P.side],R.alphaMap=P.alphaMap,R.alphaTest=P.alphaTest,R.map=P.map,R.clipShadows=P.clipShadows,R.clippingPlanes=P.clippingPlanes,R.clipIntersection=P.clipIntersection,R.displacementMap=P.displacementMap,R.displacementScale=P.displacementScale,R.displacementBias=P.displacementBias,R.wireframeLinewidth=P.wireframeLinewidth,R.linewidth=P.linewidth,N.isPointLight===!0&&R.isMeshDistanceMaterial===!0){const z=t.properties.get(R);z.light=N}return R}function E(T,P,N,U,R){if(T.visible===!1)return;if(T.layers.test(P.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&R===Il)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const I=e.update(T),G=T.material;if(Array.isArray(G)){const L=I.groups;for(let B=0,q=L.length;B<q;B++){const W=L[B],X=G[W.materialIndex];if(X&&X.visible){const Q=w(T,X,U,R);T.onBeforeShadow(t,T,P,N,I,Q,W),t.renderBufferDirect(N,null,I,Q,T,W),T.onAfterShadow(t,T,P,N,I,Q,W)}}}else if(G.visible){const L=w(T,G,U,R);T.onBeforeShadow(t,T,P,N,I,L,null),t.renderBufferDirect(N,null,I,L,T,null),T.onAfterShadow(t,T,P,N,I,L,null)}}const z=T.children;for(let I=0,G=z.length;I<G;I++)E(z[I],P,N,U,R)}}function Sve(t,e,n){const i=n.isWebGL2;function r(){let fe=!1;const ke=new Vn;let Me=null;const ge=new Vn(0,0,0,0);return{setMask:function(Be){Me!==Be&&!fe&&(t.colorMask(Be,Be,Be,Be),Me=Be)},setLocked:function(Be){fe=Be},setClear:function(Be,lt,bt,Nt,an){an===!0&&(Be*=Nt,lt*=Nt,bt*=Nt),ke.set(Be,lt,bt,Nt),ge.equals(ke)===!1&&(t.clearColor(Be,lt,bt,Nt),ge.copy(ke))},reset:function(){fe=!1,Me=null,ge.set(-1,0,0,0)}}}function a(){let fe=!1,ke=null,Me=null,ge=null;return{setTest:function(Be){Be?pe(t.DEPTH_TEST):we(t.DEPTH_TEST)},setMask:function(Be){ke!==Be&&!fe&&(t.depthMask(Be),ke=Be)},setFunc:function(Be){if(Me!==Be){switch(Be){case Ohe:t.depthFunc(t.NEVER);break;case khe:t.depthFunc(t.ALWAYS);break;case Lhe:t.depthFunc(t.LESS);break;case w_:t.depthFunc(t.LEQUAL);break;case Ihe:t.depthFunc(t.EQUAL);break;case Uhe:t.depthFunc(t.GEQUAL);break;case jhe:t.depthFunc(t.GREATER);break;case Fhe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Me=Be}},setLocked:function(Be){fe=Be},setClear:function(Be){ge!==Be&&(t.clearDepth(Be),ge=Be)},reset:function(){fe=!1,ke=null,Me=null,ge=null}}}function s(){let fe=!1,ke=null,Me=null,ge=null,Be=null,lt=null,bt=null,Nt=null,an=null;return{setTest:function(Dt){fe||(Dt?pe(t.STENCIL_TEST):we(t.STENCIL_TEST))},setMask:function(Dt){ke!==Dt&&!fe&&(t.stencilMask(Dt),ke=Dt)},setFunc:function(Dt,Nn,Gn){(Me!==Dt||ge!==Nn||Be!==Gn)&&(t.stencilFunc(Dt,Nn,Gn),Me=Dt,ge=Nn,Be=Gn)},setOp:function(Dt,Nn,Gn){(lt!==Dt||bt!==Nn||Nt!==Gn)&&(t.stencilOp(Dt,Nn,Gn),lt=Dt,bt=Nn,Nt=Gn)},setLocked:function(Dt){fe=Dt},setClear:function(Dt){an!==Dt&&(t.clearStencil(Dt),an=Dt)},reset:function(){fe=!1,ke=null,Me=null,ge=null,Be=null,lt=null,bt=null,Nt=null,an=null}}}const o=new r,l=new a,c=new s,d=new WeakMap,f=new WeakMap;let p={},m={},_=new WeakMap,b=[],v=null,x=!1,M=null,w=null,E=null,T=null,P=null,N=null,U=null,R=new Ft(0,0,0),O=0,z=!1,I=null,G=null,L=null,B=null,q=null;const W=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,Q=0;const ie=t.getParameter(t.VERSION);ie.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(ie)[1]),X=Q>=1):ie.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),X=Q>=2);let H=null,Y={};const se=t.getParameter(t.SCISSOR_BOX),ue=t.getParameter(t.VIEWPORT),xe=new Vn().fromArray(se),re=new Vn().fromArray(ue);function ve(fe,ke,Me,ge){const Be=new Uint8Array(4),lt=t.createTexture();t.bindTexture(fe,lt),t.texParameteri(fe,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(fe,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let bt=0;bt<Me;bt++)i&&(fe===t.TEXTURE_3D||fe===t.TEXTURE_2D_ARRAY)?t.texImage3D(ke,0,t.RGBA,1,1,ge,0,t.RGBA,t.UNSIGNED_BYTE,Be):t.texImage2D(ke+bt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Be);return lt}const Pe={};Pe[t.TEXTURE_2D]=ve(t.TEXTURE_2D,t.TEXTURE_2D,1),Pe[t.TEXTURE_CUBE_MAP]=ve(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(Pe[t.TEXTURE_2D_ARRAY]=ve(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Pe[t.TEXTURE_3D]=ve(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),pe(t.DEPTH_TEST),l.setFunc(w_),ee(!1),oe(iF),pe(t.CULL_FACE),ae(Pu);function pe(fe){p[fe]!==!0&&(t.enable(fe),p[fe]=!0)}function we(fe){p[fe]!==!1&&(t.disable(fe),p[fe]=!1)}function ze(fe,ke){return m[fe]!==ke?(t.bindFramebuffer(fe,ke),m[fe]=ke,i&&(fe===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=ke),fe===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=ke)),!0):!1}function ce(fe,ke){let Me=b,ge=!1;if(fe)if(Me=_.get(ke),Me===void 0&&(Me=[],_.set(ke,Me)),fe.isWebGLMultipleRenderTargets){const Be=fe.texture;if(Me.length!==Be.length||Me[0]!==t.COLOR_ATTACHMENT0){for(let lt=0,bt=Be.length;lt<bt;lt++)Me[lt]=t.COLOR_ATTACHMENT0+lt;Me.length=Be.length,ge=!0}}else Me[0]!==t.COLOR_ATTACHMENT0&&(Me[0]=t.COLOR_ATTACHMENT0,ge=!0);else Me[0]!==t.BACK&&(Me[0]=t.BACK,ge=!0);ge&&(n.isWebGL2?t.drawBuffers(Me):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function ft(fe){return v!==fe?(t.useProgram(fe),v=fe,!0):!1}const F={[Hd]:t.FUNC_ADD,[vhe]:t.FUNC_SUBTRACT,[yhe]:t.FUNC_REVERSE_SUBTRACT};if(i)F[oF]=t.MIN,F[lF]=t.MAX;else{const fe=e.get("EXT_blend_minmax");fe!==null&&(F[oF]=fe.MIN_EXT,F[lF]=fe.MAX_EXT)}const $={[bhe]:t.ZERO,[_he]:t.ONE,[She]:t.SRC_COLOR,[HN]:t.SRC_ALPHA,[Che]:t.SRC_ALPHA_SATURATE,[Ahe]:t.DST_COLOR,[Mhe]:t.DST_ALPHA,[whe]:t.ONE_MINUS_SRC_COLOR,[VN]:t.ONE_MINUS_SRC_ALPHA,[The]:t.ONE_MINUS_DST_COLOR,[Ehe]:t.ONE_MINUS_DST_ALPHA,[Nhe]:t.CONSTANT_COLOR,[Rhe]:t.ONE_MINUS_CONSTANT_COLOR,[Phe]:t.CONSTANT_ALPHA,[Dhe]:t.ONE_MINUS_CONSTANT_ALPHA};function ae(fe,ke,Me,ge,Be,lt,bt,Nt,an,Dt){if(fe===Pu){x===!0&&(we(t.BLEND),x=!1);return}if(x===!1&&(pe(t.BLEND),x=!0),fe!==xhe){if(fe!==M||Dt!==z){if((w!==Hd||P!==Hd)&&(t.blendEquation(t.FUNC_ADD),w=Hd,P=Hd),Dt)switch(fe){case bp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case rF:t.blendFunc(t.ONE,t.ONE);break;case aF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case sF:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",fe);break}else switch(fe){case bp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case rF:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case aF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case sF:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",fe);break}E=null,T=null,N=null,U=null,R.set(0,0,0),O=0,M=fe,z=Dt}return}Be=Be||ke,lt=lt||Me,bt=bt||ge,(ke!==w||Be!==P)&&(t.blendEquationSeparate(F[ke],F[Be]),w=ke,P=Be),(Me!==E||ge!==T||lt!==N||bt!==U)&&(t.blendFuncSeparate($[Me],$[ge],$[lt],$[bt]),E=Me,T=ge,N=lt,U=bt),(Nt.equals(R)===!1||an!==O)&&(t.blendColor(Nt.r,Nt.g,Nt.b,an),R.copy(Nt),O=an),M=fe,z=!1}function J(fe,ke){fe.side===Bl?we(t.CULL_FACE):pe(t.CULL_FACE);let Me=fe.side===ka;ke&&(Me=!Me),ee(Me),fe.blending===bp&&fe.transparent===!1?ae(Pu):ae(fe.blending,fe.blendEquation,fe.blendSrc,fe.blendDst,fe.blendEquationAlpha,fe.blendSrcAlpha,fe.blendDstAlpha,fe.blendColor,fe.blendAlpha,fe.premultipliedAlpha),l.setFunc(fe.depthFunc),l.setTest(fe.depthTest),l.setMask(fe.depthWrite),o.setMask(fe.colorWrite);const ge=fe.stencilWrite;c.setTest(ge),ge&&(c.setMask(fe.stencilWriteMask),c.setFunc(fe.stencilFunc,fe.stencilRef,fe.stencilFuncMask),c.setOp(fe.stencilFail,fe.stencilZFail,fe.stencilZPass)),Ne(fe.polygonOffset,fe.polygonOffsetFactor,fe.polygonOffsetUnits),fe.alphaToCoverage===!0?pe(t.SAMPLE_ALPHA_TO_COVERAGE):we(t.SAMPLE_ALPHA_TO_COVERAGE)}function ee(fe){I!==fe&&(fe?t.frontFace(t.CW):t.frontFace(t.CCW),I=fe)}function oe(fe){fe!==phe?(pe(t.CULL_FACE),fe!==G&&(fe===iF?t.cullFace(t.BACK):fe===mhe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):we(t.CULL_FACE),G=fe}function De(fe){fe!==L&&(X&&t.lineWidth(fe),L=fe)}function Ne(fe,ke,Me){fe?(pe(t.POLYGON_OFFSET_FILL),(B!==ke||q!==Me)&&(t.polygonOffset(ke,Me),B=ke,q=Me)):we(t.POLYGON_OFFSET_FILL)}function te(fe){fe?pe(t.SCISSOR_TEST):we(t.SCISSOR_TEST)}function j(fe){fe===void 0&&(fe=t.TEXTURE0+W-1),H!==fe&&(t.activeTexture(fe),H=fe)}function k(fe,ke,Me){Me===void 0&&(H===null?Me=t.TEXTURE0+W-1:Me=H);let ge=Y[Me];ge===void 0&&(ge={type:void 0,texture:void 0},Y[Me]=ge),(ge.type!==fe||ge.texture!==ke)&&(H!==Me&&(t.activeTexture(Me),H=Me),t.bindTexture(fe,ke||Pe[fe]),ge.type=fe,ge.texture=ke)}function K(){const fe=Y[H];fe!==void 0&&fe.type!==void 0&&(t.bindTexture(fe.type,null),fe.type=void 0,fe.texture=void 0)}function me(){try{t.compressedTexImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function ye(){try{t.compressedTexImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function he(){try{t.texSubImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Ye(){try{t.texSubImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Le(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function qe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function rt(){try{t.texStorage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Ie(){try{t.texStorage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Re(){try{t.texImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function ht(){try{t.texImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function tt(fe){xe.equals(fe)===!1&&(t.scissor(fe.x,fe.y,fe.z,fe.w),xe.copy(fe))}function et(fe){re.equals(fe)===!1&&(t.viewport(fe.x,fe.y,fe.z,fe.w),re.copy(fe))}function ct(fe,ke){let Me=f.get(ke);Me===void 0&&(Me=new WeakMap,f.set(ke,Me));let ge=Me.get(fe);ge===void 0&&(ge=t.getUniformBlockIndex(ke,fe.name),Me.set(fe,ge))}function de(fe,ke){const ge=f.get(ke).get(fe);d.get(ke)!==ge&&(t.uniformBlockBinding(ke,ge,fe.__bindingPointIndex),d.set(ke,ge))}function nt(){t.disable(t.BLEND),t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.disable(t.SAMPLE_ALPHA_TO_COVERAGE),t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO),t.blendFuncSeparate(t.ONE,t.ZERO,t.ONE,t.ZERO),t.blendColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(t.LESS),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),i===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),p={},H=null,Y={},m={},_=new WeakMap,b=[],v=null,x=!1,M=null,w=null,E=null,T=null,P=null,N=null,U=null,R=new Ft(0,0,0),O=0,z=!1,I=null,G=null,L=null,B=null,q=null,xe.set(0,0,t.canvas.width,t.canvas.height),re.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:pe,disable:we,bindFramebuffer:ze,drawBuffers:ce,useProgram:ft,setBlending:ae,setMaterial:J,setFlipSided:ee,setCullFace:oe,setLineWidth:De,setPolygonOffset:Ne,setScissorTest:te,activeTexture:j,bindTexture:k,unbindTexture:K,compressedTexImage2D:me,compressedTexImage3D:ye,texImage2D:Re,texImage3D:ht,updateUBOMapping:ct,uniformBlockBinding:de,texStorage2D:rt,texStorage3D:Ie,texSubImage2D:he,texSubImage3D:Ye,compressedTexSubImage2D:Le,compressedTexSubImage3D:qe,scissor:tt,viewport:et,reset:nt}}function wve(t,e,n,i,r,a,s){const o=r.isWebGL2,l=r.maxTextures,c=r.maxCubemapSize,d=r.maxTextureSize,f=r.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),_=new WeakMap;let b;const v=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(j,k){return x?new OffscreenCanvas(j,k):C_("canvas")}function w(j,k,K,me){let ye=1;if((j.width>me||j.height>me)&&(ye=me/Math.max(j.width,j.height)),ye<1||k===!0)if(typeof HTMLImageElement<"u"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&j instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&j instanceof ImageBitmap){const he=k?T_:Math.floor,Ye=he(ye*j.width),Le=he(ye*j.height);b===void 0&&(b=M(Ye,Le));const qe=K?M(Ye,Le):b;return qe.width=Ye,qe.height=Le,qe.getContext("2d").drawImage(j,0,0,Ye,Le),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+j.width+"x"+j.height+") to ("+Ye+"x"+Le+")."),qe}else return"data"in j&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+j.width+"x"+j.height+")."),j;return j}function E(j){return YN(j.width)&&YN(j.height)}function T(j){return o?!1:j.wrapS!==oo||j.wrapT!==oo||j.minFilter!==Fr&&j.minFilter!==ks}function P(j,k){return j.generateMipmaps&&k&&j.minFilter!==Fr&&j.minFilter!==ks}function N(j){t.generateMipmap(j)}function U(j,k,K,me,ye=!1){if(o===!1)return k;if(j!==null){if(t[j]!==void 0)return t[j];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+j+"'")}let he=k;if(k===t.RED&&(K===t.FLOAT&&(he=t.R32F),K===t.HALF_FLOAT&&(he=t.R16F),K===t.UNSIGNED_BYTE&&(he=t.R8)),k===t.RED_INTEGER&&(K===t.UNSIGNED_BYTE&&(he=t.R8UI),K===t.UNSIGNED_SHORT&&(he=t.R16UI),K===t.UNSIGNED_INT&&(he=t.R32UI),K===t.BYTE&&(he=t.R8I),K===t.SHORT&&(he=t.R16I),K===t.INT&&(he=t.R32I)),k===t.RG&&(K===t.FLOAT&&(he=t.RG32F),K===t.HALF_FLOAT&&(he=t.RG16F),K===t.UNSIGNED_BYTE&&(he=t.RG8)),k===t.RGBA){const Ye=ye?M_:Bn.getTransfer(me);K===t.FLOAT&&(he=t.RGBA32F),K===t.HALF_FLOAT&&(he=t.RGBA16F),K===t.UNSIGNED_BYTE&&(he=Ye===ti?t.SRGB8_ALPHA8:t.RGBA8),K===t.UNSIGNED_SHORT_4_4_4_4&&(he=t.RGBA4),K===t.UNSIGNED_SHORT_5_5_5_1&&(he=t.RGB5_A1)}return(he===t.R16F||he===t.R32F||he===t.RG16F||he===t.RG32F||he===t.RGBA16F||he===t.RGBA32F)&&e.get("EXT_color_buffer_float"),he}function R(j,k,K){return P(j,K)===!0||j.isFramebufferTexture&&j.minFilter!==Fr&&j.minFilter!==ks?Math.log2(Math.max(k.width,k.height))+1:j.mipmaps!==void 0&&j.mipmaps.length>0?j.mipmaps.length:j.isCompressedTexture&&Array.isArray(j.image)?k.mipmaps.length:1}function O(j){return j===Fr||j===cF||j===IA?t.NEAREST:t.LINEAR}function z(j){const k=j.target;k.removeEventListener("dispose",z),G(k),k.isVideoTexture&&_.delete(k)}function I(j){const k=j.target;k.removeEventListener("dispose",I),B(k)}function G(j){const k=i.get(j);if(k.__webglInit===void 0)return;const K=j.source,me=v.get(K);if(me){const ye=me[k.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&L(j),Object.keys(me).length===0&&v.delete(K)}i.remove(j)}function L(j){const k=i.get(j);t.deleteTexture(k.__webglTexture);const K=j.source,me=v.get(K);delete me[k.__cacheKey],s.memory.textures--}function B(j){const k=j.texture,K=i.get(j),me=i.get(k);if(me.__webglTexture!==void 0&&(t.deleteTexture(me.__webglTexture),s.memory.textures--),j.depthTexture&&j.depthTexture.dispose(),j.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(K.__webglFramebuffer[ye]))for(let he=0;he<K.__webglFramebuffer[ye].length;he++)t.deleteFramebuffer(K.__webglFramebuffer[ye][he]);else t.deleteFramebuffer(K.__webglFramebuffer[ye]);K.__webglDepthbuffer&&t.deleteRenderbuffer(K.__webglDepthbuffer[ye])}else{if(Array.isArray(K.__webglFramebuffer))for(let ye=0;ye<K.__webglFramebuffer.length;ye++)t.deleteFramebuffer(K.__webglFramebuffer[ye]);else t.deleteFramebuffer(K.__webglFramebuffer);if(K.__webglDepthbuffer&&t.deleteRenderbuffer(K.__webglDepthbuffer),K.__webglMultisampledFramebuffer&&t.deleteFramebuffer(K.__webglMultisampledFramebuffer),K.__webglColorRenderbuffer)for(let ye=0;ye<K.__webglColorRenderbuffer.length;ye++)K.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(K.__webglColorRenderbuffer[ye]);K.__webglDepthRenderbuffer&&t.deleteRenderbuffer(K.__webglDepthRenderbuffer)}if(j.isWebGLMultipleRenderTargets)for(let ye=0,he=k.length;ye<he;ye++){const Ye=i.get(k[ye]);Ye.__webglTexture&&(t.deleteTexture(Ye.__webglTexture),s.memory.textures--),i.remove(k[ye])}i.remove(k),i.remove(j)}let q=0;function W(){q=0}function X(){const j=q;return j>=l&&console.warn("THREE.WebGLTextures: Trying to use "+j+" texture units while this GPU supports only "+l),q+=1,j}function Q(j){const k=[];return k.push(j.wrapS),k.push(j.wrapT),k.push(j.wrapR||0),k.push(j.magFilter),k.push(j.minFilter),k.push(j.anisotropy),k.push(j.internalFormat),k.push(j.format),k.push(j.type),k.push(j.generateMipmaps),k.push(j.premultiplyAlpha),k.push(j.flipY),k.push(j.unpackAlignment),k.push(j.colorSpace),k.join()}function ie(j,k){const K=i.get(j);if(j.isVideoTexture&&Ne(j),j.isRenderTargetTexture===!1&&j.version>0&&K.__version!==j.version){const me=j.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{pe(K,j,k);return}}n.bindTexture(t.TEXTURE_2D,K.__webglTexture,t.TEXTURE0+k)}function H(j,k){const K=i.get(j);if(j.version>0&&K.__version!==j.version){pe(K,j,k);return}n.bindTexture(t.TEXTURE_2D_ARRAY,K.__webglTexture,t.TEXTURE0+k)}function Y(j,k){const K=i.get(j);if(j.version>0&&K.__version!==j.version){pe(K,j,k);return}n.bindTexture(t.TEXTURE_3D,K.__webglTexture,t.TEXTURE0+k)}function se(j,k){const K=i.get(j);if(j.version>0&&K.__version!==j.version){we(K,j,k);return}n.bindTexture(t.TEXTURE_CUBE_MAP,K.__webglTexture,t.TEXTURE0+k)}const ue={[WN]:t.REPEAT,[oo]:t.CLAMP_TO_EDGE,[qN]:t.MIRRORED_REPEAT},xe={[Fr]:t.NEAREST,[cF]:t.NEAREST_MIPMAP_NEAREST,[IA]:t.NEAREST_MIPMAP_LINEAR,[ks]:t.LINEAR,[qhe]:t.LINEAR_MIPMAP_NEAREST,[P0]:t.LINEAR_MIPMAP_LINEAR},re={[ape]:t.NEVER,[dpe]:t.ALWAYS,[spe]:t.LESS,[WG]:t.LEQUAL,[ope]:t.EQUAL,[upe]:t.GEQUAL,[lpe]:t.GREATER,[cpe]:t.NOTEQUAL};function ve(j,k,K){if(K?(t.texParameteri(j,t.TEXTURE_WRAP_S,ue[k.wrapS]),t.texParameteri(j,t.TEXTURE_WRAP_T,ue[k.wrapT]),(j===t.TEXTURE_3D||j===t.TEXTURE_2D_ARRAY)&&t.texParameteri(j,t.TEXTURE_WRAP_R,ue[k.wrapR]),t.texParameteri(j,t.TEXTURE_MAG_FILTER,xe[k.magFilter]),t.texParameteri(j,t.TEXTURE_MIN_FILTER,xe[k.minFilter])):(t.texParameteri(j,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(j,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(j===t.TEXTURE_3D||j===t.TEXTURE_2D_ARRAY)&&t.texParameteri(j,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(k.wrapS!==oo||k.wrapT!==oo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(j,t.TEXTURE_MAG_FILTER,O(k.magFilter)),t.texParameteri(j,t.TEXTURE_MIN_FILTER,O(k.minFilter)),k.minFilter!==Fr&&k.minFilter!==ks&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),k.compareFunction&&(t.texParameteri(j,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(j,t.TEXTURE_COMPARE_FUNC,re[k.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const me=e.get("EXT_texture_filter_anisotropic");if(k.magFilter===Fr||k.minFilter!==IA&&k.minFilter!==P0||k.type===ql&&e.has("OES_texture_float_linear")===!1||o===!1&&k.type===D0&&e.has("OES_texture_half_float_linear")===!1)return;(k.anisotropy>1||i.get(k).__currentAnisotropy)&&(t.texParameterf(j,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(k.anisotropy,r.getMaxAnisotropy())),i.get(k).__currentAnisotropy=k.anisotropy)}}function Pe(j,k){let K=!1;j.__webglInit===void 0&&(j.__webglInit=!0,k.addEventListener("dispose",z));const me=k.source;let ye=v.get(me);ye===void 0&&(ye={},v.set(me,ye));const he=Q(k);if(he!==j.__cacheKey){ye[he]===void 0&&(ye[he]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,K=!0),ye[he].usedTimes++;const Ye=ye[j.__cacheKey];Ye!==void 0&&(ye[j.__cacheKey].usedTimes--,Ye.usedTimes===0&&L(k)),j.__cacheKey=he,j.__webglTexture=ye[he].texture}return K}function pe(j,k,K){let me=t.TEXTURE_2D;(k.isDataArrayTexture||k.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),k.isData3DTexture&&(me=t.TEXTURE_3D);const ye=Pe(j,k),he=k.source;n.bindTexture(me,j.__webglTexture,t.TEXTURE0+K);const Ye=i.get(he);if(he.version!==Ye.__version||ye===!0){n.activeTexture(t.TEXTURE0+K);const Le=Bn.getPrimaries(Bn.workingColorSpace),qe=k.colorSpace===Is?null:Bn.getPrimaries(k.colorSpace),rt=k.colorSpace===Is||Le===qe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,k.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,k.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,rt);const Ie=T(k)&&E(k.image)===!1;let Re=w(k.image,Ie,!1,d);Re=te(k,Re);const ht=E(Re)||o,tt=a.convert(k.format,k.colorSpace);let et=a.convert(k.type),ct=U(k.internalFormat,tt,et,k.colorSpace,k.isVideoTexture);ve(me,k,ht);let de;const nt=k.mipmaps,fe=o&&k.isVideoTexture!==!0&&ct!==VG,ke=Ye.__version===void 0||ye===!0,Me=R(k,Re,ht);if(k.isDepthTexture)ct=t.DEPTH_COMPONENT,o?k.type===ql?ct=t.DEPTH_COMPONENT32F:k.type===Mu?ct=t.DEPTH_COMPONENT24:k.type===tf?ct=t.DEPTH24_STENCIL8:ct=t.DEPTH_COMPONENT16:k.type===ql&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),k.format===nf&&ct===t.DEPTH_COMPONENT&&k.type!==_P&&k.type!==Mu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),k.type=Mu,et=a.convert(k.type)),k.format===Up&&ct===t.DEPTH_COMPONENT&&(ct=t.DEPTH_STENCIL,k.type!==tf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),k.type=tf,et=a.convert(k.type))),ke&&(fe?n.texStorage2D(t.TEXTURE_2D,1,ct,Re.width,Re.height):n.texImage2D(t.TEXTURE_2D,0,ct,Re.width,Re.height,0,tt,et,null));else if(k.isDataTexture)if(nt.length>0&&ht){fe&&ke&&n.texStorage2D(t.TEXTURE_2D,Me,ct,nt[0].width,nt[0].height);for(let ge=0,Be=nt.length;ge<Be;ge++)de=nt[ge],fe?n.texSubImage2D(t.TEXTURE_2D,ge,0,0,de.width,de.height,tt,et,de.data):n.texImage2D(t.TEXTURE_2D,ge,ct,de.width,de.height,0,tt,et,de.data);k.generateMipmaps=!1}else fe?(ke&&n.texStorage2D(t.TEXTURE_2D,Me,ct,Re.width,Re.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Re.width,Re.height,tt,et,Re.data)):n.texImage2D(t.TEXTURE_2D,0,ct,Re.width,Re.height,0,tt,et,Re.data);else if(k.isCompressedTexture)if(k.isCompressedArrayTexture){fe&&ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Me,ct,nt[0].width,nt[0].height,Re.depth);for(let ge=0,Be=nt.length;ge<Be;ge++)de=nt[ge],k.format!==Ls?tt!==null?fe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ge,0,0,0,de.width,de.height,Re.depth,tt,de.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ge,ct,de.width,de.height,Re.depth,0,de.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):fe?n.texSubImage3D(t.TEXTURE_2D_ARRAY,ge,0,0,0,de.width,de.height,Re.depth,tt,et,de.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ge,ct,de.width,de.height,Re.depth,0,tt,et,de.data)}else{fe&&ke&&n.texStorage2D(t.TEXTURE_2D,Me,ct,nt[0].width,nt[0].height);for(let ge=0,Be=nt.length;ge<Be;ge++)de=nt[ge],k.format!==Ls?tt!==null?fe?n.compressedTexSubImage2D(t.TEXTURE_2D,ge,0,0,de.width,de.height,tt,de.data):n.compressedTexImage2D(t.TEXTURE_2D,ge,ct,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):fe?n.texSubImage2D(t.TEXTURE_2D,ge,0,0,de.width,de.height,tt,et,de.data):n.texImage2D(t.TEXTURE_2D,ge,ct,de.width,de.height,0,tt,et,de.data)}else if(k.isDataArrayTexture)fe?(ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Me,ct,Re.width,Re.height,Re.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Re.width,Re.height,Re.depth,tt,et,Re.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ct,Re.width,Re.height,Re.depth,0,tt,et,Re.data);else if(k.isData3DTexture)fe?(ke&&n.texStorage3D(t.TEXTURE_3D,Me,ct,Re.width,Re.height,Re.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Re.width,Re.height,Re.depth,tt,et,Re.data)):n.texImage3D(t.TEXTURE_3D,0,ct,Re.width,Re.height,Re.depth,0,tt,et,Re.data);else if(k.isFramebufferTexture){if(ke)if(fe)n.texStorage2D(t.TEXTURE_2D,Me,ct,Re.width,Re.height);else{let ge=Re.width,Be=Re.height;for(let lt=0;lt<Me;lt++)n.texImage2D(t.TEXTURE_2D,lt,ct,ge,Be,0,tt,et,null),ge>>=1,Be>>=1}}else if(nt.length>0&&ht){fe&&ke&&n.texStorage2D(t.TEXTURE_2D,Me,ct,nt[0].width,nt[0].height);for(let ge=0,Be=nt.length;ge<Be;ge++)de=nt[ge],fe?n.texSubImage2D(t.TEXTURE_2D,ge,0,0,tt,et,de):n.texImage2D(t.TEXTURE_2D,ge,ct,tt,et,de);k.generateMipmaps=!1}else fe?(ke&&n.texStorage2D(t.TEXTURE_2D,Me,ct,Re.width,Re.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,tt,et,Re)):n.texImage2D(t.TEXTURE_2D,0,ct,tt,et,Re);P(k,ht)&&N(me),Ye.__version=he.version,k.onUpdate&&k.onUpdate(k)}j.__version=k.version}function we(j,k,K){if(k.image.length!==6)return;const me=Pe(j,k),ye=k.source;n.bindTexture(t.TEXTURE_CUBE_MAP,j.__webglTexture,t.TEXTURE0+K);const he=i.get(ye);if(ye.version!==he.__version||me===!0){n.activeTexture(t.TEXTURE0+K);const Ye=Bn.getPrimaries(Bn.workingColorSpace),Le=k.colorSpace===Is?null:Bn.getPrimaries(k.colorSpace),qe=k.colorSpace===Is||Ye===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,k.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,k.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,qe);const rt=k.isCompressedTexture||k.image[0].isCompressedTexture,Ie=k.image[0]&&k.image[0].isDataTexture,Re=[];for(let ge=0;ge<6;ge++)!rt&&!Ie?Re[ge]=w(k.image[ge],!1,!0,c):Re[ge]=Ie?k.image[ge].image:k.image[ge],Re[ge]=te(k,Re[ge]);const ht=Re[0],tt=E(ht)||o,et=a.convert(k.format,k.colorSpace),ct=a.convert(k.type),de=U(k.internalFormat,et,ct,k.colorSpace),nt=o&&k.isVideoTexture!==!0,fe=he.__version===void 0||me===!0;let ke=R(k,ht,tt);ve(t.TEXTURE_CUBE_MAP,k,tt);let Me;if(rt){nt&&fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,de,ht.width,ht.height);for(let ge=0;ge<6;ge++){Me=Re[ge].mipmaps;for(let Be=0;Be<Me.length;Be++){const lt=Me[Be];k.format!==Ls?et!==null?nt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,0,0,lt.width,lt.height,et,lt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,de,lt.width,lt.height,0,lt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,0,0,lt.width,lt.height,et,ct,lt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be,de,lt.width,lt.height,0,et,ct,lt.data)}}}else{Me=k.mipmaps,nt&&fe&&(Me.length>0&&ke++,n.texStorage2D(t.TEXTURE_CUBE_MAP,ke,de,Re[0].width,Re[0].height));for(let ge=0;ge<6;ge++)if(Ie){nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,0,0,Re[ge].width,Re[ge].height,et,ct,Re[ge].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,de,Re[ge].width,Re[ge].height,0,et,ct,Re[ge].data);for(let Be=0;Be<Me.length;Be++){const bt=Me[Be].image[ge].image;nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,0,0,bt.width,bt.height,et,ct,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,de,bt.width,bt.height,0,et,ct,bt.data)}}else{nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,0,0,et,ct,Re[ge]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,0,de,et,ct,Re[ge]);for(let Be=0;Be<Me.length;Be++){const lt=Me[Be];nt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,0,0,et,ct,lt.image[ge]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ge,Be+1,de,et,ct,lt.image[ge])}}}P(k,tt)&&N(t.TEXTURE_CUBE_MAP),he.__version=ye.version,k.onUpdate&&k.onUpdate(k)}j.__version=k.version}function ze(j,k,K,me,ye,he){const Ye=a.convert(K.format,K.colorSpace),Le=a.convert(K.type),qe=U(K.internalFormat,Ye,Le,K.colorSpace);if(!i.get(k).__hasExternalTextures){const Ie=Math.max(1,k.width>>he),Re=Math.max(1,k.height>>he);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,he,qe,Ie,Re,k.depth,0,Ye,Le,null):n.texImage2D(ye,he,qe,Ie,Re,0,Ye,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,j),De(k)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,ye,i.get(K).__webglTexture,0,oe(k)):(ye===t.TEXTURE_2D||ye>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&ye<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,me,ye,i.get(K).__webglTexture,he),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ce(j,k,K){if(t.bindRenderbuffer(t.RENDERBUFFER,j),k.depthBuffer&&!k.stencilBuffer){let me=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(K||De(k)){const ye=k.depthTexture;ye&&ye.isDepthTexture&&(ye.type===ql?me=t.DEPTH_COMPONENT32F:ye.type===Mu&&(me=t.DEPTH_COMPONENT24));const he=oe(k);De(k)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,he,me,k.width,k.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,he,me,k.width,k.height)}else t.renderbufferStorage(t.RENDERBUFFER,me,k.width,k.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,j)}else if(k.depthBuffer&&k.stencilBuffer){const me=oe(k);K&&De(k)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,me,t.DEPTH24_STENCIL8,k.width,k.height):De(k)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,me,t.DEPTH24_STENCIL8,k.width,k.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,k.width,k.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,j)}else{const me=k.isWebGLMultipleRenderTargets===!0?k.texture:[k.texture];for(let ye=0;ye<me.length;ye++){const he=me[ye],Ye=a.convert(he.format,he.colorSpace),Le=a.convert(he.type),qe=U(he.internalFormat,Ye,Le,he.colorSpace),rt=oe(k);K&&De(k)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,rt,qe,k.width,k.height):De(k)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,rt,qe,k.width,k.height):t.renderbufferStorage(t.RENDERBUFFER,qe,k.width,k.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ft(j,k){if(k&&k.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,j),!(k.depthTexture&&k.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(k.depthTexture).__webglTexture||k.depthTexture.image.width!==k.width||k.depthTexture.image.height!==k.height)&&(k.depthTexture.image.width=k.width,k.depthTexture.image.height=k.height,k.depthTexture.needsUpdate=!0),ie(k.depthTexture,0);const me=i.get(k.depthTexture).__webglTexture,ye=oe(k);if(k.depthTexture.format===nf)De(k)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,me,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,me,0);else if(k.depthTexture.format===Up)De(k)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,me,0,ye):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,me,0);else throw new Error("Unknown depthTexture format")}function F(j){const k=i.get(j),K=j.isWebGLCubeRenderTarget===!0;if(j.depthTexture&&!k.__autoAllocateDepthBuffer){if(K)throw new Error("target.depthTexture not supported in Cube render targets");ft(k.__webglFramebuffer,j)}else if(K){k.__webglDepthbuffer=[];for(let me=0;me<6;me++)n.bindFramebuffer(t.FRAMEBUFFER,k.__webglFramebuffer[me]),k.__webglDepthbuffer[me]=t.createRenderbuffer(),ce(k.__webglDepthbuffer[me],j,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,k.__webglFramebuffer),k.__webglDepthbuffer=t.createRenderbuffer(),ce(k.__webglDepthbuffer,j,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function $(j,k,K){const me=i.get(j);k!==void 0&&ze(me.__webglFramebuffer,j,j.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),K!==void 0&&F(j)}function ae(j){const k=j.texture,K=i.get(j),me=i.get(k);j.addEventListener("dispose",I),j.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=k.version,s.memory.textures++);const ye=j.isWebGLCubeRenderTarget===!0,he=j.isWebGLMultipleRenderTargets===!0,Ye=E(j)||o;if(ye){K.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(o&&k.mipmaps&&k.mipmaps.length>0){K.__webglFramebuffer[Le]=[];for(let qe=0;qe<k.mipmaps.length;qe++)K.__webglFramebuffer[Le][qe]=t.createFramebuffer()}else K.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(o&&k.mipmaps&&k.mipmaps.length>0){K.__webglFramebuffer=[];for(let Le=0;Le<k.mipmaps.length;Le++)K.__webglFramebuffer[Le]=t.createFramebuffer()}else K.__webglFramebuffer=t.createFramebuffer();if(he)if(r.drawBuffers){const Le=j.texture;for(let qe=0,rt=Le.length;qe<rt;qe++){const Ie=i.get(Le[qe]);Ie.__webglTexture===void 0&&(Ie.__webglTexture=t.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&j.samples>0&&De(j)===!1){const Le=he?k:[k];K.__webglMultisampledFramebuffer=t.createFramebuffer(),K.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,K.__webglMultisampledFramebuffer);for(let qe=0;qe<Le.length;qe++){const rt=Le[qe];K.__webglColorRenderbuffer[qe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,K.__webglColorRenderbuffer[qe]);const Ie=a.convert(rt.format,rt.colorSpace),Re=a.convert(rt.type),ht=U(rt.internalFormat,Ie,Re,rt.colorSpace,j.isXRRenderTarget===!0),tt=oe(j);t.renderbufferStorageMultisample(t.RENDERBUFFER,tt,ht,j.width,j.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+qe,t.RENDERBUFFER,K.__webglColorRenderbuffer[qe])}t.bindRenderbuffer(t.RENDERBUFFER,null),j.depthBuffer&&(K.__webglDepthRenderbuffer=t.createRenderbuffer(),ce(K.__webglDepthRenderbuffer,j,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),ve(t.TEXTURE_CUBE_MAP,k,Ye);for(let Le=0;Le<6;Le++)if(o&&k.mipmaps&&k.mipmaps.length>0)for(let qe=0;qe<k.mipmaps.length;qe++)ze(K.__webglFramebuffer[Le][qe],j,k,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,qe);else ze(K.__webglFramebuffer[Le],j,k,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);P(k,Ye)&&N(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(he){const Le=j.texture;for(let qe=0,rt=Le.length;qe<rt;qe++){const Ie=Le[qe],Re=i.get(Ie);n.bindTexture(t.TEXTURE_2D,Re.__webglTexture),ve(t.TEXTURE_2D,Ie,Ye),ze(K.__webglFramebuffer,j,Ie,t.COLOR_ATTACHMENT0+qe,t.TEXTURE_2D,0),P(Ie,Ye)&&N(t.TEXTURE_2D)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((j.isWebGL3DRenderTarget||j.isWebGLArrayRenderTarget)&&(o?Le=j.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Le,me.__webglTexture),ve(Le,k,Ye),o&&k.mipmaps&&k.mipmaps.length>0)for(let qe=0;qe<k.mipmaps.length;qe++)ze(K.__webglFramebuffer[qe],j,k,t.COLOR_ATTACHMENT0,Le,qe);else ze(K.__webglFramebuffer,j,k,t.COLOR_ATTACHMENT0,Le,0);P(k,Ye)&&N(Le),n.unbindTexture()}j.depthBuffer&&F(j)}function J(j){const k=E(j)||o,K=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let me=0,ye=K.length;me<ye;me++){const he=K[me];if(P(he,k)){const Ye=j.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Le=i.get(he).__webglTexture;n.bindTexture(Ye,Le),N(Ye),n.unbindTexture()}}}function ee(j){if(o&&j.samples>0&&De(j)===!1){const k=j.isWebGLMultipleRenderTargets?j.texture:[j.texture],K=j.width,me=j.height;let ye=t.COLOR_BUFFER_BIT;const he=[],Ye=j.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=i.get(j),qe=j.isWebGLMultipleRenderTargets===!0;if(qe)for(let rt=0;rt<k.length;rt++)n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Le.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglFramebuffer);for(let rt=0;rt<k.length;rt++){he.push(t.COLOR_ATTACHMENT0+rt),j.depthBuffer&&he.push(Ye);const Ie=Le.__ignoreDepthValues!==void 0?Le.__ignoreDepthValues:!1;if(Ie===!1&&(j.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),j.stencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),qe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Le.__webglColorRenderbuffer[rt]),Ie===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Ye]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Ye])),qe){const Re=i.get(k[rt]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Re,0)}t.blitFramebuffer(0,0,K,me,0,0,K,me,ye,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,he)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),qe)for(let rt=0;rt<k.length;rt++){n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.RENDERBUFFER,Le.__webglColorRenderbuffer[rt]);const Ie=i.get(k[rt]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+rt,t.TEXTURE_2D,Ie,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglMultisampledFramebuffer)}}function oe(j){return Math.min(f,j.samples)}function De(j){const k=i.get(j);return o&&j.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&k.__useRenderToTexture!==!1}function Ne(j){const k=s.render.frame;_.get(j)!==k&&(_.set(j,k),j.update())}function te(j,k){const K=j.colorSpace,me=j.format,ye=j.type;return j.isCompressedTexture===!0||j.isVideoTexture===!0||j.format===KN||K!==uc&&K!==Is&&(Bn.getTransfer(K)===ti?o===!1?e.has("EXT_sRGB")===!0&&me===Ls?(j.format=KN,j.minFilter=ks,j.generateMipmaps=!1):k=KG.sRGBToLinear(k):(me!==Ls||ye!==Ou)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",K)),k}this.allocateTextureUnit=X,this.resetTextureUnits=W,this.setTexture2D=ie,this.setTexture2DArray=H,this.setTexture3D=Y,this.setTextureCube=se,this.rebindTextures=$,this.setupRenderTarget=ae,this.updateRenderTargetMipmap=J,this.updateMultisampleRenderTarget=ee,this.setupDepthRenderbuffer=F,this.setupFrameBufferTexture=ze,this.useMultisampledRTT=De}function Mve(t,e,n){const i=n.isWebGL2;function r(a,s=Is){let o;const l=Bn.getTransfer(s);if(a===Ou)return t.UNSIGNED_BYTE;if(a===jG)return t.UNSIGNED_SHORT_4_4_4_4;if(a===FG)return t.UNSIGNED_SHORT_5_5_5_1;if(a===Xhe)return t.BYTE;if(a===Khe)return t.SHORT;if(a===_P)return t.UNSIGNED_SHORT;if(a===UG)return t.INT;if(a===Mu)return t.UNSIGNED_INT;if(a===ql)return t.FLOAT;if(a===D0)return i?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===Yhe)return t.ALPHA;if(a===Ls)return t.RGBA;if(a===Zhe)return t.LUMINANCE;if(a===Qhe)return t.LUMINANCE_ALPHA;if(a===nf)return t.DEPTH_COMPONENT;if(a===Up)return t.DEPTH_STENCIL;if(a===KN)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===Jhe)return t.RED;if(a===zG)return t.RED_INTEGER;if(a===epe)return t.RG;if(a===BG)return t.RG_INTEGER;if(a===HG)return t.RGBA_INTEGER;if(a===UA||a===jA||a===FA||a===zA)if(l===ti)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===UA)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===jA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===FA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===zA)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===UA)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===jA)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===FA)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===zA)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===uF||a===dF||a===fF||a===hF)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===uF)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===dF)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===fF)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===hF)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===VG)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===pF||a===mF)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(a===pF)return l===ti?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===mF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===gF||a===xF||a===vF||a===yF||a===bF||a===_F||a===SF||a===wF||a===MF||a===EF||a===AF||a===TF||a===CF||a===NF)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(a===gF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===xF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===vF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===yF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===bF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===_F)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===SF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===wF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===MF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===EF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===AF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===TF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===CF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===NF)return l===ti?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===BA||a===RF||a===PF)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(a===BA)return l===ti?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===RF)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===PF)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===tpe||a===DF||a===OF||a===kF)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(a===BA)return o.COMPRESSED_RED_RGTC1_EXT;if(a===DF)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===OF)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===kF)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===tf?i?t.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:r}}class Eve extends ts{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class $g extends ma{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ave={type:"move"};class uT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new $g,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new $g,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ae,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ae),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new $g,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ae,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ae),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const i of e.hand.values())this._getHandJoint(n,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,i){let r=null,a=null,s=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(const b of e.hand.values()){const v=n.getJointPose(b,i),x=this._getHandJoint(c,b);v!==null&&(x.matrix.fromArray(v.transform.matrix),x.matrix.decompose(x.position,x.rotation,x.scale),x.matrixWorldNeedsUpdate=!0,x.jointRadius=v.radius),x.visible=v!==null}const d=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],p=d.position.distanceTo(f.position),m=.02,_=.005;c.inputState.pinching&&p>m+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&p<=m-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,i),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=n.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ave)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=s!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const i=new $g;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}}class Tve extends jf{constructor(e,n){super();const i=this;let r=null,a=1,s=null,o="local-floor",l=1,c=null,d=null,f=null,p=null,m=null,_=null;const b=n.getContextAttributes();let v=null,x=null;const M=[],w=[],E=new Gt;let T=null;const P=new ts;P.layers.enable(1),P.viewport=new Vn;const N=new ts;N.layers.enable(2),N.viewport=new Vn;const U=[P,N],R=new Eve;R.layers.enable(1),R.layers.enable(2);let O=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(se){let ue=M[se];return ue===void 0&&(ue=new uT,M[se]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(se){let ue=M[se];return ue===void 0&&(ue=new uT,M[se]=ue),ue.getGripSpace()},this.getHand=function(se){let ue=M[se];return ue===void 0&&(ue=new uT,M[se]=ue),ue.getHandSpace()};function I(se){const ue=w.indexOf(se.inputSource);if(ue===-1)return;const xe=M[ue];xe!==void 0&&(xe.update(se.inputSource,se.frame,c||s),xe.dispatchEvent({type:se.type,data:se.inputSource}))}function G(){r.removeEventListener("select",I),r.removeEventListener("selectstart",I),r.removeEventListener("selectend",I),r.removeEventListener("squeeze",I),r.removeEventListener("squeezestart",I),r.removeEventListener("squeezeend",I),r.removeEventListener("end",G),r.removeEventListener("inputsourceschange",L);for(let se=0;se<M.length;se++){const ue=w[se];ue!==null&&(w[se]=null,M[se].disconnect(ue))}O=null,z=null,e.setRenderTarget(v),m=null,p=null,f=null,r=null,x=null,Y.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(E.width,E.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(se){a=se,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(se){o=se,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(se){c=se},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(se){if(r=se,r!==null){if(v=e.getRenderTarget(),r.addEventListener("select",I),r.addEventListener("selectstart",I),r.addEventListener("selectend",I),r.addEventListener("squeeze",I),r.addEventListener("squeezestart",I),r.addEventListener("squeezeend",I),r.addEventListener("end",G),r.addEventListener("inputsourceschange",L),b.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(E),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ue={antialias:r.renderState.layers===void 0?b.antialias:!0,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(r,n,ue),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),x=new Sf(m.framebufferWidth,m.framebufferHeight,{format:Ls,type:Ou,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil})}else{let ue=null,xe=null,re=null;b.depth&&(re=b.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ue=b.stencil?Up:nf,xe=b.stencil?tf:Mu);const ve={colorFormat:n.RGBA8,depthFormat:re,scaleFactor:a};f=new XRWebGLBinding(r,n),p=f.createProjectionLayer(ve),r.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),x=new Sf(p.textureWidth,p.textureHeight,{format:Ls,type:Ou,depthTexture:new o9(p.textureWidth,p.textureHeight,xe,void 0,void 0,void 0,void 0,void 0,void 0,ue),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0});const Pe=e.properties.get(x);Pe.__ignoreDepthValues=p.ignoreDepthValues}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await r.requestReferenceSpace(o),Y.setContext(r),Y.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function L(se){for(let ue=0;ue<se.removed.length;ue++){const xe=se.removed[ue],re=w.indexOf(xe);re>=0&&(w[re]=null,M[re].disconnect(xe))}for(let ue=0;ue<se.added.length;ue++){const xe=se.added[ue];let re=w.indexOf(xe);if(re===-1){for(let Pe=0;Pe<M.length;Pe++)if(Pe>=w.length){w.push(xe),re=Pe;break}else if(w[Pe]===null){w[Pe]=xe,re=Pe;break}if(re===-1)break}const ve=M[re];ve&&ve.connect(xe)}}const B=new Ae,q=new Ae;function W(se,ue,xe){B.setFromMatrixPosition(ue.matrixWorld),q.setFromMatrixPosition(xe.matrixWorld);const re=B.distanceTo(q),ve=ue.projectionMatrix.elements,Pe=xe.projectionMatrix.elements,pe=ve[14]/(ve[10]-1),we=ve[14]/(ve[10]+1),ze=(ve[9]+1)/ve[5],ce=(ve[9]-1)/ve[5],ft=(ve[8]-1)/ve[0],F=(Pe[8]+1)/Pe[0],$=pe*ft,ae=pe*F,J=re/(-ft+F),ee=J*-ft;ue.matrixWorld.decompose(se.position,se.quaternion,se.scale),se.translateX(ee),se.translateZ(J),se.matrixWorld.compose(se.position,se.quaternion,se.scale),se.matrixWorldInverse.copy(se.matrixWorld).invert();const oe=pe+J,De=we+J,Ne=$-ee,te=ae+(re-ee),j=ze*we/De*oe,k=ce*we/De*oe;se.projectionMatrix.makePerspective(Ne,te,j,k,oe,De),se.projectionMatrixInverse.copy(se.projectionMatrix).invert()}function X(se,ue){ue===null?se.matrixWorld.copy(se.matrix):se.matrixWorld.multiplyMatrices(ue.matrixWorld,se.matrix),se.matrixWorldInverse.copy(se.matrixWorld).invert()}this.updateCamera=function(se){if(r===null)return;R.near=N.near=P.near=se.near,R.far=N.far=P.far=se.far,(O!==R.near||z!==R.far)&&(r.updateRenderState({depthNear:R.near,depthFar:R.far}),O=R.near,z=R.far);const ue=se.parent,xe=R.cameras;X(R,ue);for(let re=0;re<xe.length;re++)X(xe[re],ue);xe.length===2?W(R,P,N):R.projectionMatrix.copy(P.projectionMatrix),Q(se,R,ue)};function Q(se,ue,xe){xe===null?se.matrix.copy(ue.matrixWorld):(se.matrix.copy(xe.matrixWorld),se.matrix.invert(),se.matrix.multiply(ue.matrixWorld)),se.matrix.decompose(se.position,se.quaternion,se.scale),se.updateMatrixWorld(!0),se.projectionMatrix.copy(ue.projectionMatrix),se.projectionMatrixInverse.copy(ue.projectionMatrixInverse),se.isPerspectiveCamera&&(se.fov=k0*2*Math.atan(1/se.projectionMatrix.elements[5]),se.zoom=1)}this.getCamera=function(){return R},this.getFoveation=function(){if(!(p===null&&m===null))return l},this.setFoveation=function(se){l=se,p!==null&&(p.fixedFoveation=se),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=se)};let ie=null;function H(se,ue){if(d=ue.getViewerPose(c||s),_=ue,d!==null){const xe=d.views;m!==null&&(e.setRenderTargetFramebuffer(x,m.framebuffer),e.setRenderTarget(x));let re=!1;xe.length!==R.cameras.length&&(R.cameras.length=0,re=!0);for(let ve=0;ve<xe.length;ve++){const Pe=xe[ve];let pe=null;if(m!==null)pe=m.getViewport(Pe);else{const ze=f.getViewSubImage(p,Pe);pe=ze.viewport,ve===0&&(e.setRenderTargetTextures(x,ze.colorTexture,p.ignoreDepthValues?void 0:ze.depthStencilTexture),e.setRenderTarget(x))}let we=U[ve];we===void 0&&(we=new ts,we.layers.enable(ve),we.viewport=new Vn,U[ve]=we),we.matrix.fromArray(Pe.transform.matrix),we.matrix.decompose(we.position,we.quaternion,we.scale),we.projectionMatrix.fromArray(Pe.projectionMatrix),we.projectionMatrixInverse.copy(we.projectionMatrix).invert(),we.viewport.set(pe.x,pe.y,pe.width,pe.height),ve===0&&(R.matrix.copy(we.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),re===!0&&R.cameras.push(we)}}for(let xe=0;xe<M.length;xe++){const re=w[xe],ve=M[xe];re!==null&&ve!==void 0&&ve.update(re,ue,c||s)}ie&&ie(se,ue),ue.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ue}),_=null}const Y=new s9;Y.setAnimationLoop(H),this.setAnimationLoop=function(se){ie=se},this.dispose=function(){}}}function Cve(t,e){function n(v,x){v.matrixAutoUpdate===!0&&v.updateMatrix(),x.value.copy(v.matrix)}function i(v,x){x.color.getRGB(v.fogColor.value,i9(t)),x.isFog?(v.fogNear.value=x.near,v.fogFar.value=x.far):x.isFogExp2&&(v.fogDensity.value=x.density)}function r(v,x,M,w,E){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),f(v,x)):x.isMeshPhongMaterial?(a(v,x),d(v,x)):x.isMeshStandardMaterial?(a(v,x),p(v,x),x.isMeshPhysicalMaterial&&m(v,x,E)):x.isMeshMatcapMaterial?(a(v,x),_(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),b(v,x)):x.isMeshNormalMaterial?a(v,x):x.isLineBasicMaterial?(s(v,x),x.isLineDashedMaterial&&o(v,x)):x.isPointsMaterial?l(v,x,M,w):x.isSpriteMaterial?c(v,x):x.isShadowMaterial?(v.color.value.copy(x.color),v.opacity.value=x.opacity):x.isShaderMaterial&&(x.uniformsNeedUpdate=!1)}function a(v,x){v.opacity.value=x.opacity,x.color&&v.diffuse.value.copy(x.color),x.emissive&&v.emissive.value.copy(x.emissive).multiplyScalar(x.emissiveIntensity),x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.bumpMap&&(v.bumpMap.value=x.bumpMap,n(x.bumpMap,v.bumpMapTransform),v.bumpScale.value=x.bumpScale,x.side===ka&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===ka&&v.normalScale.value.negate()),x.displacementMap&&(v.displacementMap.value=x.displacementMap,n(x.displacementMap,v.displacementMapTransform),v.displacementScale.value=x.displacementScale,v.displacementBias.value=x.displacementBias),x.emissiveMap&&(v.emissiveMap.value=x.emissiveMap,n(x.emissiveMap,v.emissiveMapTransform)),x.specularMap&&(v.specularMap.value=x.specularMap,n(x.specularMap,v.specularMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest);const M=e.get(x).envMap;if(M&&(v.envMap.value=M,v.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=x.reflectivity,v.ior.value=x.ior,v.refractionRatio.value=x.refractionRatio),x.lightMap){v.lightMap.value=x.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=x.lightMapIntensity*w,n(x.lightMap,v.lightMapTransform)}x.aoMap&&(v.aoMap.value=x.aoMap,v.aoMapIntensity.value=x.aoMapIntensity,n(x.aoMap,v.aoMapTransform))}function s(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform))}function o(v,x){v.dashSize.value=x.dashSize,v.totalSize.value=x.dashSize+x.gapSize,v.scale.value=x.scale}function l(v,x,M,w){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.size.value=x.size*M,v.scale.value=w*.5,x.map&&(v.map.value=x.map,n(x.map,v.uvTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function c(v,x){v.diffuse.value.copy(x.color),v.opacity.value=x.opacity,v.rotation.value=x.rotation,x.map&&(v.map.value=x.map,n(x.map,v.mapTransform)),x.alphaMap&&(v.alphaMap.value=x.alphaMap,n(x.alphaMap,v.alphaMapTransform)),x.alphaTest>0&&(v.alphaTest.value=x.alphaTest)}function d(v,x){v.specular.value.copy(x.specular),v.shininess.value=Math.max(x.shininess,1e-4)}function f(v,x){x.gradientMap&&(v.gradientMap.value=x.gradientMap)}function p(v,x){v.metalness.value=x.metalness,x.metalnessMap&&(v.metalnessMap.value=x.metalnessMap,n(x.metalnessMap,v.metalnessMapTransform)),v.roughness.value=x.roughness,x.roughnessMap&&(v.roughnessMap.value=x.roughnessMap,n(x.roughnessMap,v.roughnessMapTransform)),e.get(x).envMap&&(v.envMapIntensity.value=x.envMapIntensity)}function m(v,x,M){v.ior.value=x.ior,x.sheen>0&&(v.sheenColor.value.copy(x.sheenColor).multiplyScalar(x.sheen),v.sheenRoughness.value=x.sheenRoughness,x.sheenColorMap&&(v.sheenColorMap.value=x.sheenColorMap,n(x.sheenColorMap,v.sheenColorMapTransform)),x.sheenRoughnessMap&&(v.sheenRoughnessMap.value=x.sheenRoughnessMap,n(x.sheenRoughnessMap,v.sheenRoughnessMapTransform))),x.clearcoat>0&&(v.clearcoat.value=x.clearcoat,v.clearcoatRoughness.value=x.clearcoatRoughness,x.clearcoatMap&&(v.clearcoatMap.value=x.clearcoatMap,n(x.clearcoatMap,v.clearcoatMapTransform)),x.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=x.clearcoatRoughnessMap,n(x.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),x.clearcoatNormalMap&&(v.clearcoatNormalMap.value=x.clearcoatNormalMap,n(x.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(x.clearcoatNormalScale),x.side===ka&&v.clearcoatNormalScale.value.negate())),x.iridescence>0&&(v.iridescence.value=x.iridescence,v.iridescenceIOR.value=x.iridescenceIOR,v.iridescenceThicknessMinimum.value=x.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=x.iridescenceThicknessRange[1],x.iridescenceMap&&(v.iridescenceMap.value=x.iridescenceMap,n(x.iridescenceMap,v.iridescenceMapTransform)),x.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=x.iridescenceThicknessMap,n(x.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),x.transmission>0&&(v.transmission.value=x.transmission,v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height),x.transmissionMap&&(v.transmissionMap.value=x.transmissionMap,n(x.transmissionMap,v.transmissionMapTransform)),v.thickness.value=x.thickness,x.thicknessMap&&(v.thicknessMap.value=x.thicknessMap,n(x.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=x.attenuationDistance,v.attenuationColor.value.copy(x.attenuationColor)),x.anisotropy>0&&(v.anisotropyVector.value.set(x.anisotropy*Math.cos(x.anisotropyRotation),x.anisotropy*Math.sin(x.anisotropyRotation)),x.anisotropyMap&&(v.anisotropyMap.value=x.anisotropyMap,n(x.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=x.specularIntensity,v.specularColor.value.copy(x.specularColor),x.specularColorMap&&(v.specularColorMap.value=x.specularColorMap,n(x.specularColorMap,v.specularColorMapTransform)),x.specularIntensityMap&&(v.specularIntensityMap.value=x.specularIntensityMap,n(x.specularIntensityMap,v.specularIntensityMapTransform))}function _(v,x){x.matcap&&(v.matcap.value=x.matcap)}function b(v,x){const M=e.get(x).light;v.referencePosition.value.setFromMatrixPosition(M.matrixWorld),v.nearDistance.value=M.shadow.camera.near,v.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function Nve(t,e,n,i){let r={},a={},s=[];const o=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(M,w){const E=w.program;i.uniformBlockBinding(M,E)}function c(M,w){let E=r[M.id];E===void 0&&(_(M),E=d(M),r[M.id]=E,M.addEventListener("dispose",v));const T=w.program;i.updateUBOMapping(M,T);const P=e.render.frame;a[M.id]!==P&&(p(M),a[M.id]=P)}function d(M){const w=f();M.__bindingPointIndex=w;const E=t.createBuffer(),T=M.__size,P=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,E),t.bufferData(t.UNIFORM_BUFFER,T,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,E),E}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(M){const w=r[M.id],E=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let P=0,N=E.length;P<N;P++){const U=E[P];if(m(U,P,T)===!0){const R=U.__offset,O=Array.isArray(U.value)?U.value:[U.value];let z=0;for(let I=0;I<O.length;I++){const G=O[I],L=b(G);typeof G=="number"?(U.__data[0]=G,t.bufferSubData(t.UNIFORM_BUFFER,R+z,U.__data)):G.isMatrix3?(U.__data[0]=G.elements[0],U.__data[1]=G.elements[1],U.__data[2]=G.elements[2],U.__data[3]=G.elements[0],U.__data[4]=G.elements[3],U.__data[5]=G.elements[4],U.__data[6]=G.elements[5],U.__data[7]=G.elements[0],U.__data[8]=G.elements[6],U.__data[9]=G.elements[7],U.__data[10]=G.elements[8],U.__data[11]=G.elements[0]):(G.toArray(U.__data,z),z+=L.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,R,U.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(M,w,E){const T=M.value;if(E[w]===void 0){if(typeof T=="number")E[w]=T;else{const P=Array.isArray(T)?T:[T],N=[];for(let U=0;U<P.length;U++)N.push(P[U].clone());E[w]=N}return!0}else if(typeof T=="number"){if(E[w]!==T)return E[w]=T,!0}else{const P=Array.isArray(E[w])?E[w]:[E[w]],N=Array.isArray(T)?T:[T];for(let U=0;U<P.length;U++){const R=P[U];if(R.equals(N[U])===!1)return R.copy(N[U]),!0}}return!1}function _(M){const w=M.uniforms;let E=0;const T=16;let P=0;for(let N=0,U=w.length;N<U;N++){const R=w[N],O={boundary:0,storage:0},z=Array.isArray(R.value)?R.value:[R.value];for(let I=0,G=z.length;I<G;I++){const L=z[I],B=b(L);O.boundary+=B.boundary,O.storage+=B.storage}if(R.__data=new Float32Array(O.storage/Float32Array.BYTES_PER_ELEMENT),R.__offset=E,N>0){P=E%T;const I=T-P;P!==0&&I-O.boundary<0&&(E+=T-P,R.__offset=E)}E+=O.storage}return P=E%T,P>0&&(E+=T-P),M.__size=E,M.__cache={},this}function b(M){const w={boundary:0,storage:0};return typeof M=="number"?(w.boundary=4,w.storage=4):M.isVector2?(w.boundary=8,w.storage=8):M.isVector3||M.isColor?(w.boundary=16,w.storage=12):M.isVector4?(w.boundary=16,w.storage=16):M.isMatrix3?(w.boundary=48,w.storage=48):M.isMatrix4?(w.boundary=64,w.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),w}function v(M){const w=M.target;w.removeEventListener("dispose",v);const E=s.indexOf(w.__bindingPointIndex);s.splice(E,1),t.deleteBuffer(r[w.id]),delete r[w.id],delete a[w.id]}function x(){for(const M in r)t.deleteBuffer(r[M]);s=[],r={},a={}}return{bind:l,update:c,dispose:x}}class QN{constructor(e={}){const{canvas:n=Ape(),context:i=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let p;i!==null?p=i.getContextAttributes().alpha:p=s;const m=new Uint32Array(4),_=new Int32Array(4);let b=null,v=null;const x=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=zr,this._useLegacyLights=!1,this.toneMapping=Du,this.toneMappingExposure=1;const w=this;let E=!1,T=0,P=0,N=null,U=-1,R=null;const O=new Vn,z=new Vn;let I=null;const G=new Ft(0);let L=0,B=n.width,q=n.height,W=1,X=null,Q=null;const ie=new Vn(0,0,B,q),H=new Vn(0,0,B,q);let Y=!1;const se=new OS;let ue=!1,xe=!1,re=null;const ve=new Zn,Pe=new Gt,pe=new Ae,we={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ze(){return N===null?W:1}let ce=i;function ft(le,Ue){for(let We=0;We<le.length;We++){const Xe=le[We],Ge=n.getContext(Xe,Ue);if(Ge!==null)return Ge}return null}try{const le={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${RS}`),n.addEventListener("webglcontextlost",nt,!1),n.addEventListener("webglcontextrestored",fe,!1),n.addEventListener("webglcontextcreationerror",ke,!1),ce===null){const Ue=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&Ue.shift(),ce=ft(Ue,le),ce===null)throw ft(Ue)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ce instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ce.getShaderPrecisionFormat===void 0&&(ce.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(le){throw console.error("THREE.WebGLRenderer: "+le.message),le}let F,$,ae,J,ee,oe,De,Ne,te,j,k,K,me,ye,he,Ye,Le,qe,rt,Ie,Re,ht,tt,et;function ct(){F=new z0e(ce),$=new O0e(ce,F,e),F.init($),ht=new Mve(ce,F,$),ae=new Sve(ce,F,$),J=new V0e(ce),ee=new lve,oe=new wve(ce,F,ae,ee,$,ht,J),De=new L0e(w),Ne=new F0e(w),te=new Ype(ce,$),tt=new P0e(ce,F,te,$),j=new B0e(ce,te,J,tt),k=new q0e(ce,j,te,J),rt=new W0e(ce,$,oe),Ye=new k0e(ee),K=new ove(w,De,Ne,F,$,tt,Ye),me=new Cve(w,ee),ye=new uve,he=new gve(F,$),qe=new R0e(w,De,Ne,ae,k,p,l),Le=new _ve(w,k,$),et=new Nve(ce,J,$,ae),Ie=new D0e(ce,F,J,$),Re=new H0e(ce,F,J,$),J.programs=K.programs,w.capabilities=$,w.extensions=F,w.properties=ee,w.renderLists=ye,w.shadowMap=Le,w.state=ae,w.info=J}ct();const de=new Tve(w,ce);this.xr=de,this.getContext=function(){return ce},this.getContextAttributes=function(){return ce.getContextAttributes()},this.forceContextLoss=function(){const le=F.get("WEBGL_lose_context");le&&le.loseContext()},this.forceContextRestore=function(){const le=F.get("WEBGL_lose_context");le&&le.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(le){le!==void 0&&(W=le,this.setSize(B,q,!1))},this.getSize=function(le){return le.set(B,q)},this.setSize=function(le,Ue,We=!0){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=le,q=Ue,n.width=Math.floor(le*W),n.height=Math.floor(Ue*W),We===!0&&(n.style.width=le+"px",n.style.height=Ue+"px"),this.setViewport(0,0,le,Ue)},this.getDrawingBufferSize=function(le){return le.set(B*W,q*W).floor()},this.setDrawingBufferSize=function(le,Ue,We){B=le,q=Ue,W=We,n.width=Math.floor(le*We),n.height=Math.floor(Ue*We),this.setViewport(0,0,le,Ue)},this.getCurrentViewport=function(le){return le.copy(O)},this.getViewport=function(le){return le.copy(ie)},this.setViewport=function(le,Ue,We,Xe){le.isVector4?ie.set(le.x,le.y,le.z,le.w):ie.set(le,Ue,We,Xe),ae.viewport(O.copy(ie).multiplyScalar(W).floor())},this.getScissor=function(le){return le.copy(H)},this.setScissor=function(le,Ue,We,Xe){le.isVector4?H.set(le.x,le.y,le.z,le.w):H.set(le,Ue,We,Xe),ae.scissor(z.copy(H).multiplyScalar(W).floor())},this.getScissorTest=function(){return Y},this.setScissorTest=function(le){ae.setScissorTest(Y=le)},this.setOpaqueSort=function(le){X=le},this.setTransparentSort=function(le){Q=le},this.getClearColor=function(le){return le.copy(qe.getClearColor())},this.setClearColor=function(){qe.setClearColor.apply(qe,arguments)},this.getClearAlpha=function(){return qe.getClearAlpha()},this.setClearAlpha=function(){qe.setClearAlpha.apply(qe,arguments)},this.clear=function(le=!0,Ue=!0,We=!0){let Xe=0;if(le){let Ge=!1;if(N!==null){const _t=N.texture.format;Ge=_t===HG||_t===BG||_t===zG}if(Ge){const _t=N.texture.type,Z=_t===Ou||_t===Mu||_t===_P||_t===tf||_t===jG||_t===FG,be=qe.getClearColor(),Ce=qe.getClearAlpha(),Te=be.r,Se=be.g,Qe=be.b;Z?(m[0]=Te,m[1]=Se,m[2]=Qe,m[3]=Ce,ce.clearBufferuiv(ce.COLOR,0,m)):(_[0]=Te,_[1]=Se,_[2]=Qe,_[3]=Ce,ce.clearBufferiv(ce.COLOR,0,_))}else Xe|=ce.COLOR_BUFFER_BIT}Ue&&(Xe|=ce.DEPTH_BUFFER_BIT),We&&(Xe|=ce.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ce.clear(Xe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",nt,!1),n.removeEventListener("webglcontextrestored",fe,!1),n.removeEventListener("webglcontextcreationerror",ke,!1),ye.dispose(),he.dispose(),ee.dispose(),De.dispose(),Ne.dispose(),k.dispose(),tt.dispose(),et.dispose(),K.dispose(),de.dispose(),de.removeEventListener("sessionstart",an),de.removeEventListener("sessionend",Dt),re&&(re.dispose(),re=null),Nn.stop()};function nt(le){le.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),E=!0}function fe(){console.log("THREE.WebGLRenderer: Context Restored."),E=!1;const le=J.autoReset,Ue=Le.enabled,We=Le.autoUpdate,Xe=Le.needsUpdate,Ge=Le.type;ct(),J.autoReset=le,Le.enabled=Ue,Le.autoUpdate=We,Le.needsUpdate=Xe,Le.type=Ge}function ke(le){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",le.statusMessage)}function Me(le){const Ue=le.target;Ue.removeEventListener("dispose",Me),ge(Ue)}function ge(le){Be(le),ee.remove(le)}function Be(le){const Ue=ee.get(le).programs;Ue!==void 0&&(Ue.forEach(function(We){K.releaseProgram(We)}),le.isShaderMaterial&&K.releaseShaderCache(le))}this.renderBufferDirect=function(le,Ue,We,Xe,Ge,_t){Ue===null&&(Ue=we);const Z=Ge.isMesh&&Ge.matrixWorld.determinant()<0,be=Ei(le,Ue,We,Xe,Ge);ae.setMaterial(Xe,Z);let Ce=We.index,Te=1;if(Xe.wireframe===!0){if(Ce=j.getWireframeAttribute(We),Ce===void 0)return;Te=2}const Se=We.drawRange,Qe=We.attributes.position;let ut=Se.start*Te,vt=(Se.start+Se.count)*Te;_t!==null&&(ut=Math.max(ut,_t.start*Te),vt=Math.min(vt,(_t.start+_t.count)*Te)),Ce!==null?(ut=Math.max(ut,0),vt=Math.min(vt,Ce.count)):Qe!=null&&(ut=Math.max(ut,0),vt=Math.min(vt,Qe.count));const xt=vt-ut;if(xt<0||xt===1/0)return;tt.setup(Ge,Xe,be,We,Ce);let Rt,wt=Ie;if(Ce!==null&&(Rt=te.get(Ce),wt=Re,wt.setIndex(Rt)),Ge.isMesh)Xe.wireframe===!0?(ae.setLineWidth(Xe.wireframeLinewidth*ze()),wt.setMode(ce.LINES)):wt.setMode(ce.TRIANGLES);else if(Ge.isLine){let pt=Xe.linewidth;pt===void 0&&(pt=1),ae.setLineWidth(pt*ze()),Ge.isLineSegments?wt.setMode(ce.LINES):Ge.isLineLoop?wt.setMode(ce.LINE_LOOP):wt.setMode(ce.LINE_STRIP)}else Ge.isPoints?wt.setMode(ce.POINTS):Ge.isSprite&&wt.setMode(ce.TRIANGLES);if(Ge.isBatchedMesh)wt.renderMultiDraw(Ge._multiDrawStarts,Ge._multiDrawCounts,Ge._multiDrawCount);else if(Ge.isInstancedMesh)wt.renderInstances(ut,xt,Ge.count);else if(We.isInstancedBufferGeometry){const pt=We._maxInstanceCount!==void 0?We._maxInstanceCount:1/0,Vt=Math.min(We.instanceCount,pt);wt.renderInstances(ut,xt,Vt)}else wt.render(ut,xt)};function lt(le,Ue,We){le.transparent===!0&&le.side===Bl&&le.forceSinglePass===!1?(le.side=ka,le.needsUpdate=!0,$r(le,Ue,We),le.side=$u,le.needsUpdate=!0,$r(le,Ue,We),le.side=Bl):$r(le,Ue,We)}this.compile=function(le,Ue,We=null){We===null&&(We=le),v=he.get(We),v.init(),M.push(v),We.traverseVisible(function(Ge){Ge.isLight&&Ge.layers.test(Ue.layers)&&(v.pushLight(Ge),Ge.castShadow&&v.pushShadow(Ge))}),le!==We&&le.traverseVisible(function(Ge){Ge.isLight&&Ge.layers.test(Ue.layers)&&(v.pushLight(Ge),Ge.castShadow&&v.pushShadow(Ge))}),v.setupLights(w._useLegacyLights);const Xe=new Set;return le.traverse(function(Ge){const _t=Ge.material;if(_t)if(Array.isArray(_t))for(let Z=0;Z<_t.length;Z++){const be=_t[Z];lt(be,We,Ge),Xe.add(be)}else lt(_t,We,Ge),Xe.add(_t)}),M.pop(),v=null,Xe},this.compileAsync=function(le,Ue,We=null){const Xe=this.compile(le,Ue,We);return new Promise(Ge=>{function _t(){if(Xe.forEach(function(Z){ee.get(Z).currentProgram.isReady()&&Xe.delete(Z)}),Xe.size===0){Ge(le);return}setTimeout(_t,10)}F.get("KHR_parallel_shader_compile")!==null?_t():setTimeout(_t,10)})};let bt=null;function Nt(le){bt&&bt(le)}function an(){Nn.stop()}function Dt(){Nn.start()}const Nn=new s9;Nn.setAnimationLoop(Nt),typeof self<"u"&&Nn.setContext(self),this.setAnimationLoop=function(le){bt=le,de.setAnimationLoop(le),le===null?Nn.stop():Nn.start()},de.addEventListener("sessionstart",an),de.addEventListener("sessionend",Dt),this.render=function(le,Ue){if(Ue!==void 0&&Ue.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),Ue.parent===null&&Ue.matrixWorldAutoUpdate===!0&&Ue.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(de.cameraAutoUpdate===!0&&de.updateCamera(Ue),Ue=de.getCamera()),le.isScene===!0&&le.onBeforeRender(w,le,Ue,N),v=he.get(le,M.length),v.init(),M.push(v),ve.multiplyMatrices(Ue.projectionMatrix,Ue.matrixWorldInverse),se.setFromProjectionMatrix(ve),xe=this.localClippingEnabled,ue=Ye.init(this.clippingPlanes,xe),b=ye.get(le,x.length),b.init(),x.push(b),Gn(le,Ue,0,w.sortObjects),b.finish(),w.sortObjects===!0&&b.sort(X,Q),this.info.render.frame++,ue===!0&&Ye.beginShadows();const We=v.state.shadowsArray;if(Le.render(We,le,Ue),ue===!0&&Ye.endShadows(),this.info.autoReset===!0&&this.info.reset(),qe.render(b,le),v.setupLights(w._useLegacyLights),Ue.isArrayCamera){const Xe=Ue.cameras;for(let Ge=0,_t=Xe.length;Ge<_t;Ge++){const Z=Xe[Ge];fr(b,le,Z,Z.viewport)}}else fr(b,le,Ue);N!==null&&(oe.updateMultisampleRenderTarget(N),oe.updateRenderTargetMipmap(N)),le.isScene===!0&&le.onAfterRender(w,le,Ue),tt.resetDefaultState(),U=-1,R=null,M.pop(),M.length>0?v=M[M.length-1]:v=null,x.pop(),x.length>0?b=x[x.length-1]:b=null};function Gn(le,Ue,We,Xe){if(le.visible===!1)return;if(le.layers.test(Ue.layers)){if(le.isGroup)We=le.renderOrder;else if(le.isLOD)le.autoUpdate===!0&&le.update(Ue);else if(le.isLight)v.pushLight(le),le.castShadow&&v.pushShadow(le);else if(le.isSprite){if(!le.frustumCulled||se.intersectsSprite(le)){Xe&&pe.setFromMatrixPosition(le.matrixWorld).applyMatrix4(ve);const Z=k.update(le),be=le.material;be.visible&&b.push(le,Z,be,We,pe.z,null)}}else if((le.isMesh||le.isLine||le.isPoints)&&(!le.frustumCulled||se.intersectsObject(le))){const Z=k.update(le),be=le.material;if(Xe&&(le.boundingSphere!==void 0?(le.boundingSphere===null&&le.computeBoundingSphere(),pe.copy(le.boundingSphere.center)):(Z.boundingSphere===null&&Z.computeBoundingSphere(),pe.copy(Z.boundingSphere.center)),pe.applyMatrix4(le.matrixWorld).applyMatrix4(ve)),Array.isArray(be)){const Ce=Z.groups;for(let Te=0,Se=Ce.length;Te<Se;Te++){const Qe=Ce[Te],ut=be[Qe.materialIndex];ut&&ut.visible&&b.push(le,Z,ut,We,pe.z,Qe)}}else be.visible&&b.push(le,Z,be,We,pe.z,null)}}const _t=le.children;for(let Z=0,be=_t.length;Z<be;Z++)Gn(_t[Z],Ue,We,Xe)}function fr(le,Ue,We,Xe){const Ge=le.opaque,_t=le.transmissive,Z=le.transparent;v.setupLightsView(We),ue===!0&&Ye.setGlobalState(w.clippingPlanes,We),_t.length>0&&Ki(Ge,_t,Ue,We),Xe&&ae.viewport(O.copy(Xe)),Ge.length>0&&hr(Ge,Ue,We),_t.length>0&&hr(_t,Ue,We),Z.length>0&&hr(Z,Ue,We),ae.buffers.depth.setTest(!0),ae.buffers.depth.setMask(!0),ae.buffers.color.setMask(!0),ae.setPolygonOffset(!1)}function Ki(le,Ue,We,Xe){if((We.isScene===!0?We.overrideMaterial:null)!==null)return;const _t=$.isWebGL2;re===null&&(re=new Sf(1,1,{generateMipmaps:!0,type:F.has("EXT_color_buffer_half_float")?D0:Ou,minFilter:P0,samples:_t?4:0})),w.getDrawingBufferSize(Pe),_t?re.setSize(Pe.x,Pe.y):re.setSize(T_(Pe.x),T_(Pe.y));const Z=w.getRenderTarget();w.setRenderTarget(re),w.getClearColor(G),L=w.getClearAlpha(),L<1&&w.setClearColor(16777215,.5),w.clear();const be=w.toneMapping;w.toneMapping=Du,hr(le,We,Xe),oe.updateMultisampleRenderTarget(re),oe.updateRenderTargetMipmap(re);let Ce=!1;for(let Te=0,Se=Ue.length;Te<Se;Te++){const Qe=Ue[Te],ut=Qe.object,vt=Qe.geometry,xt=Qe.material,Rt=Qe.group;if(xt.side===Bl&&ut.layers.test(Xe.layers)){const wt=xt.side;xt.side=ka,xt.needsUpdate=!0,Cr(ut,We,Xe,vt,xt,Rt),xt.side=wt,xt.needsUpdate=!0,Ce=!0}}Ce===!0&&(oe.updateMultisampleRenderTarget(re),oe.updateRenderTargetMipmap(re)),w.setRenderTarget(Z),w.setClearColor(G,L),w.toneMapping=be}function hr(le,Ue,We){const Xe=Ue.isScene===!0?Ue.overrideMaterial:null;for(let Ge=0,_t=le.length;Ge<_t;Ge++){const Z=le[Ge],be=Z.object,Ce=Z.geometry,Te=Xe===null?Z.material:Xe,Se=Z.group;be.layers.test(We.layers)&&Cr(be,Ue,We,Ce,Te,Se)}}function Cr(le,Ue,We,Xe,Ge,_t){le.onBeforeRender(w,Ue,We,Xe,Ge,_t),le.modelViewMatrix.multiplyMatrices(We.matrixWorldInverse,le.matrixWorld),le.normalMatrix.getNormalMatrix(le.modelViewMatrix),Ge.onBeforeRender(w,Ue,We,Xe,le,_t),Ge.transparent===!0&&Ge.side===Bl&&Ge.forceSinglePass===!1?(Ge.side=ka,Ge.needsUpdate=!0,w.renderBufferDirect(We,Ue,Xe,Ge,le,_t),Ge.side=$u,Ge.needsUpdate=!0,w.renderBufferDirect(We,Ue,Xe,Ge,le,_t),Ge.side=Bl):w.renderBufferDirect(We,Ue,Xe,Ge,le,_t),le.onAfterRender(w,Ue,We,Xe,Ge,_t)}function $r(le,Ue,We){Ue.isScene!==!0&&(Ue=we);const Xe=ee.get(le),Ge=v.state.lights,_t=v.state.shadowsArray,Z=Ge.state.version,be=K.getParameters(le,Ge.state,_t,Ue,We),Ce=K.getProgramCacheKey(be);let Te=Xe.programs;Xe.environment=le.isMeshStandardMaterial?Ue.environment:null,Xe.fog=Ue.fog,Xe.envMap=(le.isMeshStandardMaterial?Ne:De).get(le.envMap||Xe.environment),Te===void 0&&(le.addEventListener("dispose",Me),Te=new Map,Xe.programs=Te);let Se=Te.get(Ce);if(Se!==void 0){if(Xe.currentProgram===Se&&Xe.lightsStateVersion===Z)return fi(le,be),Se}else be.uniforms=K.getUniforms(le),le.onBuild(We,be,w),le.onBeforeCompile(be,w),Se=K.acquireProgram(be,Ce),Te.set(Ce,Se),Xe.uniforms=be.uniforms;const Qe=Xe.uniforms;return(!le.isShaderMaterial&&!le.isRawShaderMaterial||le.clipping===!0)&&(Qe.clippingPlanes=Ye.uniform),fi(le,be),Xe.needsLights=Ac(le),Xe.lightsStateVersion=Z,Xe.needsLights&&(Qe.ambientLightColor.value=Ge.state.ambient,Qe.lightProbe.value=Ge.state.probe,Qe.directionalLights.value=Ge.state.directional,Qe.directionalLightShadows.value=Ge.state.directionalShadow,Qe.spotLights.value=Ge.state.spot,Qe.spotLightShadows.value=Ge.state.spotShadow,Qe.rectAreaLights.value=Ge.state.rectArea,Qe.ltc_1.value=Ge.state.rectAreaLTC1,Qe.ltc_2.value=Ge.state.rectAreaLTC2,Qe.pointLights.value=Ge.state.point,Qe.pointLightShadows.value=Ge.state.pointShadow,Qe.hemisphereLights.value=Ge.state.hemi,Qe.directionalShadowMap.value=Ge.state.directionalShadowMap,Qe.directionalShadowMatrix.value=Ge.state.directionalShadowMatrix,Qe.spotShadowMap.value=Ge.state.spotShadowMap,Qe.spotLightMatrix.value=Ge.state.spotLightMatrix,Qe.spotLightMap.value=Ge.state.spotLightMap,Qe.pointShadowMap.value=Ge.state.pointShadowMap,Qe.pointShadowMatrix.value=Ge.state.pointShadowMatrix),Xe.currentProgram=Se,Xe.uniformsList=null,Se}function Oi(le){if(le.uniformsList===null){const Ue=le.currentProgram.getUniforms();le.uniformsList=Jb.seqWithValue(Ue.seq,le.uniforms)}return le.uniformsList}function fi(le,Ue){const We=ee.get(le);We.outputColorSpace=Ue.outputColorSpace,We.batching=Ue.batching,We.instancing=Ue.instancing,We.instancingColor=Ue.instancingColor,We.skinning=Ue.skinning,We.morphTargets=Ue.morphTargets,We.morphNormals=Ue.morphNormals,We.morphColors=Ue.morphColors,We.morphTargetsCount=Ue.morphTargetsCount,We.numClippingPlanes=Ue.numClippingPlanes,We.numIntersection=Ue.numClipIntersection,We.vertexAlphas=Ue.vertexAlphas,We.vertexTangents=Ue.vertexTangents,We.toneMapping=Ue.toneMapping}function Ei(le,Ue,We,Xe,Ge){Ue.isScene!==!0&&(Ue=we),oe.resetTextureUnits();const _t=Ue.fog,Z=Xe.isMeshStandardMaterial?Ue.environment:null,be=N===null?w.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:uc,Ce=(Xe.isMeshStandardMaterial?Ne:De).get(Xe.envMap||Z),Te=Xe.vertexColors===!0&&!!We.attributes.color&&We.attributes.color.itemSize===4,Se=!!We.attributes.tangent&&(!!Xe.normalMap||Xe.anisotropy>0),Qe=!!We.morphAttributes.position,ut=!!We.morphAttributes.normal,vt=!!We.morphAttributes.color;let xt=Du;Xe.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(xt=w.toneMapping);const Rt=We.morphAttributes.position||We.morphAttributes.normal||We.morphAttributes.color,wt=Rt!==void 0?Rt.length:0,pt=ee.get(Xe),Vt=v.state.lights;if(ue===!0&&(xe===!0||le!==R)){const Ai=le===R&&Xe.id===U;Ye.setState(Xe,le,Ai)}let kt=!1;Xe.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==Vt.state.version||pt.outputColorSpace!==be||Ge.isBatchedMesh&&pt.batching===!1||!Ge.isBatchedMesh&&pt.batching===!0||Ge.isInstancedMesh&&pt.instancing===!1||!Ge.isInstancedMesh&&pt.instancing===!0||Ge.isSkinnedMesh&&pt.skinning===!1||!Ge.isSkinnedMesh&&pt.skinning===!0||Ge.isInstancedMesh&&pt.instancingColor===!0&&Ge.instanceColor===null||Ge.isInstancedMesh&&pt.instancingColor===!1&&Ge.instanceColor!==null||pt.envMap!==Ce||Xe.fog===!0&&pt.fog!==_t||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==Ye.numPlanes||pt.numIntersection!==Ye.numIntersection)||pt.vertexAlphas!==Te||pt.vertexTangents!==Se||pt.morphTargets!==Qe||pt.morphNormals!==ut||pt.morphColors!==vt||pt.toneMapping!==xt||$.isWebGL2===!0&&pt.morphTargetsCount!==wt)&&(kt=!0):(kt=!0,pt.__version=Xe.version);let Qt=pt.currentProgram;kt===!0&&(Qt=$r(Xe,Ue,Ge));let on=!1,hn=!1,Ot=!1;const Wt=Qt.getUniforms(),Xt=pt.uniforms;if(ae.useProgram(Qt.program)&&(on=!0,hn=!0,Ot=!0),Xe.id!==U&&(U=Xe.id,hn=!0),on||R!==le){Wt.setValue(ce,"projectionMatrix",le.projectionMatrix),Wt.setValue(ce,"viewMatrix",le.matrixWorldInverse);const Ai=Wt.map.cameraPosition;Ai!==void 0&&Ai.setValue(ce,pe.setFromMatrixPosition(le.matrixWorld)),$.logarithmicDepthBuffer&&Wt.setValue(ce,"logDepthBufFC",2/(Math.log(le.far+1)/Math.LN2)),(Xe.isMeshPhongMaterial||Xe.isMeshToonMaterial||Xe.isMeshLambertMaterial||Xe.isMeshBasicMaterial||Xe.isMeshStandardMaterial||Xe.isShaderMaterial)&&Wt.setValue(ce,"isOrthographic",le.isOrthographicCamera===!0),R!==le&&(R=le,hn=!0,Ot=!0)}if(Ge.isSkinnedMesh){Wt.setOptional(ce,Ge,"bindMatrix"),Wt.setOptional(ce,Ge,"bindMatrixInverse");const Ai=Ge.skeleton;Ai&&($.floatVertexTextures?(Ai.boneTexture===null&&Ai.computeBoneTexture(),Wt.setValue(ce,"boneTexture",Ai.boneTexture,oe)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}Ge.isBatchedMesh&&(Wt.setOptional(ce,Ge,"batchingTexture"),Wt.setValue(ce,"batchingTexture",Ge._matricesTexture,oe));const vi=We.morphAttributes;if((vi.position!==void 0||vi.normal!==void 0||vi.color!==void 0&&$.isWebGL2===!0)&&rt.update(Ge,We,Qt),(hn||pt.receiveShadow!==Ge.receiveShadow)&&(pt.receiveShadow=Ge.receiveShadow,Wt.setValue(ce,"receiveShadow",Ge.receiveShadow)),Xe.isMeshGouraudMaterial&&Xe.envMap!==null&&(Xt.envMap.value=Ce,Xt.flipEnvMap.value=Ce.isCubeTexture&&Ce.isRenderTargetTexture===!1?-1:1),hn&&(Wt.setValue(ce,"toneMappingExposure",w.toneMappingExposure),pt.needsLights&&Ks(Xt,Ot),_t&&Xe.fog===!0&&me.refreshFogUniforms(Xt,_t),me.refreshMaterialUniforms(Xt,Xe,W,q,re),Jb.upload(ce,Oi(pt),Xt,oe)),Xe.isShaderMaterial&&Xe.uniformsNeedUpdate===!0&&(Jb.upload(ce,Oi(pt),Xt,oe),Xe.uniformsNeedUpdate=!1),Xe.isSpriteMaterial&&Wt.setValue(ce,"center",Ge.center),Wt.setValue(ce,"modelViewMatrix",Ge.modelViewMatrix),Wt.setValue(ce,"normalMatrix",Ge.normalMatrix),Wt.setValue(ce,"modelMatrix",Ge.matrixWorld),Xe.isShaderMaterial||Xe.isRawShaderMaterial){const Ai=Xe.uniformsGroups;for(let Tn=0,Ys=Ai.length;Tn<Ys;Tn++)if($.isWebGL2){const Rn=Ai[Tn];et.update(Rn,Qt),et.bind(Rn,Qt)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Qt}function Ks(le,Ue){le.ambientLightColor.needsUpdate=Ue,le.lightProbe.needsUpdate=Ue,le.directionalLights.needsUpdate=Ue,le.directionalLightShadows.needsUpdate=Ue,le.pointLights.needsUpdate=Ue,le.pointLightShadows.needsUpdate=Ue,le.spotLights.needsUpdate=Ue,le.spotLightShadows.needsUpdate=Ue,le.rectAreaLights.needsUpdate=Ue,le.hemisphereLights.needsUpdate=Ue}function Ac(le){return le.isMeshLambertMaterial||le.isMeshToonMaterial||le.isMeshPhongMaterial||le.isMeshStandardMaterial||le.isShadowMaterial||le.isShaderMaterial&&le.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return P},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(le,Ue,We){ee.get(le.texture).__webglTexture=Ue,ee.get(le.depthTexture).__webglTexture=We;const Xe=ee.get(le);Xe.__hasExternalTextures=!0,Xe.__hasExternalTextures&&(Xe.__autoAllocateDepthBuffer=We===void 0,Xe.__autoAllocateDepthBuffer||F.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Xe.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(le,Ue){const We=ee.get(le);We.__webglFramebuffer=Ue,We.__useDefaultFramebuffer=Ue===void 0},this.setRenderTarget=function(le,Ue=0,We=0){N=le,T=Ue,P=We;let Xe=!0,Ge=null,_t=!1,Z=!1;if(le){const Ce=ee.get(le);Ce.__useDefaultFramebuffer!==void 0?(ae.bindFramebuffer(ce.FRAMEBUFFER,null),Xe=!1):Ce.__webglFramebuffer===void 0?oe.setupRenderTarget(le):Ce.__hasExternalTextures&&oe.rebindTextures(le,ee.get(le.texture).__webglTexture,ee.get(le.depthTexture).__webglTexture);const Te=le.texture;(Te.isData3DTexture||Te.isDataArrayTexture||Te.isCompressedArrayTexture)&&(Z=!0);const Se=ee.get(le).__webglFramebuffer;le.isWebGLCubeRenderTarget?(Array.isArray(Se[Ue])?Ge=Se[Ue][We]:Ge=Se[Ue],_t=!0):$.isWebGL2&&le.samples>0&&oe.useMultisampledRTT(le)===!1?Ge=ee.get(le).__webglMultisampledFramebuffer:Array.isArray(Se)?Ge=Se[We]:Ge=Se,O.copy(le.viewport),z.copy(le.scissor),I=le.scissorTest}else O.copy(ie).multiplyScalar(W).floor(),z.copy(H).multiplyScalar(W).floor(),I=Y;if(ae.bindFramebuffer(ce.FRAMEBUFFER,Ge)&&$.drawBuffers&&Xe&&ae.drawBuffers(le,Ge),ae.viewport(O),ae.scissor(z),ae.setScissorTest(I),_t){const Ce=ee.get(le.texture);ce.framebufferTexture2D(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,ce.TEXTURE_CUBE_MAP_POSITIVE_X+Ue,Ce.__webglTexture,We)}else if(Z){const Ce=ee.get(le.texture),Te=Ue||0;ce.framebufferTextureLayer(ce.FRAMEBUFFER,ce.COLOR_ATTACHMENT0,Ce.__webglTexture,We||0,Te)}U=-1},this.readRenderTargetPixels=function(le,Ue,We,Xe,Ge,_t,Z){if(!(le&&le.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=ee.get(le).__webglFramebuffer;if(le.isWebGLCubeRenderTarget&&Z!==void 0&&(be=be[Z]),be){ae.bindFramebuffer(ce.FRAMEBUFFER,be);try{const Ce=le.texture,Te=Ce.format,Se=Ce.type;if(Te!==Ls&&ht.convert(Te)!==ce.getParameter(ce.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Qe=Se===D0&&(F.has("EXT_color_buffer_half_float")||$.isWebGL2&&F.has("EXT_color_buffer_float"));if(Se!==Ou&&ht.convert(Se)!==ce.getParameter(ce.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Se===ql&&($.isWebGL2||F.has("OES_texture_float")||F.has("WEBGL_color_buffer_float")))&&!Qe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ue>=0&&Ue<=le.width-Xe&&We>=0&&We<=le.height-Ge&&ce.readPixels(Ue,We,Xe,Ge,ht.convert(Te),ht.convert(Se),_t)}finally{const Ce=N!==null?ee.get(N).__webglFramebuffer:null;ae.bindFramebuffer(ce.FRAMEBUFFER,Ce)}}},this.copyFramebufferToTexture=function(le,Ue,We=0){const Xe=Math.pow(2,-We),Ge=Math.floor(Ue.image.width*Xe),_t=Math.floor(Ue.image.height*Xe);oe.setTexture2D(Ue,0),ce.copyTexSubImage2D(ce.TEXTURE_2D,We,0,0,le.x,le.y,Ge,_t),ae.unbindTexture()},this.copyTextureToTexture=function(le,Ue,We,Xe=0){const Ge=Ue.image.width,_t=Ue.image.height,Z=ht.convert(We.format),be=ht.convert(We.type);oe.setTexture2D(We,0),ce.pixelStorei(ce.UNPACK_FLIP_Y_WEBGL,We.flipY),ce.pixelStorei(ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,We.premultiplyAlpha),ce.pixelStorei(ce.UNPACK_ALIGNMENT,We.unpackAlignment),Ue.isDataTexture?ce.texSubImage2D(ce.TEXTURE_2D,Xe,le.x,le.y,Ge,_t,Z,be,Ue.image.data):Ue.isCompressedTexture?ce.compressedTexSubImage2D(ce.TEXTURE_2D,Xe,le.x,le.y,Ue.mipmaps[0].width,Ue.mipmaps[0].height,Z,Ue.mipmaps[0].data):ce.texSubImage2D(ce.TEXTURE_2D,Xe,le.x,le.y,Z,be,Ue.image),Xe===0&&We.generateMipmaps&&ce.generateMipmap(ce.TEXTURE_2D),ae.unbindTexture()},this.copyTextureToTexture3D=function(le,Ue,We,Xe,Ge=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const _t=le.max.x-le.min.x+1,Z=le.max.y-le.min.y+1,be=le.max.z-le.min.z+1,Ce=ht.convert(Xe.format),Te=ht.convert(Xe.type);let Se;if(Xe.isData3DTexture)oe.setTexture3D(Xe,0),Se=ce.TEXTURE_3D;else if(Xe.isDataArrayTexture)oe.setTexture2DArray(Xe,0),Se=ce.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ce.pixelStorei(ce.UNPACK_FLIP_Y_WEBGL,Xe.flipY),ce.pixelStorei(ce.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Xe.premultiplyAlpha),ce.pixelStorei(ce.UNPACK_ALIGNMENT,Xe.unpackAlignment);const Qe=ce.getParameter(ce.UNPACK_ROW_LENGTH),ut=ce.getParameter(ce.UNPACK_IMAGE_HEIGHT),vt=ce.getParameter(ce.UNPACK_SKIP_PIXELS),xt=ce.getParameter(ce.UNPACK_SKIP_ROWS),Rt=ce.getParameter(ce.UNPACK_SKIP_IMAGES),wt=We.isCompressedTexture?We.mipmaps[0]:We.image;ce.pixelStorei(ce.UNPACK_ROW_LENGTH,wt.width),ce.pixelStorei(ce.UNPACK_IMAGE_HEIGHT,wt.height),ce.pixelStorei(ce.UNPACK_SKIP_PIXELS,le.min.x),ce.pixelStorei(ce.UNPACK_SKIP_ROWS,le.min.y),ce.pixelStorei(ce.UNPACK_SKIP_IMAGES,le.min.z),We.isDataTexture||We.isData3DTexture?ce.texSubImage3D(Se,Ge,Ue.x,Ue.y,Ue.z,_t,Z,be,Ce,Te,wt.data):We.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ce.compressedTexSubImage3D(Se,Ge,Ue.x,Ue.y,Ue.z,_t,Z,be,Ce,wt.data)):ce.texSubImage3D(Se,Ge,Ue.x,Ue.y,Ue.z,_t,Z,be,Ce,Te,wt),ce.pixelStorei(ce.UNPACK_ROW_LENGTH,Qe),ce.pixelStorei(ce.UNPACK_IMAGE_HEIGHT,ut),ce.pixelStorei(ce.UNPACK_SKIP_PIXELS,vt),ce.pixelStorei(ce.UNPACK_SKIP_ROWS,xt),ce.pixelStorei(ce.UNPACK_SKIP_IMAGES,Rt),Ge===0&&Xe.generateMipmaps&&ce.generateMipmap(Se),ae.unbindTexture()},this.initTexture=function(le){le.isCubeTexture?oe.setTextureCube(le,0):le.isData3DTexture?oe.setTexture3D(le,0):le.isDataArrayTexture||le.isCompressedArrayTexture?oe.setTexture2DArray(le,0):oe.setTexture2D(le,0),ae.unbindTexture()},this.resetState=function(){T=0,P=0,N=null,ae.reset(),tt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Fo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===SP?"display-p3":"srgb",n.unpackColorSpace=Bn.workingColorSpace===DS?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===zr?rf:$G}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===rf?zr:uc}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Rve extends QN{}Rve.prototype.isWebGL1Renderer=!0;class CP{constructor(e,n=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ft(e),this.near=n,this.far=i}clone(){return new CP(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Pve extends ma{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(n.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(n.object.backgroundIntensity=this.backgroundIntensity),n}}class Dve{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=XN,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=ec()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,i){e*=this.stride,i*=n.stride;for(let r=0,a=this.stride;r<a;r++)this.array[e+r]=n.array[i+r];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ec()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(n,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ec()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const oa=new Ae;class Eu{constructor(e,n,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,i=this.data.count;n<i;n++)oa.fromBufferAttribute(this,n),oa.applyMatrix4(e),this.setXYZ(n,oa.x,oa.y,oa.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)oa.fromBufferAttribute(this,n),oa.applyNormalMatrix(e),this.setXYZ(n,oa.x,oa.y,oa.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)oa.fromBufferAttribute(this,n),oa.transformDirection(e),this.setXYZ(n,oa.x,oa.y,oa.z);return this}setX(e,n){return this.normalized&&(n=zn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=zn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=zn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=zn(n,this.array)),this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){let n=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(n=Uo(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=Uo(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=Uo(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=Uo(n,this.array)),n}setXY(e,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=zn(n,this.array),i=zn(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=i,this}setXYZ(e,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=zn(n,this.array),i=zn(i,this.array),r=zn(r,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,n,i,r,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=zn(n,this.array),i=zn(i,this.array),r=zn(r,this.array),a=zn(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[r+a])}return new ss(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Eu(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[r+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ove extends La{constructor(e=null,n=1,i=1,r,a,s,o,l,c=Fr,d=Fr,f,p){super(null,s,o,l,c,d,r,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function kve(t,e){return t.z-e.z}function Lve(t,e){return e.z-t.z}class Ive{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1});const a=i[this.index];r.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const Zh="batchId",ou=new Zn,Sz=new Zn,Uve=new Zn,wz=new Zn,dT=new OS,ib=new Bs,kd=new Bo,Cg=new Ae,fT=new Ive,Yr=new po,rb=[];function jve(t,e,n=0){const i=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const r=t.count;for(let a=0;a<r;a++)for(let s=0;s<i;s++)e.setComponent(a+n,s,t.getComponent(a,s))}else e.array.set(t.array,n*i);e.needsUpdate=!0}class Fve extends po{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,i=n*2,r){super(new ia,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=n,this._maxIndexCount=i,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const n=new Float32Array(e*e*4),i=new Ove(n,e,e,Ls,ql);this._matricesTexture=i}_initializeGeometry(e){const n=this.geometry,i=this._maxVertexCount,r=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const l=e.getAttribute(o),{array:c,itemSize:d,normalized:f}=l,p=new c.constructor(i*d),m=new l.constructor(p,d,f);m.setUsage(l.usage),n.setAttribute(o,m)}if(e.getIndex()!==null){const o=i>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new ss(o,1))}const s=r>65536?new Uint32Array(i):new Uint16Array(i);n.setAttribute(Zh,new ss(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Zh))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Zh}"`);const n=this.geometry;if(!!e.getIndex()!=!!n.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const i in n.attributes){if(i===Zh)continue;if(!e.hasAttribute(i))throw new Error(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);const r=e.getAttribute(i),a=n.getAttribute(i);if(r.itemSize!==a.itemSize||r.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bs);const e=this._geometryCount,n=this.boundingBox,i=this._active;n.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,ou),this.getBoundingBoxAt(r,ib).applyMatrix4(ou),n.union(ib))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Bo);const e=this._geometryCount,n=this.boundingSphere,i=this._active;n.makeEmpty();for(let r=0;r<e;r++)i[r]!==!1&&(this.getMatrixAt(r,ou),this.getBoundingSphereAt(r,kd).applyMatrix4(ou),n.union(kd))}addGeometry(e,n=-1,i=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const s=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(a=s[s.length-1]),n===-1?r.vertexCount=e.getAttribute("position").count:r.vertexCount=n,a===null?r.vertexStart=0:r.vertexStart=a.vertexStart+a.vertexCount;const c=e.getIndex(),d=c!==null;if(d&&(i===-1?r.indexCount=c.count:r.indexCount=i,a===null?r.indexStart=0:r.indexStart=a.indexStart+a.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,p=this._active,m=this._matricesTexture,_=this._matricesTexture.image.data;f.push(!0),p.push(!0);const b=this._geometryCount;this._geometryCount++,Uve.toArray(_,b*16),m.needsUpdate=!0,s.push(r),o.push({start:d?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Bs,sphereInitialized:!1,sphere:new Bo});const v=this.geometry.getAttribute(Zh);for(let x=0;x<r.vertexCount;x++)v.setX(r.vertexStart+x,b);return v.needsUpdate=!0,this.setGeometryAt(b,e),b}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const i=this.geometry,r=i.getIndex()!==null,a=i.getIndex(),s=n.getIndex(),o=this._reservedRanges[e];if(r&&s.count>o.indexCount||n.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const m in i.attributes){if(m===Zh)continue;const _=n.getAttribute(m),b=i.getAttribute(m);jve(_,b,l);const v=_.itemSize;for(let x=_.count,M=c;x<M;x++){const w=l+x;for(let E=0;E<v;E++)b.setComponent(w,E,0)}b.needsUpdate=!0}if(r){const m=o.indexStart;for(let _=0;_<s.count;_++)a.setX(m+_,l+s.getX(_));for(let _=s.count,b=o.indexCount;_<b;_++)a.setX(m+_,l);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],p=n.getAttribute("position");return f.count=r?s.count:p.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const r=this._bounds[e],a=r.box,s=this.geometry;if(r.boxInitialized===!1){a.makeEmpty();const o=s.index,l=s.attributes.position,c=this._drawRanges[e];for(let d=c.start,f=c.start+c.count;d<f;d++){let p=d;o&&(p=o.getX(p)),a.expandByPoint(Cg.fromBufferAttribute(l,p))}r.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const r=this._bounds[e],a=r.sphere,s=this.geometry;if(r.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,ib),ib.getCenter(a.center);const o=s.index,l=s.attributes.position,c=this._drawRanges[e];let d=0;for(let f=c.start,p=c.start+c.count;f<p;f++){let m=f;o&&(m=o.getX(m)),Cg.fromBufferAttribute(l,m),d=Math.max(d,a.center.distanceToSquared(Cg))}a.radius=Math.sqrt(d),r.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const i=this._active,r=this._matricesTexture,a=this._matricesTexture.image.data,s=this._geometryCount;return e>=s||i[e]===!1?this:(n.toArray(a,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,n){const i=this._active,r=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||i[e]===!1?null:n.fromArray(r,e*16)}setVisibleAt(e,n){const i=this._visibility,r=this._active,a=this._geometryCount;return e>=a||r[e]===!1||i[e]===n?this:(i[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1?!1:n[e]}raycast(e,n){const i=this._visibility,r=this._active,a=this._drawRanges,s=this._geometryCount,o=this.matrixWorld,l=this.geometry;Yr.material=this.material,Yr.geometry.index=l.index,Yr.geometry.attributes=l.attributes,Yr.geometry.boundingBox===null&&(Yr.geometry.boundingBox=new Bs),Yr.geometry.boundingSphere===null&&(Yr.geometry.boundingSphere=new Bo);for(let c=0;c<s;c++){if(!i[c]||!r[c])continue;const d=a[c];Yr.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(c,Yr.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,Yr.geometry.boundingBox),this.getBoundingSphereAt(c,Yr.geometry.boundingSphere),Yr.raycast(e,rb);for(let f=0,p=rb.length;f<p;f++){const m=rb[f];m.object=this,m.batchId=c,n.push(m)}rb.length=0}Yr.material=null,Yr.geometry.index=null,Yr.geometry.attributes={},Yr.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,i,r,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const s=r.getIndex(),o=s===null?1:s.array.BYTES_PER_ELEMENT,l=this._visibility,c=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,p=this.perObjectFrustumCulled;p&&(wz.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),dT.setFromProjectionMatrix(wz,e.isWebGPURenderer?O0:Fo));let m=0;if(this.sortObjects){Sz.copy(this.matrixWorld).invert(),Cg.setFromMatrixPosition(i.matrixWorld).applyMatrix4(Sz);for(let v=0,x=l.length;v<x;v++)if(l[v]){this.getMatrixAt(v,ou),this.getBoundingSphereAt(v,kd).applyMatrix4(ou);let M=!1;if(p&&(M=!dT.intersectsSphere(kd)),!M){const w=Cg.distanceTo(kd.center);fT.push(f[v],w)}}const _=fT.list,b=this.customSort;b===null?_.sort(a.transparent?Lve:kve):b.call(this,_,i);for(let v=0,x=_.length;v<x;v++){const M=_[v];c[m]=M.start*o,d[m]=M.count,m++}fT.reset()}else for(let _=0,b=l.length;_<b;_++)if(l[_]){let v=!1;if(p&&(this.getMatrixAt(_,ou),this.getBoundingSphereAt(_,kd).applyMatrix4(ou),v=!dT.intersectsSphere(kd)),!v){const x=f[_];c[m]=x.start*o,d[m]=x.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,i,r,a,s){this.onBeforeRender(e,null,r,a,s)}}class yx extends lm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ft(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Mz=new Ae,Ez=new Ae,Az=new Zn,hT=new MP,ab=new Bo;class zve extends ma{constructor(e=new ia,n=new yx){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,i=[0];for(let r=1,a=n.count;r<a;r++)Mz.fromBufferAttribute(n,r-1),Ez.fromBufferAttribute(n,r),i[r]=i[r-1],i[r]+=Mz.distanceTo(Ez);e.setAttribute("lineDistance",new Pi(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),ab.copy(i.boundingSphere),ab.applyMatrix4(r),ab.radius+=a,e.ray.intersectsSphere(ab)===!1)return;Az.copy(r).invert(),hT.copy(e.ray).applyMatrix4(Az);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new Ae,d=new Ae,f=new Ae,p=new Ae,m=this.isLineSegments?2:1,_=i.index,v=i.attributes.position;if(_!==null){const x=Math.max(0,s.start),M=Math.min(_.count,s.start+s.count);for(let w=x,E=M-1;w<E;w+=m){const T=_.getX(w),P=_.getX(w+1);if(c.fromBufferAttribute(v,T),d.fromBufferAttribute(v,P),hT.distanceSqToSegment(c,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);const U=e.ray.origin.distanceTo(p);U<e.near||U>e.far||n.push({distance:U,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const x=Math.max(0,s.start),M=Math.min(v.count,s.start+s.count);for(let w=x,E=M-1;w<E;w+=m){if(c.fromBufferAttribute(v,w),d.fromBufferAttribute(v,w+1),hT.distanceSqToSegment(c,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(p);P<e.near||P>e.far||n.push({distance:P,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,i=Object.keys(n);if(i.length>0){const r=n[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,s=r.length;a<s;a++){const o=r[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}}const Tz=new Ae,Cz=new Ae;class LS extends zve{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,i=[];for(let r=0,a=n.count;r<a;r+=2)Tz.fromBufferAttribute(n,r),Cz.fromBufferAttribute(n,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+Tz.distanceTo(Cz);e.setAttribute("lineDistance",new Pi(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Bve extends ia{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],i=new Set,r=new Ae,a=new Ae;if(e.index!==null){const s=e.attributes.position,o=e.index;let l=e.groups;l.length===0&&(l=[{start:0,count:o.count,materialIndex:0}]);for(let c=0,d=l.length;c<d;++c){const f=l[c],p=f.start,m=f.count;for(let _=p,b=p+m;_<b;_+=3)for(let v=0;v<3;v++){const x=o.getX(_+v),M=o.getX(_+(v+1)%3);r.fromBufferAttribute(s,x),a.fromBufferAttribute(s,M),Nz(r,a,i)===!0&&(n.push(r.x,r.y,r.z),n.push(a.x,a.y,a.z))}}}else{const s=e.attributes.position;for(let o=0,l=s.count/3;o<l;o++)for(let c=0;c<3;c++){const d=3*o+c,f=3*o+(c+1)%3;r.fromBufferAttribute(s,d),a.fromBufferAttribute(s,f),Nz(r,a,i)===!0&&(n.push(r.x,r.y,r.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Pi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Nz(t,e,n){const i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return n.has(i)===!0||n.has(r)===!0?!1:(n.add(i),n.add(r),!0)}class Hve extends lm{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ft(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=GG,this.normalScale=new Gt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=bP,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Vve extends yx{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class h9 extends ma{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Ft(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}const pT=new Zn,Rz=new Ae,Pz=new Ae;class $ve{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Gt(512,512),this.map=null,this.mapPass=null,this.matrix=new Zn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new OS,this._frameExtents=new Gt(1,1),this._viewportCount=1,this._viewports=[new Vn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,i=this.matrix;Rz.setFromMatrixPosition(e.matrixWorld),n.position.copy(Rz),Pz.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(Pz),n.updateMatrixWorld(),pT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(pT),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(pT)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Dz=new Zn,Ng=new Ae,mT=new Ae;class Gve extends $ve{constructor(){super(new ts(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Gt(4,2),this._viewportCount=6,this._viewports=[new Vn(2,1,1,1),new Vn(0,1,1,1),new Vn(3,1,1,1),new Vn(1,1,1,1),new Vn(3,0,1,1),new Vn(1,0,1,1)],this._cubeDirections=[new Ae(1,0,0),new Ae(-1,0,0),new Ae(0,0,1),new Ae(0,0,-1),new Ae(0,1,0),new Ae(0,-1,0)],this._cubeUps=[new Ae(0,1,0),new Ae(0,1,0),new Ae(0,1,0),new Ae(0,1,0),new Ae(0,0,1),new Ae(0,0,-1)]}updateMatrices(e,n=0){const i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),Ng.setFromMatrixPosition(e.matrixWorld),i.position.copy(Ng),mT.copy(i.position),mT.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(mT),i.updateMatrixWorld(),r.makeTranslation(-Ng.x,-Ng.y,-Ng.z),Dz.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Dz)}}class Wve extends h9{constructor(e,n,i=0,r=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new Gve}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class qve extends h9{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class Xve extends ia{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class JN extends Dve{constructor(e,n,i=1){super(e,n),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const n=super.clone(e);return n.meshPerAttribute=this.meshPerAttribute,n}toJSON(e){const n=super.toJSON(e);return n.isInstancedInterleavedBuffer=!0,n.meshPerAttribute=this.meshPerAttribute,n}}class Oz{constructor(e=1,n=0,i=0){return this.radius=e,this.phi=n,this.theta=i,this}set(e,n,i){return this.radius=e,this.phi=n,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,i){return this.radius=Math.sqrt(e*e+n*n+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Br(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const kz=new Ae,sb=new Ae;class Kve{constructor(e=new Ae,n=new Ae){this.start=e,this.end=n}set(e,n){return this.start.copy(e),this.end.copy(n),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){kz.subVectors(e,this.start),sb.subVectors(this.end,this.start);const i=sb.dot(sb);let a=sb.dot(kz)/i;return n&&(a=Br(a,0,1)),a}closestPointToPoint(e,n,i){const r=this.closestPointToPointParameter(e,n);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class Yve extends LS{constructor(e=1){const n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new ia;r.setAttribute("position",new Pi(n,3)),r.setAttribute("color",new Pi(i,3));const a=new yx({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,n,i){const r=new Ft,a=this.geometry.attributes.color.array;return r.set(e),r.toArray(a,0),r.toArray(a,3),r.set(n),r.toArray(a,6),r.toArray(a,9),r.set(i),r.toArray(a,12),r.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:RS}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=RS);class Ho{constructor(e,n,i,r,a="div"){this.parent=e,this.object=n,this.property=i,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(r),this.$name=document.createElement("div"),this.$name.classList.add("name"),Ho.nextNameID=Ho.nextNameID||0,this.$name.id=`lil-gui-name-${++Ho.nextNameID}`,this.$widget=document.createElement("div"),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.domElement.addEventListener("keydown",s=>s.stopPropagation()),this.domElement.addEventListener("keyup",s=>s.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(i)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const n=this.parent.add(this.object,this.property,e);return n.name(this._name),this.destroy(),n}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class Zve extends Ho{constructor(e,n,i){super(e,n,i,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function e3(t){let e,n;return(e=t.match(/(#|0x)?([a-f0-9]{6})/i))?n=e[2]:(e=t.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?n=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=t.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(n=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),n?"#"+n:!1}const Qve={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:e3,toHexString:e3},L0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},Jve={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const i=L0.fromHexString(t);e[0]=(i>>16&255)/255*n,e[1]=(i>>8&255)/255*n,e[2]=(i&255)/255*n},toHexString([t,e,n],i=1){i=255/i;const r=t*i<<16^e*i<<8^n*i<<0;return L0.toHexString(r)}},eye={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const i=L0.fromHexString(t);e.r=(i>>16&255)/255*n,e.g=(i>>8&255)/255*n,e.b=(i&255)/255*n},toHexString({r:t,g:e,b:n},i=1){i=255/i;const r=t*i<<16^e*i<<8^n*i<<0;return L0.toHexString(r)}},tye=[Qve,L0,Jve,eye];function nye(t){return tye.find(e=>e.match(t))}class iye extends Ho{constructor(e,n,i,r){super(e,n,i,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=nye(this.initialValue),this._rgbScale=r,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=e3(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class gT extends Ho{constructor(e,n,i){super(e,n,i,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",r=>{r.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class rye extends Ho{constructor(e,n,i,r,a,s){super(e,n,i,"number"),this._initInput(),this.min(r),this.max(a);const o=s!==void 0;this.step(o?s:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,n=!0){return this._step=e,this._stepExplicit=n,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let n=(e-this._min)/(this._max-this._min);n=Math.max(0,Math.min(n,1)),this.$fill.style.width=n*100+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),window.matchMedia("(pointer: coarse)").matches&&(this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any")),this.$widget.appendChild(this.$input),this.$disable=this.$input;const n=()=>{let M=parseFloat(this.$input.value);isNaN(M)||(this._stepExplicit&&(M=this._snap(M)),this.setValue(this._clamp(M)))},i=M=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+M),this.$input.value=this.getValue())},r=M=>{M.key==="Enter"&&this.$input.blur(),M.code==="ArrowUp"&&(M.preventDefault(),i(this._step*this._arrowKeyMultiplier(M))),M.code==="ArrowDown"&&(M.preventDefault(),i(this._step*this._arrowKeyMultiplier(M)*-1))},a=M=>{this._inputFocused&&(M.preventDefault(),i(this._step*this._normalizeMouseWheel(M)))};let s=!1,o,l,c,d,f;const p=5,m=M=>{o=M.clientX,l=c=M.clientY,s=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",_),window.addEventListener("mouseup",b)},_=M=>{if(s){const w=M.clientX-o,E=M.clientY-l;Math.abs(E)>p?(M.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>p&&b()}if(!s){const w=M.clientY-c;f-=w*this._step*this._arrowKeyMultiplier(M),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}c=M.clientY},b=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",b)},v=()=>{this._inputFocused=!0},x=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",r),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",x)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(x,M,w,E,T)=>(x-M)/(w-M)*(T-E)+E,n=x=>{const M=this.$slider.getBoundingClientRect();let w=e(x,M.left,M.right,this._min,this._max);this._snapClampSetValue(w)},i=x=>{this._setDraggingStyle(!0),n(x.clientX),window.addEventListener("mousemove",r),window.addEventListener("mouseup",a)},r=x=>{n(x.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",a)};let s=!1,o,l;const c=x=>{x.preventDefault(),this._setDraggingStyle(!0),n(x.touches[0].clientX),s=!1},d=x=>{x.touches.length>1||(this._hasScrollBar?(o=x.touches[0].clientX,l=x.touches[0].clientY,s=!0):c(x),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",p))},f=x=>{if(s){const M=x.touches[0].clientX-o,w=x.touches[0].clientY-l;Math.abs(M)>Math.abs(w)?c(x):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p))}else x.preventDefault(),n(x.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p)},m=this._callOnFinishChange.bind(this),_=400;let b;const v=x=>{if(Math.abs(x.deltaX)<Math.abs(x.deltaY)&&this._hasScrollBar)return;x.preventDefault();const w=this._normalizeMouseWheel(x)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(b),b=setTimeout(m,_)};this.$slider.addEventListener("mousedown",i),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",v,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:i}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,i=-e.wheelDelta/120,i*=this._stepExplicit?1:10),n+-i}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class aye extends Ho{constructor(e,n,i,r){super(e,n,i,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(r)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(n=>{const i=document.createElement("option");i.textContent=n,this.$select.appendChild(i)}),this.updateDisplay(),this}updateDisplay(){const e=this.getValue(),n=this._values.indexOf(e);return this.$select.selectedIndex=n,this.$display.textContent=n===-1?e:this._names[n],this}}class sye extends Ho{constructor(e,n,i){super(e,n,i,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("spellcheck","false"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",r=>{r.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}const oye=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function lye(t){const e=document.createElement("style");e.innerHTML=t;const n=document.querySelector("head link[rel=stylesheet], head style");n?document.head.insertBefore(e,n):document.head.appendChild(e)}let Lz=!1;class N_{constructor({parent:e,autoPlace:n=e===void 0,container:i,width:r,title:a="Controls",closeFolders:s=!1,injectStyles:o=!0,touchStyles:l=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",c=>{(c.code==="Enter"||c.code==="Space")&&(c.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),l&&this.domElement.classList.add("allow-touch-styles"),!Lz&&o&&(lye(oye),Lz=!0),i?i.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),r&&this.domElement.style.setProperty("--width",r+"px"),this._closeFolders=s}add(e,n,i,r,a){if(Object(i)===i)return new aye(this,e,n,i);const s=e[n];switch(typeof s){case"number":return new rye(this,e,n,i,r,a);case"boolean":return new Zve(this,e,n);case"string":return new sye(this,e,n);case"function":return new gT(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,s)}addColor(e,n,i=1){return new iye(this,e,n,i)}addFolder(e){const n=new N_({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(i=>{i instanceof gT||i._name in e.controllers&&i.load(e.controllers[i._name])}),n&&e.folders&&this.folders.forEach(i=>{i._title in e.folders&&i.load(e.folders[i._title])}),this}save(e=!0){const n={controllers:{},folders:{}};return this.controllers.forEach(i=>{if(!(i instanceof gT)){if(i._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${i._name}"`);n.controllers[i._name]=i.save()}}),e&&this.folders.forEach(i=>{if(i._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${i._title}"`);n.folders[i._title]=i.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const i=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",i))};this.$children.addEventListener("transitionend",i);const r=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=r+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(i=>i.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function xT(t,e,n,i){return new(n||(n=Promise))((function(r,a){function s(c){try{l(i.next(c))}catch(d){a(d)}}function o(c){try{l(i.throw(c))}catch(d){a(d)}}function l(c){var d;c.done?r(c.value):(d=c.value,d instanceof n?d:new n((function(f){f(d)}))).then(s,o)}l((i=i.apply(t,[])).next())}))}class NP{constructor(e,n,i,r){this.size=e,this.width=n,this.height=i,this.charLength=r,this.chars=""}static parse(e){const n=e.split(" "),i=n[0],r=i.split("x");return new NP(i,+r[0],+r[1],+n[1])}get src(){return"data:image/jpeg;base64,"+this.chars}get isValid(){return this.chars.length==this.charLength&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(this.chars)}}class RP{constructor(e,n,i,r){this.src=e,this.gcode=n,this.params=i,this.comment=r}}class Iz extends RP{constructor(e,n,i,r){super(e,n,i,r),this.params=i}}class lu extends RP{constructor(e,n,i,r){super(e,n,void 0,i),this.toolIndex=r}}class Uz{constructor(e,n,i,r=0){this.layer=e,this.commands=n,this.lineNumber=i,this.height=r}}class R_{constructor(e){this.lines=[],this.preamble=new Uz(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const i=this.lines2commands(n);this.groupIntoLayers(i);const r=this.parseMetadata(i.filter((a=>a.comment))).thumbnails;for(const[a,s]of Object.entries(r))this.metadata.thumbnails[a]=s;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var i;const r=e.trim().split(";"),a=r[0],s=n&&r[1]||void 0,o=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),l=o.length?`${(i=o[0])===null||i===void 0?void 0:i.toLowerCase()}${o[1]}`:"",c=this.parseParams(o.slice(2));switch(l){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new Iz(e,l,c,s);case"t0":return new lu(e,l,s,0);case"t1":return new lu(e,l,s,1);case"t2":return new lu(e,l,s,2);case"t3":return new lu(e,l,s,3);case"t4":return new lu(e,l,s,4);case"t5":return new lu(e,l,s,5);case"t6":return new lu(e,l,s,6);case"t7":return new lu(e,l,s,7);default:return new RP(e,l,c,s)}}parseMove(e){return e.reduce(((n,i)=>{const r=i.charAt(0).toLowerCase();return r!="x"&&r!="y"&&r!="z"&&r!="e"&&r!="r"&&r!="f"&&r!="i"&&r!="j"||(n[r]=parseFloat(i.slice(1))),n}),{})}isAlpha(e){const n=e.charCodeAt(0);return n>=97&&n<=122||n>=65&&n<=90}parseParams(e){return e.reduce(((n,i,r,a)=>{if(r%2==0)return n;let s=a[r-1];return s=s.toLowerCase(),this.isAlpha(s)&&(n[s]=parseFloat(i)),n}),{})}groupIntoLayers(e){var n;for(let i=0;i<e.length;i++){const r=e[i];if(r instanceof Iz){const a=r.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const s=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new Uz(this.layers.length,[],i,s))}}this.maxLayer.commands.push(r)}return this.layers}get maxLayer(){var e;return(e=this.layers[this.layers.length-1])!==null&&e!==void 0?e:this.preamble}parseMetadata(e){const n={};let i;for(const r of e){const a=r.comment;if(!a)continue;const s=a.indexOf("thumbnail begin"),o=a.indexOf("thumbnail end");s>-1?i=NP.parse(a.slice(s+15).trim()):i&&(o==-1?i.chars+=a.trim():(i.isValid&&(n[i.size]=i),i=void 0))}return{thumbnails:n}}}R_.prototype.parseGcode=R_.prototype.parseGCode;const jz={type:"change"},vT={type:"start"},Fz={type:"end"},ob=new MP,zz=new fu,cye=Math.cos(70*qG.DEG2RAD);class uye extends jf{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Ae,this.cursor=new Ae,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Oh.ROTATE,MIDDLE:Oh.DOLLY,RIGHT:Oh.PAN},this.touches={ONE:kh.ROTATE,TWO:kh.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function($){$.addEventListener("keydown",ze),this._domElementKeyEvents=$},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ze),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(jz),i.update(),a=r.NONE},this.update=(function(){const $=new Ae,ae=new wf().setFromUnitVectors(e.up,new Ae(0,1,0)),J=ae.clone().invert(),ee=new Ae,oe=new wf,De=new Ae,Ne=2*Math.PI;return function(te=null){const j=i.object.position;$.copy(j).sub(i.target),$.applyQuaternion(ae),o.setFromVector3($),i.autoRotate&&a===r.NONE&&O((function(ye){return ye!==null?2*Math.PI/60*i.autoRotateSpeed*ye:2*Math.PI/60/60*i.autoRotateSpeed})(te)),i.enableDamping?(o.theta+=l.theta*i.dampingFactor,o.phi+=l.phi*i.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let k=i.minAzimuthAngle,K=i.maxAzimuthAngle;isFinite(k)&&isFinite(K)&&(k<-Math.PI?k+=Ne:k>Math.PI&&(k-=Ne),K<-Math.PI?K+=Ne:K>Math.PI&&(K-=Ne),o.theta=k<=K?Math.max(k,Math.min(K,o.theta)):o.theta>(k+K)/2?Math.max(k,o.theta):Math.min(K,o.theta)),o.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,o.phi)),o.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(d,i.dampingFactor):i.target.add(d),i.target.sub(i.cursor),i.target.clampLength(i.minTargetRadius,i.maxTargetRadius),i.target.add(i.cursor),i.zoomToCursor&&P||i.object.isOrthographicCamera?o.radius=X(o.radius):o.radius=X(o.radius*c),$.setFromSpherical(o),$.applyQuaternion(J),j.copy(i.target).add($),i.object.lookAt(i.target),i.enableDamping===!0?(l.theta*=1-i.dampingFactor,l.phi*=1-i.dampingFactor,d.multiplyScalar(1-i.dampingFactor)):(l.set(0,0,0),d.set(0,0,0));let me=!1;if(i.zoomToCursor&&P){let ye=null;if(i.object.isPerspectiveCamera){const he=$.length();ye=X(he*c);const Ye=he-ye;i.object.position.addScaledVector(E,Ye),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const he=new Ae(T.x,T.y,0);he.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),me=!0;const Ye=new Ae(T.x,T.y,0);Ye.unproject(i.object),i.object.position.sub(Ye).add(he),i.object.updateMatrixWorld(),ye=$.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;ye!==null&&(this.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(ye).add(i.object.position):(ob.origin.copy(i.object.position),ob.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(ob.direction))<cye?e.lookAt(i.target):(zz.setFromNormalAndCoplanarPoint(i.object.up,i.target),ob.intersectPlane(zz,i.target))))}else i.object.isOrthographicCamera&&(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),me=!0);return c=1,P=!1,!!(me||ee.distanceToSquared(i.object.position)>s||8*(1-oe.dot(i.object.quaternion))>s||De.distanceToSquared(i.target)>0)&&(i.dispatchEvent(jz),ee.copy(i.object.position),oe.copy(i.object.quaternion),De.copy(i.target),!0)}})(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",ce),i.domElement.removeEventListener("pointerdown",ve),i.domElement.removeEventListener("pointercancel",pe),i.domElement.removeEventListener("wheel",we),i.domElement.removeEventListener("pointermove",Pe),i.domElement.removeEventListener("pointerup",pe),i._domElementKeyEvents!==null&&(i._domElementKeyEvents.removeEventListener("keydown",ze),i._domElementKeyEvents=null)};const i=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=r.NONE;const s=1e-6,o=new Oz,l=new Oz;let c=1;const d=new Ae,f=new Gt,p=new Gt,m=new Gt,_=new Gt,b=new Gt,v=new Gt,x=new Gt,M=new Gt,w=new Gt,E=new Ae,T=new Gt;let P=!1;const N=[],U={};function R(){return Math.pow(.95,i.zoomSpeed)}function O($){l.theta-=$}function z($){l.phi-=$}const I=(function(){const $=new Ae;return function(ae,J){$.setFromMatrixColumn(J,0),$.multiplyScalar(-ae),d.add($)}})(),G=(function(){const $=new Ae;return function(ae,J){i.screenSpacePanning===!0?$.setFromMatrixColumn(J,1):($.setFromMatrixColumn(J,0),$.crossVectors(i.object.up,$)),$.multiplyScalar(ae),d.add($)}})(),L=(function(){const $=new Ae;return function(ae,J){const ee=i.domElement;if(i.object.isPerspectiveCamera){const oe=i.object.position;$.copy(oe).sub(i.target);let De=$.length();De*=Math.tan(i.object.fov/2*Math.PI/180),I(2*ae*De/ee.clientHeight,i.object.matrix),G(2*J*De/ee.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(I(ae*(i.object.right-i.object.left)/i.object.zoom/ee.clientWidth,i.object.matrix),G(J*(i.object.top-i.object.bottom)/i.object.zoom/ee.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function B($){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c/=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function q($){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c*=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function W($){if(!i.zoomToCursor)return;P=!0;const ae=i.domElement.getBoundingClientRect(),J=$.clientX-ae.left,ee=$.clientY-ae.top,oe=ae.width,De=ae.height;T.x=J/oe*2-1,T.y=-ee/De*2+1,E.set(T.x,T.y,1).unproject(i.object).sub(i.object.position).normalize()}function X($){return Math.max(i.minDistance,Math.min(i.maxDistance,$))}function Q($){f.set($.clientX,$.clientY)}function ie($){_.set($.clientX,$.clientY)}function H(){if(N.length===1)f.set(N[0].pageX,N[0].pageY);else{const $=.5*(N[0].pageX+N[1].pageX),ae=.5*(N[0].pageY+N[1].pageY);f.set($,ae)}}function Y(){if(N.length===1)_.set(N[0].pageX,N[0].pageY);else{const $=.5*(N[0].pageX+N[1].pageX),ae=.5*(N[0].pageY+N[1].pageY);_.set($,ae)}}function se(){const $=N[0].pageX-N[1].pageX,ae=N[0].pageY-N[1].pageY,J=Math.sqrt($*$+ae*ae);x.set(0,J)}function ue($){if(N.length==1)p.set($.pageX,$.pageY);else{const J=F($),ee=.5*($.pageX+J.x),oe=.5*($.pageY+J.y);p.set(ee,oe)}m.subVectors(p,f).multiplyScalar(i.rotateSpeed);const ae=i.domElement;O(2*Math.PI*m.x/ae.clientHeight),z(2*Math.PI*m.y/ae.clientHeight),f.copy(p)}function xe($){if(N.length===1)b.set($.pageX,$.pageY);else{const ae=F($),J=.5*($.pageX+ae.x),ee=.5*($.pageY+ae.y);b.set(J,ee)}v.subVectors(b,_).multiplyScalar(i.panSpeed),L(v.x,v.y),_.copy(b)}function re($){const ae=F($),J=$.pageX-ae.x,ee=$.pageY-ae.y,oe=Math.sqrt(J*J+ee*ee);M.set(0,oe),w.set(0,Math.pow(M.y/x.y,i.zoomSpeed)),B(w.y),x.copy(M)}function ve($){i.enabled!==!1&&(N.length===0&&(i.domElement.setPointerCapture($.pointerId),i.domElement.addEventListener("pointermove",Pe),i.domElement.addEventListener("pointerup",pe)),(function(ae){N.push(ae)})($),$.pointerType==="touch"?(function(ae){switch(ft(ae),N.length){case 1:switch(i.touches.ONE){case kh.ROTATE:if(i.enableRotate===!1)return;H(),a=r.TOUCH_ROTATE;break;case kh.PAN:if(i.enablePan===!1)return;Y(),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(i.touches.TWO){case kh.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;i.enableZoom&&se(),i.enablePan&&Y(),a=r.TOUCH_DOLLY_PAN;break;case kh.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;i.enableZoom&&se(),i.enableRotate&&H(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&i.dispatchEvent(vT)})($):(function(ae){let J;switch(ae.button){case 0:J=i.mouseButtons.LEFT;break;case 1:J=i.mouseButtons.MIDDLE;break;case 2:J=i.mouseButtons.RIGHT;break;default:J=-1}switch(J){case Oh.DOLLY:if(i.enableZoom===!1)return;(function(ee){W(ee),x.set(ee.clientX,ee.clientY)})(ae),a=r.DOLLY;break;case Oh.ROTATE:if(ae.ctrlKey||ae.metaKey||ae.shiftKey){if(i.enablePan===!1)return;ie(ae),a=r.PAN}else{if(i.enableRotate===!1)return;Q(ae),a=r.ROTATE}break;case Oh.PAN:if(ae.ctrlKey||ae.metaKey||ae.shiftKey){if(i.enableRotate===!1)return;Q(ae),a=r.ROTATE}else{if(i.enablePan===!1)return;ie(ae),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&i.dispatchEvent(vT)})($))}function Pe($){i.enabled!==!1&&($.pointerType==="touch"?(function(ae){switch(ft(ae),a){case r.TOUCH_ROTATE:if(i.enableRotate===!1)return;ue(ae),i.update();break;case r.TOUCH_PAN:if(i.enablePan===!1)return;xe(ae),i.update();break;case r.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;(function(J){i.enableZoom&&re(J),i.enablePan&&xe(J)})(ae),i.update();break;case r.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;(function(J){i.enableZoom&&re(J),i.enableRotate&&ue(J)})(ae),i.update();break;default:a=r.NONE}})($):(function(ae){switch(a){case r.ROTATE:if(i.enableRotate===!1)return;(function(J){p.set(J.clientX,J.clientY),m.subVectors(p,f).multiplyScalar(i.rotateSpeed);const ee=i.domElement;O(2*Math.PI*m.x/ee.clientHeight),z(2*Math.PI*m.y/ee.clientHeight),f.copy(p),i.update()})(ae);break;case r.DOLLY:if(i.enableZoom===!1)return;(function(J){M.set(J.clientX,J.clientY),w.subVectors(M,x),w.y>0?B(R()):w.y<0&&q(R()),x.copy(M),i.update()})(ae);break;case r.PAN:if(i.enablePan===!1)return;(function(J){b.set(J.clientX,J.clientY),v.subVectors(b,_).multiplyScalar(i.panSpeed),L(v.x,v.y),_.copy(b),i.update()})(ae)}})($))}function pe($){(function(ae){delete U[ae.pointerId];for(let J=0;J<N.length;J++)if(N[J].pointerId==ae.pointerId)return void N.splice(J,1)})($),N.length===0&&(i.domElement.releasePointerCapture($.pointerId),i.domElement.removeEventListener("pointermove",Pe),i.domElement.removeEventListener("pointerup",pe)),i.dispatchEvent(Fz),a=r.NONE}function we($){i.enabled!==!1&&i.enableZoom!==!1&&a===r.NONE&&($.preventDefault(),i.dispatchEvent(vT),(function(ae){W(ae),ae.deltaY<0?q(R()):ae.deltaY>0&&B(R()),i.update()})($),i.dispatchEvent(Fz))}function ze($){i.enabled!==!1&&i.enablePan!==!1&&(function(ae){let J=!1;switch(ae.code){case i.keys.UP:ae.ctrlKey||ae.metaKey||ae.shiftKey?z(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):L(0,i.keyPanSpeed),J=!0;break;case i.keys.BOTTOM:ae.ctrlKey||ae.metaKey||ae.shiftKey?z(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):L(0,-i.keyPanSpeed),J=!0;break;case i.keys.LEFT:ae.ctrlKey||ae.metaKey||ae.shiftKey?O(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):L(i.keyPanSpeed,0),J=!0;break;case i.keys.RIGHT:ae.ctrlKey||ae.metaKey||ae.shiftKey?O(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):L(-i.keyPanSpeed,0),J=!0}J&&(ae.preventDefault(),i.update())})($)}function ce($){i.enabled!==!1&&$.preventDefault()}function ft($){let ae=U[$.pointerId];ae===void 0&&(ae=new Gt,U[$.pointerId]=ae),ae.set($.pageX,$.pageY)}function F($){const ae=$.pointerId===N[0].pointerId?N[1]:N[0];return U[ae.pointerId]}i.domElement.addEventListener("contextmenu",ce),i.domElement.addEventListener("pointerdown",ve),i.domElement.addEventListener("pointercancel",pe),i.domElement.addEventListener("wheel",we,{passive:!1}),this.update()}}yt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Gt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Ra.line={uniforms:EP.merge([yt.common,yt.fog,yt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class p9 extends Gu{constructor(e){super({type:"LineMaterial",uniforms:EP.clone(Ra.line.uniforms),vertexShader:Ra.line.vertexShader,fragmentShader:Ra.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const Bz=new Bs,lb=new Ae;class m9 extends Xve{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new Pi([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new Pi([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const n=this.attributes.instanceStart,i=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),i.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new JN(n,6,1);return this.setAttribute("instanceStart",new Eu(i,3,0)),this.setAttribute("instanceEnd",new Eu(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new JN(n,6,1);return this.setAttribute("instanceColorStart",new Eu(i,3,0)),this.setAttribute("instanceColorEnd",new Eu(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Bve(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Bs);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Bz.setFromBufferAttribute(n),this.boundingBox.union(Bz))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Bo),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)lb.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(lb)),lb.fromBufferAttribute(n,a),r=Math.max(r,i.distanceToSquared(lb));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}const Hz=new Ae,Vz=new Ae,kr=new Vn,Lr=new Vn,No=new Vn,yT=new Ae,bT=new Zn,Ir=new Kve,$z=new Ae,cb=new Bs,ub=new Bo,Ro=new Vn;let Po,$d;function Gz(t,e,n){return Ro.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Ro.multiplyScalar(1/Ro.w),Ro.x=$d/n.width,Ro.y=$d/n.height,Ro.applyMatrix4(t.projectionMatrixInverse),Ro.multiplyScalar(1/Ro.w),Math.abs(Math.max(Ro.x,Ro.y))}class dye extends po{constructor(e=new m9,n=new p9({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,i=e.attributes.instanceEnd,r=new Float32Array(2*n.count);for(let s=0,o=0,l=n.count;s<l;s++,o+=2)Hz.fromBufferAttribute(n,s),Vz.fromBufferAttribute(i,s),r[o]=o===0?0:r[o-1],r[o+1]=r[o]+Hz.distanceTo(Vz);const a=new JN(r,2,1);return e.setAttribute("instanceDistanceStart",new Eu(a,1,0)),e.setAttribute("instanceDistanceEnd",new Eu(a,1,1)),this}raycast(e,n){const i=this.material.worldUnits,r=e.camera;r!==null||i||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Po=e.ray;const s=this.matrixWorld,o=this.geometry,l=this.material;let c,d;$d=l.linewidth+a,o.boundingSphere===null&&o.computeBoundingSphere(),ub.copy(o.boundingSphere).applyMatrix4(s),i?c=.5*$d:c=Gz(r,Math.max(r.near,ub.distanceToPoint(Po.origin)),l.resolution),ub.radius+=c,Po.intersectsSphere(ub)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),cb.copy(o.boundingBox).applyMatrix4(s),i?d=.5*$d:d=Gz(r,Math.max(r.near,cb.distanceToPoint(Po.origin)),l.resolution),cb.expandByScalar(d),Po.intersectsBox(cb)!==!1&&(i?(function(f,p){const m=f.matrixWorld,_=f.geometry,b=_.attributes.instanceStart,v=_.attributes.instanceEnd;for(let x=0,M=Math.min(_.instanceCount,b.count);x<M;x++){Ir.start.fromBufferAttribute(b,x),Ir.end.fromBufferAttribute(v,x),Ir.applyMatrix4(m);const w=new Ae,E=new Ae;Po.distanceSqToSegment(Ir.start,Ir.end,E,w),E.distanceTo(w)<.5*$d&&p.push({point:E,pointOnLine:w,distance:Po.origin.distanceTo(E),object:f,face:null,faceIndex:x,uv:null,uv1:null})}})(this,n):(function(f,p,m){const _=p.projectionMatrix,b=f.material.resolution,v=f.matrixWorld,x=f.geometry,M=x.attributes.instanceStart,w=x.attributes.instanceEnd,E=Math.min(x.instanceCount,M.count),T=-p.near;Po.at(1,No),No.w=1,No.applyMatrix4(p.matrixWorldInverse),No.applyMatrix4(_),No.multiplyScalar(1/No.w),No.x*=b.x/2,No.y*=b.y/2,No.z=0,yT.copy(No),bT.multiplyMatrices(p.matrixWorldInverse,v);for(let P=0,N=E;P<N;P++){if(kr.fromBufferAttribute(M,P),Lr.fromBufferAttribute(w,P),kr.w=1,Lr.w=1,kr.applyMatrix4(bT),Lr.applyMatrix4(bT),kr.z>T&&Lr.z>T)continue;if(kr.z>T){const I=kr.z-Lr.z,G=(kr.z-T)/I;kr.lerp(Lr,G)}else if(Lr.z>T){const I=Lr.z-kr.z,G=(Lr.z-T)/I;Lr.lerp(kr,G)}kr.applyMatrix4(_),Lr.applyMatrix4(_),kr.multiplyScalar(1/kr.w),Lr.multiplyScalar(1/Lr.w),kr.x*=b.x/2,kr.y*=b.y/2,Lr.x*=b.x/2,Lr.y*=b.y/2,Ir.start.copy(kr),Ir.start.z=0,Ir.end.copy(Lr),Ir.end.z=0;const U=Ir.closestPointToPointParameter(yT,!0);Ir.at(U,$z);const R=qG.lerp(kr.z,Lr.z,U),O=R>=-1&&R<=1,z=yT.distanceTo($z)<.5*$d;if(O&&z){Ir.start.fromBufferAttribute(M,P),Ir.end.fromBufferAttribute(w,P),Ir.start.applyMatrix4(v),Ir.end.applyMatrix4(v);const I=new Ae,G=new Ae;Po.distanceSqToSegment(Ir.start,Ir.end,G,I),m.push({point:G,pointOnLine:I,distance:Po.origin.distanceTo(G),object:f,face:null,faceIndex:P,uv:null,uv1:null})}}})(this,r,n)))}}class fye extends LS{constructor(e,n,i,r,a=4473924,s=8947848){a=new Ft(a),s=new Ft(s);const o=Math.round(e/n);i=Math.round(i/r)*r/2;const l=[],c=[];let d=0;for(let p=-1*(e=o*n/2);p<=e;p+=n){l.push(p,0,-1*i,p,0,i);const m=p===0?a:s;m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3}for(let p=-1*i;p<=i;p+=r){l.push(-1*e,0,p,e,0,p);const m=p===0?a:s;m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3,m.toArray(c,d),d+=3}const f=new ia;f.setAttribute("position",new Pi(l,3)),f.setAttribute("color",new Pi(c,3)),super(f,new yx({vertexColors:!0,toneMapped:!1}))}}function hye(t,e,n,i){const r=(function(s,o,l){s*=.5,o*=.5,l*=.5;const c=new ia,d=[];return d.push(-s,-o,-l,-s,o,-l,-s,o,-l,s,o,-l,s,o,-l,s,-o,-l,s,-o,-l,-s,-o,-l,-s,-o,l,-s,o,l,-s,o,l,s,o,l,s,o,l,s,-o,l,s,-o,l,-s,-o,l,-s,-o,-l,-s,-o,l,-s,o,-l,-s,o,l,s,o,-l,s,o,l,s,-o,-l,s,-o,l),c.setAttribute("position",new Pi(d,3)),c})(t,e,n),a=new LS(r,new Vve({color:new Ft(i),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var e0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function i(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),i(++t%e.children.length)}),!1);var r=(performance||Date).now(),a=r,s=0,o=n(new e0.Panel("FPS","#0ff","#002")),l=n(new e0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new e0.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:e,addPanel:n,showPanel:i,begin:function(){r=(performance||Date).now()},end:function(){s++;var d=(performance||Date).now();if(l.update(d-r,200),d>=a+1e3&&(o.update(1e3*s/(d-a),100),a=d,s=0,c)){var f=performance.memory;c.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){r=this.end()},domElement:e,setMode:i}};e0.Panel=function(t,e,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,c=3*s,d=2*s,f=3*s,p=15*s,m=74*s,_=30*s,b=document.createElement("canvas");b.width=o,b.height=l,b.style.cssText="width:80px;height:48px";var v=b.getContext("2d");return v.font="bold "+9*s+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=n,v.fillRect(0,0,o,l),v.fillStyle=e,v.fillText(t,c,d),v.fillRect(f,p,m,_),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f,p,m,_),{dom:b,update:function(x,M){i=Math.min(i,x),r=Math.max(r,x),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,o,p),v.fillStyle=e,v.fillText(a(x)+" "+t+" ("+a(i)+"-"+a(r)+")",c,d),v.drawImage(b,f+s,p,m-s,_,f,p,m-s,_),v.fillRect(f+m-s,p,s,_),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f+m-s,p,s,a((1-x/M)*_))}}};var pye=e0;class Wz{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new N_,this.gui.title("Dev info"),this.setup()}setup(){this.loadOpenFolders(),this.options&&!this.options.renderer||this.setupRedererFolder(),this.options&&!this.options.camera||this.setupCameraFolder(),this.options&&!this.options.parser||this.setupParserFolder(),this.options&&!this.options.buildVolume||this.setupBuildVolumeFolder(),this.options&&!this.options.devHelpers||this.setupDevHelpers()}reset(){this.gui.destroy(),this.gui=new N_,this.gui.title("Dev info"),this.setup()}loadOpenFolders(){this.openFolders=JSON.parse(localStorage.getItem("dev-gui-open")||"{}").open||[]}saveOpenFolders(){this.openFolders=this.gui.foldersRecursive().filter((e=>!e._closed)).map((e=>e._title)),console.log(this.openFolders),localStorage.setItem("dev-gui-open",JSON.stringify({open:this.openFolders}))}setupRedererFolder(){const e=this.gui.addFolder("Render Info");this.openFolders.includes("Render Info")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.renderer.info.render,"triangles").listen(),e.add(this.watchedObject.renderer.info.render,"calls").listen(),e.add(this.watchedObject.renderer.info.render,"lines").listen(),e.add(this.watchedObject.renderer.info.render,"points").listen(),e.add(this.watchedObject.renderer.info.memory,"geometries").listen(),e.add(this.watchedObject.renderer.info.memory,"textures").listen(),e.add(this.watchedObject,"_lastRenderTime").listen()}setupCameraFolder(){const e=this.gui.addFolder("Camera");this.openFolders.includes("Camera")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()}));const n=e.addFolder("Camera position");n.add(this.watchedObject.camera.position,"x").listen(),n.add(this.watchedObject.camera.position,"y").listen(),n.add(this.watchedObject.camera.position,"z").listen();const i=e.addFolder("Camera rotation");i.add(this.watchedObject.camera.rotation,"x").listen(),i.add(this.watchedObject.camera.rotation,"y").listen(),i.add(this.watchedObject.camera.rotation,"z").listen()}setupParserFolder(){const e=this.gui.addFolder("Parser");this.openFolders.includes("Parser")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.parser,"curZ").listen(),e.add(this.watchedObject.parser,"maxZ").listen(),e.add(this.watchedObject.parser,"tolerance").listen(),e.add(this.watchedObject.parser.layers,"length").name("layers.count").listen(),e.add(this.watchedObject.parser.lines,"length").name("lines.count").listen()}setupBuildVolumeFolder(){const e=this.gui.addFolder("Build Volume");this.openFolders.includes("Build Volume")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.buildVolume,"x").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,"y").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,"z").min(0).max(600).listen().onChange((()=>{this.watchedObject.render()}))}setupDevHelpers(){const e=this.gui.addFolder("Dev Helpers");this.openFolders.includes("Dev Helpers")||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject,"_wireframe").listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject,"render").listen(),e.add(this.watchedObject,"clear").listen()}}class mye extends ia{constructor(e=[new Ae],n=.6,i=.2,r=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:i,radialSegments:r,closed:!1};const a=new Ae,s=new Ae,o=new Gt,l=[],c=[],d=[],f=[];function p(m){const[_,b,v]=(function(x){const M=e[x],w=new Ae,E=new Ae,T=new Ae,P=new Ae;w.copy(M).sub(e[x-1]||M).normalize().add((e[x+1]||M).clone().sub(M).normalize()).normalize();let N=Number.MAX_VALUE;const U=Math.abs(w.x),R=Math.abs(w.y),O=Math.abs(w.z);return U<=N&&(N=U,E.set(1,0,0)),R<=N&&(N=R,E.set(0,1,0)),O<=N&&E.set(0,0,1),P.crossVectors(w,E).normalize(),E.crossVectors(w,P),T.crossVectors(w,E),[M,E,T]})(m);for(let x=0;x<=r;x++){const M=x/r*Math.PI*2,w=Math.sin(M),E=-Math.cos(M);s.x=E*b.x+w*v.x,s.y=E*b.y+w*v.y,s.z=E*b.z+w*v.z,s.normalize(),c.push(s.x,s.y,s.z),a.x=_.x+n*s.x*.5,a.y=_.y+n*s.y*.5,a.z=_.z+i*s.z*.5,l.push(a.x,a.y,a.z)}}(function(){for(let m=0;m<e.length;m++)p(m);p(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let _=0;_<=r;_++)o.x=m/e.length,o.y=_/r,d.push(o.x,o.y)})(),(function(){for(let m=1;m<e.length;m++)for(let _=1;_<=r;_++){const b=(r+1)*(m-1)+(_-1),v=(r+1)*m+(_-1),x=(r+1)*m+_,M=(r+1)*(m-1)+_;f.push(b,v,M),f.push(v,x,M)}})()})(),this.setIndex(f),this.setAttribute("position",new Pi(l,3)),this.setAttribute("normal",new Pi(c,3)),this.setAttribute("uv",new Pi(d,2))}}class t0{static get initial(){const e=new t0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const _T={h:0,s:0,l:0};class Sp{constructor(e){var n,i,r,a,s,o,l,c,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=t0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Sp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Ft(14737632),this._travelColor=new Ft(10027008),this._toolColors={},this.devMode=!1,this._lastRenderTime=0,this._wireframe=!1,this.minLayerThreshold=(n=e.minLayerThreshold)!==null&&n!==void 0?n:this.minLayerThreshold,this.parser=new R_(this.minLayerThreshold),this.scene=new Pve,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Ft(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(i=e.initialCameraPosition)!==null&&i!==void 0?i:this.initialCameraPosition,this.debug=(r=e.debug)!==null&&r!==void 0?r:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(s=e.renderTravel)!==null&&s!==void 0?s:this.renderTravel,this.nonTravelmoves=(o=e.nonTravelMoves)!==null&&o!==void 0?o:this.nonTravelmoves,this.renderTubes=(l=e.renderTubes)!==null&&l!==void 0?l:this.renderTubes,this.extrusionWidth=(c=e.extrusionWidth)!==null&&c!==void 0?c:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new pye:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Ft(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Ft(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Ft(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,_]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new Ft(_)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+RS),console.debug("opts",e),this.targetId&&console.warn("`targetId` is deprecated and will removed in the future. Use `canvas` instead."),e.canvas)this.canvas=e.canvas,this.renderer=new QN({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new QN({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ts(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,p=.8*f;this.scene.fog=new CP(this._backgroundColor,p,f),this.resize(),this.controls=new uye(this.camera,this.renderer.domElement),this.initScene(),this.animate(),e.allowDragNDrop&&this._enableDropHandler(),this.initStats()}get extrusionColor(){return this._extrusionColor}set extrusionColor(e){if(Array.isArray(e)){this._extrusionColor=[];for(const[n,i]of e.entries())this._extrusionColor[n]=new Ft(i)}else this._extrusionColor=new Ft(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Sp.defaultExtrusionColor:this._extrusionColor instanceof Ft?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Sp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Ft(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Ft(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Ft(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Ft(e):void 0}get layers(){return[this.parser.preamble].concat(this.parser.layers.concat())}get maxLayerIndex(){var e;return((e=this.endLayer)!==null&&e!==void 0?e:this.layers.length)-1}get minLayerIndex(){var e;return this.singleLayerMode?this.maxLayerIndex:((e=this.startLayer)!==null&&e!==void 0?e:0)-1}animate(){var e;this.animationFrameId=requestAnimationFrame((()=>this.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)===null||e===void 0||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){const e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){const e=new Yve(Math.max(this.buildVolume.x/2,this.buildVolume.y/2)+20);this.scene.add(e)}if(this.buildVolume&&this.drawBuildVolume(),this.renderTubes){console.warn("Volumetric rendering is experimental. It may not work as expected or change in the future.");const e=new qve(13421772,.3*Math.PI),n=new Wve(16777215,Math.PI,void 0,.001);n.position.set(0,500,500),this.scene.add(e),this.scene.add(n)}}createGroup(e){const n=new $g;return n.name=e,n.quaternion.setFromEuler(new xx(-Math.PI/2,0,0)),this.buildVolume?n.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):n.position.set(-100,0,100),n}render(){const e=performance.now();this.group=this.createGroup("allLayers"),this.state=t0.initial,this.initScene();for(let n=0;n<this.layers.length;n++)this.renderLayer(n);this.batchGeometries(),this.scene.add(this.group),this.renderer.render(this.scene,this.camera),this._lastRenderTime=performance.now()-e}renderAnimated(e=1){return xT(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const i=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(i))};i()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,i,r,a,s,o,l,c;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const p of d.commands)if(p.gcode!="g20"){if(p.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const m=p;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(p.gcode)>-1){const m=p,_={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(i=m.params.y)!==null&&i!==void 0?i:this.state.y,z:(r=m.params.z)!==null&&r!==void 0?r:this.state.z,r:(a=m.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=m.params.e)!==null&&s!==void 0?s:this.state.e,i:(o=m.params.i)!==null&&o!==void 0?o:this.state.i,j:(l=m.params.j)!==null&&l!==void 0?l:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const b=((c=m.params.e)!==null&&c!==void 0?c:0)>0||this.nonTravelmoves.indexOf(p.gcode)>-1;(_.x!=this.state.x||_.y!=this.state.y||_.z!=this.state.z)&&(b&&this.renderExtrusion||!b&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(f,this.state,_,b,p.gcode=="g2"||p.gcode=="g02"):this.addLineSegment(f,this.state,_,b))}this.state.x=_.x,this.state.y=_.y,this.state.z=_.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var i,r;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const s=.1+.7*n/this.layers.length;a.getHSL(_T),a=new Ft().setHSL(_T.h,_T.s,s)}if(n==this.layers.length-1){const s=(i=this._topLayerColor)!==null&&i!==void 0?i:a,o=(r=this._lastSegmentColor)!==null&&r!==void 0?r:s,l=e.extrusion.splice(-3),c=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,s.getHex(),e.height),this.addTubeLine([...c,...l],o.getHex(),e.height)):(this.addLine(e.extrusion,s.getHex()),this.addLine([...c,...l],o.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new fye(this.buildVolume.x,10,this.buildVolume.y,10));const e=hye(this.buildVolume.x,this.buildVolume.z,this.buildVolume.y,8947848);e.position.setY(this.buildVolume.z/2),this.scene.add(e)}clear(){this.resetState(),this.parser=new R_(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=t0.initial,(e=this.devGui)===null||e===void 0||e.reset(),this._geometries={}}resize(){const[e,n]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,n,!1)}addLineSegment(e,n,i,r){(r?e.extrusion:e.travel).push(n.x,n.y,n.z,i.x,i.y,i.z)}addArcSegment(e,n,i,r,a){const s=r?e.extrusion:e.travel,o=n.x,l=n.y,c=n.z,d=i.x,f=i.y,p=i.z;let m=i.r,_=i.i,b=i.j;if(m){const B=d-o,q=f-l,W=Math.sqrt(Math.pow(B/2,2)+Math.pow(q/2,2));m=Math.max(m,W);const X=Math.pow(B,2)+Math.pow(q,2),Q=Math.pow(m,2)-X/4;let ie=Math.sqrt(Q/X);(a&&m<0||!a&&m>0)&&(ie=-ie),_=B/2+q*ie,b=q/2-B*ie}const v=o==d&&l==f,x=o+_,M=l+b,w=Math.sqrt(_*_+b*b),E=Math.atan2(-b,-_),T=Math.atan2(f-M,d-x);let P;v?P=2*Math.PI:(P=a?E-T:T-E,P<0&&(P+=2*Math.PI));let N=w*P/1.8;this.inches&&(N*=25),N<1&&(N=1);let U=P/N;U*=a?-1:1;const R=[];R.push({x:o,y:l,z:c});const O=(c-p)/N;let z=o,I=l,G=c,L=E;for(let B=0;B<N-1;B++)L+=U,z=x+w*Math.cos(L),I=M+w*Math.sin(L),G+=O,R.push({x:z,y:I,z:G});R.push({x:i.x,y:i.y,z:i.z});for(let B=0;B<R.length-1;B++)s.push(R[B].x,R[B].y,R[B].z,R[B+1].x,R[B+1].y,R[B+1].z)}addLine(e,n){var i;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const r=new ia;r.setAttribute("position",new Pi(e,3)),this.disposables.push(r);const a=new yx({color:n});this.disposables.push(a);const s=new LS(r,a);(i=this.group)===null||i===void 0||i.add(s)}addTubeLine(e,n,i=.2){let r=[];const a=[];for(let s=0;s<e.length;s+=6){const o=e.slice(s,s+9),l=new Ae(o[0],o[1],o[2]),c=new Ae(o[3],o[4],o[5]),d=new Ae(o[6],o[7],o[8]);r.push(l),c.equals(d)||(r.push(c),a.push(r),r=[])}a.forEach((s=>{var o;const l=new mye(s,this.extrusionWidth,this.lineHeight||i,4);(o=this._geometries)[n]||(o[n]=[]),this._geometries[n].push(l)}))}addThickLine(e,n){var i;if(!e.length||!this.lineWidth)return;const r=new m9;this.disposables.push(r);const a=new p9({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),r.setPositions(e);const s=new dye(r,a);(i=this.group)===null||i===void 0||i.add(s)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn("Drag and drop is deprecated as a library feature. See the demo how to implement your own."),this.canvas.addEventListener("dragover",(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),this.canvas.classList.add("dragging")})),this.canvas.addEventListener("dragleave",(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging")})),this.canvas.addEventListener("drop",(e=>xT(this,void 0,void 0,(function*(){var n,i;e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging");const r=((i=(n=e.dataTransfer)===null||n===void 0?void 0:n.files)!==null&&i!==void 0?i:[])[0];this.clear(),yield this._readFromStream(r.stream()),this.render()}))))}batchGeometries(){if(this._geometries)for(const e in this._geometries){const n=this.createBatchMesh(parseInt(e));for(;this._geometries[e].length>0;){const i=this._geometries[e].pop();n.addGeometry(i)}}}createBatchMesh(e){var n;const i=this._geometries[e],r=new Hve({color:e,wireframe:this._wireframe});this.disposables.push(r);const a=i.reduce(((o,l)=>3*l.attributes.position.count+o),0),s=new Fve(i.length,a,void 0,r);return this.disposables.push(s),(n=this.group)===null||n===void 0||n.add(s),s}_readFromStream(e){var n,i;return xT(this,void 0,void 0,(function*(){const r=e.getReader();let a,s="",o=0;do{console.debug("reading from stream"),a=yield r.read(),o+=(i=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0;const c=(l=a.value,new TextDecoder("utf-8").decode(l)),d=c.lastIndexOf(`
- `),f=c.slice(0,d);this.parser.parseGCode(s+f),s=c.slice(d)}while(!a.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new Wz(this):typeof this.devMode=="object"&&(this.devGui=new Wz(this,this.devMode))}initStats(){var e;this.stats&&(typeof this.devMode=="object"&&(this.statsContainer=this.devMode.statsContainer),((e=this.statsContainer)!==null&&e!==void 0?e:document.body).appendChild(this.stats.dom),this.stats.dom.classList.add("stats"),this.initGui())}}Sp.defaultExtrusionColor=new Ft("hotpink");const gye=function(t){return new Sp(t)};function xye({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const i=A.useRef(null),r=A.useRef(null),[a,s]=A.useState(!0),[o,l]=A.useState(null),[c,d]=A.useState(!1),[f,p]=A.useState(0),[m,_]=A.useState(0);A.useEffect(()=>{if(!i.current)return;const x=i.current,M=gye({canvas:x,buildVolume:e,backgroundColor:1710618,travelColor:4473924,extrusionColor:44610,topLayerColor:65370,lastSegmentColor:16777215,lineWidth:2,renderTravel:!1,renderExtrusion:!0});r.current=M,s(!0),l(null),d(!1),fetch(t).then(async E=>{if(!E.ok)throw E.status===404&&(await E.json().catch(()=>({}))).detail?.includes("sliced")?(d(!0),new Error("not_sliced")):new Error("Failed to load G-code");return E.text()}).then(E=>{M.processGCode(E);const T=M.layers?.length||0;_(T),p(T),M.render(),s(!1)}).catch(E=>{l(E.message),s(!1)});const w=()=>{if(x.parentElement){const E=x.parentElement.getBoundingClientRect();x.width=E.width,x.height=E.height,M.resize()}};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),M.dispose()}},[t,e]);const b=x=>{if(!r.current)return;const M=Math.max(1,Math.min(x,m));p(M),r.current.render()},v=x=>{b(parseInt(x.target.value,10))};return g.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[g.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[g.jsx("canvas",{ref:i,className:"w-full h-full"}),a&&g.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:g.jsxs("div",{className:"text-center",children:[g.jsx(Yt,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),g.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),c&&g.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:g.jsxs("div",{className:"text-center max-w-sm px-4",children:[g.jsx(Jie,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),g.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),g.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing the model in Bambu Studio or Orca Slicer."})]})}),o&&!c&&g.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:g.jsx("div",{className:"text-center text-red-400",children:g.jsx("p",{className:"text-sm",children:o})})})]}),!a&&!o&&!c&&m>0&&g.jsx("div",{className:"mt-4 px-2",children:g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(F$,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),g.jsx("button",{onClick:()=>b(f-1),disabled:f<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:g.jsx(xf,{className:"w-4 h-4"})}),g.jsx("input",{type:"range",min:1,max:m,value:f,onChange:v,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),g.jsx("button",{onClick:()=>b(f+1),disabled:f>=m,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:g.jsx(If,{className:"w-4 h-4"})}),g.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[f," / ",m]})]})})]})}function vye({archiveId:t,title:e,onClose:n}){const[i,r]=A.useState(null),[a,s]=A.useState(null),[o,l]=A.useState(!0);A.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),A.useEffect(()=>{Ze.getArchiveCapabilities(t).then(d=>{s(d),d.has_model?r("3d"):d.has_gcode&&r("gcode"),l(!1)}).catch(()=>{s({has_model:!0,has_gcode:!1,build_volume:{x:256,y:256,z:256}}),r("3d"),l(!1)})},[t]);const c=()=>{const d=e||"model",f=`${window.location.origin}${Ze.getArchiveForSlicer(t,d)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[g.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs(ot,{variant:"secondary",size:"sm",onClick:c,children:[g.jsx(sc,{className:"w-4 h-4"}),"Open in Slicer"]}),g.jsx(ot,{variant:"ghost",size:"sm",onClick:n,children:g.jsx(Cn,{className:"w-5 h-5"})})]})]}),a&&g.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[g.jsxs("button",{onClick:()=>a.has_model&&r("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[g.jsx(b0,{className:"w-4 h-4"}),"3D Model",!a.has_model&&g.jsx("span",{className:"text-xs",children:"(not available)"})]}),g.jsxs("button",{onClick:()=>a.has_gcode&&r("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[g.jsx(Uie,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&g.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),g.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?g.jsx("div",{className:"w-full h-full flex items-center justify-center",children:g.jsx(Yt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):i==="3d"&&a?g.jsx(hhe,{url:Ze.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):i==="gcode"&&a?g.jsx(xye,{gcodeUrl:Ze.getArchiveGcode(t),buildVolume:a.build_volume,className:"w-full h-full"}):g.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function yye({archiveId:t,archiveName:e,onClose:n,onSuccess:i}){const[r,a]=A.useState(null);A.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]);const{data:s,isLoading:o}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),l=Ut({mutationFn:()=>{if(!r)throw new Error("No printer selected");return Ze.reprintArchive(t,r)},onSuccess:()=>{i(),n()}}),c=s?.filter(d=>d.is_active)||[];return g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:g.jsx(cn,{className:"w-full max-w-md",children:g.jsxs(gn,{children:[g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),g.jsx(ot,{variant:"ghost",size:"sm",onClick:n,children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",g.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?g.jsx("div",{className:"flex justify-center py-8",children:g.jsx(Yt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c.length===0?g.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):g.jsx("div",{className:"space-y-2 mb-6",children:c.map(d=>g.jsxs("button",{onClick:()=>a(d.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${r===d.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[g.jsx("div",{className:`p-2 rounded-lg ${r===d.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:g.jsx(lc,{className:`w-5 h-5 ${r===d.id?"text-bambu-green":"text-bambu-gray"}`})}),g.jsxs("div",{className:"text-left",children:[g.jsx("p",{className:"text-white font-medium",children:d.name}),g.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.model||"Unknown model"," • ",d.ip_address]})]})]},d.id))}),l.isError&&g.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:l.error.message||"Failed to start print"}),g.jsxs("div",{className:"flex gap-3",children:[g.jsx(ot,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),g.jsx(ot,{onClick:()=>l.mutate(),disabled:!r||l.isPending,className:"flex-1",children:l.isPending?g.jsxs(g.Fragment,{children:[g.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):g.jsxs(g.Fragment,{children:[g.jsx(lc,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function bye({onClose:t,initialFiles:e}){const n=ui(),{showToast:i}=_o(),r=A.useRef(null),[a,s]=A.useState(()=>e?.filter(N=>N.name.endsWith(".3mf")).map(N=>({file:N,status:"pending"}))||[]),[o,l]=A.useState(!1),[c,d]=A.useState(),[f,p]=A.useState(null);A.useEffect(()=>{const N=U=>{U.key==="Escape"&&t()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[t]);const{data:m}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),_=Ut({mutationFn:N=>Ze.uploadArchivesBulk(N,c),onSuccess:N=>{p(N),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(U=>U.map(R=>{const O=N.results.find(I=>I.filename===R.file.name),z=N.errors.find(I=>I.filename===R.file.name);return O?{...R,status:"success",archiveId:O.id}:z?{...R,status:"error",error:z.error}:R})),N.failed===0?i(`${N.uploaded} file${N.uploaded!==1?"s":""} uploaded`):N.uploaded===0?i(`Failed to upload ${N.failed} file${N.failed!==1?"s":""}`,"error"):i(`${N.uploaded} uploaded, ${N.failed} failed`,"warning")},onError:()=>{s(N=>N.map(U=>({...U,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),b=A.useCallback(N=>{N.preventDefault(),l(!0)},[]),v=A.useCallback(N=>{N.preventDefault(),l(!1)},[]),x=A.useCallback(N=>{N.preventDefault(),l(!1);const U=Array.from(N.dataTransfer.files).filter(R=>R.name.endsWith(".3mf"));U.length>0&&s(R=>[...R,...U.map(O=>({file:O,status:"pending"}))])},[]),M=A.useCallback(N=>{const U=Array.from(N.target.files||[]).filter(R=>R.name.endsWith(".3mf"));U.length>0&&s(R=>[...R,...U.map(O=>({file:O,status:"pending"}))]),r.current&&(r.current.value="")},[]),w=A.useCallback(N=>{s(U=>U.filter((R,O)=>O!==N))},[]),E=()=>{if(a.length===0)return;const N=a.filter(U=>U.status==="pending");N.length!==0&&(s(U=>U.map(R=>R.status==="pending"?{...R,status:"uploading"}:R)),_.mutate(N.map(U=>U.file)))},T=a.filter(N=>N.status==="pending").length,P=_.isPending;return g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:g.jsx(cn,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:g.jsxs(gn,{className:"p-0 flex flex-col h-full",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),g.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsx("div",{className:"p-4",children:g.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:b,onDragLeave:v,onDrop:x,children:[g.jsx(E0,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),g.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),g.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),g.jsx(ot,{variant:"secondary",onClick:()=>r.current?.click(),disabled:P,children:"Browse Files"}),g.jsx("input",{ref:r,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),g.jsxs("div",{className:"px-4 pb-4",children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),g.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c||"",onChange:N=>d(N.target.value?Number(N.target.value):void 0),disabled:P,children:[g.jsx("option",{value:"",children:"No printer"}),m?.map(N=>g.jsx("option",{value:N.id,children:N.name},N.id))]})]}),a.length>0&&g.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:g.jsx("div",{className:"space-y-2",children:a.map((N,U)=>g.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[g.jsx(I$,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),g.jsx("span",{className:"flex-1 text-white text-sm truncate",children:N.file.name}),g.jsxs("span",{className:"text-xs text-bambu-gray",children:[(N.file.size/(1024*1024)).toFixed(1)," MB"]}),N.status==="pending"&&g.jsx("button",{onClick:()=>w(U),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:P,children:g.jsx(Cn,{className:"w-4 h-4"})}),N.status==="uploading"&&g.jsx(Yt,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&g.jsx(td,{className:"w-4 h-4 text-bambu-green"}),N.status==="error"&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-xs text-red-400",children:N.error}),g.jsx(ed,{className:"w-4 h-4 text-red-400"})]})]},`${N.file.name}-${U}`))})}),f&&g.jsx("div",{className:"px-4 pb-4",children:g.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:g.jsxs("p",{className:"text-sm text-white",children:[g.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&g.jsxs(g.Fragment,{children:[", ",g.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),g.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[g.jsx(ot,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&g.jsx(ot,{onClick:E,disabled:T===0||P,className:"flex-1",children:P?g.jsxs(g.Fragment,{children:[g.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):g.jsxs(g.Fragment,{children:[g.jsx(E0,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const _ye=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function Sye({archive:t,onClose:e,existingTags:n=[]}){A.useEffect(()=>{const X=Q=>{Q.key==="Escape"&&e()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e]);const i=ui(),[r,a]=A.useState(t.print_name||""),[s,o]=A.useState(t.printer_id),[l,c]=A.useState(t.notes||""),[d,f]=A.useState(t.tags||""),[p,m]=A.useState(t.failure_reason||""),[_,b]=A.useState(t.photos||[]),[v,x]=A.useState(!1),[M,w]=A.useState(!1),E=A.useRef(null),T=A.useRef(null),P=A.useRef(null),{data:N}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),{data:U}=Bt({queryKey:["archives"],queryFn:()=>Ze.getArchives(void 0,1e3,0),enabled:n.length===0}),R=n.length>0?n:[...new Set(U?.flatMap(X=>X.tags?.split(",").map(Q=>Q.trim())||[]).filter(Boolean)||[])].sort(),O=d.split(",").map(X=>X.trim()).filter(Boolean),z=R.filter(X=>!O.includes(X)),I=X=>{if(!O.includes(X)){const Q=[...O,X].join(", ");f(Q)}P.current!==null&&clearTimeout(P.current),E.current?.focus()},G=X=>{const Q=O.filter(ie=>ie!==X).join(", ");f(Q)},L=Ut({mutationFn:X=>Ze.updateArchive(t.id,X),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),e()}}),B=async X=>{const Q=X.target.files?.[0];if(Q){x(!0);try{const ie=await Ze.uploadArchivePhoto(t.id,Q);b(ie.photos),i.invalidateQueries({queryKey:["archives"]})}catch(ie){console.error("Failed to upload photo:",ie)}finally{x(!1),T.current&&(T.current.value="")}}},q=async X=>{try{const Q=await Ze.deleteArchivePhoto(t.id,X);b(Q.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(Q){console.error("Failed to delete photo:",Q)}},W=X=>{X.preventDefault(),L.mutate({print_name:r||void 0,printer_id:s,notes:l||void 0,tags:d||void 0,failure_reason:t.status==="failed"&&p||void 0})};return g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col",onClick:X=>X.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),g.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("form",{onSubmit:W,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),g.jsx("input",{type:"text",value:r,onChange:X=>a(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"Print name"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),g.jsxs("select",{value:s??"",onChange:X=>o(X.target.value?Number(X.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"",children:"No printer"}),N?.map(X=>g.jsx("option",{value:X.id,children:X.name},X.id))]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),g.jsx("textarea",{value:l,onChange:X=>c(X.target.value),rows:3,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none",placeholder:"Add notes about this print..."})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),O.length>0&&g.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:O.map(X=>g.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[g.jsx(M0,{className:"w-3 h-3"}),X,g.jsx("button",{type:"button",onClick:()=>G(X),className:"ml-0.5 text-bambu-gray hover:text-white",children:g.jsx(Cn,{className:"w-3 h-3"})})]},X))}),g.jsxs("div",{className:"relative",children:[g.jsx("input",{ref:E,type:"text",value:d,onChange:X=>f(X.target.value),onFocus:()=>{P.current!==null&&clearTimeout(P.current),w(!0)},onBlur:()=>{P.current=window.setTimeout(()=>w(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:O.length>0?"Add more tags...":"Add tags..."}),M&&z.length>0&&g.jsxs("div",{className:"absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto",children:[g.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),g.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:z.map(X=>g.jsx("button",{type:"button",onClick:()=>I(X),className:"px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors",children:X},X))})]})]})]}),t.status==="failed"&&g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),g.jsxs("select",{value:p,onChange:X=>m(X.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"",children:"Select reason..."}),_ye.map(X=>g.jsx("option",{value:X,children:X},X))]})]}),g.jsxs("div",{children:[g.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[g.jsx(qC,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),g.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[_.map(X=>g.jsxs("div",{className:"relative group",children:[g.jsx("img",{src:Ze.getArchivePhotoUrl(t.id,X),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),g.jsx("button",{type:"button",onClick:()=>q(X),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:g.jsx(ta,{className:"w-3 h-3 text-white"})})]},X)),g.jsxs("label",{className:"w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors",children:[g.jsx("input",{ref:T,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:B,className:"hidden",disabled:v}),v?g.jsx(Yt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):g.jsx(oc,{className:"w-6 h-6 text-bambu-gray"})]})]}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),g.jsxs("div",{className:"flex gap-3 pt-2",children:[g.jsx(ot,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),g.jsxs(ot,{type:"submit",disabled:L.isPending,className:"flex-1",children:[g.jsx(mx,{className:"w-4 h-4"}),L.isPending?"Saving...":"Save"]})]})]})]})})}function wye({x:t,y:e,items:n,onClose:i}){const r=A.useRef(null);return A.useEffect(()=>{const a=l=>{r.current&&!r.current.contains(l.target)&&i()},s=l=>{l.key==="Escape"&&i()},o=()=>{i()};return document.addEventListener("mousedown",a),document.addEventListener("keydown",s),document.addEventListener("scroll",o,!0),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",s),document.removeEventListener("scroll",o,!0)}},[i]),A.useEffect(()=>{if(r.current){const a=r.current.getBoundingClientRect(),s=window.innerWidth,o=window.innerHeight;let l=t,c=e;t+a.width>s&&(l=s-a.width-8),e+a.height>o&&(c=o-a.height-8),r.current.style.left=`${l}px`,r.current.style.top=`${c}px`}},[t,e]),g.jsx("div",{ref:r,className:"fixed z-50 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden",style:{left:t,top:e},children:n.map((a,s)=>a.divider?g.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},s):g.jsxs("button",{onClick:()=>{a.disabled||(a.onClick(),i())},disabled:a.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${a.disabled?"text-bambu-gray cursor-not-allowed":a.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[a.icon&&g.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:a.icon}),a.label]},s))})}function Mye({selectedIds:t,existingTags:e,onClose:n}){const i=ui(),{showToast:r}=_o(),[a,s]=A.useState(""),[o,l]=A.useState(new Set),[c,d]=A.useState("add");A.useEffect(()=>{const b=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[n]);const f=Ut({mutationFn:async()=>{const b=Array.from(o);return await Promise.all(t.map(async v=>{const x=await Ze.getArchive(v),M=x.tags?x.tags.split(",").map(E=>E.trim()).filter(Boolean):[];let w;return c==="add"?w=[...new Set([...M,...b])]:w=M.filter(E=>!o.has(E)),Ze.updateArchive(v,{tags:w.join(", ")})})),{count:t.length,mode:c,tags:b}},onSuccess:({count:b,mode:v,tags:x})=>{i.invalidateQueries({queryKey:["archives"]}),r(`${v==="add"?"Added":"Removed"} ${x.length} tag${x.length!==1?"s":""} ${v==="add"?"to":"from"} ${b} archive${b!==1?"s":""}`),n()},onError:()=>{r("Failed to update tags","error")}}),p=b=>{l(v=>{const x=new Set(v);return x.has(b)?x.delete(b):x.add(b),x})},m=()=>{a.trim()&&!o.has(a.trim())&&(l(b=>new Set([...b,a.trim()])),s(""))},_=b=>{b.key==="Enter"&&(b.preventDefault(),m())};return g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:g.jsx(cn,{className:"w-full max-w-md",children:g.jsxs(gn,{className:"p-0",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(M0,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-xl font-semibold text-white",children:c==="add"?"Add Tags":"Remove Tags"})]}),g.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("div",{className:"p-4 space-y-4",children:[g.jsxs("p",{className:"text-sm text-bambu-gray",children:[c==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(ot,{size:"sm",variant:c==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),g.jsx(ot,{size:"sm",variant:c==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),c==="add"&&g.jsxs("div",{className:"flex gap-2",children:[g.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:b=>s(b.target.value),onKeyDown:_}),g.jsx(ot,{size:"sm",variant:"secondary",onClick:m,disabled:!a.trim(),children:g.jsx(oc,{className:"w-4 h-4"})})]}),e.length>0&&g.jsxs("div",{children:[g.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),g.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(b=>g.jsx("button",{onClick:()=>p(b),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(b)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:b},b))})]}),o.size>0&&g.jsxs("div",{children:[g.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",c==="add"?"add":"remove",":"]}),g.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(b=>g.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${c==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[b,g.jsx("button",{onClick:()=>p(b),className:"hover:opacity-70",children:g.jsx(Cn,{className:"w-3 h-3"})})]},b))})]})]}),g.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[g.jsx(ot,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),g.jsx(ot,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?g.jsxs(g.Fragment,{children:[g.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):g.jsxs(g.Fragment,{children:[g.jsx(M0,{className:"w-4 h-4"}),c==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function Eye(t,e){return new Date(t,e+1,0).getDate()}function Aye(t,e){return new Date(t,e,1).getDay()}const Tye=["January","February","March","April","May","June","July","August","September","October","November","December"],Cye=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Nye({archives:t,onArchiveClick:e}){const n=new Date,[i,r]=A.useState(n.getMonth()),[a,s]=A.useState(n.getFullYear()),[o,l]=A.useState(null),c=A.useMemo(()=>{const x=new Map;return t.forEach(M=>{const w=new Date(M.completed_at||M.created_at),E=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,T=x.get(E)||[];T.push(M),x.set(E,T)}),x},[t]),d=Eye(a,i),f=Aye(a,i),p=()=>{i===0?(r(11),s(a-1)):r(i-1)},m=()=>{i===11?(r(0),s(a+1)):r(i+1)},_=()=>{r(n.getMonth()),s(n.getFullYear())},b=[];for(let x=0;x<f;x++)b.push(null);for(let x=1;x<=d;x++)b.push(x);const v=o?c.get(o)||[]:[];return g.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[g.jsxs("div",{className:"flex-1",children:[g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("button",{onClick:p,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:g.jsx(xf,{className:"w-5 h-5 text-bambu-gray"})}),g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsxs("h2",{className:"text-lg font-semibold text-white",children:[Tye[i]," ",a]}),g.jsx("button",{onClick:_,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),g.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:g.jsx(If,{className:"w-5 h-5 text-bambu-gray"})})]}),g.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:Cye.map(x=>g.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:x},x))}),g.jsx("div",{className:"grid grid-cols-7 gap-1",children:b.map((x,M)=>{if(x===null)return g.jsx("div",{className:"aspect-square"},`empty-${M}`);const w=`${a}-${String(i+1).padStart(2,"0")}-${String(x).padStart(2,"0")}`,E=c.get(w)||[],T=E.length>0,P=x===n.getDate()&&i===n.getMonth()&&a===n.getFullYear(),N=w===o,U=E.filter(O=>O.status==="completed").length,R=E.filter(O=>O.status==="failed").length;return g.jsxs("button",{onClick:()=>l(N?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${N?"bg-bambu-green text-white":P?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":T?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[g.jsx("span",{className:`text-sm font-medium ${P&&!N?"text-bambu-green":""}`,children:x}),T&&g.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[g.jsx("div",{className:`w-2 h-2 rounded-full ${R>0&&U===0?"bg-red-400":R>0?"bg-yellow-400":"bg-green-400"}`}),g.jsx("span",{className:"text-xs font-medium",children:E.length})]})]},x)})}),g.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:g.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[g.jsxs("div",{children:[g.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===i&&M.getFullYear()===a}).length}),g.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),g.jsxs("div",{children:[g.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===i&&M.getFullYear()===a&&x.status==="completed"}).length}),g.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),g.jsxs("div",{children:[g.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(x=>{const M=new Date(x.completed_at||x.created_at);return M.getMonth()===i&&M.getFullYear()===a&&x.status==="failed"}).length}),g.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),g.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?g.jsxs(g.Fragment,{children:[g.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(o+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),v.length>0?g.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(x=>g.jsxs("button",{onClick:()=>e?.(x),className:"w-full flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-left",children:[x.thumbnail_path?g.jsx("img",{src:Ze.getArchiveThumbnail(x.id),alt:"",className:"w-12 h-12 rounded object-cover"}):g.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:g.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"text-sm text-white truncate",children:x.print_name||x.filename}),g.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[g.jsx("span",{className:x.status==="failed"?"text-red-400":"text-green-400",children:x.status==="failed"?"Failed":"Completed"}),x.filament_color&&g.jsx("div",{className:"flex gap-0.5",children:x.filament_color.split(",").map((M,w)=>g.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},w))})]})]})]},x.id))}):g.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):g.jsx("div",{className:"text-center py-8",children:g.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function Rye({archiveId:t,archiveName:e,onClose:n}){const i=Ze.getArchiveQRCodeUrl(t,300);A.useEffect(()=>{const a=s=>{s.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const r=()=>{const a=document.createElement("a");a.href=i,a.download=`${e}_qrcode.png`,a.click()};return g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),g.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("div",{className:"p-6 flex flex-col items-center",children:[g.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),g.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:g.jsx("img",{src:i,alt:"QR Code",className:"w-64 h-64"})}),g.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),g.jsxs(ot,{onClick:r,className:"w-full",children:[g.jsx(Fu,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Pye({archiveId:t,archiveName:e,photos:n,onClose:i,onDelete:r}){const[a,s]=A.useState(0),[o,l]=A.useState(!1);if(A.useEffect(()=>{const m=_=>{_.key==="Escape"&&i(),_.key==="ArrowLeft"&&s(b=>Math.max(0,b-1)),_.key==="ArrowRight"&&s(b=>Math.min(n.length-1,b+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[i,n.length]),A.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return i(),null;const c=n[a],d=Ze.getArchivePhotoUrl(t,c),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${a+1}.jpg`,m.click()},p=()=>{r&&l(!0)};return g.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:i,children:[g.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[g.jsxs("div",{children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),g.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs(ot,{variant:"secondary",size:"sm",onClick:f,children:[g.jsx(Fu,{className:"w-4 h-4"}),"Download"]}),r&&g.jsx(ot,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:g.jsx(ta,{className:"w-4 h-4"})}),g.jsx("button",{onClick:i,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-6 h-6"})})]})]}),g.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&g.jsx("button",{onClick:()=>s(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:g.jsx(xf,{className:"w-8 h-8 text-white"})}),g.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&g.jsx("button",{onClick:()=>s(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:g.jsx(If,{className:"w-8 h-8 text-white"})})]}),n.length>1&&g.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,_)=>g.jsx("button",{onClick:()=>s(_),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${_===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:g.jsx("img",{src:Ze.getArchivePhotoUrl(t,m),alt:`Thumbnail ${_+1}`,className:"w-full h-full object-cover"})},m))})]}),o&&g.jsx(pa,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{r?.(c),l(!1)},onCancel:()=>l(!1)})]})}var ST={exports:{}},wT={};var qz;function Dye(){if(qz)return wT;qz=1;var t=tm();function e(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var n=typeof Object.is=="function"?Object.is:e,i=t.useState,r=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function o(f,p){var m=p(),_=i({inst:{value:m,getSnapshot:p}}),b=_[0].inst,v=_[1];return a(function(){b.value=m,b.getSnapshot=p,l(b)&&v({inst:b})},[f,m,p]),r(function(){return l(b)&&v({inst:b}),f(function(){l(b)&&v({inst:b})})},[f]),s(m),m}function l(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!n(f,m)}catch{return!0}}function c(f,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:o;return wT.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,wT}var Xz;function g9(){return Xz||(Xz=1,ST.exports=Dye()),ST.exports}var x9=g9();function jr(t){this.content=t}jr.prototype={constructor:jr,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var i=n&&n!=t?this.remove(n):this,r=i.find(t),a=i.content.slice();return r==-1?a.push(n||t,e):(a[r+1]=e,n&&(a[r]=n)),new jr(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new jr(n)},addToStart:function(t,e){return new jr([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new jr(n)},addBefore:function(t,e,n){var i=this.remove(e),r=i.content.slice(),a=i.find(t);return r.splice(a==-1?r.length:a,0,e,n),new jr(r)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=jr.from(t),t.size?new jr(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=jr.from(t),t.size?new jr(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=jr.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};jr.from=function(t){if(t instanceof jr)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new jr(e)};function v9(t,e,n){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(i),a=e.child(i);if(r==a){n+=r.nodeSize;continue}if(!r.sameMarkup(a))return n;if(r.isText&&r.text!=a.text){for(let s=0;r.text[s]==a.text[s];s++)n++;return n}if(r.content.size||a.content.size){let s=v9(r.content,a.content,n+1);if(s!=null)return s}n+=r.nodeSize}}function y9(t,e,n,i){for(let r=t.childCount,a=e.childCount;;){if(r==0||a==0)return r==a?null:{a:n,b:i};let s=t.child(--r),o=e.child(--a),l=s.nodeSize;if(s==o){n-=l,i-=l;continue}if(!s.sameMarkup(o))return{a:n,b:i};if(s.isText&&s.text!=o.text){let c=0,d=Math.min(s.text.length,o.text.length);for(;c<d&&s.text[s.text.length-c-1]==o.text[o.text.length-c-1];)c++,n--,i--;return{a:n,b:i}}if(s.content.size||o.content.size){let c=y9(s.content,o.content,n-1,i-1);if(c)return c}n-=l,i-=l}}class dt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,n,i,r=0,a){for(let s=0,o=0;o<n;s++){let l=this.content[s],c=o+l.nodeSize;if(c>e&&i(l,r+o,a||null,s)!==!1&&l.content.size){let d=o+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),i,r+d)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,i,r){let a="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let c=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?r?typeof r=="function"?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&i&&(s?s=!1:a+=i),a+=c},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,i=e.firstChild,r=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(i)&&(r[r.length-1]=n.withText(n.text+i.text),a=1);a<e.content.length;a++)r.push(e.content[a]);return new dt(r,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let i=[],r=0;if(n>e)for(let a=0,s=0;s<n;a++){let o=this.content[a],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),i.push(o),r+=o.nodeSize),s=l}return new dt(i,r)}cutByIndex(e,n){return e==n?dt.empty:e==0&&n==this.content.length?this:new dt(this.content.slice(e,n))}replaceChild(e,n){let i=this.content[e];if(i==n)return this;let r=this.content.slice(),a=this.size+n.nodeSize-i.nodeSize;return r[e]=n,new dt(r,a)}addToStart(e){return new dt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new dt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,i=0;n<this.content.length;n++){let r=this.content[n];e(r,i,n),i+=r.nodeSize}}findDiffStart(e,n=0){return v9(this,e,n)}findDiffEnd(e,n=this.size,i=e.size){return y9(this,e,n,i)}findIndex(e){if(e==0)return db(0,e);if(e==this.size)return db(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let r=this.child(n),a=i+r.nodeSize;if(a>=e)return a==e?db(n+1,a):db(n,i);i=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return dt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new dt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return dt.empty;let n,i=0;for(let r=0;r<e.length;r++){let a=e[r];i+=a.nodeSize,r&&a.isText&&e[r-1].sameMarkup(a)?(n||(n=e.slice(0,r)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new dt(n||e,i)}static from(e){if(!e)return dt.empty;if(e instanceof dt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new dt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}dt.empty=new dt([],0);const MT={index:0,offset:0};function db(t,e){return MT.index=t,MT.offset=e,MT}function P_(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!P_(t[i],e[i]))return!1}else{for(let i in t)if(!(i in e)||!P_(t[i],e[i]))return!1;for(let i in e)if(!(i in t))return!1}return!0}let qn=class t3{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,i=!1;for(let r=0;r<e.length;r++){let a=e[r];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,r));else{if(a.type.excludes(this.type))return e;!i&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,r)),n.push(this),i=!0),n&&n.push(a)}}return n||(n=e.slice()),i||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&P_(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let i=e.marks[n.type];if(!i)throw new RangeError(`There is no mark type ${n.type} in this schema`);let r=i.create(n.attrs);return i.checkAttrs(r.attrs),r}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(n[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return t3.none;if(e instanceof t3)return[e];let n=e.slice();return n.sort((i,r)=>i.type.rank-r.type.rank),n}};qn.none=[];class D_ extends Error{}class Mt{constructor(e,n,i){this.content=e,this.openStart=n,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let i=_9(this.content,e+this.openStart,n);return i&&new Mt(i,this.openStart,this.openEnd)}removeBetween(e,n){return new Mt(b9(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return Mt.empty;let i=n.openStart||0,r=n.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Mt(dt.fromJSON(e,n.content),i,r)}static maxOpen(e,n=!0){let i=0,r=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)i++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)r++;return new Mt(e,i,r)}}Mt.empty=new Mt(dt.empty,0,0);function b9(t,e,n){let{index:i,offset:r}=t.findIndex(e),a=t.maybeChild(i),{index:s,offset:o}=t.findIndex(n);if(r==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(i!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(i,a.copy(b9(a.content,e-r-1,n-r-1)))}function _9(t,e,n,i){let{index:r,offset:a}=t.findIndex(e),s=t.maybeChild(r);if(a==e||s.isText)return i&&!i.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=_9(s.content,e-a-1,n,s);return o&&t.replaceChild(r,s.copy(o))}function Oye(t,e,n){if(n.openStart>t.depth)throw new D_("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new D_("Inconsistent open depths");return S9(t,e,n,0)}function S9(t,e,n,i){let r=t.index(i),a=t.node(i);if(r==e.index(i)&&i<t.depth-n.openStart){let s=S9(t,e,n,i+1);return a.copy(a.content.replaceChild(r,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==i&&e.depth==i){let s=t.parent,o=s.content;return sf(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=kye(n,t);return sf(a,M9(t,s,o,e,i))}else return sf(a,O_(t,e,i))}function w9(t,e){if(!e.type.compatibleContent(t.type))throw new D_("Cannot join "+e.type.name+" onto "+t.type.name)}function n3(t,e,n){let i=t.node(n);return w9(i,e.node(n)),i}function af(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function n0(t,e,n,i){let r=(e||t).node(n),a=0,s=e?e.index(n):r.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(af(t.nodeAfter,i),a++));for(let o=a;o<s;o++)af(r.child(o),i);e&&e.depth==n&&e.textOffset&&af(e.nodeBefore,i)}function sf(t,e){return t.type.checkContent(e),t.copy(e)}function M9(t,e,n,i,r){let a=t.depth>r&&n3(t,e,r+1),s=i.depth>r&&n3(n,i,r+1),o=[];return n0(null,t,r,o),a&&s&&e.index(r)==n.index(r)?(w9(a,s),af(sf(a,M9(t,e,n,i,r+1)),o)):(a&&af(sf(a,O_(t,e,r+1)),o),n0(e,n,r,o),s&&af(sf(s,O_(n,i,r+1)),o)),n0(i,null,r,o),new dt(o)}function O_(t,e,n){let i=[];if(n0(null,t,n,i),t.depth>n){let r=n3(t,e,n+1);af(sf(r,O_(t,e,n+1)),i)}return n0(e,null,n,i),new dt(i)}function kye(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)r=e.node(a).copy(dt.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}class I0{constructor(e,n,i){this.pos=e,this.path=n,this.parentOffset=i,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=e.child(n);return i?e.child(n).cut(i):r}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let i=this.path[n*3],r=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)r+=i.child(a).nodeSize;return r}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return qn.none;if(this.textOffset)return e.child(n).marks;let i=e.maybeChild(n-1),r=e.maybeChild(n);if(!i){let o=i;i=r,r=o}let a=i.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!r||!a[s].isInSet(r.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let i=n.marks,r=e.parent.maybeChild(e.index());for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!n||n(this.node(i))))return new k_(this,e,i);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let i=[],r=0,a=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(a),c=a-l;if(i.push(s,o,r+l),!c||(s=s.child(o),s.isText))break;a=c-1,r+=l+1}return new I0(n,i,a)}static resolveCached(e,n){let i=Kz.get(e);if(i)for(let a=0;a<i.elts.length;a++){let s=i.elts[a];if(s.pos==n)return s}else Kz.set(e,i=new Lye);let r=i.elts[i.i]=I0.resolve(e,n);return i.i=(i.i+1)%Iye,r}}class Lye{constructor(){this.elts=[],this.i=0}}const Iye=12,Kz=new WeakMap;class k_{constructor(e,n,i){this.$from=e,this.$to=n,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Uye=Object.create(null);let ku=class i3{constructor(e,n,i,r=qn.none){this.type=e,this.attrs=n,this.marks=r,this.content=i||dt.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,i,r=0){this.content.nodesBetween(e,n,i,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,i,r){return this.content.textBetween(e,n,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,i){return this.type==e&&P_(this.attrs,n||e.defaultAttrs||Uye)&&qn.sameSet(this.marks,i||qn.none)}copy(e=null){return e==this.content?this:new i3(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new i3(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,i=!1){if(e==n)return Mt.empty;let r=this.resolve(e),a=this.resolve(n),s=i?0:r.sharedDepth(n),o=r.start(s),c=r.node(s).content.cut(r.pos-o,a.pos-o);return new Mt(c,r.depth-s,a.depth-s)}replace(e,n,i){return Oye(this.resolve(e),this.resolve(n),i)}nodeAt(e){for(let n=this;;){let{index:i,offset:r}=n.content.findIndex(e);if(n=n.maybeChild(i),!n)return null;if(r==e||n.isText)return n;e-=r+1}}childAfter(e){let{index:n,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(n),index:n,offset:i};let r=this.content.child(n-1);return{node:r,index:n-1,offset:i-r.nodeSize}}resolve(e){return I0.resolveCached(this,e)}resolveNoCache(e){return I0.resolve(this,e)}rangeHasMark(e,n,i){let r=!1;return n>e&&this.nodesBetween(e,n,a=>(i.isInSet(a.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),E9(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,i=dt.empty,r=0,a=i.childCount){let s=this.contentMatchAt(e).matchFragment(i,r,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=r;l<a;l++)if(!this.type.allowsMarks(i.child(l).marks))return!1;return!0}canReplaceWith(e,n,i,r){if(r&&!this.type.allowsMarks(r))return!1;let a=this.contentMatchAt(e).matchType(i),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=qn.none;for(let n=0;n<this.marks.length;n++){let i=this.marks[n];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!qn.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let i;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,i)}let r=dt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,r,i);return a.type.checkAttrs(a.attrs),a}};ku.prototype.text=void 0;class L_ extends ku{constructor(e,n,i,r){if(super(e,n,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):E9(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new L_(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new L_(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function E9(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Mf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let i=new jye(e,n);if(i.next==null)return Mf.empty;let r=A9(i);i.next&&i.err("Unexpected trailing text");let a=Gye($ye(r));return Wye(a,i),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,i=e.childCount){let r=this;for(let a=n;r&&a<i;a++)r=r.matchType(e.child(a).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let i=0;i<e.next.length;i++)if(this.next[n].type==e.next[i].type)return!0;return!1}fillBefore(e,n=!1,i=0){let r=[this];function a(s,o){let l=s.matchFragment(e,i);if(l&&(!n||l.validEnd))return dt.from(o.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:f}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let p=a(f,o.concat(d));if(p)return p}}return null}return a(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),a=r.match;if(a.matchType(e)){let s=[];for(let o=r;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:l}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!r.type||l.validEnd)&&(i.push({match:o.contentMatch,type:o,via:r}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(i){e.push(i);for(let r=0;r<i.next.length;r++)e.indexOf(i.next[r].next)==-1&&n(i.next[r].next)}return n(this),e.map((i,r)=>{let a=r+(i.validEnd?"*":" ")+" ";for(let s=0;s<i.next.length;s++)a+=(s?", ":"")+i.next[s].type.name+"->"+e.indexOf(i.next[s].next);return a}).join(`
- `)}}Mf.empty=new Mf(!0);class jye{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function A9(t){let e=[];do e.push(Fye(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Fye(t){let e=[];do e.push(zye(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function zye(t){let e=Vye(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Bye(t,e);else break;return e}function Yz(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Bye(t,e){let n=Yz(t),i=n;return t.eat(",")&&(t.next!="}"?i=Yz(t):i=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:e}}function Hye(t,e){let n=t.nodeTypes,i=n[e];if(i)return[i];let r=[];for(let a in n){let s=n[a];s.isInGroup(e)&&r.push(s)}return r.length==0&&t.err("No node type or group '"+e+"' found"),r}function Vye(t){if(t.eat("(")){let e=A9(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Hye(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function $ye(t){let e=[[]];return r(a(t,0),n()),e;function n(){return e.push([])-1}function i(s,o,l){let c={term:l,to:o};return e[s].push(c),c}function r(s,o){s.forEach(l=>l.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(a(c,o)),[]);if(s.type=="seq")for(let l=0;;l++){let c=a(s.exprs[l],o);if(l==s.exprs.length-1)return c;r(c,o=n())}else if(s.type=="star"){let l=n();return i(o,l),r(a(s.expr,l),l),[i(l)]}else if(s.type=="plus"){let l=n();return r(a(s.expr,o),l),r(a(s.expr,l),l),[i(l)]}else{if(s.type=="opt")return[i(o)].concat(a(s.expr,o));if(s.type=="range"){let l=o;for(let c=0;c<s.min;c++){let d=n();r(a(s.expr,l),d),l=d}if(s.max==-1)r(a(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let d=n();i(l,d),r(a(s.expr,l),d),l=d}return[i(l)]}else{if(s.type=="name")return[i(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function T9(t,e){return e-t}function Zz(t,e){let n=[];return i(e),n.sort(T9);function i(r){let a=t[r];if(a.length==1&&!a[0].term)return i(a[0].to);n.push(r);for(let s=0;s<a.length;s++){let{term:o,to:l}=a[s];!o&&n.indexOf(l)==-1&&i(l)}}}function Gye(t){let e=Object.create(null);return n(Zz(t,0));function n(i){let r=[];i.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let c;for(let d=0;d<r.length;d++)r[d][0]==o&&(c=r[d][1]);Zz(t,l).forEach(d=>{c||r.push([o,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let a=e[i.join(",")]=new Mf(i.indexOf(t.length-1)>-1);for(let s=0;s<r.length;s++){let o=r[s][1].sort(T9);a.next.push({type:r[s][0],next:e[o.join(",")]||n(o)})}return a}}function Wye(t,e){for(let n=0,i=[t];n<i.length;n++){let r=i[n],a=!r.validEnd,s=[];for(let o=0;o<r.next.length;o++){let{type:l,next:c}=r.next[o];s.push(l.name),a&&!(l.isText||l.hasRequiredAttrs())&&(a=!1),i.indexOf(c)==-1&&i.push(c)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function C9(t){let e=Object.create(null);for(let n in t){let i=t[n];if(!i.hasDefault)return null;e[n]=i.default}return e}function N9(t,e){let n=Object.create(null);for(let i in t){let r=e&&e[i];if(r===void 0){let a=t[i];if(a.hasDefault)r=a.default;else throw new RangeError("No value supplied for attribute "+i)}n[i]=r}return n}function R9(t,e,n,i){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let r in t){let a=t[r];a.validate&&a.validate(e[r])}}function P9(t,e){let n=Object.create(null);if(e)for(let i in e)n[i]=new Xye(t,i,e[i]);return n}let Qz=class D9{constructor(e,n,i){this.name=e,this.schema=n,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=P9(e,i.attrs),this.defaultAttrs=C9(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mf.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:N9(this.attrs,e)}create(e=null,n,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ku(this,this.computeAttrs(e),dt.from(n),qn.setFrom(i))}createChecked(e=null,n,i){return n=dt.from(n),this.checkContent(n),new ku(this,this.computeAttrs(e),n,qn.setFrom(i))}createAndFill(e=null,n,i){if(e=this.computeAttrs(e),n=dt.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let r=this.contentMatch.matchFragment(n),a=r&&r.fillBefore(dt.empty,!0);return a?new ku(this,e,n.append(a),qn.setFrom(i)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){R9(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?n&&n.push(e[i]):n||(n=e.slice(0,i));return n?n.length?n:qn.none:e}static compile(e,n){let i=Object.create(null);e.forEach((a,s)=>i[a]=new D9(a,n,s));let r=n.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let a in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function qye(t,e,n){let i=n.split("|");return r=>{let a=r===null?"null":typeof r;if(i.indexOf(a)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${a}`)}}class Xye{constructor(e,n,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?qye(e,n,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class IS{constructor(e,n,i,r){this.name=e,this.rank=n,this.schema=i,this.spec=r,this.attrs=P9(e,r.attrs),this.excluded=null;let a=C9(this.attrs);this.instance=a?new qn(this,a):null}create(e=null){return!e&&this.instance?this.instance:new qn(this,N9(this.attrs,e))}static compile(e,n){let i=Object.create(null),r=0;return e.forEach((a,s)=>i[a]=new IS(a,r++,n,s)),i}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){R9(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class O9{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let r in e)n[r]=e[r];n.nodes=jr.from(e.nodes),n.marks=jr.from(e.marks||{}),this.nodes=Qz.compile(this.spec.nodes,this),this.marks=IS.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let a=this.nodes[r],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=i[s]||(i[s]=Mf.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?Jz(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let r in this.marks){let a=this.marks[r],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:Jz(this,s.split(" "))}this.nodeFromJSON=r=>ku.fromJSON(this,r),this.markFromJSON=r=>qn.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Qz){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,i,r)}text(e,n){let i=this.nodes.text;return new L_(i,i.defaultAttrs,e,qn.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Jz(t,e){let n=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.marks[r],s=a;if(a)n.push(a);else for(let o in t.marks){let l=t.marks[o];(r=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return n}function Kye(t){return t.tag!=null}function Yye(t){return t.style!=null}let i0=class r3{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let i=this.matchedStyles=[];n.forEach(r=>{if(Kye(r))this.tags.push(r);else if(Yye(r)){let a=/[^=]*/.exec(r.style)[0];i.indexOf(a)<0&&i.push(a),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=e.nodes[r.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let i=new t5(this,n,!1);return i.addAll(e,qn.none,n.from,n.to),i.finish()}parseSlice(e,n={}){let i=new t5(this,n,!0);return i.addAll(e,qn.none,n.from,n.to),Mt.maxOpen(i.finish())}matchTag(e,n,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let a=this.tags[r];if(Jye(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,i,r){for(let a=r?this.styles.indexOf(r)+1:0;a<this.styles.length;a++){let s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!i.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function i(r){let a=r.priority==null?50:r.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,r)}for(let r in e.marks){let a=e.marks[r].spec.parseDOM;a&&a.forEach(s=>{i(s=n5(s)),s.mark||s.ignore||s.clearMark||(s.mark=r)})}for(let r in e.nodes){let a=e.nodes[r].spec.parseDOM;a&&a.forEach(s=>{i(s=n5(s)),s.node||s.ignore||s.mark||(s.node=r)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new r3(e,r3.schemaRules(e)))}};const k9={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Zye={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},L9={ol:!0,ul:!0},U0=1,a3=2,r0=4;function e5(t,e,n){return e!=null?(e?U0:0)|(e==="full"?a3:0):t&&t.whitespace=="pre"?U0|a3:n&~r0}class fb{constructor(e,n,i,r,a,s){this.type=e,this.attrs=n,this.marks=i,this.solid=r,this.options=s,this.content=[],this.activeMarks=qn.none,this.match=a||(s&r0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(dt.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&U0)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let a=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-r[0].length))}}let n=dt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(dt.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!k9.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class t5{constructor(e,n,i){this.parser=e,this.options=n,this.isOpen=i,this.open=0,this.localPreserveWS=!1;let r=n.topNode,a,s=e5(null,n.preserveWhitespace,0)|(i?r0:0);r?a=new fb(r.type,r.attrs,qn.none,!0,n.topMatch||r.type.contentMatch,s):i?a=new fb(null,null,qn.none,!0,null,s):a=new fb(e.schema.topNodeType,null,qn.none,!0,null,s),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let i=e.nodeValue,r=this.top,a=r.options&a3?"full":this.localPreserveWS||(r.options&U0)>0,{schema:s}=this.parser;if(a==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(a)if(a==="full")i=i.replace(/\r\n?/g,`
- `);else if(s.linebreakReplacement&&/[\r\n]/.test(i)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=i.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(s.text(o[l]),n,!/\S/.test(o[l]));i=""}else i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let o=r.content[r.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(i=i.slice(1))}i&&this.insertNode(s.text(i),n,!/\S/.test(i)),this.findInText(e)}else this.findInside(e)}addElement(e,n,i){let r=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;L9.hasOwnProperty(s)&&this.parser.normalizeLists&&Qye(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,i));e:if(l?l.ignore:Zye.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(k9.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),c=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),c&&this.sync(a),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let a=this.parser.matchedStyles[r],s=i.getPropertyValue(a);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(a,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,i,r){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),i,e.nodeName=="BR")||this.leafFallback(e,i);else{let l=this.enter(s,n.attrs||null,i,n.preserveWhitespace);l&&(a=!0,i=l)}else{let l=this.parser.schema.marks[n.mark];i=i.concat(l.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,i,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,i),this.findAround(e,l,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,i,r){let a=i||0;for(let s=i?e.childNodes[i]:e.firstChild,o=r==null?null:e.childNodes[r];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,i){let r,a;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],c=l.findWrapping(e);if(c&&(!r||r.length>c.length+o)&&(r=c,a=l,!c.length))break;if(l.solid){if(i)break;o+=2}}if(!r)return null;this.sync(a);for(let s=0;s<r.length;s++)n=this.enterInner(r[s],null,n,!1);return n}insertNode(e,n,i){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let r=this.findPlace(e,n,i);if(r){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let s=qn.none;for(let o of r.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):i5(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!0}return!1}enter(e,n,i,r){let a=this.findPlace(e.create(n),i,!1);return a&&(a=this.enterInner(e,n,i,!0,r)),a}enterInner(e,n,i,r=!1,a){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=e5(e,a,s.options);s.options&r0&&s.content.length==0&&(o|=r0);let l=qn.none;return i=i.filter(c=>(s.type?s.type.allowsMarkType(c.type):i5(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new fb(e,n,l,r,null,o)),this.open++,i}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=U0)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let i=this.nodes[n].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==n&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,i){if(e!=n&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&n.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),a=-(i?i.depth+1:0)+(r?0:1),s=(o,l)=>{for(;o>=0;o--){let c=n[o];if(c==""){if(o==n.length-1||o==0)continue;for(;l>=a;l--)if(s(o-1,l))return!0;return!1}else{let d=l>0||l==0&&r?this.nodes[l].type:i&&l>=a?i.node(l-a).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let n in this.parser.schema.nodes){let i=this.parser.schema.nodes[n];if(i.isTextblock&&i.defaultAttrs)return i}}}function Qye(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&L9.hasOwnProperty(i)&&n?(n.appendChild(e),e=n):i=="li"?n=e:i&&(n=null)}}function Jye(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function n5(t){let e={};for(let n in t)e[n]=t[n];return e}function i5(t,e){let n=e.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let l=0;l<o.edgeCount;l++){let{type:c,next:d}=o.edge(l);if(c==e||a.indexOf(d)<0&&s(d))return!0}};if(s(r.contentMatch))return!0}}class Ff{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},i){i||(i=ET(n).createDocumentFragment());let r=i,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,l=0;for(;o<a.length&&l<s.marks.length;){let c=s.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(a[o][0])||c.type.spec.spanning===!1)break;o++,l++}for(;o<a.length;)r=a.pop()[1];for(;l<s.marks.length;){let c=s.marks[l++],d=this.serializeMark(c,s.isInline,n);d&&(a.push([c,r]),r.appendChild(d.dom),r=d.contentDOM||d.dom)}}r.appendChild(this.serializeNodeInner(s,n))}),i}serializeNodeInner(e,n){let{dom:i,contentDOM:r}=e_(ET(n),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,r)}return i}serializeNode(e,n={}){let i=this.serializeNodeInner(e,n);for(let r=e.marks.length-1;r>=0;r--){let a=this.serializeMark(e.marks[r],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(i),i=a.dom)}return i}serializeMark(e,n,i={}){let r=this.marks[e.type.name];return r&&e_(ET(i),r(e,n),null,e.attrs)}static renderSpec(e,n,i=null,r){return e_(e,n,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ff(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=r5(e.nodes);return n.text||(n.text=i=>i.text),n}static marksFromSchema(e){return r5(e.marks)}}function r5(t){let e={};for(let n in t){let i=t[n].spec.toDOM;i&&(e[n]=i)}return e}function ET(t){return t.document||window.document}const a5=new WeakMap;function ebe(t){let e=a5.get(t);return e===void 0&&a5.set(t,e=tbe(t)),e}function tbe(t){let e=null;function n(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)n(i[r]);else for(let r in i)n(i[r])}return n(t),e}function e_(t,e,n,i){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],a;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(a=ebe(i))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=r.indexOf(" ");s>0&&(n=r.slice(0,s),r=r.slice(s+1));let o,l=n?t.createElementNS(n,r):t.createElement(r),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let f in c)if(c[f]!=null){let p=f.indexOf(" ");p>0?l.setAttributeNS(f.slice(0,p),f.slice(p+1),c[f]):f=="style"&&l.style?l.style.cssText=c[f]:l.setAttribute(f,c[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:m,contentDOM:_}=e_(t,p,n,i);if(l.appendChild(m),_){if(o)throw new RangeError("Multiple content holes");o=_}}}return{dom:l,contentDOM:o}}const I9=65535,U9=Math.pow(2,16);function nbe(t,e){return t+e*U9}function s5(t){return t&I9}function ibe(t){return(t-(t&I9))/U9}const j9=1,F9=2,t_=4,z9=8;class s3{constructor(e,n,i){this.pos=e,this.delInfo=n,this.recover=i}get deleted(){return(this.delInfo&z9)>0}get deletedBefore(){return(this.delInfo&(j9|t_))>0}get deletedAfter(){return(this.delInfo&(F9|t_))>0}get deletedAcross(){return(this.delInfo&t_)>0}}class ns{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ns.empty)return ns.empty}recover(e){let n=0,i=s5(e);if(!this.inverted)for(let r=0;r<i;r++)n+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+n+ibe(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,i){let r=0,a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[o+a],d=this.ranges[o+s],f=l+c;if(e<=f){let p=c?e==l?-1:e==f?1:n:n,m=l+r+(p<0?0:d);if(i)return m;let _=e==(n<0?l:f)?null:nbe(o/3,e-l),b=e==l?F9:e==f?j9:t_;return(n<0?e!=l:e!=f)&&(b|=z9),new s3(m,b,_)}r+=d-c}return i?e+r:new s3(e+r,0,null)}touches(e,n){let i=0,r=s5(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[o+a],d=l+c;if(e<=d&&o==r*3)return!0;i+=this.ranges[o+s]-c}return!1}forEach(e){let n=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,a=0;r<this.ranges.length;r+=3){let s=this.ranges[r],o=s-(this.inverted?a:0),l=s+(this.inverted?0:a),c=this.ranges[r+n],d=this.ranges[r+i];e(o,o+c,l,l+d),a+=d-c}}invert(){return new ns(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ns.empty:new ns(e<0?[0,-e,0]:[0,0,e])}}ns.empty=new ns([]);class j0{constructor(e,n,i=0,r=e?e.length:0){this.mirror=n,this.from=i,this.to=r,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new j0(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,i=this._maps.length;n<e._maps.length;n++){let r=e.getMirror(n);this.appendMap(e._maps[n],r!=null&&r<n?i+r:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,i=this._maps.length+e._maps.length;n>=0;n--){let r=e.getMirror(n);this.appendMap(e._maps[n].invert(),r!=null&&r>n?i-r-1:void 0)}}invert(){let e=new j0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let i=this.from;i<this.to;i++)e=this._maps[i].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,i){let r=0;for(let a=this.from;a<this.to;a++){let s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(a);if(l!=null&&l>a&&l<this.to){a=l,e=this._maps[l].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return i?e:new s3(e,r,null)}}const AT=Object.create(null);let ra=class{getMap(){return ns.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=AT[n.stepType];if(!i)throw new RangeError(`No step type ${n.stepType} defined`);return i.fromJSON(e,n)}static jsonID(e,n){if(e in AT)throw new RangeError("Duplicate use of step JSON ID "+e);return AT[e]=n,n.prototype.jsonID=e,n}};class Hi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Hi(e,null)}static fail(e){return new Hi(null,e)}static fromReplace(e,n,i,r){try{return Hi.ok(e.replace(n,i,r))}catch(a){if(a instanceof D_)return Hi.fail(a.message);throw a}}}function PP(t,e,n){let i=[];for(let r=0;r<t.childCount;r++){let a=t.child(r);a.content.size&&(a=a.copy(PP(a.content,e,a))),a.isInline&&(a=e(a,n,r)),i.push(a)}return dt.fromArray(i)}class Au extends ra{constructor(e,n,i){super(),this.from=e,this.to=n,this.mark=i}apply(e){let n=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),a=new Mt(PP(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),r),n.openStart,n.openEnd);return Hi.fromReplace(e,this.from,this.to,a)}invert(){return new mo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new Au(n.pos,i.pos,this.mark)}merge(e){return e instanceof Au&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Au(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Au(n.from,n.to,e.markFromJSON(n.mark))}}ra.jsonID("addMark",Au);class mo extends ra{constructor(e,n,i){super(),this.from=e,this.to=n,this.mark=i}apply(e){let n=e.slice(this.from,this.to),i=new Mt(PP(n.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),n.openStart,n.openEnd);return Hi.fromReplace(e,this.from,this.to,i)}invert(){return new Au(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new mo(n.pos,i.pos,this.mark)}merge(e){return e instanceof mo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new mo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new mo(n.from,n.to,e.markFromJSON(n.mark))}}ra.jsonID("removeMark",mo);class Tu extends ra{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Hi.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Hi.fromReplace(e,this.pos,this.pos+1,new Mt(dt.from(i),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let i=this.mark.addToSet(n.marks);if(i.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(i))return new Tu(this.pos,n.marks[r]);return new Tu(this.pos,this.mark)}}return new Ef(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Tu(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Tu(n.pos,e.markFromJSON(n.mark))}}ra.jsonID("addNodeMark",Tu);class Ef extends ra{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Hi.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Hi.fromReplace(e,this.pos,this.pos+1,new Mt(dt.from(i),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Tu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ef(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ef(n.pos,e.markFromJSON(n.mark))}}ra.jsonID("removeNodeMark",Ef);class wr extends ra{constructor(e,n,i,r=!1){super(),this.from=e,this.to=n,this.slice=i,this.structure=r}apply(e){return this.structure&&o3(e,this.from,this.to)?Hi.fail("Structure replace would overwrite content"):Hi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ns([this.from,this.to-this.from,this.slice.size])}invert(e){return new wr(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deletedAcross&&i.deletedAcross?null:new wr(n.pos,Math.max(n.pos,i.pos),this.slice,this.structure)}merge(e){if(!(e instanceof wr)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Mt.empty:new Mt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new wr(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Mt.empty:new Mt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new wr(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new wr(n.from,n.to,Mt.fromJSON(e,n.slice),!!n.structure)}}ra.jsonID("replace",wr);class Er extends ra{constructor(e,n,i,r,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=i,this.gapTo=r,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(o3(e,this.from,this.gapFrom)||o3(e,this.gapTo,this.to)))return Hi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Hi.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,n.content);return i?Hi.fromReplace(e,this.from,this.to,i):Hi.fail("Content does not fit in gap")}getMap(){return new ns([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Er(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return n.deletedAcross&&i.deletedAcross||r<n.pos||a>i.pos?null:new Er(n.pos,i.pos,r,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Er(n.from,n.to,n.gapFrom,n.gapTo,Mt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ra.jsonID("replaceAround",Er);function o3(t,e,n){let i=t.resolve(e),r=n-e,a=i.depth;for(;r>0&&a>0&&i.indexAfter(a)==i.node(a).childCount;)a--,r--;if(r>0){let s=i.node(a).maybeChild(i.indexAfter(a));for(;r>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,r--}}return!1}function rbe(t,e,n,i){let r=[],a=[],s,o;t.doc.nodesBetween(e,n,(l,c,d)=>{if(!l.isInline)return;let f=l.marks;if(!i.isInSet(f)&&d.type.allowsMarkType(i.type)){let p=Math.max(c,e),m=Math.min(c+l.nodeSize,n),_=i.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(_)||(s&&s.to==p&&s.mark.eq(f[b])?s.to=m:r.push(s=new mo(p,m,f[b])));o&&o.to==p?o.to=m:a.push(o=new Au(p,m,i))}}),r.forEach(l=>t.step(l)),a.forEach(l=>t.step(l))}function abe(t,e,n,i){let r=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let l=null;if(i instanceof IS){let c=s.marks,d;for(;d=i.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else i?i.isInSet(s.marks)&&(l=[i]):l=s.marks;if(l&&l.length){let c=Math.min(o+s.nodeSize,n);for(let d=0;d<l.length;d++){let f=l[d],p;for(let m=0;m<r.length;m++){let _=r[m];_.step==a-1&&f.eq(r[m].style)&&(p=_)}p?(p.to=c,p.step=a):r.push({style:f,from:Math.max(o,e),to:c,step:a})}}}),r.forEach(s=>t.step(new mo(s.from,s.to,s.style)))}function DP(t,e,n,i=n.contentMatch,r=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<a.childCount;l++){let c=a.child(l),d=o+c.nodeSize,f=i.matchType(c.type);if(!f)s.push(new wr(o,d,Mt.empty));else{i=f;for(let p=0;p<c.marks.length;p++)n.allowsMarkType(c.marks[p].type)||t.step(new mo(o,d,c.marks[p]));if(r&&c.isText&&n.whitespace!="pre"){let p,m=/\r?\n|\r/g,_;for(;p=m.exec(c.text);)_||(_=new Mt(dt.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new wr(o+p.index,o+p.index+p[0].length,_))}}o=d}if(!i.validEnd){let l=i.fillBefore(dt.empty,!0);t.replace(o,o,new Mt(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function sbe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function um(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let i=t.depth,r=0,a=0;;--i){let s=t.$from.node(i),o=t.$from.index(i)+r,l=t.$to.indexAfter(i)-a;if(i<t.depth&&s.canReplace(o,l,n))return i;if(i==0||s.type.spec.isolating||!sbe(s,o,l))break;o&&(r=1),l<s.childCount&&(a=1)}return null}function obe(t,e,n){let{$from:i,$to:r,depth:a}=e,s=i.before(a+1),o=r.after(a+1),l=s,c=o,d=dt.empty,f=0;for(let _=a,b=!1;_>n;_--)b||i.index(_)>0?(b=!0,d=dt.from(i.node(_).copy(d)),f++):l--;let p=dt.empty,m=0;for(let _=a,b=!1;_>n;_--)b||r.after(_+1)<r.end(_)?(b=!0,p=dt.from(r.node(_).copy(p)),m++):c++;t.step(new Er(l,c,s,o,new Mt(d.append(p),f,m),d.size-f,!0))}function OP(t,e,n=null,i=t){let r=lbe(t,e),a=r&&cbe(i,e);return a?r.map(o5).concat({type:e,attrs:n}).concat(a.map(o5)):null}function o5(t){return{type:t,attrs:null}}function lbe(t,e){let{parent:n,startIndex:i,endIndex:r}=t,a=n.contentMatchAt(i).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(i,r,s)?a:null}function cbe(t,e){let{parent:n,startIndex:i,endIndex:r}=t,a=n.child(i),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let c=i;l&&c<r;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:s}function ube(t,e,n){let i=dt.empty;for(let s=n.length-1;s>=0;s--){if(i.size){let o=n[s].type.contentMatch.matchFragment(i);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=dt.from(n[s].type.create(n[s].attrs,i))}let r=e.start,a=e.end;t.step(new Er(r,a,r,a,new Mt(i,0,0),n.length,!0))}function dbe(t,e,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let l=typeof r=="function"?r(s):r;if(s.isTextblock&&!s.hasMarkup(i,l)&&fbe(t.doc,t.mapping.slice(a).map(o),i)){let c=null;if(i.schema.linebreakReplacement){let m=i.whitespace=="pre",_=!!i.contentMatch.matchType(i.schema.linebreakReplacement);m&&!_?c=!1:!m&&_&&(c=!0)}c===!1&&H9(t,s,o,a),DP(t,t.mapping.slice(a).map(o,1),i,void 0,c===null);let d=t.mapping.slice(a),f=d.map(o,1),p=d.map(o+s.nodeSize,1);return t.step(new Er(f,p,f+1,p-1,new Mt(dt.from(i.create(l,null,s.marks)),0,0),1,!0)),c===!0&&B9(t,s,o,a),!1}})}function B9(t,e,n,i){e.forEach((r,a)=>{if(r.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(r.text);){let l=t.mapping.slice(i).map(n+1+a+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function H9(t,e,n,i){e.forEach((r,a)=>{if(r.type==r.type.schema.linebreakReplacement){let s=t.mapping.slice(i).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
- `))}})}function fbe(t,e,n){let i=t.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}function hbe(t,e,n,i,r){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let s=n.create(i,null,r||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,s);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Er(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Mt(dt.from(s),0,0),1,!0))}function tc(t,e,n=1,i){let r=t.resolve(e),a=r.depth-n,s=i&&i[i.length-1]||r.parent;if(a<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let c=r.depth-1,d=n-2;c>a;c--,d--){let f=r.node(c),p=r.index(c);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(p,f.childCount),_=i&&i[d+1];_&&(m=m.replaceChild(0,_.type.create(_.attrs)));let b=i&&i[d]||f;if(!f.canReplace(p+1,f.childCount)||!b.type.validContent(m))return!1}let o=r.indexAfter(a),l=i&&i[0];return r.node(a).canReplaceWith(o,o,l?l.type:r.node(a+1).type)}function pbe(t,e,n=1,i){let r=t.doc.resolve(e),a=dt.empty,s=dt.empty;for(let o=r.depth,l=r.depth-n,c=n-1;o>l;o--,c--){a=dt.from(r.node(o).copy(a));let d=i&&i[c];s=dt.from(d?d.type.create(d.attrs,s):r.node(o).copy(s))}t.step(new wr(e,e,new Mt(a.append(s),n,n),!0))}function nd(t,e){let n=t.resolve(e),i=n.index();return V9(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function mbe(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:i}=t.type.schema;for(let r=0;r<e.childCount;r++){let a=e.child(r),s=a.type==i?t.type.schema.nodes.text:a.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function V9(t,e){return!!(t&&e&&!t.isLeaf&&mbe(t,e))}function US(t,e,n=-1){let i=t.resolve(e);for(let r=i.depth;;r--){let a,s,o=i.index(r);if(r==i.depth?(a=i.nodeBefore,s=i.nodeAfter):n>0?(a=i.node(r+1),o++,s=i.node(r).maybeChild(o)):(a=i.node(r).maybeChild(o-1),s=i.node(r+1)),a&&!a.isTextblock&&V9(a,s)&&i.node(r).canReplace(o,o+1))return e;if(r==0)break;e=n<0?i.before(r):i.after(r)}}function gbe(t,e,n){let i=null,{linebreakReplacement:r}=t.doc.type.schema,a=t.doc.resolve(e-n),s=a.node().type;if(r&&s.inlineContent){let d=s.whitespace=="pre",f=!!s.contentMatch.matchType(r);d&&!f?i=!1:!d&&f&&(i=!0)}let o=t.steps.length;if(i===!1){let d=t.doc.resolve(e+n);H9(t,d.node(),d.before(),o)}s.inlineContent&&DP(t,e+n-1,s,a.node().contentMatchAt(a.index()),i==null);let l=t.mapping.slice(o),c=l.map(e-n);if(t.step(new wr(c,l.map(e+n,-1),Mt.empty,!0)),i===!0){let d=t.doc.resolve(c);B9(t,d.node(),d.before(),t.steps.length)}return t}function xbe(t,e,n){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),n))return e;if(i.parentOffset==0)for(let r=i.depth-1;r>=0;r--){let a=i.index(r);if(i.node(r).canReplaceWith(a,a,n))return i.before(r+1);if(a>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let a=i.indexAfter(r);if(i.node(r).canReplaceWith(a,a,n))return i.after(r+1);if(a<i.node(r).childCount)return null}return null}function $9(t,e,n){let i=t.resolve(e);if(!n.content.size)return e;let r=n.content;for(let a=0;a<n.openStart;a++)r=r.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let s=i.depth;s>=0;s--){let o=s==i.depth?0:i.pos<=(i.start(s+1)+i.end(s+1))/2?-1:1,l=i.index(s)+(o>0?1:0),c=i.node(s),d=!1;if(a==1)d=c.canReplace(l,l,r);else{let f=c.contentMatchAt(l).findWrapping(r.firstChild.type);d=f&&c.canReplaceWith(l,l,f[0])}if(d)return o==0?i.pos:o<0?i.before(s+1):i.after(s+1)}return null}function jS(t,e,n=e,i=Mt.empty){if(e==n&&!i.size)return null;let r=t.resolve(e),a=t.resolve(n);return G9(r,a,i)?new wr(e,n,i):new vbe(r,a,i).fit()}function G9(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class vbe{constructor(e,n,i){this.$from=e,this.$to=n,this.unplaced=i,this.frontier=[],this.placed=dt.empty;for(let r=0;r<=e.depth;r++){let a=e.node(r);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=dt.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(e<0?this.$to:i.doc.resolve(e));if(!r)return null;let a=this.placed,s=i.depth,o=r.depth;for(;s&&o&&a.childCount==1;)a=a.firstChild.content,s--,o--;let l=new Mt(a,s,o);return e>-1?new Er(i.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||i.pos!=this.$to.pos?new wr(i.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<e;i++){let a=n.firstChild;if(n.childCount>1&&(r=0),a.type.spec.isolating&&r<=i){e=i;break}n=a.content}for(let n=1;n<=2;n++)for(let i=n==1?e:this.unplaced.openStart;i>=0;i--){let r,a=null;i?(a=TT(this.unplaced.content,i-1).firstChild,r=a.content):r=this.unplaced.content;let s=r.firstChild;for(let o=this.depth;o>=0;o--){let{type:l,match:c}=this.frontier[o],d,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(dt.from(s),!1)):a&&l.compatibleContent(a.type)))return{sliceDepth:i,frontierDepth:o,parent:a,inject:f};if(n==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:i,frontierDepth:o,parent:a,wrap:d};if(a&&c.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:i}=this.unplaced,r=TT(e,n);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new Mt(e,n+1,Math.max(i,r.size+n>=e.size-i?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:i}=this.unplaced,r=TT(e,n);if(r.childCount<=1&&n>0){let a=e.size-n<=n+r.size;this.unplaced=new Mt(Gg(e,n-1,1),n-1,a?n-1:i)}else this.unplaced=new Mt(Gg(e,n,1),n,i)}placeNodes({sliceDepth:e,frontierDepth:n,parent:i,inject:r,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let b=0;b<a.length;b++)this.openFrontierNode(a[b]);let s=this.unplaced,o=i?i.content:s.content,l=s.openStart-e,c=0,d=[],{match:f,type:p}=this.frontier[n];if(r){for(let b=0;b<r.childCount;b++)d.push(r.child(b));f=f.matchFragment(r)}let m=o.size+e-(s.content.size-s.openEnd);for(;c<o.childCount;){let b=o.child(c),v=f.matchType(b.type);if(!v)break;c++,(c>1||l==0||b.content.size)&&(f=v,d.push(W9(b.mark(p.allowedMarks(b.marks)),c==1?l:0,c==o.childCount?m:-1)))}let _=c==o.childCount;_||(m=-1),this.placed=Wg(this.placed,n,dt.from(d)),this.frontier[n].match=f,_&&m<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,v=o;b<m;b++){let x=v.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),v=x.content}this.unplaced=_?e==0?Mt.empty:new Mt(Gg(s.content,e-1,1),e-1,m<0?s.openEnd:e-1):new Mt(Gg(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!CT(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:i,type:r}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=CT(e,n,r,i,a);if(s){for(let o=n-1;o>=0;o--){let{match:l,type:c}=this.frontier[o],d=CT(e,o,c,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Wg(this.placed,n.depth,n.fit)),e=n.move;for(let i=n.depth+1;i<=e.depth;i++){let r=e.node(i),a=r.type.contentMatch.fillBefore(r.content,!0,e.index(i));this.openFrontierNode(r.type,r.attrs,a)}return e}openFrontierNode(e,n=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Wg(this.placed,this.depth,dt.from(e.create(n,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(dt.empty,!0);n.childCount&&(this.placed=Wg(this.placed,this.frontier.length,n))}}function Gg(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Gg(t.firstChild.content,e-1,n)))}function Wg(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Wg(t.lastChild.content,e-1,n)))}function TT(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function W9(t,e,n){if(e<=0)return t;let i=t.content;return e>1&&(i=i.replaceChild(0,W9(i.firstChild,e-1,i.childCount==1?n-1:0))),e>0&&(i=t.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(dt.empty,!0)))),t.copy(i)}function CT(t,e,n,i,r){let a=t.node(e),s=r?t.indexAfter(e):t.index(e);if(s==a.childCount&&!n.compatibleContent(a.type))return null;let o=i.fillBefore(a.content,!0,s);return o&&!ybe(n,a.content,s)?o:null}function ybe(t,e,n){for(let i=n;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return!0;return!1}function bbe(t){return t.spec.defining||t.spec.definingForContent}function _be(t,e,n,i){if(!i.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),a=t.doc.resolve(n);if(G9(r,a,i))return t.step(new wr(e,n,i));let s=X9(r,a);s[s.length-1]==0&&s.pop();let o=-(r.depth+1);s.unshift(o);for(let p=r.depth,m=r.pos-1;p>0;p--,m--){let _=r.node(p).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;s.indexOf(p)>-1?o=p:r.before(p)==m&&s.splice(1,0,-p)}let l=s.indexOf(o),c=[],d=i.openStart;for(let p=i.content,m=0;;m++){let _=p.firstChild;if(c.push(_),m==i.openStart)break;p=_.content}for(let p=d-1;p>=0;p--){let m=c[p],_=bbe(m.type);if(_&&!m.sameMarkup(r.node(Math.abs(o)-1)))d=p;else if(_||!m.type.isTextblock)break}for(let p=i.openStart;p>=0;p--){let m=(p+d+1)%(i.openStart+1),_=c[m];if(_)for(let b=0;b<s.length;b++){let v=s[(b+l)%s.length],x=!0;v<0&&(x=!1,v=-v);let M=r.node(v-1),w=r.index(v-1);if(M.canReplaceWith(w,w,_.type,_.marks))return t.replace(r.before(v),x?a.after(v):n,new Mt(q9(i.content,0,i.openStart,m),m,i.openEnd))}}let f=t.steps.length;for(let p=s.length-1;p>=0&&(t.replace(e,n,i),!(t.steps.length>f));p--){let m=s[p];m<0||(e=r.before(m),n=a.after(m))}}function q9(t,e,n,i,r){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(q9(a.content,e+1,n,i,a)))}if(e>i){let a=r.contentMatchAt(0),s=a.fillBefore(t).append(t);t=s.append(a.matchFragment(s).fillBefore(dt.empty,!0))}return t}function Sbe(t,e,n,i){if(!i.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=xbe(t.doc,e,i.type);r!=null&&(e=n=r)}t.replaceRange(e,n,new Mt(dt.from(i),0,0))}function wbe(t,e,n){let i=t.doc.resolve(e),r=t.doc.resolve(n),a=X9(i,r);for(let s=0;s<a.length;s++){let o=a[s],l=s==a.length-1;if(l&&o==0||i.node(o).type.contentMatch.validEnd)return t.delete(i.start(o),r.end(o));if(o>0&&(l||i.node(o-1).canReplace(i.index(o-1),r.indexAfter(o-1))))return t.delete(i.before(o),r.after(o))}for(let s=1;s<=i.depth&&s<=r.depth;s++)if(e-i.start(s)==i.depth-s&&n>i.end(s)&&r.end(s)-n!=r.depth-s&&i.start(s-1)==r.start(s-1)&&i.node(s-1).canReplace(i.index(s-1),r.index(s-1)))return t.delete(i.before(s),n);t.delete(e,n)}function X9(t,e){let n=[],i=Math.min(t.depth,e.depth);for(let r=i;r>=0;r--){let a=t.start(r);if(a<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(a==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==a-1)&&n.push(r)}return n}class wp extends ra{constructor(e,n,i){super(),this.pos=e,this.attr=n,this.value=i}apply(e){let n=e.nodeAt(this.pos);if(!n)return Hi.fail("No node at attribute step's position");let i=Object.create(null);for(let a in n.attrs)i[a]=n.attrs[a];i[this.attr]=this.value;let r=n.type.create(i,null,n.marks);return Hi.fromReplace(e,this.pos,this.pos+1,new Mt(dt.from(r),0,n.isLeaf?0:1))}getMap(){return ns.empty}invert(e){return new wp(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new wp(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new wp(n.pos,n.attr,n.value)}}ra.jsonID("attr",wp);class F0 extends ra{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let r in e.attrs)n[r]=e.attrs[r];n[this.attr]=this.value;let i=e.type.create(n,e.content,e.marks);return Hi.ok(i)}getMap(){return ns.empty}invert(e){return new F0(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new F0(n.attr,n.value)}}ra.jsonID("docAttr",F0);let Fp=class extends Error{};Fp=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Fp.prototype=Object.create(Error.prototype);Fp.prototype.constructor=Fp;Fp.prototype.name="TransformError";class K9{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new j0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Fp(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,i=Mt.empty){let r=jS(this.doc,e,n,i);return r&&this.step(r),this}replaceWith(e,n,i){return this.replace(e,n,new Mt(dt.from(i),0,0))}delete(e,n){return this.replace(e,n,Mt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,i){return _be(this,e,n,i),this}replaceRangeWith(e,n,i){return Sbe(this,e,n,i),this}deleteRange(e,n){return wbe(this,e,n),this}lift(e,n){return obe(this,e,n),this}join(e,n=1){return gbe(this,e,n),this}wrap(e,n){return ube(this,e,n),this}setBlockType(e,n=e,i,r=null){return dbe(this,e,n,i,r),this}setNodeMarkup(e,n,i=null,r){return hbe(this,e,n,i,r),this}setNodeAttribute(e,n,i){return this.step(new wp(e,n,i)),this}setDocAttribute(e,n){return this.step(new F0(e,n)),this}addNodeMark(e,n){return this.step(new Tu(e,n)),this}removeNodeMark(e,n){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(n instanceof qn)n.isInSet(i.marks)&&this.step(new Ef(e,n));else{let r=i.marks,a,s=[];for(;a=n.isInSet(r);)s.push(new Ef(e,a)),r=a.removeFromSet(r);for(let o=s.length-1;o>=0;o--)this.step(s[o])}return this}split(e,n=1,i){return pbe(this,e,n,i),this}addMark(e,n,i){return rbe(this,e,n,i),this}removeMark(e,n,i){return abe(this,e,n,i),this}clearIncompatible(e,n,i){return DP(this,e,n,i),this}}const NT=Object.create(null);class rn{constructor(e,n,i){this.$anchor=e,this.$head=n,this.ranges=i||[new Mbe(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=Mt.empty){let i=n.content.lastChild,r=null;for(let o=0;o<n.openEnd;o++)r=i,i=i.lastChild;let a=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:l,$to:c}=s[o],d=e.mapping.slice(a);e.replaceRange(d.map(l.pos),d.map(c.pos),o?Mt.empty:n),o==0&&u5(e,a,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,n){let i=e.steps.length,r=this.ranges;for(let a=0;a<r.length;a++){let{$from:s,$to:o}=r[a],l=e.mapping.slice(i),c=l.map(s.pos),d=l.map(o.pos);a?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),u5(e,i,n.isInline?-1:1))}}static findFrom(e,n,i=!1){let r=e.parent.inlineContent?new Ht(e):rp(e.node(0),e.parent,e.pos,e.index(),n,i);if(r)return r;for(let a=e.depth-1;a>=0;a--){let s=n<0?rp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,i):rp(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,i);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ls(e.node(0))}static atStart(e){return rp(e,e,0,0,1)||new ls(e)}static atEnd(e){return rp(e,e,e.content.size,e.childCount,-1)||new ls(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=NT[n.type];if(!i)throw new RangeError(`No selection type ${n.type} defined`);return i.fromJSON(e,n)}static jsonID(e,n){if(e in NT)throw new RangeError("Duplicate use of selection JSON ID "+e);return NT[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Ht.between(this.$anchor,this.$head).getBookmark()}}rn.prototype.visible=!0;class Mbe{constructor(e,n){this.$from=e,this.$to=n}}let l5=!1;function c5(t){!l5&&!t.parent.inlineContent&&(l5=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ht extends rn{constructor(e,n=e){c5(e),c5(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let i=e.resolve(n.map(this.head));if(!i.parent.inlineContent)return rn.near(i);let r=e.resolve(n.map(this.anchor));return new Ht(r.parent.inlineContent?r:i,i)}replace(e,n=Mt.empty){if(super.replace(e,n),n==Mt.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof Ht&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new FS(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ht(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,i=n){let r=e.resolve(n);return new this(r,i==n?r:e.resolve(i))}static between(e,n,i){let r=e.pos-n.pos;if((!i||r)&&(i=r>=0?1:-1),!n.parent.inlineContent){let a=rn.findFrom(n,i,!0)||rn.findFrom(n,-i,!0);if(a)n=a.$head;else return rn.near(n,i)}return e.parent.inlineContent||(r==0?e=n:(e=(rn.findFrom(e,-i,!0)||rn.findFrom(e,i,!0)).$anchor,e.pos<n.pos!=r<0&&(e=n))),new Ht(e,n)}}rn.jsonID("text",Ht);class FS{constructor(e,n){this.anchor=e,this.head=n}map(e){return new FS(e.map(this.anchor),e.map(this.head))}resolve(e){return Ht.between(e.resolve(this.anchor),e.resolve(this.head))}}class jt extends rn{constructor(e){let n=e.nodeAfter,i=e.node(0).resolve(e.pos+n.nodeSize);super(e,i),this.node=n}map(e,n){let{deleted:i,pos:r}=n.mapResult(this.anchor),a=e.resolve(r);return i?rn.near(a):new jt(a)}content(){return new Mt(dt.from(this.node),0,0)}eq(e){return e instanceof jt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new kP(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new jt(e.resolve(n.anchor))}static create(e,n){return new jt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}jt.prototype.visible=!1;rn.jsonID("node",jt);class kP{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:i}=e.mapResult(this.anchor);return n?new FS(i,i):new kP(i)}resolve(e){let n=e.resolve(this.anchor),i=n.nodeAfter;return i&&jt.isSelectable(i)?new jt(n):rn.near(n)}}class ls extends rn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Mt.empty){if(n==Mt.empty){e.delete(0,e.doc.content.size);let i=rn.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ls(e)}map(e){return new ls(e)}eq(e){return e instanceof ls}getBookmark(){return Ebe}}rn.jsonID("all",ls);const Ebe={map(){return this},resolve(t){return new ls(t)}};function rp(t,e,n,i,r,a=!1){if(e.inlineContent)return Ht.create(t,n);for(let s=i-(r>0?0:1);r>0?s<e.childCount:s>=0;s+=r){let o=e.child(s);if(o.isAtom){if(!a&&jt.isSelectable(o))return jt.create(t,n-(r<0?o.nodeSize:0))}else{let l=rp(t,o,n+r,r<0?o.childCount:0,r,a);if(l)return l}n+=o.nodeSize*r}return null}function u5(t,e,n){let i=t.steps.length-1;if(i<e)return;let r=t.steps[i];if(!(r instanceof wr||r instanceof Er))return;let a=t.mapping.maps[i],s;a.forEach((o,l,c,d)=>{s==null&&(s=d)}),t.setSelection(rn.near(t.doc.resolve(s),n))}const d5=1,hb=2,f5=4;class Abe extends K9{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|d5)&~hb,this.storedMarks=null,this}get selectionSet(){return(this.updated&d5)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=hb,this}ensureMarks(e){return qn.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&hb)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~hb,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let i=this.selection;return n&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||qn.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,i){let r=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(i==null&&(i=n),!e)return this.deleteRange(n,i);let a=this.storedMarks;if(!a){let s=this.doc.resolve(n);a=i==n?s.marks():s.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(n,i,r.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(rn.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=f5,this}get scrolledIntoView(){return(this.updated&f5)>0}}function h5(t,e){return!e||!t?t:t.bind(e)}class qg{constructor(e,n,i){this.name=e,this.init=h5(n.init,i),this.apply=h5(n.apply,i)}}const Tbe=[new qg("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new qg("selection",{init(t,e){return t.selection||rn.atStart(e.doc)},apply(t){return t.selection}}),new qg("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,i){return i.selection.$cursor?t.storedMarks:null}}),new qg("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class RT{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tbe.slice(),n&&n.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new qg(i.key,i.spec.state,i))})}}class fp{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=n){let r=this.config.plugins[i];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],i=this.applyInner(e),r=null;for(;;){let a=!1;for(let s=0;s<this.config.plugins.length;s++){let o=this.config.plugins[s];if(o.spec.appendTransaction){let l=r?r[s].n:0,c=r?r[s].state:this,d=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,c,i);if(d&&i.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!r){r=[];for(let f=0;f<this.config.plugins.length;f++)r.push(f<s?{state:i,n:n.length}:{state:this,n:0})}n.push(d),i=i.applyInner(d),a=!0}r&&(r[s]={state:i,n:n.length})}}if(!a)return{state:i,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new fp(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let a=i[r];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new Abe(this)}static create(e){let n=new RT(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new fp(n);for(let r=0;r<n.fields.length;r++)i[n.fields[r].name]=n.fields[r].init(e,i);return i}reconfigure(e){let n=new RT(this.schema,e.plugins),i=n.fields,r=new fp(n);for(let a=0;a<i.length;a++){let s=i[a].name;r[s]=this.hasOwnProperty(s)?this[s]:i[a].init(e,r)}return r}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[i],a=r.spec.state;a&&a.toJSON&&(n[i]=a.toJSON.call(r,this[r.key]))}return n}static fromJSON(e,n,i){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new RT(e.schema,e.plugins),a=new fp(r);return r.fields.forEach(s=>{if(s.name=="doc")a.doc=ku.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=rn.fromJSON(a.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let o in i){let l=i[o],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){a[s.name]=c.fromJSON.call(l,e,n[o],a);return}}a[s.name]=s.init(e,a)}}),a}}function Y9(t,e,n){for(let i in t){let r=t[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=Y9(r,e,{})),n[i]=r}return n}class gi{constructor(e){this.spec=e,this.props={},e.props&&Y9(e.props,this,this.props),this.key=e.key?e.key.key:Z9("plugin")}getState(e){return e[this.key]}}const PT=Object.create(null);function Z9(t){return t in PT?t+"$"+ ++PT[t]:(PT[t]=0,t+"$")}class or{constructor(e="key"){this.key=Z9(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const LP=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Q9(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const J9=(t,e,n)=>{let i=Q9(t,n);if(!i)return!1;let r=IP(i);if(!r){let s=i.blockRange(),o=s&&um(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let a=r.nodeBefore;if(lW(t,r,e,-1))return!0;if(i.parent.content.size==0&&(zp(a,"end")||jt.isSelectable(a)))for(let s=i.depth;;s--){let o=jS(t.doc,i.before(s),i.after(s),Mt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(zp(a,"end")?rn.findFrom(l.doc.resolve(l.mapping.map(r.pos,-1)),-1):jt.create(l.doc,r.pos-a.nodeSize)),e(l.scrollIntoView())}return!0}if(s==1||i.node(s-1).childCount>1)break}return a.isAtom&&r.depth==i.depth-1?(e&&e(t.tr.delete(r.pos-a.nodeSize,r.pos).scrollIntoView()),!0):!1},Cbe=(t,e,n)=>{let i=Q9(t,n);if(!i)return!1;let r=IP(i);return r?eW(t,r,e):!1},Nbe=(t,e,n)=>{let i=nW(t,n);if(!i)return!1;let r=UP(i);return r?eW(t,r,e):!1};function eW(t,e,n){let i=e.nodeBefore,r=i,a=e.pos-1;for(;!r.isTextblock;a--){if(r.type.spec.isolating)return!1;let d=r.lastChild;if(!d)return!1;r=d}let s=e.nodeAfter,o=s,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let c=jS(t.doc,a,l,Mt.empty);if(!c||c.from!=a||c instanceof wr&&c.slice.size>=l-a)return!1;if(n){let d=t.tr.step(c);d.setSelection(Ht.create(d.doc,a)),n(d.scrollIntoView())}return!0}function zp(t,e,n=!1){for(let i=t;i;i=e=="start"?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&i.childCount!=1)return!1}return!1}const tW=(t,e,n)=>{let{$head:i,empty:r}=t.selection,a=i;if(!r)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):i.parentOffset>0)return!1;a=IP(i)}let s=a&&a.nodeBefore;return!s||!jt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(jt.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function IP(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function nW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const iW=(t,e,n)=>{let i=nW(t,n);if(!i)return!1;let r=UP(i);if(!r)return!1;let a=r.nodeAfter;if(lW(t,r,e,1))return!0;if(i.parent.content.size==0&&(zp(a,"start")||jt.isSelectable(a))){let s=jS(t.doc,i.before(),i.after(),Mt.empty);if(s&&s.slice.size<s.to-s.from){if(e){let o=t.tr.step(s);o.setSelection(zp(a,"start")?rn.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):jt.create(o.doc,o.mapping.map(r.pos))),e(o.scrollIntoView())}return!0}}return a.isAtom&&r.depth==i.depth-1?(e&&e(t.tr.delete(r.pos,r.pos+a.nodeSize).scrollIntoView()),!0):!1},rW=(t,e,n)=>{let{$head:i,empty:r}=t.selection,a=i;if(!r)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):i.parentOffset<i.parent.content.size)return!1;a=UP(i)}let s=a&&a.nodeAfter;return!s||!jt.isSelectable(s)?!1:(e&&e(t.tr.setSelection(jt.create(t.doc,a.pos)).scrollIntoView()),!0)};function UP(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const Rbe=(t,e)=>{let n=t.selection,i=n instanceof jt,r;if(i){if(n.node.isTextblock||!nd(t.doc,n.from))return!1;r=n.from}else if(r=US(t.doc,n.from,-1),r==null)return!1;if(e){let a=t.tr.join(r);i&&a.setSelection(jt.create(a.doc,r-t.doc.resolve(r).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},Pbe=(t,e)=>{let n=t.selection,i;if(n instanceof jt){if(n.node.isTextblock||!nd(t.doc,n.to))return!1;i=n.to}else if(i=US(t.doc,n.to,1),i==null)return!1;return e&&e(t.tr.join(i).scrollIntoView()),!0},Dbe=(t,e)=>{let{$from:n,$to:i}=t.selection,r=n.blockRange(i),a=r&&um(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)},aW=(t,e)=>{let{$head:n,$anchor:i}=t.selection;return!n.parent.type.spec.code||!n.sameParent(i)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function jP(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Obe=(t,e)=>{let{$head:n,$anchor:i}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(i))return!1;let r=n.node(-1),a=n.indexAfter(-1),s=jP(r.contentMatchAt(a));if(!s||!r.canReplaceWith(a,a,s))return!1;if(e){let o=n.after(),l=t.tr.replaceWith(o,o,s.createAndFill());l.setSelection(rn.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},sW=(t,e)=>{let n=t.selection,{$from:i,$to:r}=n;if(n instanceof ls||i.parent.inlineContent||r.parent.inlineContent)return!1;let a=jP(r.parent.contentMatchAt(r.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let s=(!i.parentOffset&&r.index()<r.parent.childCount?i:r).pos,o=t.tr.insert(s,a.createAndFill());o.setSelection(Ht.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},oW=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(tc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let i=n.blockRange(),r=i&&um(i);return r==null?!1:(e&&e(t.tr.lift(i,r).scrollIntoView()),!0)};function kbe(t){return(e,n)=>{let{$from:i,$to:r}=e.selection;if(e.selection instanceof jt&&e.selection.node.isBlock)return!i.parentOffset||!tc(e.doc,i.pos)?!1:(n&&n(e.tr.split(i.pos).scrollIntoView()),!0);if(!i.depth)return!1;let a=[],s,o,l=!1,c=!1;for(let m=i.depth;;m--)if(i.node(m).isBlock){l=i.end(m)==i.pos+(i.depth-m),c=i.start(m)==i.pos-(i.depth-m),o=jP(i.node(m-1).contentMatchAt(i.indexAfter(m-1))),a.unshift(l&&o?{type:o}:null),s=m;break}else{if(m==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof Ht||e.selection instanceof ls)&&d.deleteSelection();let f=d.mapping.map(i.pos),p=tc(d.doc,f,a.length,a);if(p||(a[0]=o?{type:o}:null,p=tc(d.doc,f,a.length,a)),!p)return!1;if(d.split(f,a.length,a),!l&&c&&i.node(s).type!=o){let m=d.mapping.map(i.before(s)),_=d.doc.resolve(m);o&&i.node(s-1).canReplaceWith(_.index(),_.index()+1,o)&&d.setNodeMarkup(d.mapping.map(i.before(s)),o)}return n&&n(d.scrollIntoView()),!0}}const Lbe=kbe(),Ibe=(t,e)=>{let{$from:n,to:i}=t.selection,r,a=n.sharedDepth(i);return a==0?!1:(r=n.before(a),e&&e(t.tr.setSelection(jt.create(t.doc,r))),!0)};function Ube(t,e,n){let i=e.nodeBefore,r=e.nodeAfter,a=e.index();return!i||!r||!i.type.compatibleContent(r.type)?!1:!i.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-i.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(r.isTextblock||nd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function lW(t,e,n,i){let r=e.nodeBefore,a=e.nodeAfter,s,o,l=r.type.spec.isolating||a.type.spec.isolating;if(!l&&Ube(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(o=r.contentMatchAt(r.childCount)).findWrapping(a.type))&&o.matchType(s[0]||a.type).validEnd){if(n){let m=e.pos+a.nodeSize,_=dt.empty;for(let x=s.length-1;x>=0;x--)_=dt.from(s[x].create(null,_));_=dt.from(r.copy(_));let b=t.tr.step(new Er(e.pos-1,m,e.pos,m,new Mt(_,1,0),s.length,!0)),v=b.doc.resolve(m+2*s.length);v.nodeAfter&&v.nodeAfter.type==r.type&&nd(b.doc,v.pos)&&b.join(v.pos),n(b.scrollIntoView())}return!0}let d=a.type.spec.isolating||i>0&&l?null:rn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),p=f&&um(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(c&&zp(a,"start",!0)&&zp(r,"end")){let m=r,_=[];for(;_.push(m),!m.isTextblock;)m=m.lastChild;let b=a,v=1;for(;!b.isTextblock;b=b.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,b.content)){if(n){let x=dt.empty;for(let w=_.length-1;w>=0;w--)x=dt.from(_[w].copy(x));let M=t.tr.step(new Er(e.pos-_.length,e.pos+a.nodeSize,e.pos+v,e.pos+a.nodeSize-v,new Mt(x,_.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function cW(t){return function(e,n){let i=e.selection,r=t<0?i.$from:i.$to,a=r.depth;for(;r.node(a).isInline;){if(!a)return!1;a--}return r.node(a).isTextblock?(n&&n(e.tr.setSelection(Ht.create(e.doc,t<0?r.start(a):r.end(a)))),!0):!1}}const jbe=cW(-1),Fbe=cW(1);function zbe(t,e=null){return function(n,i){let{$from:r,$to:a}=n.selection,s=r.blockRange(a),o=s&&OP(s,t,e);return o?(i&&i(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function p5(t,e=null){return function(n,i){let r=!1;for(let a=0;a<n.selection.ranges.length&&!r;a++){let{$from:{pos:s},$to:{pos:o}}=n.selection.ranges[a];n.doc.nodesBetween(s,o,(l,c)=>{if(r)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)r=!0;else{let d=n.doc.resolve(c),f=d.index();r=d.parent.canReplaceWith(f,f+1,t)}})}if(!r)return!1;if(i){let a=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];a.setBlockType(o,l,t,e)}i(a.scrollIntoView())}return!0}}function FP(...t){return function(e,n,i){for(let r=0;r<t.length;r++)if(t[r](e,n,i))return!0;return!1}}FP(LP,J9,tW);FP(LP,iW,rW);FP(aW,sW,oW,Lbe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Bbe(t,e=null){return function(n,i){let{$from:r,$to:a}=n.selection,s=r.blockRange(a);if(!s)return!1;let o=i?n.tr:null;return Hbe(o,s,t,e)?(i&&i(o.scrollIntoView()),!0):!1}}function Hbe(t,e,n,i=null){let r=!1,a=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=s.resolve(e.start-2);a=new k_(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new k_(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let o=OP(a,n,i,e);return o?(t&&Vbe(t,e,o,r,n),!0):!1}function Vbe(t,e,n,i,r){let a=dt.empty;for(let d=n.length-1;d>=0;d--)a=dt.from(n[d].type.create(n[d].attrs,a));t.step(new Er(e.start-(i?2:0),e.end,e.start,e.end,new Mt(a,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==r&&(s=d+1);let o=n.length-s,l=e.start+n.length-(i?2:0),c=e.parent;for(let d=e.startIndex,f=e.endIndex,p=!0;d<f;d++,p=!1)!p&&tc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=c.child(d).nodeSize;return t}function $be(t){return function(e,n){let{$from:i,$to:r}=e.selection,a=i.blockRange(r,s=>s.childCount>0&&s.firstChild.type==t);return a?n?i.node(a.depth-1).type==t?Gbe(e,n,t,a):Wbe(e,n,a):!0:!1}}function Gbe(t,e,n,i){let r=t.tr,a=i.end,s=i.$to.end(i.depth);a<s&&(r.step(new Er(a-1,s,a,s,new Mt(dt.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new k_(r.doc.resolve(i.$from.pos),r.doc.resolve(s),i.depth));const o=um(i);if(o==null)return!1;r.lift(i,o);let l=r.doc.resolve(r.mapping.map(a,-1)-1);return nd(r.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&r.join(l.pos),e(r.scrollIntoView()),!0}function Wbe(t,e,n){let i=t.tr,r=n.parent;for(let m=n.end,_=n.endIndex-1,b=n.startIndex;_>b;_--)m-=r.child(_).nodeSize,i.delete(m-1,m+1);let a=i.doc.resolve(n.start),s=a.nodeAfter;if(i.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,l=n.endIndex==r.childCount,c=a.node(-1),d=a.index(-1);if(!c.canReplace(d+(o?0:1),d+1,s.content.append(l?dt.empty:dt.from(r))))return!1;let f=a.pos,p=f+s.nodeSize;return i.step(new Er(f-(o?1:0),p+(l?1:0),f+1,p-1,new Mt((o?dt.empty:dt.from(r.copy(dt.empty))).append(l?dt.empty:dt.from(r.copy(dt.empty))),o?0:1,l?0:1),o?0:1)),e(i.scrollIntoView()),!0}function qbe(t){return function(e,n){let{$from:i,$to:r}=e.selection,a=i.blockRange(r,c=>c.childCount>0&&c.firstChild.type==t);if(!a)return!1;let s=a.startIndex;if(s==0)return!1;let o=a.parent,l=o.child(s-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==o.type,d=dt.from(c?t.create():null),f=new Mt(dt.from(t.create(null,dt.from(o.type.create(null,d)))),c?3:1,0),p=a.start,m=a.end;n(e.tr.step(new Er(p-(c?3:1),m,p,m,f,1,!0)).scrollIntoView())}return!0}}const Hr=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Bp=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let l3=null;const jl=function(t,e,n){let i=l3||(l3=document.createRange());return i.setEnd(t,n??t.nodeValue.length),i.setStart(t,e||0),i},Xbe=function(){l3=null},Af=function(t,e,n,i){return n&&(m5(t,e,n,i,-1)||m5(t,e,n,i,1))},Kbe=/^(img|br|input|textarea|hr)$/i;function m5(t,e,n,i,r){for(var a;;){if(t==n&&e==i)return!0;if(e==(r<0?0:Us(t))){let s=t.parentNode;if(!s||s.nodeType!=1||bx(t)||Kbe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Hr(t)+(r<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(r<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((a=s.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=r;else return!1;else t=s,e=r<0?Us(t):0}else return!1}}function Us(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ybe(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Us(t)}else if(t.parentNode&&!bx(t))e=Hr(t),t=t.parentNode;else return null}}function Zbe(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!bx(t))e=Hr(t)+1,t=t.parentNode;else return null}}function Qbe(t,e,n){for(let i=e==0,r=e==Us(t);i||r;){if(t==n)return!0;let a=Hr(t);if(t=t.parentNode,!t)return!1;i=i&&a==0,r=r&&a==Us(t)}}function bx(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const zS=function(t){return t.focusNode&&Af(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Gd(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Jbe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function e_e(t,e,n){if(t.caretPositionFromPoint)try{let i=t.caretPositionFromPoint(e,n);if(i)return{node:i.offsetNode,offset:Math.min(Us(i.offsetNode),i.offset)}}catch{}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,n);if(i)return{node:i.startContainer,offset:Math.min(Us(i.startContainer),i.startOffset)}}}const qo=typeof navigator<"u"?navigator:null,g5=typeof document<"u"?document:null,id=qo&&qo.userAgent||"",c3=/Edge\/(\d+)/.exec(id),uW=/MSIE \d/.exec(id),u3=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(id),Ia=!!(uW||u3||c3),Lu=uW?document.documentMode:u3?+u3[1]:c3?+c3[1]:0,Hs=!Ia&&/gecko\/(\d+)/i.test(id);Hs&&+(/Firefox\/(\d+)/.exec(id)||[0,0])[1];const d3=!Ia&&/Chrome\/(\d+)/.exec(id),ea=!!d3,dW=d3?+d3[1]:0,ga=!Ia&&!!qo&&/Apple Computer/.test(qo.vendor),Hp=ga&&(/Mobile\/\w+/.test(id)||!!qo&&qo.maxTouchPoints>2),Ps=Hp||(qo?/Mac/.test(qo.platform):!1),t_e=qo?/Win/.test(qo.platform):!1,Xl=/Android \d/.test(id),_x=!!g5&&"webkitFontSmoothing"in g5.documentElement.style,n_e=_x?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function i_e(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Pl(t,e){return typeof t=="number"?t:t[e]}function r_e(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,i=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*i}}function x5(t,e,n){let i=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=Bp(s);continue}let o=s,l=o==a.body,c=l?i_e(a):r_e(o),d=0,f=0;if(e.top<c.top+Pl(i,"top")?f=-(c.top-e.top+Pl(r,"top")):e.bottom>c.bottom-Pl(i,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Pl(r,"top")-c.top:e.bottom-c.bottom+Pl(r,"bottom")),e.left<c.left+Pl(i,"left")?d=-(c.left-e.left+Pl(r,"left")):e.right>c.right-Pl(i,"right")&&(d=e.right-c.right+Pl(r,"right")),d||f)if(l)a.defaultView.scrollBy(d,f);else{let m=o.scrollLeft,_=o.scrollTop;f&&(o.scrollTop+=f),d&&(o.scrollLeft+=d);let b=o.scrollLeft-m,v=o.scrollTop-_;e={left:e.left-b,top:e.top-v,right:e.right-b,bottom:e.bottom-v}}let p=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(p))break;s=p=="absolute"?s.offsetParent:Bp(s)}}function a_e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),i,r;for(let a=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let o=t.root.elementFromPoint(a,s);if(!o||o==t.dom||!t.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=n-20){i=o,r=l.top;break}}return{refDOM:i,refTop:r,stack:fW(t.dom)}}function fW(t){let e=[],n=t.ownerDocument;for(let i=t;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),t!=n);i=Bp(i));return e}function s_e({refDOM:t,refTop:e,stack:n}){let i=t?t.getBoundingClientRect().top:0;hW(n,i==0?0:i-e)}function hW(t,e){for(let n=0;n<t.length;n++){let{dom:i,top:r,left:a}=t[n];i.scrollTop!=r+e&&(i.scrollTop=r+e),i.scrollLeft!=a&&(i.scrollLeft=a)}}let Qh=null;function o_e(t){if(t.setActive)return t.setActive();if(Qh)return t.focus(Qh);let e=fW(t);t.focus(Qh==null?{get preventScroll(){return Qh={preventScroll:!0},!0}}:void 0),Qh||(Qh=!1,hW(e,0))}function pW(t,e){let n,i=2e8,r,a=0,s=e.top,o=e.top,l,c;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=jl(d).getClientRects();else continue;for(let m=0;m<p.length;m++){let _=p[m];if(_.top<=s&&_.bottom>=o){s=Math.max(_.bottom,s),o=Math.min(_.top,o);let b=_.left>e.left?_.left-e.left:_.right<e.left?e.left-_.right:0;if(b<i){n=d,i=b,r=b&&n.nodeType==3?{left:_.right<e.left?_.right:_.left,top:e.top}:e,d.nodeType==1&&b&&(a=f+(e.left>=(_.left+_.right)/2?1:0));continue}}else _.top>e.top&&!l&&_.left<=e.left&&_.right>=e.left&&(l=d,c={left:Math.max(_.left,Math.min(_.right,e.left)),top:_.top});!n&&(e.left>=_.right&&e.top>=_.top||e.left>=_.left&&e.top>=_.bottom)&&(a=f+1)}}return!n&&l&&(n=l,r=c,i=0),n&&n.nodeType==3?l_e(n,r):!n||i&&n.nodeType==1?{node:t,offset:a}:pW(n,r)}function l_e(t,e){let n=t.nodeValue.length,i=document.createRange();for(let r=0;r<n;r++){i.setEnd(t,r+1),i.setStart(t,r);let a=uu(i,1);if(a.top!=a.bottom&&zP(e,a))return{node:t,offset:r+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function zP(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function c_e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function u_e(t,e,n){let{node:i,offset:r}=pW(e,n),a=-1;if(i.nodeType==1&&!i.firstChild){let s=i.getBoundingClientRect();a=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(i,r,a)}function d_e(t,e,n,i){let r=-1;for(let a=e,s=!1;a!=t.dom;){let o=t.docView.nearestDesc(a,!0),l;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((l=o.dom.getBoundingClientRect()).width||l.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!s&&l.left>i.left||l.top>i.top?r=o.posBefore:(!s&&l.right<i.left||l.bottom<i.top)&&(r=o.posAfter),s=!0),!o.contentDOM&&r<0&&!o.node.isText))return(o.node.isBlock?i.top<(l.top+l.bottom)/2:i.left<(l.left+l.right)/2)?o.posBefore:o.posAfter;a=o.dom.parentNode}return r>-1?r:t.docView.posFromDOM(e,n,-1)}function mW(t,e,n){let i=t.childNodes.length;if(i&&n.top<n.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-n.top)/(n.bottom-n.top))-2)),a=r;;){let s=t.childNodes[a];if(s.nodeType==1){let o=s.getClientRects();for(let l=0;l<o.length;l++){let c=o[l];if(zP(e,c))return mW(s,e,c)}}if((a=(a+1)%i)==r)break}return t}function f_e(t,e){let n=t.dom.ownerDocument,i,r=0,a=e_e(n,e.left,e.top);a&&({node:i,offset:r}=a);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!zP(e,c)||(s=mW(t.dom,e,c),!s))return null}if(ga)for(let c=s;i&&c;c=Bp(c))c.draggable&&(i=void 0);if(s=c_e(s,e),i){if(Hs&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let d=i.childNodes[r],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&r++}let c;_x&&r&&i.nodeType==1&&(c=i.childNodes[r-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&r--,i==t.dom&&r==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(r==0||i.nodeType!=1||i.childNodes[r-1].nodeName!="BR")&&(o=d_e(t,i,r,e))}o==null&&(o=u_e(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function v5(t){return t.top<t.bottom||t.left<t.right}function uu(t,e){let n=t.getClientRects();if(n.length){let i=n[e<0?0:n.length-1];if(v5(i))return i}return Array.prototype.find.call(n,v5)||t.getBoundingClientRect()}const h_e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function gW(t,e,n){let{node:i,offset:r,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=_x||Hs;if(i.nodeType==3)if(s&&(h_e.test(i.nodeValue)||(n<0?!r:r==i.nodeValue.length))){let l=uu(jl(i,r,r),n);if(Hs&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let c=uu(jl(i,r-1,r-1),-1);if(c.top==l.top){let d=uu(jl(i,r,r+1),-1);if(d.top!=l.top)return Rg(d,d.left<c.left)}}return l}else{let l=r,c=r,d=n<0?1:-1;return n<0&&!r?(c++,d=-1):n>=0&&r==i.nodeValue.length?(l--,d=1):n<0?l--:c++,Rg(uu(jl(i,l,c),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&r&&(n<0||r==Us(i))){let l=i.childNodes[r-1];if(l.nodeType==1)return DT(l.getBoundingClientRect(),!1)}if(a==null&&r<Us(i)){let l=i.childNodes[r];if(l.nodeType==1)return DT(l.getBoundingClientRect(),!0)}return DT(i.getBoundingClientRect(),n>=0)}if(a==null&&r&&(n<0||r==Us(i))){let l=i.childNodes[r-1],c=l.nodeType==3?jl(l,Us(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Rg(uu(c,1),!1)}if(a==null&&r<Us(i)){let l=i.childNodes[r];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?jl(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Rg(uu(c,-1),!0)}return Rg(uu(i.nodeType==3?jl(i):i,-n),n>=0)}function Rg(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function DT(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function xW(t,e,n){let i=t.state,r=t.root.activeElement;i!=e&&t.updateState(e),r!=t.dom&&t.focus();try{return n()}finally{i!=e&&t.updateState(i),r!=t.dom&&r&&r.focus()}}function p_e(t,e,n){let i=e.selection,r=n=="up"?i.$from:i.$to;return xW(t,e,()=>{let{node:a}=t.docView.domFromPos(r.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(a,!0);if(!o)break;if(o.node.isBlock){a=o.contentDOM||o.dom;break}a=o.dom.parentNode}let s=gW(t,r.pos,1);for(let o=a.firstChild;o;o=o.nextSibling){let l;if(o.nodeType==1)l=o.getClientRects();else if(o.nodeType==3)l=jl(o,0,o.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const m_e=/[\u0590-\u08ac]/;function g_e(t,e,n){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,a=!r,s=r==i.parent.content.size,o=t.domSelection();return o?!m_e.test(i.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:s:xW(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),p=o.caretBidiLevel;o.modify("move",n,"character");let m=i.depth?t.docView.domAfterPos(i.before()):t.dom,{focusNode:_,focusOffset:b}=t.domSelectionRange(),v=_&&!m.contains(_.nodeType==1?_:_.parentNode)||l==_&&c==b;try{o.collapse(d,f),l&&(l!=d||c!=f)&&o.extend&&o.extend(l,c)}catch{}return p!=null&&(o.caretBidiLevel=p),v}):i.pos==i.start()||i.pos==i.end()}let y5=null,b5=null,_5=!1;function x_e(t,e,n){return y5==e&&b5==n?_5:(y5=e,b5=n,_5=n=="up"||n=="down"?p_e(t,e,n):g_e(t,e,n))}const Vs=0,S5=1,Xd=2,Xo=3;class Sx{constructor(e,n,i,r){this.parent=e,this.children=n,this.dom=i,this.contentDOM=r,this.dirty=Vs,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,i){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,i=this.posAtStart;;n++){let r=this.children[n];if(r==e)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<0){let a,s;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(s)+s.size:this.posAtStart}else{let a,s;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((s=a.pmViewDesc)&&s.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(s):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=n>Hr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){r=!1;break}if(a.previousSibling)break}if(r==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){r=!0;break}if(a.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let i=!0,r=e;r;r=r.parentNode){let a=this.getDesc(r),s;if(a&&(!n||a.node))if(i&&(s=a.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))i=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let i=n;i;i=i.parent)if(i==this)return n}posFromDOM(e,n,i){for(let r=e;r;r=r.parentNode){let a=this.getDesc(r);if(a)return a.localPosFromDOM(e,n,i)}return-1}descAt(e){for(let n=0,i=0;n<this.children.length;n++){let r=this.children[n],a=i+r.size;if(i==e&&a!=i){for(;!r.border&&r.children.length;)for(let s=0;s<r.children.length;s++){let o=r.children[s];if(o.size){r=o;break}}return r}if(e<a)return r.descAt(e-i-r.border);i=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,r=0;for(let a=0;i<this.children.length;i++){let s=this.children[i],o=a+s.size;if(o>e||s instanceof yW){r=e-a;break}a=o}if(r)return this.children[i].domFromPos(r-this.children[i].border,n);for(let a;i&&!(a=this.children[i-1]).size&&a instanceof vW&&a.side>=0;i--);if(n<=0){let a,s=!0;for(;a=i?this.children[i-1]:null,!(!a||a.dom.parentNode==this.contentDOM);i--,s=!1);return a&&n&&s&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?Hr(a.dom)+1:0}}else{let a,s=!0;for(;a=i<this.children.length?this.children[i]:null,!(!a||a.dom.parentNode==this.contentDOM);i++,s=!1);return a&&s&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?Hr(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,a=-1;for(let s=i,o=0;;o++){let l=this.children[o],c=s+l.size;if(r==-1&&e<=c){let d=s+l.border;if(e>=d&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=s;for(let f=o;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){r=Hr(p.dom)+1;break}e-=p.size}r==-1&&(r=0)}if(r>-1&&(c>n||o==this.children.length-1)){n=c;for(let d=o+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=Hr(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:r,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:i}=this.domFromPos(e,0);if(n.nodeType!=1||i==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[i]}setSelection(e,n,i,r=!1){let a=Math.min(e,n),s=Math.max(e,n);for(let m=0,_=0;m<this.children.length;m++){let b=this.children[m],v=_+b.size;if(a>_&&s<v)return b.setSelection(e-_-b.border,n-_-b.border,i,r);_=v}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),c=i.root.getSelection(),d=i.domSelectionRange(),f=!1;if((Hs||ga)&&e==n){let{node:m,offset:_}=o;if(m.nodeType==3){if(f=!!(_&&m.nodeValue[_-1]==`
- `),f&&_==m.nodeValue.length)for(let b=m,v;b;b=b.parentNode){if(v=b.nextSibling){v.nodeName=="BR"&&(o=l={node:v.parentNode,offset:Hr(v)+1});break}let x=b.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let b=m.childNodes[_-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Hs&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(r=!0)}if(!(r||f&&ga)&&Af(o.node,o.offset,d.anchorNode,d.anchorOffset)&&Af(l.node,l.offset,d.focusNode,d.focusOffset))return;let p=!1;if((c.extend||e==n)&&!(f&&Hs)){c.collapse(o.node,o.offset);try{e!=n&&c.extend(l.node,l.offset),p=!0}catch{}}if(!p){if(e>n){let _=o;o=l,l=_}let m=document.createRange();m.setEnd(l.node,l.offset),m.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let i=0,r=0;r<this.children.length;r++){let a=this.children[r],s=i+a.size;if(i==s?e<=s&&n>=i:e<s&&n>i){let o=i+a.border,l=s-a.border;if(e>=o&&n<=l){this.dirty=e==i||n==s?Xd:S5,e==o&&n==l&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Xo:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Xd:Xo}i=s}this.dirty=Xd}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let i=e==1?Xd:S5;n.dirty<i&&(n.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class vW extends Sx{constructor(e,n,i,r){let a,s=n.type.toDOM;if(typeof s=="function"&&(s=s(i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(s.nodeType!=1){let o=document.createElement("span");o.appendChild(s),s=o}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==Vs&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class v_e extends Sx{constructor(e,n,i,r){super(e,[],n,null),this.textDOM=i,this.text=r}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Tf extends Sx{constructor(e,n,i,r,a){super(e,[],i,r),this.mark=n,this.spec=a}static create(e,n,i,r){let a=r.nodeViews[n.type.name],s=a&&a(n,r,i);return(!s||!s.dom)&&(s=Ff.renderSpec(document,n.type.spec.toDOM(n,i),null,n.attrs)),new Tf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Xo||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Xo&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Vs){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=Vs}}slice(e,n,i){let r=Tf.create(this.parent,this.mark,!0,i),a=this.children,s=this.size;n<s&&(a=h3(a,n,s,i)),e>0&&(a=h3(a,0,e,i));for(let o=0;o<a.length;o++)a[o].parent=r;return r.children=a,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Iu extends Sx{constructor(e,n,i,r,a,s,o,l,c){super(e,[],a,s),this.node=n,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=o}static create(e,n,i,r,a,s){let o=a.nodeViews[n.type.name],l,c=o&&o(n,a,()=>{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},i,r),d=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=Ff.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=SW(d,i,n),c?l=new y_e(e,n,i,r,d,f||null,p,c,a,s+1):n.isText?new BS(e,n,i,r,d,p,a):new Iu(e,n,i,r,d,f||null,p,a,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let i=this.children[n];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>dt.empty)}return e}matchesNode(e,n,i){return this.dirty==Vs&&e.eq(this.node)&&I_(n,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let i=this.node.inlineContent,r=n,a=e.composing?this.localCompositionInfo(e,n):null,s=a&&a.pos>-1?a:null,o=a&&a.pos<0,l=new __e(this,s&&s.node,e);M_e(this.node,this.innerDeco,(c,d,f)=>{c.spec.marks?l.syncToMarks(c.spec.marks,i,e):c.type.side>=0&&!f&&l.syncToMarks(d==this.node.childCount?qn.none:this.node.child(d).marks,i,e),l.placeWidget(c,e,r)},(c,d,f,p)=>{l.syncToMarks(c.marks,i,e);let m;l.findNodeMatch(c,d,f,p)||o&&e.state.selection.from>r&&e.state.selection.to<r+c.nodeSize&&(m=l.findIndexWithChild(a.node))>-1&&l.updateNodeAt(c,d,f,m,e)||l.updateNextNode(c,d,f,e,p,r)||l.addNode(c,d,f,e,r),r+=c.nodeSize}),l.syncToMarks([],i,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Xd)&&(s&&this.protectLocalComposition(e,s),bW(this.contentDOM,this.children,e),Hp&&E_e(this.dom))}localCompositionInfo(e,n){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof Ht)||i<n||r>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let s=a.nodeValue,o=A_e(this.node.content,s,i-n,r-n);return o<0?null:{node:a,pos:o,text:s}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:i,text:r}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let s=new v_e(this,a,n,r);e.input.compositionNodes.push(s),this.children=h3(this.children,i,i+r.length,e,s)}update(e,n,i,r){return this.dirty==Xo||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,i,r),!0)}updateInner(e,n,i,r){this.updateOuterDeco(n),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Vs}updateOuterDeco(e){if(I_(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=_W(this.dom,this.nodeDOM,f3(this.outerDeco,this.node,n),f3(e,this.node,n)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function w5(t,e,n,i,r){SW(i,e,t);let a=new Iu(void 0,t,e,n,i,i,i,r,0);return a.contentDOM&&a.updateChildren(r,0),a}class BS extends Iu{constructor(e,n,i,r,a,s,o){super(e,n,i,r,a,null,s,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,i,r){return this.dirty==Xo||this.dirty!=Vs&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Vs||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Vs,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,i){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,i){let r=this.node.cut(e,n),a=document.createTextNode(r.text);return new BS(this.parent,r,this.outerDeco,this.innerDeco,a,a,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Xo)}get domAtom(){return!1}isText(e){return this.node.text==e}}class yW extends Sx{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Vs&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class y_e extends Iu{constructor(e,n,i,r,a,s,o,l,c,d){super(e,n,i,r,a,s,o,c,d),this.spec=l}update(e,n,i,r){if(this.dirty==Xo)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,i);return a&&this.updateInner(e,n,i,r),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,i,r){this.spec.setSelection?this.spec.setSelection(e,n,i.root):super.setSelection(e,n,i,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function bW(t,e,n){let i=t.firstChild,r=!1;for(let a=0;a<e.length;a++){let s=e[a],o=s.dom;if(o.parentNode==t){for(;o!=i;)i=M5(i),r=!0;i=i.nextSibling}else r=!0,t.insertBefore(o,i);if(s instanceof Tf){let l=i?i.previousSibling:t.lastChild;bW(s.contentDOM,s.children,n),i=l?l.nextSibling:t.firstChild}}for(;i;)i=M5(i),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const a0=function(t){t&&(this.nodeName=t)};a0.prototype=Object.create(null);const Kd=[new a0];function f3(t,e,n){if(t.length==0)return Kd;let i=n?Kd[0]:new a0,r=[i];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&r.push(i=new a0(s.nodeName));for(let o in s){let l=s[o];l!=null&&(n&&r.length==1&&r.push(i=new a0(e.isInline?"span":"div")),o=="class"?i.class=(i.class?i.class+" ":"")+l:o=="style"?i.style=(i.style?i.style+";":"")+l:o!="nodeName"&&(i[o]=l))}}}return r}function _W(t,e,n,i){if(n==Kd&&i==Kd)return e;let r=e;for(let a=0;a<i.length;a++){let s=i[a],o=n[a];if(a){let l;o&&o.nodeName==s.nodeName&&r!=t&&(l=r.parentNode)&&l.nodeName.toLowerCase()==s.nodeName||(l=document.createElement(s.nodeName),l.pmIsDeco=!0,l.appendChild(r),o=Kd[0]),r=l}b_e(r,o||Kd[0],s)}return r}function b_e(t,e,n){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in n)&&t.removeAttribute(i);for(let i in n)i!="class"&&i!="style"&&i!="nodeName"&&n[i]!=e[i]&&t.setAttribute(i,n[i]);if(e.class!=n.class){let i=e.class?e.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.remove(i[a]);for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.add(r[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=i.exec(e.style);)t.style.removeProperty(r[1])}n.style&&(t.style.cssText+=n.style)}}function SW(t,e,n){return _W(t,t,Kd,f3(e,n,t.nodeType!=1))}function I_(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function M5(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class __e{constructor(e,n,i){this.lock=n,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=S_e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let i=e;i<n;i++)this.top.children[i].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,i){let r=0,a=this.stack.length>>1,s=Math.min(a,e.length);for(;r<s&&(r==a-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<a;)this.destroyRest(),this.top.dirty=Vs,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[a])&&!this.isLocked(c.dom)){o=l;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let l=Tf.create(this.top,e[a],n,i);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,i,r){let a=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,i))a=this.top.children.indexOf(s,this.index);else for(let o=this.index,l=Math.min(this.top.children.length,o+5);o<l;o++){let c=this.top.children[o];if(c.matchesNode(e,n,i)&&!this.preMatch.matched.has(c)){a=o;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,i,r,a){let s=this.top.children[r];return s.dirty==Xo&&s.dom==s.contentDOM&&(s.dirty=Xd),s.update(e,n,i,a)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==i)return r}return-1}e=n}}updateNextNode(e,n,i,r,a,s){for(let o=this.index;o<this.top.children.length;o++){let l=this.top.children[o];if(l instanceof Iu){let c=this.preMatch.matched.get(l);if(c!=null&&c!=a)return!1;let d=l.dom,f,p=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=Xo&&I_(n,l.outerDeco));if(!p&&l.update(e,n,i,r))return this.destroyBetween(this.index,o),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(l,e,n,i,r,s)))return this.destroyBetween(this.index,o),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Xd,f.updateChildren(r,s+1),f.dirty=Vs),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,i,r,a,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!I_(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Iu.create(this.top,n,i,r,a,s);if(o.contentDOM){o.children=e.children,e.children=[];for(let l of o.children)l.parent=o}return e.destroy(),o}addNode(e,n,i,r,a){let s=Iu.create(this.top,e,n,i,r,a);s.contentDOM&&s.updateChildren(r,a+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let a=new vW(this.top,e,n,i);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Tf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof BS)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ga||ea)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let r=new yW(this.top,[],i,null);n!=this.top?n.children.push(r):n.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function S_e(t,e){let n=e,i=n.children.length,r=t.childCount,a=new Map,s=[];e:for(;r>0;){let o;for(;;)if(i){let c=n.children[i-1];if(c instanceof Tf)n=c,i=c.children.length;else{o=c,i--;break}}else{if(n==e)break e;i=n.parent.children.indexOf(n),n=n.parent}let l=o.node;if(l){if(l!=t.child(r-1))break;--r,a.set(o,r),s.push(o)}}return{index:r,matched:a,matches:s.reverse()}}function w_e(t,e){return t.type.side-e.type.side}function M_e(t,e,n,i){let r=e.locals(t),a=0;if(r.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);i(d,r,e.forChild(a,d),c),a+=d.nodeSize}return}let s=0,o=[],l=null;for(let c=0;;){let d,f;for(;s<r.length&&r[s].to==a;){let v=r[s++];v.widget&&(d?(f||(f=[d])).push(v):d=v)}if(d)if(f){f.sort(w_e);for(let v=0;v<f.length;v++)n(f[v],c,!!l)}else n(d,c,!!l);let p,m;if(l)m=-1,p=l,l=null;else if(c<t.childCount)m=c,p=t.child(c++);else break;for(let v=0;v<o.length;v++)o[v].to<=a&&o.splice(v--,1);for(;s<r.length&&r[s].from<=a&&r[s].to>a;)o.push(r[s++]);let _=a+p.nodeSize;if(p.isText){let v=_;s<r.length&&r[s].from<v&&(v=r[s].from);for(let x=0;x<o.length;x++)o[x].to<v&&(v=o[x].to);v<_&&(l=p.cut(v-a),p=p.cut(0,v-a),_=v,m=-1)}else for(;s<r.length&&r[s].to<_;)s++;let b=p.isInline&&!p.isLeaf?o.filter(v=>!v.inline):o.slice();i(p,b,e.forChild(a,p),m),a=_}}function E_e(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function A_e(t,e,n,i){for(let r=0,a=0;r<t.childCount&&a<=i;){let s=t.child(r++),o=a;if(a+=s.nodeSize,!s.isText)continue;let l=s.text;for(;r<t.childCount;){let c=t.child(r++);if(a+=c.nodeSize,!c.isText)break;l+=c.text}if(a>=n){if(a>=i&&l.slice(i-e.length-o,i-o)==e)return i-e.length;let c=o<i?l.lastIndexOf(e,i-o-1):-1;if(c>=0&&c+e.length+o>=n)return o+c;if(n==i&&l.length>=i+e.length-o&&l.slice(i-o,i-o+e.length)==e)return i}}return-1}function h3(t,e,n,i,r){let a=[];for(let s=0,o=0;s<t.length;s++){let l=t[s],c=o,d=o+=l.size;c>=n||d<=e?a.push(l):(c<e&&a.push(l.slice(0,e-c,i)),r&&(a.push(r),r=void 0),d>n&&a.push(l.slice(n-c,l.size,i)))}return a}function BP(t,e=null){let n=t.domSelectionRange(),i=t.state.doc;if(!n.focusNode)return null;let r=t.docView.nearestDesc(n.focusNode),a=r&&r.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let o=i.resolve(s),l,c;if(zS(n)){for(l=s;r&&!r.node;)r=r.parent;let f=r.node;if(r&&f.isAtom&&jt.isSelectable(f)&&r.parent&&!(f.isInline&&Qbe(n.focusNode,n.focusOffset,r.dom))){let p=r.posBefore;c=new jt(s==p?o:i.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,p=s;for(let m=0;m<n.rangeCount;m++){let _=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(_.startContainer,_.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(_.endContainer,_.endOffset,-1))}if(f<0)return null;[l,s]=p==t.state.selection.anchor?[p,f]:[f,p],o=i.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=i.resolve(l);if(!c){let f=e=="pointer"||t.state.selection.head<o.pos&&!a?1:-1;c=HP(t,d,o,f)}return c}function wW(t){return t.editable?t.hasFocus():EW(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function nc(t,e=!1){let n=t.state.selection;if(MW(t,n),!!wW(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ea){let i=t.domSelectionRange(),r=t.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&Af(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)C_e(t);else{let{anchor:i,head:r}=n,a,s;E5&&!(n instanceof Ht)&&(n.$from.parent.inlineContent||(a=A5(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=A5(t,n.to))),t.docView.setSelection(i,r,t,e),E5&&(a&&T5(a),s&&T5(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&T_e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const E5=ga||ea&&dW<63;function A5(t,e){let{node:n,offset:i}=t.docView.domFromPos(e,0),r=i<n.childNodes.length?n.childNodes[i]:null,a=i?n.childNodes[i-1]:null;if(ga&&r&&r.contentEditable=="false")return OT(r);if((!r||r.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(r)return OT(r);if(a)return OT(a)}}function OT(t){return t.contentEditable="true",ga&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function T5(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function T_e(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),i=n.anchorNode,r=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=i||n.anchorOffset!=r)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!wW(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function C_e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,i=n.nodeName=="IMG";i?e.collapse(n.parentNode,Hr(n)+1):e.collapse(n,0),!i&&!t.state.selection.visible&&Ia&&Lu<=11&&(n.disabled=!0,n.disabled=!1)}function MW(t,e){if(e instanceof jt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(C5(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else C5(t)}function C5(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function HP(t,e,n,i){return t.someProp("createSelectionBetween",r=>r(t,e,n))||Ht.between(e,n,i)}function N5(t){return t.editable&&!t.hasFocus()?!1:EW(t)}function EW(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function N_e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Af(e.node,e.offset,n.anchorNode,n.anchorOffset)}function p3(t,e){let{$anchor:n,$head:i}=t.selection,r=e>0?n.max(i):n.min(i),a=r.parent.inlineContent?r.depth?t.doc.resolve(e>0?r.after():r.before()):null:r;return a&&rn.findFrom(a,e)}function hu(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function R5(t,e,n){let i=t.state.selection;if(i instanceof Ht)if(n.indexOf("s")>-1){let{$head:r}=i,a=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let s=t.state.doc.resolve(r.pos+a.nodeSize*(e<0?-1:1));return hu(t,new Ht(i.$anchor,s))}else if(i.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let r=p3(t.state,e);return r&&r instanceof jt?hu(t,r):!1}else if(!(Ps&&n.indexOf("m")>-1)){let r=i.$head,a=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!a||a.isText)return!1;let o=e<0?r.pos-a.nodeSize:r.pos;return a.isAtom||(s=t.docView.descAt(o))&&!s.contentDOM?jt.isSelectable(a)?hu(t,new jt(e<0?t.state.doc.resolve(r.pos-a.nodeSize):r)):_x?hu(t,new Ht(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(i instanceof jt&&i.node.isInline)return hu(t,new Ht(e>0?i.$to:i.$from));{let r=p3(t.state,e);return r?hu(t,r):!1}}}function U_(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function s0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Jh(t,e){return e<0?R_e(t):P_e(t)}function R_e(t){let e=t.domSelectionRange(),n=e.focusNode,i=e.focusOffset;if(!n)return;let r,a,s=!1;for(Hs&&n.nodeType==1&&i<U_(n)&&s0(n.childNodes[i],-1)&&(s=!0);;)if(i>0){if(n.nodeType!=1)break;{let o=n.childNodes[i-1];if(s0(o,-1))r=n,a=--i;else if(o.nodeType==3)n=o,i=n.nodeValue.length;else break}}else{if(AW(n))break;{let o=n.previousSibling;for(;o&&s0(o,-1);)r=n.parentNode,a=Hr(o),o=o.previousSibling;if(o)n=o,i=U_(n);else{if(n=n.parentNode,n==t.dom)break;i=0}}}s?m3(t,n,i):r&&m3(t,r,a)}function P_e(t){let e=t.domSelectionRange(),n=e.focusNode,i=e.focusOffset;if(!n)return;let r=U_(n),a,s;for(;;)if(i<r){if(n.nodeType!=1)break;let o=n.childNodes[i];if(s0(o,1))a=n,s=++i;else break}else{if(AW(n))break;{let o=n.nextSibling;for(;o&&s0(o,1);)a=o.parentNode,s=Hr(o)+1,o=o.nextSibling;if(o)n=o,i=0,r=U_(n);else{if(n=n.parentNode,n==t.dom)break;i=r=0}}}a&&m3(t,a,s)}function AW(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function D_e(t,e){for(;t&&e==t.childNodes.length&&!bx(t);)e=Hr(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function O_e(t,e){for(;t&&!e&&!bx(t);)e=Hr(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function m3(t,e,n){if(e.nodeType!=3){let a,s;(s=D_e(e,n))?(e=s,n=0):(a=O_e(e,n))&&(e=a,n=a.nodeValue.length)}let i=t.domSelection();if(!i)return;if(zS(i)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),i.removeAllRanges(),i.addRange(a)}else i.extend&&i.extend(e,n);t.domObserver.setCurSelection();let{state:r}=t;setTimeout(()=>{t.state==r&&nc(t)},50)}function P5(t,e){let n=t.state.doc.resolve(e);if(!(ea||t_e)&&n.parent.inlineContent){let r=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),s=(a.top+a.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(a.left-r.left)>1)return a.left<r.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),s=(a.top+a.bottom)/2;if(s>r.top&&s<r.bottom&&Math.abs(a.left-r.left)>1)return a.left>r.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function D5(t,e,n){let i=t.state.selection;if(i instanceof Ht&&!i.empty||n.indexOf("s")>-1||Ps&&n.indexOf("m")>-1)return!1;let{$from:r,$to:a}=i;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=p3(t.state,e);if(s&&s instanceof jt)return hu(t,s)}if(!r.parent.inlineContent){let s=e<0?r:a,o=i instanceof ls?rn.near(s,e):rn.findFrom(s,e);return o?hu(t,o):!1}return!1}function O5(t,e){if(!(t.state.selection instanceof Ht))return!0;let{$head:n,$anchor:i,empty:r}=t.state.selection;if(!n.sameParent(i))return!0;if(!r)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let s=t.state.tr;return e<0?s.delete(n.pos-a.nodeSize,n.pos):s.delete(n.pos,n.pos+a.nodeSize),t.dispatch(s),!0}return!1}function k5(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function k_e(t){if(!ga||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;k5(t,i,"true"),setTimeout(()=>k5(t,i,"false"),20)}return!1}function L_e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function I_e(t,e){let n=e.keyCode,i=L_e(e);if(n==8||Ps&&n==72&&i=="c")return O5(t,-1)||Jh(t,-1);if(n==46&&!e.shiftKey||Ps&&n==68&&i=="c")return O5(t,1)||Jh(t,1);if(n==13||n==27)return!0;if(n==37||Ps&&n==66&&i=="c"){let r=n==37?P5(t,t.state.selection.from)=="ltr"?-1:1:-1;return R5(t,r,i)||Jh(t,r)}else if(n==39||Ps&&n==70&&i=="c"){let r=n==39?P5(t,t.state.selection.from)=="ltr"?1:-1:1;return R5(t,r,i)||Jh(t,r)}else{if(n==38||Ps&&n==80&&i=="c")return D5(t,-1,i)||Jh(t,-1);if(n==40||Ps&&n==78&&i=="c")return k_e(t)||D5(t,1,i)||Jh(t,1);if(i==(Ps?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function VP(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:i,openStart:r,openEnd:a}=e;for(;r>1&&a>1&&i.childCount==1&&i.firstChild.childCount==1;){r--,a--;let m=i.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),i=m.content}let s=t.someProp("clipboardSerializer")||Ff.fromSchema(t.state.schema),o=DW(),l=o.createElement("div");l.appendChild(s.serializeFragment(i,{document:o}));let c=l.firstChild,d,f=0;for(;c&&c.nodeType==1&&(d=PW[c.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let _=o.createElement(d[m]);for(;l.firstChild;)_.appendChild(l.firstChild);l.appendChild(_),f++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${r} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:l,text:p,slice:e}}function TW(t,e,n,i,r){let a=r.parent.type.spec.code,s,o;if(!n&&!e)return null;let l=!!e&&(i||a||!n);if(l){if(t.someProp("transformPastedText",p=>{e=p(e,a||i,t)}),a)return o=new Mt(dt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",p=>{o=p(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",p=>p(e,r,i,t));if(f)o=f;else{let p=r.marks(),{schema:m}=t.state,_=Ff.fromSchema(m);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let v=s.appendChild(document.createElement("p"));b&&v.appendChild(_.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=z_e(n),_x&&B_e(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let p=s.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;s=p}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||i0.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||d),context:r,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!U_e.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)o=H_e(L5(o,+d[1],+d[2]),d[4]);else if(o=Mt.maxOpen(j_e(o.content,r),!0),o.openStart||o.openEnd){let f=0,p=0;for(let m=o.content.firstChild;f<o.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=o.content.lastChild;p<o.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);o=L5(o,f,p)}return t.someProp("transformPasted",f=>{o=f(o,t,l)}),o}const U_e=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function j_e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.index(n)),a,s=[];if(t.forEach(o=>{if(!s)return;let l=r.findWrapping(o.type),c;if(!l)return s=null;if(c=s.length&&a.length&&NW(l,a,o,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=RW(s[s.length-1],a.length));let d=CW(o,l);s.push(d),r=r.matchType(d.type),a=l}}),s)return dt.from(s)}return t}function CW(t,e,n=0){for(let i=e.length-1;i>=n;i--)t=e[i].create(null,dt.from(t));return t}function NW(t,e,n,i,r){if(r<t.length&&r<e.length&&t[r]==e[r]){let a=NW(t,e,n,i.lastChild,r+1);if(a)return i.copy(i.content.replaceChild(i.childCount-1,a));if(i.contentMatchAt(i.childCount).matchType(r==t.length-1?n.type:t[r+1]))return i.copy(i.content.append(dt.from(CW(n,t,r+1))))}}function RW(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,RW(t.lastChild,e-1)),i=t.contentMatchAt(t.childCount).fillBefore(dt.empty,!0);return t.copy(n.append(i))}function g3(t,e,n,i,r,a){let s=e<0?t.firstChild:t.lastChild,o=s.content;return t.childCount>1&&(a=0),r<i-1&&(o=g3(o,e,n,i,r+1,a)),r>=n&&(o=e<0?s.contentMatchAt(0).fillBefore(o,a<=r).append(o):o.append(s.contentMatchAt(s.childCount).fillBefore(dt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function L5(t,e,n){return e<t.openStart&&(t=new Mt(g3(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Mt(g3(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const PW={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let I5=null;function DW(){return I5||(I5=document.implementation.createHTMLDocument("title"))}let kT=null;function F_e(t){let e=window.trustedTypes;return e?(kT||(kT=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),kT.createHTML(t)):t}function z_e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=DW().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(t),r;if((r=i&&PW[i[1].toLowerCase()])&&(t=r.map(a=>"<"+a+">").join("")+t+r.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=F_e(t),r)for(let a=0;a<r.length;a++)n=n.querySelector(r[a])||n;return n}function B_e(t){let e=t.querySelectorAll(ea?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let i=e[n];i.childNodes.length==1&&i.textContent==" "&&i.parentNode&&i.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),i)}}function H_e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,i;try{i=JSON.parse(e)}catch{return t}let{content:r,openStart:a,openEnd:s}=t;for(let o=i.length-2;o>=0;o-=2){let l=n.nodes[i[o]];if(!l||l.hasRequiredAttrs())break;r=dt.from(l.create(i[o+1],r)),a++,s++}return new Mt(r,a,s)}const xa={},va={},V_e={touchstart:!0,touchmove:!0};class $_e{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function G_e(t){for(let e in xa){let n=xa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=i=>{q_e(t,i)&&!$P(t,i)&&(t.editable||!(i.type in va))&&n(t,i)},V_e[e]?{passive:!0}:void 0)}ga&&t.dom.addEventListener("input",()=>null),x3(t)}function Cu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function W_e(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function x3(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=i=>$P(t,i))})}function $P(t,e){return t.someProp("handleDOMEvents",n=>{let i=n[e.type];return i?i(t,e)||e.defaultPrevented:!1})}function q_e(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function X_e(t,e){!$P(t,e)&&xa[e.type]&&(t.editable||!(e.type in va))&&xa[e.type](t,e)}va.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!kW(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Xl&&ea&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Hp&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let i=Date.now();t.input.lastIOSEnter=i,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==i&&(t.someProp("handleKeyDown",r=>r(t,Gd(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",i=>i(t,n))||I_e(t,n)?n.preventDefault():Cu(t,"key")};va.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};va.keypress=(t,e)=>{let n=e;if(kW(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ps&&n.metaKey)return;if(t.someProp("handleKeyPress",r=>r(t,n))){n.preventDefault();return}let i=t.state.selection;if(!(i instanceof Ht)||!i.$from.sameParent(i.$to)){let r=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!t.someProp("handleTextInput",s=>s(t,i.$from.pos,i.$to.pos,r,a))&&t.dispatch(a()),n.preventDefault()}};function HS(t){return{left:t.clientX,top:t.clientY}}function K_e(t,e){let n=e.x-t.clientX,i=e.y-t.clientY;return n*n+i*i<100}function GP(t,e,n,i,r){if(i==-1)return!1;let a=t.state.doc.resolve(i);for(let s=a.depth+1;s>0;s--)if(t.someProp(e,o=>s>a.depth?o(t,n,a.nodeAfter,a.before(s),r,!0):o(t,n,a.node(s),a.before(s),r,!1)))return!0;return!1}function Mp(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let i=t.state.tr.setSelection(e);i.setMeta("pointer",!0),t.dispatch(i)}function Y_e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),i=n.nodeAfter;return i&&i.isAtom&&jt.isSelectable(i)?(Mp(t,new jt(n)),!0):!1}function Z_e(t,e){if(e==-1)return!1;let n=t.state.selection,i,r;n instanceof jt&&(i=n.node);let a=t.state.doc.resolve(e);for(let s=a.depth+1;s>0;s--){let o=s>a.depth?a.nodeAfter:a.node(s);if(jt.isSelectable(o)){i&&n.$from.depth>0&&s>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?r=a.before(n.$from.depth):r=a.before(s);break}}return r!=null?(Mp(t,jt.create(t.state.doc,r)),!0):!1}function Q_e(t,e,n,i,r){return GP(t,"handleClickOn",e,n,i)||t.someProp("handleClick",a=>a(t,e,i))||(r?Z_e(t,n):Y_e(t,n))}function J_e(t,e,n,i){return GP(t,"handleDoubleClickOn",e,n,i)||t.someProp("handleDoubleClick",r=>r(t,e,i))}function e1e(t,e,n,i){return GP(t,"handleTripleClickOn",e,n,i)||t.someProp("handleTripleClick",r=>r(t,e,i))||t1e(t,n,i)}function t1e(t,e,n){if(n.button!=0)return!1;let i=t.state.doc;if(e==-1)return i.inlineContent?(Mp(t,Ht.create(i,0,i.content.size)),!0):!1;let r=i.resolve(e);for(let a=r.depth+1;a>0;a--){let s=a>r.depth?r.nodeAfter:r.node(a),o=r.before(a);if(s.inlineContent)Mp(t,Ht.create(i,o+1,o+1+s.content.size));else if(jt.isSelectable(s))Mp(t,jt.create(i,o));else continue;return!0}}function WP(t){return j_(t)}const OW=Ps?"metaKey":"ctrlKey";xa.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let i=WP(t),r=Date.now(),a="singleClick";r-t.input.lastClick.time<500&&K_e(n,t.input.lastClick)&&!n[OW]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:a,button:n.button};let s=t.posAtCoords(HS(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new n1e(t,s,n,!!i)):(a=="doubleClick"?J_e:e1e)(t,s.pos,s.inside,n)?n.preventDefault():Cu(t,"pointer"))};class n1e{constructor(e,n,i,r){this.view=e,this.pos=n,this.event=i,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!i[OW],this.allowDefault=i.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,s=d.depth?d.before():0}const o=r?null:i.target,l=o?e.docView.nearestDesc(o,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(i.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||c instanceof jt&&c.from<=s&&c.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Hs&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Cu(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>nc(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(HS(e))),this.updateAllowDefault(e),this.allowDefault||!n?Cu(this.view,"pointer"):Q_e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ga&&this.mightDrag&&!this.mightDrag.node.isAtom||ea&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Mp(this.view,rn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Cu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Cu(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}xa.touchstart=t=>{t.input.lastTouch=Date.now(),WP(t),Cu(t,"pointer")};xa.touchmove=t=>{t.input.lastTouch=Date.now(),Cu(t,"pointer")};xa.contextmenu=t=>WP(t);function kW(t,e){return t.composing?!0:ga&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const i1e=Xl?5e3:-1;va.compositionstart=va.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Ht&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),j_(t,!0),t.markCursor=null;else if(j_(t,!e.selection.empty),Hs&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let i=t.domSelectionRange();for(let r=i.focusNode,a=i.focusOffset;r&&r.nodeType==1&&a!=0;){let s=a<0?r.lastChild:r.childNodes[a-1];if(!s)break;if(s.nodeType==3){let o=t.domSelection();o&&o.collapse(s,s.nodeValue.length);break}else r=s,a=-1}}t.input.composing=!0}LW(t,i1e)};va.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,LW(t,20))};function LW(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>j_(t),e))}function IW(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=a1e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function r1e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Ybe(e.focusNode,e.focusOffset),i=Zbe(e.focusNode,e.focusOffset);if(n&&i&&n!=i){let r=i.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||i==a)return a;if(!r||!r.isText(i.nodeValue))return i;if(t.input.compositionNode==i){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return i}}return n||i}function a1e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function j_(t,e=!1){if(!(Xl&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),IW(t),e||t.docView&&t.docView.dirty){let n=BP(t),i=t.state.selection;return n&&!n.eq(i)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function s1e(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(e),t.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const z0=Ia&&Lu<15||Hp&&n_e<604;xa.copy=va.cut=(t,e)=>{let n=e,i=t.state.selection,r=n.type=="cut";if(i.empty)return;let a=z0?null:n.clipboardData,s=i.content(),{dom:o,text:l}=VP(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",l)):s1e(t,o),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function o1e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function l1e(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,i=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),i.parentNode&&i.parentNode.removeChild(i),n?B0(t,i.value,null,r,e):B0(t,i.textContent,i.innerHTML,r,e)},50)}function B0(t,e,n,i,r){let a=TW(t,e,n,i,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,r,a||Mt.empty)))return!0;if(!a)return!1;let s=o1e(a),o=s?t.state.tr.replaceSelectionWith(s,i):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function UW(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}va.paste=(t,e)=>{let n=e;if(t.composing&&!Xl)return;let i=z0?null:n.clipboardData,r=t.input.shiftKey&&t.input.lastKeyCode!=45;i&&B0(t,UW(i),i.getData("text/html"),r,n)?n.preventDefault():l1e(t,n)};class jW{constructor(e,n,i){this.slice=e,this.move=n,this.node=i}}const c1e=Ps?"altKey":"ctrlKey";function FW(t,e){let n=t.someProp("dragCopies",i=>!i(e));return n??!e[c1e]}xa.dragstart=(t,e)=>{let n=e,i=t.input.mouseDown;if(i&&i.done(),!n.dataTransfer)return;let r=t.state.selection,a=r.empty?null:t.posAtCoords(HS(n)),s;if(!(a&&a.pos>=r.from&&a.pos<=(r instanceof jt?r.to-1:r.to))){if(i&&i.mightDrag)s=jt.create(t.state.doc,i.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(s=jt.create(t.state.doc,f.posBefore))}}let o=(s||t.state.selection).content(),{dom:l,text:c,slice:d}=VP(t,o);(!n.dataTransfer.files.length||!ea||dW>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(z0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",z0||n.dataTransfer.setData("text/plain",c),t.dragging=new jW(d,FW(t,n),s)};xa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};va.dragover=va.dragenter=(t,e)=>e.preventDefault();va.drop=(t,e)=>{let n=e,i=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let r=t.posAtCoords(HS(n));if(!r)return;let a=t.state.doc.resolve(r.pos),s=i&&i.slice;s?t.someProp("transformPasted",_=>{s=_(s,t,!1)}):s=TW(t,UW(n.dataTransfer),z0?null:n.dataTransfer.getData("text/html"),!1,a);let o=!!(i&&FW(t,n));if(t.someProp("handleDrop",_=>_(t,n,s||Mt.empty,o))){n.preventDefault();return}if(!s)return;n.preventDefault();let l=s?$9(t.state.doc,a.pos,s):a.pos;l==null&&(l=a.pos);let c=t.state.tr;if(o){let{node:_}=i;_?_.replace(c):c.deleteSelection()}let d=c.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,p=c.doc;if(f?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(p))return;let m=c.doc.resolve(d);if(f&&jt.isSelectable(s.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new jt(m));else{let _=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((b,v,x,M)=>_=M),c.setSelection(HP(t,m,c.doc.resolve(_)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};xa.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&nc(t)},20))};xa.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};xa.beforeinput=(t,e)=>{if(ea&&Xl&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:i}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=i||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Gd(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;r&&r.pos>0&&t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let t in va)xa[t]=va[t];function H0(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class F_{constructor(e,n){this.toDOM=e,this.spec=n||of,this.side=this.spec.side||0}map(e,n,i,r){let{pos:a,deleted:s}=e.mapResult(n.from+r,this.side<0?-1:1);return s?null:new fa(a-i,a-i,this)}valid(){return!0}eq(e){return this==e||e instanceof F_&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&H0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Uu{constructor(e,n){this.attrs=e,this.spec=n||of}map(e,n,i,r){let a=e.map(n.from+r,this.spec.inclusiveStart?-1:1)-i,s=e.map(n.to+r,this.spec.inclusiveEnd?1:-1)-i;return a>=s?null:new fa(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Uu&&H0(this.attrs,e.attrs)&&H0(this.spec,e.spec)}static is(e){return e.type instanceof Uu}destroy(){}}class qP{constructor(e,n){this.attrs=e,this.spec=n||of}map(e,n,i,r){let a=e.mapResult(n.from+r,1);if(a.deleted)return null;let s=e.mapResult(n.to+r,-1);return s.deleted||s.pos<=a.pos?null:new fa(a.pos-i,s.pos-i,this)}valid(e,n){let{index:i,offset:r}=e.content.findIndex(n.from),a;return r==n.from&&!(a=e.child(i)).isText&&r+a.nodeSize==n.to}eq(e){return this==e||e instanceof qP&&H0(this.attrs,e.attrs)&&H0(this.spec,e.spec)}destroy(){}}class fa{constructor(e,n,i){this.from=e,this.to=n,this.type=i}copy(e,n){return new fa(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,i){return this.type.map(e,this,n,i)}static widget(e,n,i){return new fa(e,e,new F_(n,i))}static inline(e,n,i,r){return new fa(e,n,new Uu(i,r))}static node(e,n,i,r){return new fa(e,n,new qP(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Uu}get widget(){return this.type instanceof F_}}const ap=[],of={};class hi{constructor(e,n){this.local=e.length?e:ap,this.children=n.length?n:ap}static create(e,n){return n.length?z_(n,e,0,of):Zr}find(e,n,i){let r=[];return this.findInner(e??0,n??1e9,r,0,i),r}findInner(e,n,i,r,a){for(let s=0;s<this.local.length;s++){let o=this.local[s];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&i.push(o.copy(o.from+r,o.to+r))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let o=this.children[s]+1;this.children[s+2].findInner(e-o,n-o,i,r+o,a)}}map(e,n,i){return this==Zr||e.maps.length==0?this:this.mapInner(e,n,0,0,i||of)}mapInner(e,n,i,r,a){let s;for(let o=0;o<this.local.length;o++){let l=this.local[o].map(e,i,r);l&&l.type.valid(n,l)?(s||(s=[])).push(l):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?u1e(this.children,s||[],e,n,i,r,a):s?new hi(s.sort(lf),ap):Zr}add(e,n){return n.length?this==Zr?hi.create(e,n):this.addInner(e,n,0):this}addInner(e,n,i){let r,a=0;e.forEach((o,l)=>{let c=l+i,d;if(d=BW(n,o,c)){for(r||(r=this.children.slice());a<r.length&&r[a]<l;)a+=3;r[a]==l?r[a+2]=r[a+2].addInner(o,d,c+1):r.splice(a,0,l,l+o.nodeSize,z_(d,o,c+1,of)),a+=3}});let s=zW(a?HW(n):n,-i);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new hi(s.length?this.local.concat(s).sort(lf):this.local,r||this.children)}remove(e){return e.length==0||this==Zr?this:this.removeInner(e,0)}removeInner(e,n){let i=this.children,r=this.local;for(let a=0;a<i.length;a+=3){let s,o=i[a]+n,l=i[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>o&&f.to<l&&(e[d]=null,(s||(s=[])).push(f));if(!s)continue;i==this.children&&(i=this.children.slice());let c=i[a+2].removeInner(s,o+1);c!=Zr?i[a+2]=c:(i.splice(a,3),a-=3)}if(r.length){for(let a=0,s;a<e.length;a++)if(s=e[a])for(let o=0;o<r.length;o++)r[o].eq(s,n)&&(r==this.local&&(r=this.local.slice()),r.splice(o--,1))}return i==this.children&&r==this.local?this:r.length||i.length?new hi(r,i):Zr}forChild(e,n){if(this==Zr)return this;if(n.isLeaf)return hi.empty;let i,r;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(i=this.children[o+2]);break}let a=e+1,s=a+n.content.size;for(let o=0;o<this.local.length;o++){let l=this.local[o];if(l.from<s&&l.to>a&&l.type instanceof Uu){let c=Math.max(a,l.from)-a,d=Math.min(s,l.to)-a;c<d&&(r||(r=[])).push(l.copy(c,d))}}if(r){let o=new hi(r.sort(lf),ap);return i?new bu([o,i]):o}return i||Zr}eq(e){if(this==e)return!0;if(!(e instanceof hi)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return XP(this.localsInner(e))}localsInner(e){if(this==Zr)return ap;if(e.inlineContent||!this.local.some(Uu.is))return this.local;let n=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Uu||n.push(this.local[i]);return n}forEachSet(e){e(this)}}hi.empty=new hi([],[]);hi.removeOverlap=XP;const Zr=hi.empty;class bu{constructor(e){this.members=e}map(e,n){const i=this.members.map(r=>r.map(e,n,of));return bu.from(i)}forChild(e,n){if(n.isLeaf)return hi.empty;let i=[];for(let r=0;r<this.members.length;r++){let a=this.members[r].forChild(e,n);a!=Zr&&(a instanceof bu?i=i.concat(a.members):i.push(a))}return bu.from(i)}eq(e){if(!(e instanceof bu)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,i=!0;for(let r=0;r<this.members.length;r++){let a=this.members[r].localsInner(e);if(a.length)if(!n)n=a;else{i&&(n=n.slice(),i=!1);for(let s=0;s<a.length;s++)n.push(a[s])}}return n?XP(i?n:n.sort(lf)):ap}static from(e){switch(e.length){case 0:return Zr;case 1:return e[0];default:return new bu(e.every(n=>n instanceof hi)?e:e.reduce((n,i)=>n.concat(i instanceof hi?i:i.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function u1e(t,e,n,i,r,a,s){let o=t.slice();for(let c=0,d=a;c<n.maps.length;c++){let f=0;n.maps[c].forEach((p,m,_,b)=>{let v=b-_-(m-p);for(let x=0;x<o.length;x+=3){let M=o[x+1];if(M<0||p>M+d-f)continue;let w=o[x]+d-f;m>=w?o[x+1]=p<=w?-2:-1:p>=d&&v&&(o[x]+=v,o[x+1]+=v)}f+=v}),d=n.maps[c].map(d,-1)}let l=!1;for(let c=0;c<o.length;c+=3)if(o[c+1]<0){if(o[c+1]==-2){l=!0,o[c+1]=-1;continue}let d=n.map(t[c]+a),f=d-r;if(f<0||f>=i.content.size){l=!0;continue}let p=n.map(t[c+1]+a,-1),m=p-r,{index:_,offset:b}=i.content.findIndex(f),v=i.maybeChild(_);if(v&&b==f&&b+v.nodeSize==m){let x=o[c+2].mapInner(n,v,d+1,t[c]+a+1,s);x!=Zr?(o[c]=f,o[c+1]=m,o[c+2]=x):(o[c+1]=-2,l=!0)}else l=!0}if(l){let c=d1e(o,t,e,n,r,a,s),d=z_(c,i,0,s);e=d.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,p=0;f<d.children.length;f+=3){let m=d.children[f];for(;p<o.length&&o[p]<m;)p+=3;o.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new hi(e.sort(lf),o)}function zW(t,e){if(!e||!t.length)return t;let n=[];for(let i=0;i<t.length;i++){let r=t[i];n.push(new fa(r.from+e,r.to+e,r.type))}return n}function d1e(t,e,n,i,r,a,s){function o(l,c){for(let d=0;d<l.local.length;d++){let f=l.local[d].map(i,r,c);f?n.push(f):s.onRemove&&s.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)o(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&o(t[l+2],e[l]+a+1);return n}function BW(t,e,n){if(e.isLeaf)return null;let i=n+e.nodeSize,r=null;for(let a=0,s;a<t.length;a++)(s=t[a])&&s.from>n&&s.to<i&&((r||(r=[])).push(s),t[a]=null);return r}function HW(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function z_(t,e,n,i){let r=[],a=!1;e.forEach((o,l)=>{let c=BW(t,o,l+n);if(c){a=!0;let d=z_(c,o,n+l+1,i);d!=Zr&&r.push(l,l+o.nodeSize,d)}});let s=zW(a?HW(t):t,-n).sort(lf);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||(i.onRemove&&i.onRemove(s[o].spec),s.splice(o--,1));return s.length||r.length?new hi(s,r):Zr}function lf(t,e){return t.from-e.from||t.to-e.to}function XP(t){let e=t;for(let n=0;n<e.length-1;n++){let i=e[n];if(i.from!=i.to)for(let r=n+1;r<e.length;r++){let a=e[r];if(a.from==i.from){a.to!=i.to&&(e==t&&(e=t.slice()),e[r]=a.copy(a.from,i.to),U5(e,r+1,a.copy(i.to,a.to)));continue}else{a.from<i.to&&(e==t&&(e=t.slice()),e[n]=i.copy(i.from,a.from),U5(e,r,i.copy(a.from,i.to)));break}}}return e}function U5(t,e,n){for(;e<t.length&&lf(n,t[e])>0;)e++;t.splice(e,0,n)}function LT(t){let e=[];return t.someProp("decorations",n=>{let i=n(t.state);i&&i!=Zr&&e.push(i)}),t.cursorWrapper&&e.push(hi.create(t.state.doc,[t.cursorWrapper.deco])),bu.from(e)}const f1e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},h1e=Ia&&Lu<=11;class p1e{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class m1e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new p1e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(i=>{for(let r=0;r<i.length;r++)this.queue.push(i[r]);Ia&&Lu<=11&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),h1e&&(this.onCharData=i=>{this.queue.push({target:i.target,type:"characterData",oldValue:i.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,f1e)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(N5(this.view)){if(this.suppressingSelectionUpdates)return nc(this.view);if(Ia&&Lu<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Af(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,i;for(let a=e.focusNode;a;a=Bp(a))n.add(a);for(let a=e.anchorNode;a;a=Bp(a))if(n.has(a)){i=a;break}let r=i&&this.view.docView.nearestDesc(i);if(r&&r.ignoreMutation({type:"selection",target:i.nodeType==3?i.parentNode:i}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let i=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(i)&&N5(e)&&!this.ignoreSelectionChange(i),a=-1,s=-1,o=!1,l=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],l);f&&(a=a<0?f.from:Math.min(f.from,a),s=s<0?f.to:Math.max(f.to,s),f.typeOver&&(o=!0))}if(Hs&&l.length){let d=l.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,p]=d;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of d){let m=p.parentNode;m&&m.nodeName=="LI"&&(!f||v1e(e,f)!=m)&&p.remove()}}}let c=null;a<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&zS(i)&&(c=BP(e))&&c.eq(rn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,nc(e),this.currentSelection.set(i),e.scrollToSelection()):(a>-1||r)&&(a>-1&&(e.docView.markDirty(a,s),g1e(e)),this.handleDOMChange(a,s,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||nc(e),this.currentSelection.set(i))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let i=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(i==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!i||i.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(i.contentDOM&&i.contentDOM!=i.dom&&!i.contentDOM.contains(e.target))return{from:i.posBefore,to:i.posAfter};let r=e.previousSibling,a=e.nextSibling;if(Ia&&Lu<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:p}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(r=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(a=p)}let s=r&&r.parentNode==e.target?Hr(r)+1:0,o=i.localPosFromDOM(e.target,s,-1),l=a&&a.parentNode==e.target?Hr(a):e.target.childNodes.length,c=i.localPosFromDOM(e.target,l,1);return{from:o,to:c}}else return e.type=="attributes"?{from:i.posAtStart-i.border,to:i.posAtEnd+i.border}:(this.lastChangedTextNode=e.target,{from:i.posAtStart,to:i.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let j5=new WeakMap,F5=!1;function g1e(t){if(!j5.has(t)&&(j5.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Hs,F5)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),F5=!0}}function z5(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Af(s.node,s.offset,r,a)&&([n,i,r,a]=[r,a,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:a}}function x1e(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return z5(t,r)}let n;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",i,!0),n?z5(t,n):null}function v1e(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let i=t.docView.nearestDesc(n,!0);if(i&&i.node.isBlock)return n}return null}function y1e(t,e,n){let{node:i,fromOffset:r,toOffset:a,from:s,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,d=l.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],zS(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ea&&t.input.lastKeyCode===8)for(let v=a;v>r;v--){let x=i.childNodes[v-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){a=v;break}if(!M||M.size)break}let f=t.state.doc,p=t.someProp("domParser")||i0.fromSchema(t.state.schema),m=f.resolve(s),_=null,b=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:r,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:b1e,context:m});if(c&&c[0].pos!=null){let v=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=v),_={anchor:v+s,head:x+s}}return{doc:b,sel:_,from:s,to:o}}function b1e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ga&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ga&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const _1e=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function S1e(t,e,n,i,r){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,U=BP(t,N);if(U&&!t.state.selection.eq(U)){if(ea&&Xl&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",O=>O(t,Gd(13,"Enter"))))return;let R=t.state.tr.setSelection(U);N=="pointer"?R.setMeta("pointer",!0):N=="key"&&R.scrollIntoView(),a&&R.setMeta("composition",a),t.dispatch(R)}return}let s=t.state.doc.resolve(e),o=s.sharedDepth(n);e=s.before(o+1),n=t.state.doc.resolve(n).after(o+1);let l=t.state.selection,c=y1e(t,e,n),d=t.state.doc,f=d.slice(c.from,c.to),p,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,m="end"):(p=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let _=E1e(f.content,c.doc.content,c.from,p,m);if(_&&t.input.domChangeCount++,(Hp&&t.input.lastIOSEnter>Date.now()-225||Xl)&&r.some(N=>N.nodeType==1&&!_1e.test(N.nodeName))&&(!_||_.endA>=_.endB)&&t.someProp("handleKeyDown",N=>N(t,Gd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!_)if(i&&l instanceof Ht&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))_={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let N=B5(t,t.state.doc,c.sel);if(N&&!N.eq(t.state.selection)){let U=t.state.tr.setSelection(N);a&&U.setMeta("composition",a),t.dispatch(U)}}return}t.state.selection.from<t.state.selection.to&&_.start==_.endB&&t.state.selection instanceof Ht&&(_.start>t.state.selection.from&&_.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?_.start=t.state.selection.from:_.endA<t.state.selection.to&&_.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(_.endB+=t.state.selection.to-_.endA,_.endA=t.state.selection.to)),Ia&&Lu<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>c.from&&c.doc.textBetween(_.start-c.from-1,_.start-c.from+1)==" "&&(_.start--,_.endA--,_.endB--);let b=c.doc.resolveNoCache(_.start-c.from),v=c.doc.resolveNoCache(_.endB-c.from),x=d.resolve(_.start),M=b.sameParent(v)&&b.parent.inlineContent&&x.end()>=_.endA;if((Hp&&t.input.lastIOSEnter>Date.now()-225&&(!M||r.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!M&&b.pos<c.doc.content.size&&(!b.sameParent(v)||!b.parent.inlineContent)&&b.pos<v.pos&&!/\S/.test(c.doc.textBetween(b.pos,v.pos,"","")))&&t.someProp("handleKeyDown",N=>N(t,Gd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>_.start&&M1e(d,_.start,_.endA,b,v)&&t.someProp("handleKeyDown",N=>N(t,Gd(8,"Backspace")))){Xl&&ea&&t.domObserver.suppressSelectionUpdates();return}ea&&_.endB==_.start&&(t.input.lastChromeDelete=Date.now()),Xl&&!M&&b.start()!=v.start()&&v.parentOffset==0&&b.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==_.endA&&(_.endB-=2,v=c.doc.resolveNoCache(_.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,Gd(13,"Enter"))})},20));let w=_.start,E=_.endA,T=N=>{let U=N||t.state.tr.replace(w,E,c.doc.slice(_.start-c.from,_.endB-c.from));if(c.sel){let R=B5(t,U.doc,c.sel);R&&!(ea&&t.composing&&R.empty&&(_.start!=_.endB||t.input.lastChromeDelete<Date.now()-100)&&(R.head==w||R.head==U.mapping.map(E)-1)||Ia&&R.empty&&R.head==w)&&U.setSelection(R)}return a&&U.setMeta("composition",a),U.scrollIntoView()},P;if(M)if(b.pos==v.pos){Ia&&Lu<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>nc(t),20));let N=T(t.state.tr.delete(w,E)),U=d.resolve(_.start).marksAcross(d.resolve(_.endA));U&&N.ensureMarks(U),t.dispatch(N)}else if(_.endA==_.endB&&(P=w1e(b.parent.content.cut(b.parentOffset,v.parentOffset),x.parent.content.cut(x.parentOffset,_.endA-x.start())))){let N=T(t.state.tr);P.type=="add"?N.addMark(w,E,P.mark):N.removeMark(w,E,P.mark),t.dispatch(N)}else if(b.parent.child(b.index()).isText&&b.index()==v.index()-(v.textOffset?0:1)){let N=b.parent.textBetween(b.parentOffset,v.parentOffset),U=()=>T(t.state.tr.insertText(N,w,E));t.someProp("handleTextInput",R=>R(t,w,E,N,U))||t.dispatch(U())}else t.dispatch(T());else t.dispatch(T())}function B5(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:HP(t,e.resolve(n.anchor),e.resolve(n.head))}function w1e(t,e){let n=t.firstChild.marks,i=e.firstChild.marks,r=n,a=i,s,o,l;for(let d=0;d<i.length;d++)r=i[d].removeFromSet(r);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(r.length==1&&a.length==0)o=r[0],s="add",l=d=>d.mark(o.addToSet(d.marks));else if(r.length==0&&a.length==1)o=a[0],s="remove",l=d=>d.mark(o.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(dt.from(c).eq(t))return{mark:o,type:s}}function M1e(t,e,n,i,r){if(n-e<=r.pos-i.pos||IT(i,!0,!1)<r.pos)return!1;let a=t.resolve(e);if(!i.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let s=t.resolve(IT(a,!0,!0));return!s.parent.isTextblock||s.pos>n||IT(s,!0,!1)<n?!1:i.parent.content.cut(i.parentOffset).eq(s.parent.content)}function IT(t,e,n){let i=t.depth,r=e?t.end():t.pos;for(;i>0&&(e||t.indexAfter(i)==t.node(i).childCount);)i--,r++,e=!1;if(n){let a=t.node(i).maybeChild(t.indexAfter(i));for(;a&&!a.isLeaf;)a=a.firstChild,r++}return r}function E1e(t,e,n,i,r){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:s,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(r=="end"){let l=Math.max(0,a-Math.min(s,o));i-=s+l-a}if(s<a&&t.size<e.size){let l=i<=a&&i>=s?a-i:0;a-=l,a&&a<e.size&&H5(e.textBetween(a-1,a+1))&&(a+=l?1:-1),o=a+(o-s),s=a}else if(o<a){let l=i<=a&&i>=o?a-i:0;a-=l,a&&a<t.size&&H5(t.textBetween(a-1,a+1))&&(a+=l?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function H5(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class VW{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new $_e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(q5),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=G5(this),$5(this),this.nodeViews=W5(this),this.docView=w5(this.state.doc,V5(this),LT(this),this.dom,this),this.domObserver=new m1e(this,(i,r,a,s)=>S1e(this,i,r,a,s)),this.domObserver.start(),G_e(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&x3(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(q5),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let i in this._props)n[i]=this._props[i];n.state=this.state;for(let i in e)n[i]=e[i];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var i;let r=this.state,a=!1,s=!1;e.storedMarks&&this.composing&&(IW(this),s=!0),this.state=e;let o=r.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=W5(this);T1e(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&x3(this),this.editable=G5(this),$5(this);let l=LT(this),c=V5(this),d=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,c,l);(f||!e.selection.eq(r.selection))&&(s=!0);let p=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&a_e(this);if(s){this.domObserver.stop();let m=f&&(Ia||ea)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&A1e(r.selection,e.selection);if(f){let _=ea?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=r1e(this)),(a||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=w5(e.doc,c,l,this.dom,this)),_&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&N_e(this))?nc(this,m):(MW(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((i=this.dragging)===null||i===void 0)&&i.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&s_e(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof jt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&x5(this,n.getBoundingClientRect(),e)}else x5(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n];i.spec.view&&this.pluginViews.push(i.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let i=this.state.plugins[n];i.spec.view&&this.pluginViews.push(i.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let i=this.pluginViews[n];i.update&&i.update(this,e)}}updateDraggedNode(e,n){let i=e.node,r=-1;if(this.state.doc.nodeAt(i.from)==i.node)r=i.from;else{let a=i.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==i.node&&(r=a)}this.dragging=new jW(e.slice,e.move,r<0?void 0:jt.create(this.state.doc,r))}someProp(e,n){let i=this._props&&this._props[e],r;if(i!=null&&(r=n?n(i):i))return r;for(let s=0;s<this.directPlugins.length;s++){let o=this.directPlugins[s].props[e];if(o!=null&&(r=n?n(o):o))return r}let a=this.state.plugins;if(a)for(let s=0;s<a.length;s++){let o=a[s].props[e];if(o!=null&&(r=n?n(o):o))return r}}hasFocus(){if(Ia){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&o_e(this.dom),nc(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return f_e(this,e)}coordsAtPos(e,n=1){return gW(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,i=-1){let r=this.docView.posFromDOM(e,n,i);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,n){return x_e(this,n||this.state,e)}pasteHTML(e,n){return B0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return B0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return VP(this,e)}destroy(){this.docView&&(W_e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],LT(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Xbe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return X_e(this,e)}domSelectionRange(){let e=this.domSelection();return e?ga&&this.root.nodeType===11&&Jbe(this.dom.ownerDocument)==this.dom&&x1e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}VW.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function V5(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let i in n)i=="class"?e.class+=" "+n[i]:i=="style"?e.style=(e.style?e.style+";":"")+n[i]:!e[i]&&i!="contenteditable"&&i!="nodeName"&&(e[i]=String(n[i]))}),e.translate||(e.translate="no"),[fa.node(0,t.state.doc.content.size,e)]}function $5(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:fa.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function G5(t){return!t.someProp("editable",e=>e(t.state)===!1)}function A1e(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function W5(t){let e=Object.create(null);function n(i){for(let r in i)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=i[r])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function T1e(t,e){let n=0,i=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let r in e)i++;return n!=i}function q5(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Wu={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},B_={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},C1e=typeof navigator<"u"&&/Mac/.test(navigator.platform),N1e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Vr=0;Vr<10;Vr++)Wu[48+Vr]=Wu[96+Vr]=String(Vr);for(var Vr=1;Vr<=24;Vr++)Wu[Vr+111]="F"+Vr;for(var Vr=65;Vr<=90;Vr++)Wu[Vr]=String.fromCharCode(Vr+32),B_[Vr]=String.fromCharCode(Vr);for(var UT in Wu)B_.hasOwnProperty(UT)||(B_[UT]=Wu[UT]);function R1e(t){var e=C1e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||N1e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?B_:Wu)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const P1e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),D1e=typeof navigator<"u"&&/Win/.test(navigator.platform);function O1e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let i,r,a,s;for(let o=0;o<e.length-1;o++){let l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))i=!0;else if(/^(c|ctrl|control)$/i.test(l))r=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))P1e?s=!0:r=!0;else throw new Error("Unrecognized modifier name: "+l)}return i&&(n="Alt-"+n),r&&(n="Ctrl-"+n),s&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function k1e(t){let e=Object.create(null);for(let n in t)e[O1e(n)]=t[n];return e}function jT(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function L1e(t){return new gi({props:{handleKeyDown:$W(t)}})}function $W(t){let e=k1e(t);return function(n,i){let r=R1e(i),a,s=e[jT(r,i)];if(s&&s(n.state,n.dispatch,n))return!0;if(r.length==1&&r!=" "){if(i.shiftKey){let o=e[jT(r,i,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(D1e&&i.ctrlKey&&i.altKey)&&(a=Wu[i.keyCode])&&a!=r){let o=e[jT(a,i)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var I1e=Object.defineProperty,KP=(t,e)=>{for(var n in e)I1e(t,n,{get:e[n],enumerable:!0})};function VS(t){const{state:e,transaction:n}=t;let{selection:i}=n,{doc:r}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return i},get doc(){return r},get tr(){return i=n.selection,r=n.doc,a=n.storedMarks,n}}}var $S=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:i}=e,{tr:r}=n,a=this.buildProps(r);return Object.fromEntries(Object.entries(t).map(([s,o])=>[s,(...c)=>{const d=o(...c)(a);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:i,state:r}=this,{view:a}=i,s=[],o=!!t,l=t||r.tr,c=()=>(!o&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(l),s.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(..._)=>{const b=this.buildProps(l,e),v=p(..._)(b);return s.push(v),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,i=!1,r=t||n.tr,a=this.buildProps(r,i);return{...Object.fromEntries(Object.entries(e).map(([o,l])=>[o,(...c)=>l(...c)({...a,dispatch:void 0})])),chain:()=>this.createChain(r,i)}}buildProps(t,e=!0){const{rawCommands:n,editor:i,state:r}=this,{view:a}=i,s={tr:t,editor:i,view:a,state:VS({state:r,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,l])=>[o,(...c)=>l(...c)(s)]))}};return s}},GW={};KP(GW,{blur:()=>U1e,clearContent:()=>j1e,clearNodes:()=>F1e,command:()=>z1e,createParagraphNear:()=>B1e,cut:()=>H1e,deleteCurrentNode:()=>V1e,deleteNode:()=>$1e,deleteRange:()=>G1e,deleteSelection:()=>W1e,enter:()=>q1e,exitCode:()=>X1e,extendMarkRange:()=>K1e,first:()=>Y1e,focus:()=>Q1e,forEach:()=>J1e,insertContent:()=>eSe,insertContentAt:()=>iSe,joinBackward:()=>sSe,joinDown:()=>aSe,joinForward:()=>oSe,joinItemBackward:()=>lSe,joinItemForward:()=>cSe,joinTextblockBackward:()=>uSe,joinTextblockForward:()=>dSe,joinUp:()=>rSe,keyboardShortcut:()=>hSe,lift:()=>pSe,liftEmptyBlock:()=>mSe,liftListItem:()=>gSe,newlineInCode:()=>xSe,resetAttributes:()=>vSe,scrollIntoView:()=>ySe,selectAll:()=>bSe,selectNodeBackward:()=>_Se,selectNodeForward:()=>SSe,selectParentNode:()=>wSe,selectTextblockEnd:()=>MSe,selectTextblockStart:()=>ESe,setContent:()=>ASe,setMark:()=>$Se,setMeta:()=>GSe,setNode:()=>WSe,setNodeSelection:()=>qSe,setTextDirection:()=>XSe,setTextSelection:()=>KSe,sinkListItem:()=>YSe,splitBlock:()=>ZSe,splitListItem:()=>QSe,toggleList:()=>JSe,toggleMark:()=>ewe,toggleNode:()=>twe,toggleWrap:()=>nwe,undoInputRule:()=>iwe,unsetAllMarks:()=>rwe,unsetMark:()=>awe,unsetTextDirection:()=>swe,updateAttributes:()=>owe,wrapIn:()=>lwe,wrapInList:()=>cwe});var U1e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),j1e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),F1e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:i}=e,{ranges:r}=i;return n&&r.forEach(({$from:a,$to:s})=>{t.doc.nodesBetween(a.pos,s.pos,(o,l)=>{if(o.type.isText)return;const{doc:c,mapping:d}=e,f=c.resolve(d.map(l)),p=c.resolve(d.map(l+o.nodeSize)),m=f.blockRange(p);if(!m)return;const _=um(m);if(o.type.isTextblock){const{defaultType:b}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,b)}(_||_===0)&&e.lift(m,_)})}),!0},z1e=t=>e=>t(e),B1e=()=>({state:t,dispatch:e})=>sW(t,e),H1e=(t,e)=>({editor:n,tr:i})=>{const{state:r}=n,a=r.doc.slice(t.from,t.to);i.deleteRange(t.from,t.to);const s=i.mapping.map(e);return i.insert(s,a.content),i.setSelection(new Ht(i.doc.resolve(Math.max(s-1,0)))),!0},V1e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,i=n.$anchor.node();if(i.content.size>0)return!1;const r=t.selection.$anchor;for(let a=r.depth;a>0;a-=1)if(r.node(a).type===i.type){if(e){const o=r.before(a),l=r.after(a);t.delete(o,l).scrollIntoView()}return!0}return!1};function qi(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var $1e=t=>({tr:e,state:n,dispatch:i})=>{const r=qi(t,n.schema),a=e.selection.$anchor;for(let s=a.depth;s>0;s-=1)if(a.node(s).type===r){if(i){const l=a.before(s),c=a.after(s);e.delete(l,c).scrollIntoView()}return!0}return!1},G1e=t=>({tr:e,dispatch:n})=>{const{from:i,to:r}=t;return n&&e.delete(i,r),!0},W1e=()=>({state:t,dispatch:e})=>LP(t,e),q1e=()=>({commands:t})=>t.keyboardShortcut("Enter"),X1e=()=>({state:t,dispatch:e})=>Obe(t,e);function YP(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function H_(t,e,n={strict:!0}){const i=Object.keys(e);return i.length?i.every(r=>n.strict?e[r]===t[r]:YP(e[r])?e[r].test(t[r]):e[r]===t[r]):!0}function WW(t,e,n={}){return t.find(i=>i.type===e&&H_(Object.fromEntries(Object.keys(n).map(r=>[r,i.attrs[r]])),n))}function X5(t,e,n={}){return!!WW(t,e,n)}function ZP(t,e,n){var i;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(d=>d.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(d=>d.type===e)||(n=n||((i=r.node.marks[0])==null?void 0:i.attrs),!WW([...r.node.marks],e,n)))return;let s=r.index,o=t.start()+r.offset,l=s+1,c=o+r.node.nodeSize;for(;s>0&&X5([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&X5([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:c}}function vc(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var K1e=(t,e={})=>({tr:n,state:i,dispatch:r})=>{const a=vc(t,i.schema),{doc:s,selection:o}=n,{$from:l,from:c,to:d}=o;if(r){const f=ZP(l,a,e);if(f&&f.from<=c&&f.to>=d){const p=Ht.create(s,f.from,f.to);n.setSelection(p)}}return!0},Y1e=t=>e=>{const n=typeof t=="function"?t(e):t;for(let i=0;i<n.length;i+=1)if(n[i](e))return!0;return!1};function qW(t){return t instanceof Ht}function Yd(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function XW(t,e=null){if(!e)return null;const n=rn.atStart(t),i=rn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return i;const r=n.from,a=i.to;return e==="all"?Ht.create(t,Yd(0,r,a),Yd(t.content.size,r,a)):Ht.create(t,Yd(e,r,a),Yd(e,r,a))}function Z1e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function QP(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var Q1e=(t=null,e={})=>({editor:n,view:i,tr:r,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(QP()||Z1e())&&i.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(i.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(i.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!qW(n.state.selection))return s(),!0;const o=XW(r.doc,t)||n.state.selection,l=n.state.selection.eq(o);return a&&(l||r.setSelection(o),l&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},J1e=(t,e)=>n=>t.every((i,r)=>e(i,{...n,index:r})),eSe=(t,e)=>({tr:n,commands:i})=>i.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),KW=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const i=e[n];i.nodeType===3&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?t.removeChild(i):i.nodeType===1&&KW(i)}return t};function pb(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return KW(n)}function V0(t,e,n){if(t instanceof ku||t instanceof dt)return t;n={slice:!0,parseOptions:{},...n};const i=typeof t=="object"&&t!==null,r=typeof t=="string";if(i)try{if(Array.isArray(t)&&t.length>0)return dt.fromArray(t.map(o=>e.nodeFromJSON(o)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),V0("",e,n)}if(r){if(n.errorOnInvalidContent){let s=!1,o="";const l=new O9({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,o=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?i0.fromSchema(l).parseSlice(pb(t),n.parseOptions):i0.fromSchema(l).parse(pb(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=i0.fromSchema(e);return n.slice?a.parseSlice(pb(t),n.parseOptions).content:a.parse(pb(t),n.parseOptions)}return V0("",e,n)}function tSe(t,e,n){const i=t.steps.length-1;if(i<e)return;const r=t.steps[i];if(!(r instanceof wr||r instanceof Er))return;const a=t.mapping.maps[i];let s=0;a.forEach((o,l,c,d)=>{s===0&&(s=d)}),t.setSelection(rn.near(t.doc.resolve(s),n))}var nSe=t=>!("type"in t),iSe=(t,e,n)=>({tr:i,dispatch:r,editor:a})=>{var s;if(r){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const l=v=>{a.emit("contentError",{editor:a,error:v,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{V0(e,a.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(v){l(v)}try{o=V0(e,a.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(v){return l(v),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,m=!0;if((nSe(o)?o:[o]).forEach(v=>{v.check(),p=p?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),d===f&&m){const{parent:v}=i.doc.resolve(d);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(d-=1,f+=1)}let b;if(p){if(Array.isArray(e))b=e.map(v=>v.text||"").join("");else if(e instanceof dt){let v="";e.forEach(x=>{x.text&&(v+=x.text)}),b=v}else typeof e=="object"&&e&&e.text?b=e.text:b=e;i.insertText(b,d,f)}else{b=o;const v=i.doc.resolve(d),x=v.node(),M=v.parentOffset===0,w=x.isText||x.isTextblock,E=x.content.size>0;M&&w&&E&&(d=Math.max(0,d-1)),i.replaceWith(d,f,b)}n.updateSelection&&tSe(i,i.steps.length-1,-1),n.applyInputRules&&i.setMeta("applyInputRules",{from:d,text:b}),n.applyPasteRules&&i.setMeta("applyPasteRules",{from:d,text:b})}return!0},rSe=()=>({state:t,dispatch:e})=>Rbe(t,e),aSe=()=>({state:t,dispatch:e})=>Pbe(t,e),sSe=()=>({state:t,dispatch:e})=>J9(t,e),oSe=()=>({state:t,dispatch:e})=>iW(t,e),lSe=()=>({state:t,dispatch:e,tr:n})=>{try{const i=US(t.doc,t.selection.$from.pos,-1);return i==null?!1:(n.join(i,2),e&&e(n),!0)}catch{return!1}},cSe=()=>({state:t,dispatch:e,tr:n})=>{try{const i=US(t.doc,t.selection.$from.pos,1);return i==null?!1:(n.join(i,2),e&&e(n),!0)}catch{return!1}},uSe=()=>({state:t,dispatch:e})=>Cbe(t,e),dSe=()=>({state:t,dispatch:e})=>Nbe(t,e);function YW(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function fSe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let i,r,a,s;for(let o=0;o<e.length-1;o+=1){const l=e[o];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))i=!0;else if(/^(c|ctrl|control)$/i.test(l))r=!0;else if(/^s(hift)?$/i.test(l))a=!0;else if(/^mod$/i.test(l))QP()||YW()?s=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return i&&(n=`Alt-${n}`),r&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var hSe=t=>({editor:e,view:n,tr:i,dispatch:r})=>{const a=fSe(t).split(/-(?!$)/),s=a.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),o=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,o))});return l?.steps.forEach(c=>{const d=c.map(i.mapping);d&&r&&i.maybeStep(d)}),!0};function qu(t,e,n={}){const{from:i,to:r,empty:a}=t.selection,s=e?qi(e,t.schema):null,o=[];t.doc.nodesBetween(i,r,(f,p)=>{if(f.isText)return;const m=Math.max(i,p),_=Math.min(r,p+f.nodeSize);o.push({node:f,from:m,to:_})});const l=r-i,c=o.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>H_(f.node.attrs,n,{strict:!1}));return a?!!c.length:c.reduce((f,p)=>f+p.to-p.from,0)>=l}var pSe=(t,e={})=>({state:n,dispatch:i})=>{const r=qi(t,n.schema);return qu(n,r,e)?Dbe(n,i):!1},mSe=()=>({state:t,dispatch:e})=>oW(t,e),gSe=t=>({state:e,dispatch:n})=>{const i=qi(t,e.schema);return $be(i)(e,n)},xSe=()=>({state:t,dispatch:e})=>aW(t,e);function GS(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function K5(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((i,r)=>(n.includes(r)||(i[r]=t[r]),i),{})}var vSe=(t,e)=>({tr:n,state:i,dispatch:r})=>{let a=null,s=null;const o=GS(typeof t=="string"?t:t.name,i.schema);if(!o)return!1;o==="node"&&(a=qi(t,i.schema)),o==="mark"&&(s=vc(t,i.schema));let l=!1;return n.selection.ranges.forEach(c=>{i.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,f)=>{a&&a===d.type&&(l=!0,r&&n.setNodeMarkup(f,void 0,K5(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(p=>{s===p.type&&(l=!0,r&&n.addMark(f,f+d.nodeSize,s.create(K5(p.attrs,e))))})})}),l},ySe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),bSe=()=>({tr:t,dispatch:e})=>{if(e){const n=new ls(t.doc);t.setSelection(n)}return!0},_Se=()=>({state:t,dispatch:e})=>tW(t,e),SSe=()=>({state:t,dispatch:e})=>rW(t,e),wSe=()=>({state:t,dispatch:e})=>Ibe(t,e),MSe=()=>({state:t,dispatch:e})=>Fbe(t,e),ESe=()=>({state:t,dispatch:e})=>jbe(t,e);function v3(t,e,n={},i={}){return V0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:i.errorOnInvalidContent})}var ASe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:i={}}={})=>({editor:r,tr:a,dispatch:s,commands:o})=>{const{doc:l}=a;if(i.preserveWhitespace!=="full"){const c=v3(t,r.schema,i,{errorOnInvalidContent:e??r.options.enableContentCheck});return s&&a.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return s&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:l.content.size},t,{parseOptions:i,errorOnInvalidContent:e??r.options.enableContentCheck})};function ZW(t,e){const n=vc(e,t.schema),{from:i,to:r,empty:a}=t.selection,s=[];a?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(i,r,l=>{s.push(...l.marks)});const o=s.find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function QW(t,e){const n=new K9(t);return e.forEach(i=>{i.steps.forEach(r=>{n.step(r)})}),n}function TSe(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function CSe(t,e,n){const i=[];return t.nodesBetween(e.from,e.to,(r,a)=>{n(r)&&i.push({node:r,pos:a})}),i}function NSe(t,e){for(let n=t.depth;n>0;n-=1){const i=t.node(n);if(e(i))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:i}}}function WS(t){return e=>NSe(e.$from,t)}function It(t,e,n){return t.config[e]===void 0&&t.parent?It(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?It(t.parent,e,n):null}):t.config[e]}function JP(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},i=It(e,"addExtensions",n);return i?[e,...JP(i())]:e}).flat(10)}function eD(t,e){const n=Ff.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function JW(t){return typeof t=="function"}function On(t,e=void 0,...n){return JW(t)?e?t.bind(e)(...n):t(...n):t}function RSe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Vp(t){const e=t.filter(r=>r.type==="extension"),n=t.filter(r=>r.type==="node"),i=t.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:i}}function e7(t){const e=[],{nodeExtensions:n,markExtensions:i}=Vp(t),r=[...n,...i],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage,extensions:r},l=It(s,"addGlobalAttributes",o);if(!l)return;l().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:f,name:p,attribute:{...a,...m}})})})})}),r.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},l=It(s,"addAttributes",o);if(!l)return;const c=l();Object.entries(c).forEach(([d,f])=>{const p={...a,...f};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:s.name,name:d,attribute:p})})}),e}function Mi(...t){return t.filter(e=>!!e).reduce((e,n)=>{const i={...e};return Object.entries(n).forEach(([r,a])=>{if(!i[r]){i[r]=a;return}if(r==="class"){const o=a?String(a).split(" "):[],l=i[r]?i[r].split(" "):[],c=o.filter(d=>!l.includes(d));i[r]=[...l,...c].join(" ")}else if(r==="style"){const o=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],l=i[r]?i[r].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;l.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());c.set(f,p)}),o.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());c.set(f,p)}),i[r]=Array.from(c.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else i[r]=a}),i},{})}function V_(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,i)=>Mi(n,i),{})}function PSe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Y5(t,e){return"style"in t?t:{...t,getAttrs:n=>{const i=t.getAttrs?t.getAttrs(n):t.attrs;if(i===!1)return!1;const r=e.reduce((a,s)=>{const o=s.attribute.parseHTML?s.attribute.parseHTML(n):PSe(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...i,...r}}}}function Z5(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&RSe(n)?!1:n!=null))}function Q5(t){var e,n;const i={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(i.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(i.validate=t.attribute.validate),[t.name,i]}function DSe(t,e){var n;const i=e7(t),{nodeExtensions:r,markExtensions:a}=Vp(t),s=(n=r.find(c=>It(c,"topNode")))==null?void 0:n.name,o=Object.fromEntries(r.map(c=>{const d=i.filter(x=>x.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},p=t.reduce((x,M)=>{const w=It(M,"extendNodeSchema",f);return{...x,...w?w(c):{}}},{}),m=Z5({...p,content:On(It(c,"content",f)),marks:On(It(c,"marks",f)),group:On(It(c,"group",f)),inline:On(It(c,"inline",f)),atom:On(It(c,"atom",f)),selectable:On(It(c,"selectable",f)),draggable:On(It(c,"draggable",f)),code:On(It(c,"code",f)),whitespace:On(It(c,"whitespace",f)),linebreakReplacement:On(It(c,"linebreakReplacement",f)),defining:On(It(c,"defining",f)),isolating:On(It(c,"isolating",f)),attrs:Object.fromEntries(d.map(Q5))}),_=On(It(c,"parseHTML",f));_&&(m.parseDOM=_.map(x=>Y5(x,d)));const b=It(c,"renderHTML",f);b&&(m.toDOM=x=>b({node:x,HTMLAttributes:V_(x,d)}));const v=It(c,"renderText",f);return v&&(m.toText=v),[c.name,m]})),l=Object.fromEntries(a.map(c=>{const d=i.filter(v=>v.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},p=t.reduce((v,x)=>{const M=It(x,"extendMarkSchema",f);return{...v,...M?M(c):{}}},{}),m=Z5({...p,inclusive:On(It(c,"inclusive",f)),excludes:On(It(c,"excludes",f)),group:On(It(c,"group",f)),spanning:On(It(c,"spanning",f)),code:On(It(c,"code",f)),attrs:Object.fromEntries(d.map(Q5))}),_=On(It(c,"parseHTML",f));_&&(m.parseDOM=_.map(v=>Y5(v,d)));const b=It(c,"renderHTML",f);return b&&(m.toDOM=v=>b({mark:v,HTMLAttributes:V_(v,d)})),[c.name,m]}));return new O9({topNode:s,nodes:o,marks:l})}function OSe(t){const e=t.filter((n,i)=>t.indexOf(n)!==i);return Array.from(new Set(e))}function tD(t){return t.sort((n,i)=>{const r=It(n,"priority")||100,a=It(i,"priority")||100;return r>a?-1:r<a?1:0})}function t7(t){const e=tD(JP(t)),n=OSe(e.map(i=>i.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),e}function n7(t,e,n){const{from:i,to:r}=e,{blockSeparator:a=`
- `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(i,r,(l,c,d,f)=>{var p;l.isBlock&&c>i&&(o+=a);const m=s?.[l.type.name];if(m)return d&&(o+=m({node:l,pos:c,parent:d,index:f,range:e})),!1;l.isText&&(o+=(p=l?.text)==null?void 0:p.slice(Math.max(i,c)-c,r-c))}),o}function kSe(t,e){const n={from:0,to:t.content.size};return n7(t,n,e)}function i7(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function LSe(t,e){const n=qi(e,t.schema),{from:i,to:r}=t.selection,a=[];t.doc.nodesBetween(i,r,o=>{a.push(o)});const s=a.reverse().find(o=>o.type.name===n.name);return s?{...s.attrs}:{}}function r7(t,e){const n=GS(typeof e=="string"?e:e.name,t.schema);return n==="node"?LSe(t,e):n==="mark"?ZW(t,e):{}}function ISe(t,e=JSON.stringify){const n={};return t.filter(i=>{const r=e(i);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function USe(t){const e=ISe(t);return e.length===1?e:e.filter((n,i)=>!e.filter((a,s)=>s!==i).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function a7(t){const{mapping:e,steps:n}=t,i=[];return e.maps.forEach((r,a)=>{const s=[];if(r.ranges.length)r.forEach((o,l)=>{s.push({from:o,to:l})});else{const{from:o,to:l}=n[a];if(o===void 0||l===void 0)return;s.push({from:o,to:l})}s.forEach(({from:o,to:l})=>{const c=e.slice(a).map(o,-1),d=e.slice(a).map(l),f=e.invert().map(c,-1),p=e.invert().map(d);i.push({oldRange:{from:f,to:p},newRange:{from:c,to:d}})})}),USe(i)}function nD(t,e,n){const i=[];return t===e?n.resolve(t).marks().forEach(r=>{const a=n.resolve(t),s=ZP(a,r.type);s&&i.push({mark:r,...s})}):n.nodesBetween(t,e,(r,a)=>{!r||r?.nodeSize===void 0||i.push(...r.marks.map(s=>({from:a,to:a+r.nodeSize,mark:s})))}),i}var jSe=(t,e,n,i=20)=>{const r=t.doc.resolve(n);let a=i,s=null;for(;a>0&&s===null;){const o=r.node(a);o?.type.name===e?s=o:a-=1}return[s,a]};function FT(t,e){return e.nodes[t]||e.marks[t]||null}function n_(t,e,n){return Object.fromEntries(Object.entries(n).filter(([i])=>{const r=t.find(a=>a.type===e&&a.name===i);return r?r.attribute.keepOnSplit:!1}))}var FSe=(t,e=500)=>{let n="";const i=t.parentOffset;return t.parent.nodesBetween(Math.max(0,i-e),i,(r,a,s,o)=>{var l,c;const d=((c=(l=r.type.spec).toText)==null?void 0:c.call(l,{node:r,pos:a,parent:s,index:o}))||r.textContent||"%leaf%";n+=r.isAtom&&!r.isText?d:d.slice(0,Math.max(0,i-a))}),n};function y3(t,e,n={}){const{empty:i,ranges:r}=t.selection,a=e?vc(e,t.schema):null;if(i)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>H_(f.attrs,n,{strict:!1}));let s=0;const o=[];if(r.forEach(({$from:f,$to:p})=>{const m=f.pos,_=p.pos;t.doc.nodesBetween(m,_,(b,v)=>{if(!b.isText&&!b.marks.length)return;const x=Math.max(m,v),M=Math.min(_,v+b.nodeSize),w=M-x;s+=w,o.push(...b.marks.map(E=>({mark:E,from:x,to:M})))})}),s===0)return!1;const l=o.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>H_(f.mark.attrs,n,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),c=o.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,p)=>f+p.to-p.from,0);return(l>0?l+c:l)>=s}function zSe(t,e,n={}){if(!e)return qu(t,null,n)||y3(t,null,n);const i=GS(e,t.schema);return i==="node"?qu(t,e,n):i==="mark"?y3(t,e,n):!1}var BSe=(t,e)=>{const{$from:n,$to:i,$anchor:r}=t.selection;if(e){const a=WS(o=>o.type.name===e)(t.selection);if(!a)return!1;const s=t.doc.resolve(a.pos+1);return r.pos+1===s.end()}return!(i.parentOffset<i.parent.nodeSize-2||n.pos!==i.pos)},HSe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function J5(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function eB(t,e){const{nodeExtensions:n}=Vp(e),i=n.find(s=>s.name===t);if(!i)return!1;const r={name:i.name,options:i.options,storage:i.storage},a=On(It(i,"group",r));return typeof a!="string"?!1:a.split(" ").includes("list")}function qS(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var i;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((i=t.text)!=null?i:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let r=!0;return t.content.forEach(a=>{r!==!1&&(qS(a,{ignoreWhitespace:n,checkChildren:e})||(r=!1))}),r}return!1}function s7(t){return t instanceof jt}function VSe(t,e,n){var i;const{selection:r}=e;let a=null;if(qW(r)&&(a=r.$cursor),a){const o=(i=t.storedMarks)!=null?i:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(c=>c.type.excludes(n)))}const{ranges:s}=r;return s.some(({$from:o,$to:l})=>{let c=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,l.pos,(d,f,p)=>{if(c)return!1;if(d.isInline){const m=!p||p.type.allowsMarkType(n),_=!!n.isInSet(d.marks)||!d.marks.some(b=>b.type.excludes(n));c=m&&_}return!c}),c})}var $Se=(t,e={})=>({tr:n,state:i,dispatch:r})=>{const{selection:a}=n,{empty:s,ranges:o}=a,l=vc(t,i.schema);if(r)if(s){const c=ZW(i,l);n.addStoredMark(l.create({...c,...e}))}else o.forEach(c=>{const d=c.$from.pos,f=c.$to.pos;i.doc.nodesBetween(d,f,(p,m)=>{const _=Math.max(m,d),b=Math.min(m+p.nodeSize,f);p.marks.find(x=>x.type===l)?p.marks.forEach(x=>{l===x.type&&n.addMark(_,b,l.create({...x.attrs,...e}))}):n.addMark(_,b,l.create(e))})});return VSe(i,n,l)},GSe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),WSe=(t,e={})=>({state:n,dispatch:i,chain:r})=>{const a=qi(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),a.isTextblock?r().command(({commands:o})=>p5(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>p5(a,{...s,...e})(o,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},qSe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:i}=e,r=Yd(t,0,i.content.size),a=jt.create(i,r);e.setSelection(a)}return!0},XSe=(t,e)=>({tr:n,state:i,dispatch:r})=>{const{selection:a}=i;let s,o;return typeof e=="number"?(s=e,o=e):e&&"from"in e&&"to"in e?(s=e.from,o=e.to):(s=a.from,o=a.to),r&&n.doc.nodesBetween(s,o,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},KSe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:i}=e,{from:r,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Ht.atStart(i).from,o=Ht.atEnd(i).to,l=Yd(r,s,o),c=Yd(a,s,o),d=Ht.create(i,l,c);e.setSelection(d)}return!0},YSe=t=>({state:e,dispatch:n})=>{const i=qi(t,e.schema);return qbe(i)(e,n)};function tB(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const i=n.filter(r=>e?.includes(r.type.name));t.tr.ensureMarks(i)}}var ZSe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:i,editor:r})=>{const{selection:a,doc:s}=e,{$from:o,$to:l}=a,c=r.extensionManager.attributes,d=n_(c,o.node().type.name,o.node().attrs);if(a instanceof jt&&a.node.isBlock)return!o.parentOffset||!tc(s,o.pos)?!1:(i&&(t&&tB(n,r.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,p=o.depth===0?void 0:TSe(o.node(-1).contentMatchAt(o.indexAfter(-1)));let m=f&&p?[{type:p,attrs:d}]:void 0,_=tc(e.doc,e.mapping.map(o.pos),1,m);if(!m&&!_&&tc(e.doc,e.mapping.map(o.pos),1,p?[{type:p}]:void 0)&&(_=!0,m=p?[{type:p,attrs:d}]:void 0),i){if(_&&(a instanceof Ht&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,m),p&&!f&&!o.parentOffset&&o.parent.type!==p)){const b=e.mapping.map(o.before()),v=e.doc.resolve(b);o.node(-1).canReplaceWith(v.index(),v.index()+1,p)&&e.setNodeMarkup(e.mapping.map(o.before()),p)}t&&tB(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return _},QSe=(t,e={})=>({tr:n,state:i,dispatch:r,editor:a})=>{var s;const o=qi(t,i.schema),{$from:l,$to:c}=i.selection,d=i.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const f=l.node(-1);if(f.type!==o)return!1;const p=a.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let x=dt.empty;const M=l.index(-1)?1:l.index(-2)?2:3;for(let U=l.depth-M;U>=l.depth-3;U-=1)x=dt.from(l.node(U).copy(x));const w=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,E={...n_(p,l.node().type.name,l.node().attrs),...e},T=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(E))||void 0;x=x.append(dt.from(o.createAndFill(null,T)||void 0));const P=l.before(l.depth-(M-1));n.replace(P,l.after(-w),new Mt(x,4-M,0));let N=-1;n.doc.nodesBetween(P,n.doc.content.size,(U,R)=>{if(N>-1)return!1;U.isTextblock&&U.content.size===0&&(N=R+1)}),N>-1&&n.setSelection(Ht.near(n.doc.resolve(N))),n.scrollIntoView()}return!0}const m=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,_={...n_(p,f.type.name,f.attrs),...e},b={...n_(p,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const v=m?[{type:o,attrs:_},{type:m,attrs:b}]:[{type:o,attrs:_}];if(!tc(n.doc,l.pos,2))return!1;if(r){const{selection:x,storedMarks:M}=i,{splittableMarks:w}=a.extensionManager,E=M||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,v).scrollIntoView(),!E||!r)return!0;const T=E.filter(P=>w.includes(P.type.name));n.ensureMarks(T)}return!0},zT=(t,e)=>{const n=WS(s=>s.type===e)(t.selection);if(!n)return!0;const i=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(i===void 0)return!0;const r=t.doc.nodeAt(i);return n.node.type===r?.type&&nd(t.doc,n.pos)&&t.join(n.pos),!0},BT=(t,e)=>{const n=WS(s=>s.type===e)(t.selection);if(!n)return!0;const i=t.doc.resolve(n.start).after(n.depth);if(i===void 0)return!0;const r=t.doc.nodeAt(i);return n.node.type===r?.type&&nd(t.doc,i)&&t.join(i),!0},JSe=(t,e,n,i={})=>({editor:r,tr:a,state:s,dispatch:o,chain:l,commands:c,can:d})=>{const{extensions:f,splittableMarks:p}=r.extensionManager,m=qi(t,s.schema),_=qi(e,s.schema),{selection:b,storedMarks:v}=s,{$from:x,$to:M}=b,w=x.blockRange(M),E=v||b.$to.parentOffset&&b.$from.marks();if(!w)return!1;const T=WS(P=>eB(P.type.name,f))(b);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===m)return c.liftListItem(_);if(eB(T.node.type.name,f)&&m.validContent(T.node.content)&&o)return l().command(()=>(a.setNodeMarkup(T.pos,m),!0)).command(()=>zT(a,m)).command(()=>BT(a,m)).run()}return!n||!E||!o?l().command(()=>d().wrapInList(m,i)?!0:c.clearNodes()).wrapInList(m,i).command(()=>zT(a,m)).command(()=>BT(a,m)).run():l().command(()=>{const P=d().wrapInList(m,i),N=E.filter(U=>p.includes(U.type.name));return a.ensureMarks(N),P?!0:c.clearNodes()}).wrapInList(m,i).command(()=>zT(a,m)).command(()=>BT(a,m)).run()},ewe=(t,e={},n={})=>({state:i,commands:r})=>{const{extendEmptyMarkRange:a=!1}=n,s=vc(t,i.schema);return y3(i,s,e)?r.unsetMark(s,{extendEmptyMarkRange:a}):r.setMark(s,e)},twe=(t,e,n={})=>({state:i,commands:r})=>{const a=qi(t,i.schema),s=qi(e,i.schema),o=qu(i,a,n);let l;return i.selection.$anchor.sameParent(i.selection.$head)&&(l=i.selection.$anchor.parent.attrs),o?r.setNode(s,l):r.setNode(a,{...l,...n})},nwe=(t,e={})=>({state:n,commands:i})=>{const r=qi(t,n.schema);return qu(n,r,e)?i.lift(r):i.wrapIn(r,e)},iwe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let i=0;i<n.length;i+=1){const r=n[i];let a;if(r.spec.isInputRules&&(a=r.getState(t))){if(e){const s=t.tr,o=a.transform;for(let l=o.steps.length-1;l>=0;l-=1)s.step(o.steps[l].invert(o.docs[l]));if(a.text){const l=s.doc.resolve(a.from).marks();s.replaceWith(a.from,a.to,t.schema.text(a.text,l))}else s.delete(a.from,a.to)}return!0}}return!1},rwe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:i,ranges:r}=n;return i||e&&r.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},awe=(t,e={})=>({tr:n,state:i,dispatch:r})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,l=vc(t,i.schema),{$from:c,empty:d,ranges:f}=o;if(!r)return!0;if(d&&s){let{from:p,to:m}=o;const _=(a=c.marks().find(v=>v.type===l))==null?void 0:a.attrs,b=ZP(c,l,_);b&&(p=b.from,m=b.to),n.removeMark(p,m,l)}else f.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},swe=t=>({tr:e,state:n,dispatch:i})=>{const{selection:r}=n;let a,s;return typeof t=="number"?(a=t,s=t):t&&"from"in t&&"to"in t?(a=t.from,s=t.to):(a=r.from,s=r.to),i&&e.doc.nodesBetween(a,s,(o,l)=>{if(o.isText)return;const c={...o.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},owe=(t,e={})=>({tr:n,state:i,dispatch:r})=>{let a=null,s=null;const o=GS(typeof t=="string"?t:t.name,i.schema);if(!o)return!1;o==="node"&&(a=qi(t,i.schema)),o==="mark"&&(s=vc(t,i.schema));let l=!1;return n.selection.ranges.forEach(c=>{const d=c.$from.pos,f=c.$to.pos;let p,m,_,b;n.selection.empty?i.doc.nodesBetween(d,f,(v,x)=>{a&&a===v.type&&(l=!0,_=Math.max(x,d),b=Math.min(x+v.nodeSize,f),p=x,m=v)}):i.doc.nodesBetween(d,f,(v,x)=>{x<d&&a&&a===v.type&&(l=!0,_=Math.max(x,d),b=Math.min(x+v.nodeSize,f),p=x,m=v),x>=d&&x<=f&&(a&&a===v.type&&(l=!0,r&&n.setNodeMarkup(x,void 0,{...v.attrs,...e})),s&&v.marks.length&&v.marks.forEach(M=>{if(s===M.type&&(l=!0,r)){const w=Math.max(x,d),E=Math.min(x+v.nodeSize,f);n.addMark(w,E,s.create({...M.attrs,...e}))}}))}),m&&(p!==void 0&&r&&n.setNodeMarkup(p,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(v=>{s===v.type&&r&&n.addMark(_,b,s.create({...v.attrs,...e}))}))}),l},lwe=(t,e={})=>({state:n,dispatch:i})=>{const r=qi(t,n.schema);return zbe(r,e)(n,i)},cwe=(t,e={})=>({state:n,dispatch:i})=>{const r=qi(t,n.schema);return Bbe(r,e)(n,i)},uwe=class{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const i=this.callbacks[e];return i&&i.forEach(r=>r.apply(this,n)),this}off(e,n){const i=this.callbacks[e];return i&&(n?this.callbacks[e]=i.filter(r=>r!==n):delete this.callbacks[e]),this}once(e,n){const i=(...r)=>{this.off(e,i),n.apply(this,r)};return this.on(e,i)}removeAllListeners(){this.callbacks={}}},XS=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},dwe=(t,e)=>{if(YP(e))return e.exec(t);const n=e(t);if(!n)return null;const i=[n.text];return i.index=n.index,i.input=t,i.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(n.replaceWith)),i};function mb(t){var e;const{editor:n,from:i,to:r,text:a,rules:s,plugin:o}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(i);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let d=!1;const f=FSe(c)+a;return s.forEach(p=>{if(d)return;const m=dwe(f,p.find);if(!m)return;const _=l.state.tr,b=VS({state:l.state,transaction:_}),v={from:i-(m[0].length-a.length),to:r},{commands:x,chain:M,can:w}=new $S({editor:n,state:b});p.handler({state:b,range:v,match:m,commands:x,chain:M,can:w})===null||!_.steps.length||(p.undoable&&_.setMeta(o,{transform:_,from:i,to:r,text:a}),l.dispatch(_),d=!0)}),d}function fwe(t){const{editor:e,rules:n}=t,i=new gi({state:{init(){return null},apply(r,a,s){const o=r.getMeta(i);if(o)return o;const l=r.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=eD(dt.from(d),s.schema);const{from:f}=l,p=f+d.length;mb({editor:e,from:f,to:p,text:d,rules:n,plugin:i})}),r.selectionSet||r.docChanged?null:a}},props:{handleTextInput(r,a,s,o){return mb({editor:e,from:a,to:s,text:o,rules:n,plugin:i})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{const{$cursor:a}=r.state.selection;a&&mb({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:i})}),!1)},handleKeyDown(r,a){if(a.key!=="Enter")return!1;const{$cursor:s}=r.state.selection;return s?mb({editor:e,from:s.pos,to:s.pos,text:`
- `,rules:n,plugin:i}):!1}},isInputRules:!0});return i}function hwe(t){return Object.prototype.toString.call(t).slice(8,-1)}function gb(t){return hwe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function o7(t,e){const n={...t};return gb(t)&&gb(e)&&Object.keys(e).forEach(i=>{gb(e[i])&&gb(t[i])?n[i]=o7(t[i],e[i]):n[i]=e[i]}),n}var iD=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...On(It(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...On(It(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>o7(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},rd=class l7 extends iD{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new l7(n)}static handleExit({editor:e,mark:n}){const{tr:i}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const s=r.marks();if(!!!s.find(c=>c?.type.name===n.name))return!1;const l=s.find(c=>c?.type.name===n.name);return l&&i.removeStoredMark(l),i.insertText(" ",r.pos),e.view.dispatch(i),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function pwe(t){return typeof t=="number"}var mwe=class{constructor(t){this.find=t.find,this.handler=t.handler}},gwe=(t,e,n)=>{if(YP(e))return[...t.matchAll(e)];const i=e(t,n);return i?i.map(r=>{const a=[r.text];return a.index=r.index,a.input=t,a.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(r.replaceWith)),a}):[]};function xwe(t){const{editor:e,state:n,from:i,to:r,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:l,chain:c,can:d}=new $S({editor:e,state:n}),f=[];return n.doc.nodesBetween(i,r,(m,_)=>{var b,v,x,M,w;if((v=(b=m.type)==null?void 0:b.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const E=(w=(M=(x=m.content)==null?void 0:x.size)!=null?M:m.nodeSize)!=null?w:0,T=Math.max(i,_),P=Math.min(r,_+E);if(T>=P)return;const N=m.isText?m.text||"":m.textBetween(T-_,P-_,void 0,"");gwe(N,a.find,s).forEach(R=>{if(R.index===void 0)return;const O=T+R.index+1,z=O+R[0].length,I={from:n.tr.mapping.map(O),to:n.tr.mapping.map(z)},G=a.handler({state:n,range:I,match:R,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:o});f.push(G)})}),f.every(m=>m!==null)}var xb=null,vwe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function ywe(t){const{editor:e,rules:n}=t;let i=null,r=!1,a=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const l=({state:d,from:f,to:p,rule:m,pasteEvt:_})=>{const b=d.tr,v=VS({state:d,transaction:b});if(!(!xwe({editor:e,state:v,from:Math.max(f-1,0),to:p.b-1,rule:m,pasteEvent:_,dropEvent:o})||!b.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,b}};return n.map(d=>new gi({view(f){const p=_=>{var b;i=(b=f.dom.parentElement)!=null&&b.contains(_.target)?f.dom.parentElement:null,i&&(xb=e)},m=()=>{xb&&(xb=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(a=i===f.dom.parentElement,o=p,!a){const m=xb;m?.isEditable&&setTimeout(()=>{const _=m.state.selection;_&&m.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(f,p)=>{var m;const _=(m=p.clipboardData)==null?void 0:m.getData("text/html");return s=p,r=!!_?.includes("data-pm-slice"),!1}}},appendTransaction:(f,p,m)=>{const _=f[0],b=_.getMeta("uiEvent")==="paste"&&!r,v=_.getMeta("uiEvent")==="drop"&&!a,x=_.getMeta("applyPasteRules"),M=!!x;if(!b&&!v&&!M)return;if(M){let{text:T}=x;typeof T=="string"?T=T:T=eD(dt.from(T),m.schema);const{from:P}=x,N=P+T.length,U=vwe(T);return l({rule:d,state:m,from:P,to:{b:N},pasteEvt:U})}const w=p.doc.content.findDiffStart(m.doc.content),E=p.doc.content.findDiffEnd(m.doc.content);if(!(!pwe(w)||!E||w===E.b))return l({rule:d,state:m,from:w,to:E,pasteEvt:s})}}))}var KS=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=t7(t),this.schema=DSe(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:FT(e.name,this.schema)},i=It(e,"addCommands",n);return i?{...t,...i()}:t},{})}get plugins(){const{editor:t}=this;return tD([...this.extensions].reverse()).flatMap(i=>{const r={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:t,type:FT(i.name,this.schema)},a=[],s=It(i,"addKeyboardShortcuts",r);let o={};if(i.type==="mark"&&It(i,"exitable",r)&&(o.ArrowRight=()=>rd.handleExit({editor:t,mark:i})),s){const p=Object.fromEntries(Object.entries(s()).map(([m,_])=>[m,()=>_({editor:t})]));o={...o,...p}}const l=L1e(o);a.push(l);const c=It(i,"addInputRules",r);if(J5(i,t.options.enableInputRules)&&c){const p=c();if(p&&p.length){const m=fwe({editor:t,rules:p}),_=Array.isArray(m)?m:[m];a.push(..._)}}const d=It(i,"addPasteRules",r);if(J5(i,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const m=ywe({editor:t,rules:p});a.push(...m)}}const f=It(i,"addProseMirrorPlugins",r);if(f){const p=f();a.push(...p)}return a})}get attributes(){return e7(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Vp(this.extensions);return Object.fromEntries(e.filter(n=>!!It(n,"addNodeView")).map(n=>{const i=this.attributes.filter(l=>l.type===n.name),r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:qi(n.name,this.schema)},a=It(n,"addNodeView",r);if(!a)return[];const s=a();if(!s)return[];const o=(l,c,d,f,p)=>{const m=V_(l,i);return s({node:l,view:c,getPos:d,decorations:f,innerDecorations:p,editor:t,extension:n,HTMLAttributes:m})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Vp(this.extensions);return Object.fromEntries(e.filter(n=>!!It(n,"addMarkView")).map(n=>{const i=this.attributes.filter(o=>o.type===n.name),r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:vc(n.name,this.schema)},a=It(n,"addMarkView",r);if(!a)return[];const s=(o,l,c)=>{const d=V_(o,i);return a()({mark:o,view:l,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{kwe(o,t,f)}})};return[n.name,s]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:FT(e.name,this.schema)};e.type==="mark"&&((n=On(It(e,"keepOnSplit",i)))==null||n)&&this.splittableMarks.push(e.name);const r=It(e,"onBeforeCreate",i),a=It(e,"onCreate",i),s=It(e,"onUpdate",i),o=It(e,"onSelectionUpdate",i),l=It(e,"onTransaction",i),c=It(e,"onFocus",i),d=It(e,"onBlur",i),f=It(e,"onDestroy",i);r&&this.editor.on("beforeCreate",r),a&&this.editor.on("create",a),s&&this.editor.on("update",s),o&&this.editor.on("selectionUpdate",o),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};KS.resolve=t7;KS.sort=tD;KS.flatten=JP;var bwe={};KP(bwe,{ClipboardTextSerializer:()=>u7,Commands:()=>d7,Delete:()=>f7,Drop:()=>h7,Editable:()=>p7,FocusEvents:()=>g7,Keymap:()=>x7,Paste:()=>v7,Tabindex:()=>y7,TextDirection:()=>b7,focusEventsPluginKey:()=>m7});var $n=class c7 extends iD{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new c7(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},u7=$n.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new gi({key:new or("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:i,selection:r}=e,{ranges:a}=r,s=Math.min(...a.map(d=>d.$from.pos)),o=Math.max(...a.map(d=>d.$to.pos)),l=i7(n);return n7(i,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),d7=$n.create({name:"commands",addCommands(){return{...GW}}}),f7=$n.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,i,r;const a=()=>{var s,o,l,c;if((c=(l=(o=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:o.filterTransaction)==null?void 0:l.call(o,t))!=null?c:t.getMeta("y-sync$"))return;const d=QW(t.before,[t,...e]);a7(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(_,b)=>{const v=b+_.nodeSize-2,x=m.oldRange.from<=b&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:_,from:b,to:v,newFrom:d.mapping.map(b),newTo:d.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((m,_)=>{var b,v;if(m instanceof mo){const x=p.slice(_).map(m.from,-1),M=p.slice(_).map(m.to),w=p.invert().map(x,-1),E=p.invert().map(M),T=(b=d.doc.nodeAt(x-1))==null?void 0:b.marks.some(N=>N.eq(m.mark)),P=(v=d.doc.nodeAt(M))==null?void 0:v.marks.some(N=>N.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:w,to:E},newRange:{from:x,to:M},partial:!!(P||T),editor:this.editor,transaction:t,combinedTransform:d})}})};(r=(i=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:i.async)==null||r?setTimeout(a,0):a()}}),h7=$n.create({name:"drop",addProseMirrorPlugins(){return[new gi({key:new or("tiptapDrop"),props:{handleDrop:(t,e,n,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:i})}}})]}}),p7=$n.create({name:"editable",addProseMirrorPlugins(){return[new gi({key:new or("editable"),props:{editable:()=>this.editor.options.editable}})]}}),m7=new or("focusEvents"),g7=$n.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new gi({key:m7,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const i=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(i),!1},blur:(e,n)=>{t.isFocused=!1;const i=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(i),!1}}}})]}}),x7=$n.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:o})=>{const{selection:l,doc:c}=o,{empty:d,$anchor:f}=l,{pos:p,parent:m}=f,_=f.parent.isTextblock&&p>0?o.doc.resolve(p-1):f,b=_.parent.type.spec.isolating,v=f.pos-f.parentOffset,x=b&&_.parent.childCount===1?v===f.pos:rn.atStart(c).from===p;return!d||!m.type.isTextblock||m.textContent.length||!x||x&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),i={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...i},a={...i,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return QP()||YW()?a:r},addProseMirrorPlugins(){return[new gi({key:new or("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(b=>b.getMeta("composition")))return;const i=t.some(b=>b.docChanged)&&!e.doc.eq(n.doc),r=t.some(b=>b.getMeta("preventClearDocument"));if(!i||r)return;const{empty:a,from:s,to:o}=e.selection,l=rn.atStart(e.doc).from,c=rn.atEnd(e.doc).to;if(a||!(s===l&&o===c)||!qS(n.doc))return;const p=n.tr,m=VS({state:n,transaction:p}),{commands:_}=new $S({editor:this.editor,state:m});if(_.clearNodes(),!!p.steps.length)return p}})]}}),v7=$n.create({name:"paste",addProseMirrorPlugins(){return[new gi({key:new or("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),y7=$n.create({name:"tabindex",addProseMirrorPlugins(){return[new gi({key:new or("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),b7=$n.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Vp(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new gi({key:new or("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),_we=class sp{constructor(e,n,i=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=i,this.resolvedPos=e,this.editor=n,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,i=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,i=this.to-1}this.editor.commands.insertContentAt({from:n,to:i},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new sp(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new sp(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new sp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,i)=>{const r=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,s=this.pos+i+(a?0:1);if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;const o=this.resolvedPos.doc.resolve(s);if(!r&&o.depth<=this.depth)return;const l=new sp(o,this.editor,r,r?n:null);r&&(l.actualDepth=this.depth+1),e.push(new sp(o,this.editor,r,r?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let i=null,r=this.parent;for(;r&&!i;){if(r.node.type.name===e)if(Object.keys(n).length>0){const a=r.node.attrs,s=Object.keys(n);for(let o=0;o<s.length;o+=1){const l=s[o];if(a[l]!==n[l])break}}else i=r;r=r.parent}return i}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},i=!1){let r=[];if(!this.children||this.children.length===0)return r;const a=Object.keys(n);return this.children.forEach(s=>{i&&r.length>0||(s.node.type.name===e&&a.every(l=>n[l]===s.node.attrs[l])&&r.push(s),!(i&&r.length>0)&&(r=r.concat(s.querySelectorAll(e,n,i))))}),r}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Swe=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function wwe(t,e,n){const i=document.querySelector("style[data-tiptap-style]");if(i!==null)return i;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(r),r}var Mwe=class extends uwe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:i})=>{throw i},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:i,slice:r,moved:a})=>this.options.onDrop(i,r,a)),this.on("paste",({event:i,slice:r})=>this.options.onPaste(i,r)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=XW(e,this.options.autofocus);this.editorState=fp.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=wwe(Swe,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=JW(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(r=>{const a=typeof r=="string"?`${r}$`:r.key;n=n.filter(s=>!s.key.startsWith(a))}),e.length===n.length)return;const i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}createExtensionManager(){var t,e;const i=[...this.options.enableCoreExtensions?[p7,u7.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),d7,g7,x7,y7,h7,v7,f7,b7.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r?.type));this.extensionManager=new KS(i,this)}createCommandManager(){this.commandManager=new $S({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=v3(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=v3(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new VW(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),i=!this.state.selection.eq(e.selection),r=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!r)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),i&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),o=s?.getMeta("focus"),l=s?.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:s}),l&&this.emit("blur",{editor:this,event:l.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return r7(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,i=typeof t=="string"?e:t;return zSe(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return eD(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return kSe(this.state.doc,{blockSeparator:e,textSerializers:{...i7(this.schema),...n}})}get isEmpty(){return qS(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new _we(e,this)}get $doc(){return this.$pos(0)}};function $p(t){return new XS({find:t.find,handler:({state:e,range:n,match:i})=>{const r=On(t.getAttributes,void 0,i);if(r===!1||r===null)return null;const{tr:a}=e,s=i[i.length-1],o=i[0];if(s){const l=o.search(/\S/),c=n.from+o.indexOf(s),d=c+s.length;if(nD(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(b=>b===t.type&&b!==m.mark.type)).filter(m=>m.to>c).length)return null;d<n.to&&a.delete(d,n.to),c>n.from&&a.delete(n.from+l,c);const p=n.from+l+s.length;a.addMark(n.from+l,p,t.type.create(r||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function _7(t){return new XS({find:t.find,handler:({state:e,range:n,match:i})=>{const r=On(t.getAttributes,void 0,i)||{},{tr:a}=e,s=n.from;let o=n.to;const l=t.type.create(r);if(i[1]){const c=i[0].lastIndexOf(i[1]);let d=s+c;d>o?d=o:o=d+i[1].length;const f=i[0][i[0].length-1];a.insertText(f,s+i[0].length-1),a.replaceWith(d,o,l)}else if(i[0]){const c=t.type.isInline?s:s-1;a.insert(c,t.type.create(r)).delete(a.mapping.map(s),a.mapping.map(o))}a.scrollIntoView()},undoable:t.undoable})}function b3(t){return new XS({find:t.find,handler:({state:e,range:n,match:i})=>{const r=e.doc.resolve(n.from),a=On(t.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function Gp(t){return new XS({find:t.find,handler:({state:e,range:n,match:i,chain:r})=>{const a=On(t.getAttributes,void 0,i)||{},s=e.tr.delete(n.from,n.to),l=s.doc.resolve(n.from).blockRange(),c=l&&OP(l,t.type,a);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:f,storedMarks:p}=e,{splittableMarks:m}=t.editor.extensionManager,_=p||f.$to.parentOffset&&f.$from.marks();if(_){const b=_.filter(v=>m.includes(v.type.name));s.ensureMarks(b)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";r().updateAttributes(f,a).run()}const d=s.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&nd(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(i,d))&&s.join(n.from-1)},undoable:t.undoable})}var Ewe=t=>"touches"in t,Awe=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.clientX-this.startX,l=s.clientY-this.startY;this.handleResize(o,l)},this.handleTouchMove=s=>{if(!this.isResizing||!this.activeHandle)return;const o=s.touches[0];if(!o)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;const s=this.element.offsetWidth,o=this.element.offsetHeight;this.onCommit(s,o),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=s=>{s.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,i,r,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(i=t?.options)!=null&&i.directions&&(this.directions=t.options.directions),(r=t.options)!=null&&r.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),i=e.includes("bottom"),r=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),i&&(t.style.bottom="0"),r&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,Ewe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:i,height:r}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(i,r,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let i=this.startWidth,r=this.startHeight;const a=t.includes("right"),s=t.includes("left"),o=t.includes("bottom"),l=t.includes("top");return a?i=this.startWidth+e:s&&(i=this.startWidth-e),o?r=this.startHeight+n:l&&(r=this.startHeight-n),(t==="right"||t==="left")&&(i=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(r=this.startHeight+(o?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(i,r,t):{width:i,height:r}}applyConstraints(t,e,n){var i,r,a,s;if(!n){let c=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(i=this.maxSize)!=null&&i.width&&(c=Math.min(this.maxSize.width,c)),(r=this.maxSize)!=null&&r.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let o=t,l=e;return o<this.minSize.width&&(o=this.minSize.width,l=o/this.aspectRatio),l<this.minSize.height&&(l=this.minSize.height,o=l*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&o>this.maxSize.width&&(o=this.maxSize.width,l=o/this.aspectRatio),(s=this.maxSize)!=null&&s.height&&l>this.maxSize.height&&(l=this.maxSize.height,o=l*this.aspectRatio),{width:o,height:l}}applyAspectRatio(t,e,n){const i=n==="left"||n==="right",r=n==="top"||n==="bottom";return i?{width:t,height:t/this.aspectRatio}:r?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function Twe(t,e){const{selection:n}=t,{$from:i}=n;if(n instanceof jt){const a=i.index();return i.parent.canReplaceWith(a,a+1,e)}let r=i.depth;for(;r>=0;){const a=i.index(r);if(i.node(r).contentMatchAt(a).matchType(e))return!0;r-=1}return!1}var Cwe={};KP(Cwe,{createAtomBlockMarkdownSpec:()=>Nwe,createBlockMarkdownSpec:()=>Rwe,createInlineMarkdownSpec:()=>Owe,parseAttributes:()=>rD,parseIndentedBlocks:()=>_3,renderNestedMarkdownContent:()=>sD,serializeAttributes:()=>aD});function rD(t){if(!t?.trim())return{};const e={},n=[],i=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),r=i.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){const c=r.map(d=>d.trim().slice(1));e.class=c.join(" ")}const a=i.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(i.matchAll(s)).forEach(([,c,d])=>{var f;const p=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),m=n[p];m&&(e[c]=m.slice(1,-1))});const l=i.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function aD(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(i=>e.push(`.${i}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,i])=>{n==="class"||n==="id"||(i===!0?e.push(n):i!==!1&&i!=null&&e.push(`${n}="${String(i)}"`))}),e.join(" ")}function Nwe(t){const{nodeName:e,name:n,parseAttributes:i=rD,serializeAttributes:r=aD,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:o}=t,l=n||e,c=d=>{if(!o)return d;const f={};return o.forEach(p=>{p in d&&(f[p]=d[p])}),f};return{parseMarkdown:(d,f)=>{const p={...a,...d.attributes};return f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const p=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(f=d.match(p))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,p){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),_=d.match(m);if(!_)return;const b=_[1]||"",v=i(b);if(!s.find(M=>!(M in v)))return{type:e,raw:_[0],attributes:v}}},renderMarkdown:d=>{const f=c(d.attrs||{}),p=r(f),m=p?` {${p}}`:"";return`:::${l}${m} :::`}}}function Rwe(t){const{nodeName:e,name:n,getContent:i,parseAttributes:r=rD,serializeAttributes:a=aD,defaultAttributes:s={},content:o="block",allowedAttributes:l}=t,c=n||e,d=f=>{if(!l)return f;const p={};return l.forEach(m=>{m in f&&(p[m]=f[m])}),p};return{parseMarkdown:(f,p)=>{let m;if(i){const b=i(f);m=typeof b=="string"?[{type:"text",text:b}]:b}else o==="block"?m=p.parseChildren(f.tokens||[]):m=p.parseInline(f.tokens||[]);const _={...s,...f.attributes};return p.createNode(e,_,m)},markdownTokenizer:{name:e,level:"block",start(f){var p;const m=new RegExp(`^:::${c}`,"m"),_=(p=f.match(m))==null?void 0:p.index;return _!==void 0?_:-1},tokenize(f,p,m){var _;const b=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=f.match(b);if(!v)return;const[x,M=""]=v,w=r(M);let E=1;const T=x.length;let P="";const N=/^:::([\w-]*)(\s.*)?/gm,U=f.slice(T);for(N.lastIndex=0;;){const R=N.exec(U);if(R===null)break;const O=R.index,z=R[1];if(!((_=R[2])!=null&&_.endsWith(":::"))){if(z)E+=1;else if(E-=1,E===0){const I=U.slice(0,O);P=I.trim();const G=f.slice(0,T+O+R[0].length);let L=[];if(P)if(o==="block")for(L=m.blockTokens(I),L.forEach(B=>{B.text&&(!B.tokens||B.tokens.length===0)&&(B.tokens=m.inlineTokens(B.text))});L.length>0;){const B=L[L.length-1];if(B.type==="paragraph"&&(!B.text||B.text.trim()===""))L.pop();else break}else L=m.inlineTokens(P);return{type:e,raw:G,attributes:w,content:P,tokens:L}}}}}},renderMarkdown:(f,p)=>{const m=d(f.attrs||{}),_=a(m),b=_?` {${_}}`:"",v=p.renderChildren(f.content||[],`
- `);return`:::${c}${b}
- ${v}
- :::`}}}function Pwe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let i=n.exec(t);for(;i!==null;){const[,r,a,s]=i;e[r]=a||s,i=n.exec(t)}return e}function Dwe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function Owe(t){const{nodeName:e,name:n,getContent:i,parseAttributes:r=Pwe,serializeAttributes:a=Dwe,defaultAttributes:s={},selfClosing:o=!1,allowedAttributes:l}=t,c=n||e,d=p=>{if(!l)return p;const m={};return l.forEach(_=>{_ in p&&(m[_]=p[_])}),m},f=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,m)=>{const _={...s,...p.attributes};if(o)return m.createNode(e,_);const b=i?i(p):p.content||"";return b?m.createNode(e,_,[m.createTextNode(b)]):m.createNode(e,_,[])},markdownTokenizer:{name:e,level:"inline",start(p){const m=o?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),_=p.match(m),b=_?.index;return b!==void 0?b:-1},tokenize(p,m,_){const b=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),v=p.match(b);if(!v)return;let x="",M="";if(o){const[,E]=v;M=E}else{const[,E,T]=v;M=E,x=T||""}const w=r(M.trim());return{type:e,raw:v[0],content:x.trim(),attributes:w}}},renderMarkdown:p=>{let m="";i?m=i(p):p.content&&p.content.length>0&&(m=p.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const _=d(p.attrs||{}),b=a(_),v=b?` ${b}`:"";return o?`[${c}${v}]`:`[${c}${v}]${m}[/${c}]`}}}function _3(t,e,n){var i,r,a,s;const o=t.split(`
- `),l=[];let c="",d=0;const f=e.baseIndentSize||2;for(;d<o.length;){const p=o[d],m=p.match(e.itemPattern);if(!m){if(l.length>0)break;if(p.trim()===""){d+=1,c=`${c}${p}
- `;continue}else return}const _=e.extractItemData(m),{indentLevel:b,mainContent:v}=_;c=`${c}${p}
- `;const x=[v];for(d+=1;d<o.length;){const T=o[d];if(T.trim()===""){const N=o.slice(d+1).findIndex(O=>O.trim()!=="");if(N===-1)break;if((((r=(i=o[d+1+N].match(/^(\s*)/))==null?void 0:i[1])==null?void 0:r.length)||0)>b){x.push(T),c=`${c}${T}
- `,d+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>b)x.push(T),c=`${c}${T}
- `,d+=1;else break}let M;const w=x.slice(1);if(w.length>0){const T=w.map(P=>P.slice(b+f)).join(`
- `);T.trim()&&(e.customNestedParser?M=e.customNestedParser(T):M=n.blockTokens(T))}const E=e.createToken(_,M);l.push(E)}if(l.length!==0)return{items:l,raw:c}}function sD(t,e,n,i){if(!t||!Array.isArray(t.content))return"";const r=typeof n=="function"?n(i):n,[a,...s]=t.content,o=e.renderChildren([a]),l=[`${r}${o}`];return s&&s.length>0&&s.forEach(c=>{const d=e.renderChildren([c]);if(d){const f=d.split(`
- `).map(p=>p?e.indent(p):"").join(`
- `);l.push(f)}}),l.join(`
- `)}function kwe(t,e,n={}){const{state:i}=e,{doc:r,tr:a}=i,s=t;r.descendants((o,l)=>{const c=a.mapping.map(l),d=a.mapping.map(l)+o.nodeSize;let f=null;if(o.marks.forEach(m=>{if(m!==s)return!1;f=m}),!f)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});a.removeMark(c,d,t.type),a.addMark(c,d,m)}}),a.docChanged&&e.view.dispatch(a)}var ja=class S7 extends iD{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new S7(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Cf(t){return new mwe({find:t.find,handler:({state:e,range:n,match:i,pasteEvent:r})=>{const a=On(t.getAttributes,void 0,i,r);if(a===!1||a===null)return null;const{tr:s}=e,o=i[i.length-1],l=i[0];let c=n.to;if(o){const d=l.search(/\S/),f=n.from+l.indexOf(o),p=f+o.length;if(nD(n.from,n.to,e.doc).filter(_=>_.mark.type.excluded.find(v=>v===t.type&&v!==_.mark.type)).filter(_=>_.to>f).length)return null;p<n.to&&s.delete(p,n.to),f>n.from&&s.delete(n.from+d,f),c=n.from+d+o.length,s.addMark(n.from+d,c,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var HT,nB;function Lwe(){return nB||(nB=1,HT=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var i,r,a;if(Array.isArray(e)){if(i=e.length,i!=n.length)return!1;for(r=i;r--!==0;)if(!t(e[r],n[r]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;for(r of e.entries())if(!t(r[1],n.get(r[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(r of e.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(i=e.length,i!=n.length)return!1;for(r=i;r--!==0;)if(e[r]!==n[r])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),i=a.length,i!==Object.keys(n).length)return!1;for(r=i;r--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[r]))return!1;for(r=i;r--!==0;){var s=a[r];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),HT}var Iwe=Lwe();const Uwe=qs(Iwe);var VT={exports:{}},$T={};var iB;function jwe(){if(iB)return $T;iB=1;var t=tm(),e=g9();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var i=typeof Object.is=="function"?Object.is:n,r=e.useSyncExternalStore,a=t.useRef,s=t.useEffect,o=t.useMemo,l=t.useDebugValue;return $T.useSyncExternalStoreWithSelector=function(c,d,f,p,m){var _=a(null);if(_.current===null){var b={hasValue:!1,value:null};_.current=b}else b=_.current;_=o(function(){function x(P){if(!M){if(M=!0,w=P,P=p(P),m!==void 0&&b.hasValue){var N=b.value;if(m(N,P))return E=N}return E=P}if(N=E,i(w,P))return N;var U=p(P);return m!==void 0&&m(N,U)?(w=P,N):(w=P,E=U)}var M=!1,w,E,T=f===void 0?null:f;return[function(){return x(d())},T===null?void 0:function(){return x(T())}]},[d,f,p,m]);var v=r(c,_[0],_[1]);return s(function(){b.hasValue=!0,b.value=v},[v]),l(v),v},$T}var rB;function Fwe(){return rB||(rB=1,VT.exports=jwe()),VT.exports}var w7=Fwe(),zwe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},Bwe=({contentComponent:t})=>{const e=x9.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return g.jsx(g.Fragment,{children:Object.values(e)})};function Hwe(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,i){e={...e,[n]:gne.createPortal(i.reactElement,i.element,n)},t.forEach(r=>r())},removeRenderer(n){const i={...e};delete i[n],e=i,t.forEach(r=>r())}}}var Vwe=class extends li.Component{constructor(t){var e;super(t),this.editorContentRef=li.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=Hwe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:zwe(e,this.editorContentRef),...n}),t?.contentComponent&&g.jsx(Bwe,{contentComponent:t.contentComponent})]})}},$we=A.forwardRef((t,e)=>{const n=li.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return li.createElement(Vwe,{key:n,innerRef:e,...t})}),Gwe=li.memo($we),Wwe=typeof window<"u"?A.useLayoutEffect:A.useEffect,qwe=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(i=>i())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function Xwe(t){var e;const[n]=A.useState(()=>new qwe(t.editor)),i=w7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:Uwe);return Wwe(()=>n.watch(t.editor),[t.editor,n]),A.useDebugValue(i),i}var Kwe=!1,S3=typeof window>"u",Ywe=S3||!!(typeof window<"u"&&window.next),Zwe=class M7{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?S3||Ywe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...i)=>{var r,a;return(a=(r=this.options.current).onBeforeCreate)==null?void 0:a.call(r,...i)},onBlur:(...i)=>{var r,a;return(a=(r=this.options.current).onBlur)==null?void 0:a.call(r,...i)},onCreate:(...i)=>{var r,a;return(a=(r=this.options.current).onCreate)==null?void 0:a.call(r,...i)},onDestroy:(...i)=>{var r,a;return(a=(r=this.options.current).onDestroy)==null?void 0:a.call(r,...i)},onFocus:(...i)=>{var r,a;return(a=(r=this.options.current).onFocus)==null?void 0:a.call(r,...i)},onSelectionUpdate:(...i)=>{var r,a;return(a=(r=this.options.current).onSelectionUpdate)==null?void 0:a.call(r,...i)},onTransaction:(...i)=>{var r,a;return(a=(r=this.options.current).onTransaction)==null?void 0:a.call(r,...i)},onUpdate:(...i)=>{var r,a;return(a=(r=this.options.current).onUpdate)==null?void 0:a.call(r,...i)},onContentError:(...i)=>{var r,a;return(a=(r=this.options.current).onContentError)==null?void 0:a.call(r,...i)},onDrop:(...i)=>{var r,a;return(a=(r=this.options.current).onDrop)==null?void 0:a.call(r,...i)},onPaste:(...i)=>{var r,a;return(a=(r=this.options.current).onPaste)==null?void 0:a.call(r,...i)},onDelete:(...i)=>{var r,a;return(a=(r=this.options.current).onDelete)==null?void 0:a.call(r,...i)}};return new Mwe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(i=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(i)?!0:i==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((r,a)=>{var s;return r===((s=n.extensions)==null?void 0:s[a])}):e[i]===n[i])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?M7.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((i,r)=>i===e[r]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Qwe(t={},e=[]){const n=A.useRef(t);n.current=t;const[i]=A.useState(()=>new Zwe(n)),r=x9.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return A.useDebugValue(r),A.useEffect(i.onRender(e)),Xwe({editor:r,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),r}var Jwe=A.createContext({editor:null});Jwe.Consumer;var eMe=A.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),tMe=()=>A.useContext(eMe);li.forwardRef((t,e)=>{const{onDragStart:n}=tMe(),i=t.as||"div";return g.jsx(i,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});li.createContext({markViewContentRef:()=>{}});var $_=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...i}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,i,n]},nMe=/^\s*>\s$/,iMe=ja.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return $_("blockquote",{...Mi(this.options.HTMLAttributes,t),children:$_("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",i=[];return t.content.forEach(r=>{const o=e.renderChildren([r]).split(`
- `).map(l=>l.trim()===""?n:`${n} ${l}`);i.push(o.join(`
- `))}),i.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Gp({find:nMe,type:this.type})]}}),rMe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,aMe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,sMe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,oMe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,lMe=rd.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return $_("strong",{...Mi(this.options.HTMLAttributes,t),children:$_("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[$p({find:rMe,type:this.type}),$p({find:sMe,type:this.type})]},addPasteRules(){return[Cf({find:aMe,type:this.type}),Cf({find:oMe,type:this.type})]}}),cMe=/(^|[^`])`([^`]+)`(?!`)$/,uMe=/(^|[^`])`([^`]+)`(?!`)/g,dMe=rd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Mi(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[$p({find:cMe,type:this.type})]},addPasteRules(){return[Cf({find:uMe,type:this.type})]}}),GT=4,fMe=/^```([a-z]+)?[\s\n]$/,hMe=/^~~~([a-z]+)?[\s\n]$/,pMe=ja.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:GT,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(s=>s.startsWith(n)).map(s=>s.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Mi(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let i="";const r=((n=t.attrs)==null?void 0:n.language)||"";return t.content?i=[`\`\`\`${r}`,e.renderChildren(t.content),"```"].join(`
- `):i=`\`\`\`${r}
- \`\`\``,i},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:GT,{state:i}=t,{selection:r}=i,{$from:a,empty:s}=r;if(a.parent.type!==this.type)return!1;const o=" ".repeat(n);return s?t.commands.insertContent(o):t.commands.command(({tr:l})=>{const{from:c,to:d}=r,m=i.doc.textBetween(c,d,`
- `,`
- `).split(`
- `).map(_=>o+_).join(`
- `);return l.replaceWith(c,d,i.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:GT,{state:i}=t,{selection:r}=i,{$from:a,empty:s}=r;return a.parent.type!==this.type?!1:s?t.commands.command(({tr:o})=>{var l;const{pos:c}=a,d=a.start(),f=a.end(),m=i.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let _=0,b=0;const v=c-d;for(let P=0;P<m.length;P+=1){if(b+m[P].length>=v){_=P;break}b+=m[P].length+1}const M=((l=m[_].match(/^ */))==null?void 0:l[0])||"",w=Math.min(M.length,n);if(w===0)return!0;let E=d;for(let P=0;P<_;P+=1)E+=m[P].length+1;return o.delete(E,E+w),c-E<=w&&o.setSelection(Ht.create(o.doc,E)),!0}):t.commands.command(({tr:o})=>{const{from:l,to:c}=r,p=i.doc.textBetween(l,c,`
- `,`
- `).split(`
- `).map(m=>{var _;const b=((_=m.match(/^ */))==null?void 0:_[0])||"",v=Math.min(b.length,n);return m.slice(v)}).join(`
- `);return o.replaceWith(l,c,i.schema.text(p)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:i,empty:r}=n;if(!r||i.parent.type!==this.type)return!1;const a=i.parentOffset===i.parent.nodeSize-2,s=i.parent.textContent.endsWith(`
- `);return!a||!s?!1:t.chain().command(({tr:o})=>(o.delete(i.pos-2,i.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:i}=e,{$from:r,empty:a}=n;if(!a||r.parent.type!==this.type||!(r.parentOffset===r.parent.nodeSize-2))return!1;const o=r.after();return o===void 0?!1:i.nodeAt(o)?t.commands.command(({tr:c})=>(c.setSelection(rn.near(i.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[b3({find:fMe,type:this.type,getAttributes:t=>({language:t[1]})}),b3({find:hMe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new gi({key:new or("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),i=e.clipboardData.getData("vscode-editor-data"),r=i?JSON.parse(i):void 0,a=r?.mode;if(!n||!a)return!1;const{tr:s,schema:o}=t.state,l=o.text(n.replace(/\r\n?/g,`
- `));return s.replaceSelectionWith(this.type.create({language:a},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(Ht.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),mMe=ja.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),gMe=ja.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Mi(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:i})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:r,storedMarks:a}=n;if(r.$from.parent.type.spec.isolating)return!1;const{keepMarks:s}=this.options,{splittableMarks:o}=i.extensionManager,l=a||r.$to.parentOffset&&r.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&s){const f=l.filter(p=>o.includes(p.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),xMe=ja.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Mi(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const i=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,r="#".repeat(i);return t.content?`${r} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>b3({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),vMe=ja.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Mi(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Twe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:i}=n,r=t();return s7(n)?r.insertContentAt(i.pos,{type:this.name}):r.insertContent({type:this.name}),r.command(({state:a,tr:s,dispatch:o})=>{if(o){const{$to:l}=s.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?s.setSelection(Ht.create(s.doc,l.pos+1)):l.nodeAfter.isBlock?s.setSelection(jt.create(s.doc,l.pos)):s.setSelection(Ht.create(s.doc,l.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,f=d?.create();f&&(s.insert(c,f),s.setSelection(Ht.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[_7({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),yMe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,bMe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,_Me=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,SMe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,wMe=rd.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Mi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[$p({find:yMe,type:this.type}),$p({find:_Me,type:this.type})]},addPasteRules(){return[Cf({find:bMe,type:this.type}),Cf({find:SMe,type:this.type})]}});const MMe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",EMe="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",w3="numeric",M3="ascii",E3="alpha",o0="asciinumeric",Xg="alphanumeric",A3="domain",E7="emoji",AMe="scheme",TMe="slashscheme",WT="whitespace";function CMe(t,e){return t in e||(e[t]=[]),e[t]}function Zd(t,e,n){e[w3]&&(e[o0]=!0,e[Xg]=!0),e[M3]&&(e[o0]=!0,e[E3]=!0),e[o0]&&(e[Xg]=!0),e[E3]&&(e[Xg]=!0),e[Xg]&&(e[A3]=!0),e[E7]&&(e[A3]=!0);for(const i in e){const r=CMe(i,n);r.indexOf(t)<0&&r.push(t)}}function NMe(t,e){const n={};for(const i in e)e[i].indexOf(t)>=0&&(n[i]=!0);return n}function Pa(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Pa.groups={};Pa.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let i=0;i<e.jr.length;i++){const r=e.jr[i][0],a=e.jr[i][1];if(a&&r.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,i){for(let r=0;r<t.length;r++)this.tt(t[r],e,n,i)},tr(t,e,n,i){i=i||Pa.groups;let r;return e&&e.j?r=e:(r=new Pa(e),n&&i&&Zd(e,n,i)),this.jr.push([t,r]),r},ts(t,e,n,i){let r=this;const a=t.length;if(!a)return r;for(let s=0;s<a-1;s++)r=r.tt(t[s]);return r.tt(t[a-1],e,n,i)},tt(t,e,n,i){i=i||Pa.groups;const r=this;if(e&&e.j)return r.j[t]=e,e;const a=e;let s,o=r.go(t);if(o?(s=new Pa,Object.assign(s.j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new Pa,a){if(i)if(s.t&&typeof s.t=="string"){const l=Object.assign(NMe(s.t,i),n);Zd(a,l,i)}else n&&Zd(a,n,i);s.t=a}return r.j[t]=s,s}};const Jt=(t,e,n,i,r)=>t.ta(e,n,i,r),_i=(t,e,n,i,r)=>t.tr(e,n,i,r),aB=(t,e,n,i,r)=>t.ts(e,n,i,r),mt=(t,e,n,i,r)=>t.tt(e,n,i,r),Ul="WORD",T3="UWORD",A7="ASCIINUMERICAL",T7="ALPHANUMERICAL",$0="LOCALHOST",C3="TLD",N3="UTLD",i_="SCHEME",op="SLASH_SCHEME",oD="NUM",R3="WS",lD="NL",l0="OPENBRACE",c0="CLOSEBRACE",G_="OPENBRACKET",W_="CLOSEBRACKET",q_="OPENPAREN",X_="CLOSEPAREN",K_="OPENANGLEBRACKET",Y_="CLOSEANGLEBRACKET",Z_="FULLWIDTHLEFTPAREN",Q_="FULLWIDTHRIGHTPAREN",J_="LEFTCORNERBRACKET",e1="RIGHTCORNERBRACKET",t1="LEFTWHITECORNERBRACKET",n1="RIGHTWHITECORNERBRACKET",i1="FULLWIDTHLESSTHAN",r1="FULLWIDTHGREATERTHAN",a1="AMPERSAND",s1="APOSTROPHE",o1="ASTERISK",pu="AT",l1="BACKSLASH",c1="BACKTICK",u1="CARET",_u="COLON",cD="COMMA",d1="DOLLAR",Do="DOT",f1="EQUALS",uD="EXCLAMATION",Ts="HYPHEN",u0="PERCENT",h1="PIPE",p1="PLUS",m1="POUND",d0="QUERY",dD="QUOTE",C7="FULLWIDTHMIDDLEDOT",fD="SEMI",Oo="SLASH",f0="TILDE",g1="UNDERSCORE",N7="EMOJI",x1="SYM";var R7=Object.freeze({__proto__:null,ALPHANUMERICAL:T7,AMPERSAND:a1,APOSTROPHE:s1,ASCIINUMERICAL:A7,ASTERISK:o1,AT:pu,BACKSLASH:l1,BACKTICK:c1,CARET:u1,CLOSEANGLEBRACKET:Y_,CLOSEBRACE:c0,CLOSEBRACKET:W_,CLOSEPAREN:X_,COLON:_u,COMMA:cD,DOLLAR:d1,DOT:Do,EMOJI:N7,EQUALS:f1,EXCLAMATION:uD,FULLWIDTHGREATERTHAN:r1,FULLWIDTHLEFTPAREN:Z_,FULLWIDTHLESSTHAN:i1,FULLWIDTHMIDDLEDOT:C7,FULLWIDTHRIGHTPAREN:Q_,HYPHEN:Ts,LEFTCORNERBRACKET:J_,LEFTWHITECORNERBRACKET:t1,LOCALHOST:$0,NL:lD,NUM:oD,OPENANGLEBRACKET:K_,OPENBRACE:l0,OPENBRACKET:G_,OPENPAREN:q_,PERCENT:u0,PIPE:h1,PLUS:p1,POUND:m1,QUERY:d0,QUOTE:dD,RIGHTCORNERBRACKET:e1,RIGHTWHITECORNERBRACKET:n1,SCHEME:i_,SEMI:fD,SLASH:Oo,SLASH_SCHEME:op,SYM:x1,TILDE:f0,TLD:C3,UNDERSCORE:g1,UTLD:N3,UWORD:T3,WORD:Ul,WS:R3});const Dl=/[a-z]/,Pg=new RegExp("\\p{L}","u"),qT=new RegExp("\\p{Emoji}","u"),Ol=/\d/,XT=/\s/,sB="\r",KT=`
- `,RMe="️",PMe="",YT="";let vb=null,yb=null;function DMe(t=[]){const e={};Pa.groups=e;const n=new Pa;vb==null&&(vb=oB(MMe)),yb==null&&(yb=oB(EMe)),mt(n,"'",s1),mt(n,"{",l0),mt(n,"}",c0),mt(n,"[",G_),mt(n,"]",W_),mt(n,"(",q_),mt(n,")",X_),mt(n,"<",K_),mt(n,">",Y_),mt(n,"(",Z_),mt(n,")",Q_),mt(n,"「",J_),mt(n,"」",e1),mt(n,"『",t1),mt(n,"』",n1),mt(n,"<",i1),mt(n,">",r1),mt(n,"&",a1),mt(n,"*",o1),mt(n,"@",pu),mt(n,"`",c1),mt(n,"^",u1),mt(n,":",_u),mt(n,",",cD),mt(n,"$",d1),mt(n,".",Do),mt(n,"=",f1),mt(n,"!",uD),mt(n,"-",Ts),mt(n,"%",u0),mt(n,"|",h1),mt(n,"+",p1),mt(n,"#",m1),mt(n,"?",d0),mt(n,'"',dD),mt(n,"/",Oo),mt(n,";",fD),mt(n,"~",f0),mt(n,"_",g1),mt(n,"\\",l1),mt(n,"・",C7);const i=_i(n,Ol,oD,{[w3]:!0});_i(i,Ol,i);const r=_i(i,Dl,A7,{[o0]:!0}),a=_i(i,Pg,T7,{[Xg]:!0}),s=_i(n,Dl,Ul,{[M3]:!0});_i(s,Ol,r),_i(s,Dl,s),_i(r,Ol,r),_i(r,Dl,r);const o=_i(n,Pg,T3,{[E3]:!0});_i(o,Dl),_i(o,Ol,a),_i(o,Pg,o),_i(a,Ol,a),_i(a,Dl),_i(a,Pg,a);const l=mt(n,KT,lD,{[WT]:!0}),c=mt(n,sB,R3,{[WT]:!0}),d=_i(n,XT,R3,{[WT]:!0});mt(n,YT,d),mt(c,KT,l),mt(c,YT,d),_i(c,XT,d),mt(d,sB),mt(d,KT),_i(d,XT,d),mt(d,YT,d);const f=_i(n,qT,N7,{[E7]:!0});mt(f,"#"),_i(f,qT,f),mt(f,RMe,f);const p=mt(f,PMe);mt(p,"#"),_i(p,qT,f);const m=[[Dl,s],[Ol,r]],_=[[Dl,null],[Pg,o],[Ol,a]];for(let b=0;b<vb.length;b++)cu(n,vb[b],C3,Ul,m);for(let b=0;b<yb.length;b++)cu(n,yb[b],N3,T3,_);Zd(C3,{tld:!0,ascii:!0},e),Zd(N3,{utld:!0,alpha:!0},e),cu(n,"file",i_,Ul,m),cu(n,"mailto",i_,Ul,m),cu(n,"http",op,Ul,m),cu(n,"https",op,Ul,m),cu(n,"ftp",op,Ul,m),cu(n,"ftps",op,Ul,m),Zd(i_,{scheme:!0,ascii:!0},e),Zd(op,{slashscheme:!0,ascii:!0},e),t=t.sort((b,v)=>b[0]>v[0]?1:-1);for(let b=0;b<t.length;b++){const v=t[b][0],M=t[b][1]?{[AMe]:!0}:{[TMe]:!0};v.indexOf("-")>=0?M[A3]=!0:Dl.test(v)?Ol.test(v)?M[o0]=!0:M[M3]=!0:M[w3]=!0,aB(n,v,v,M)}return aB(n,"localhost",$0,{ascii:!0}),n.jd=new Pa(x1),{start:n,tokens:Object.assign({groups:e},R7)}}function P7(t,e){const n=OMe(e.replace(/[A-Z]/g,o=>o.toLowerCase())),i=n.length,r=[];let a=0,s=0;for(;s<i;){let o=t,l=null,c=0,d=null,f=-1,p=-1;for(;s<i&&(l=o.go(n[s]));)o=l,o.accepts()?(f=0,p=0,d=o):f>=0&&(f+=n[s].length,p++),c+=n[s].length,a+=n[s].length,s++;a-=f,s-=p,c-=f,r.push({t:d.t,v:e.slice(a-c,a),s:a-c,e:a})}return r}function OMe(t){const e=[],n=t.length;let i=0;for(;i<n;){let r=t.charCodeAt(i),a,s=r<55296||r>56319||i+1===n||(a=t.charCodeAt(i+1))<56320||a>57343?t[i]:t.slice(i,i+2);e.push(s),i+=s.length}return e}function cu(t,e,n,i,r){let a;const s=e.length;for(let o=0;o<s-1;o++){const l=e[o];t.j[l]?a=t.j[l]:(a=new Pa(i),a.jr=r.slice(),t.j[l]=a),t=a}return a=new Pa(n),a.jr=r.slice(),t.j[e[s-1]]=a,a}function oB(t){const e=[],n=[];let i=0,r="0123456789";for(;i<t.length;){let a=0;for(;r.indexOf(t[i+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let s=parseInt(t.substring(i,i+a),10);s>0;s--)n.pop();i+=a}else n.push(t[i]),i++}return e}const G0={defaultProtocol:"http",events:null,format:lB,formatHref:lB,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function hD(t,e=null){let n=Object.assign({},G0);t&&(n=Object.assign(n,t instanceof hD?t.o:t));const i=n.ignoreTags,r=[];for(let a=0;a<i.length;a++)r.push(i[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=r}hD.prototype={o:G0,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const i=e!=null;let r=this.o[t];return r&&(typeof r=="object"?(r=n.t in r?r[n.t]:G0[t],typeof r=="function"&&i&&(r=r(e,n))):typeof r=="function"&&i&&(r=r(e,n.t,n)),r)},getObj(t,e,n){let i=this.o[t];return typeof i=="function"&&e!=null&&(i=i(e,n.t,n)),i},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function lB(t){return t}function D7(t,e){this.t="token",this.v=t,this.tk=e}D7.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),i=t.get("format",e,this);return n&&i.length>n?i.substring(0,n)+"…":i},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=G0.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),i=t.get("formatHref",n,this),r=t.get("tagName",n,e),a=this.toFormattedString(t),s={},o=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return s.href=i,o&&(s.class=o),l&&(s.target=l),c&&(s.rel=c),d&&Object.assign(s,d),{tagName:r,attributes:s,content:a,eventListeners:f}}};function YS(t,e){class n extends D7{constructor(r,a){super(r,a),this.t=t}}for(const i in e)n.prototype[i]=e[i];return n.t=t,n}const cB=YS("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),uB=YS("text"),kMe=YS("nl"),bb=YS("url",{isLink:!0,toHref(t=G0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==$0&&t[1].t===_u}}),ws=t=>new Pa(t);function LMe({groups:t}){const e=t.domain.concat([a1,o1,pu,l1,c1,u1,d1,f1,Ts,oD,u0,h1,p1,m1,Oo,x1,f0,g1]),n=[s1,_u,cD,Do,uD,u0,d0,dD,fD,K_,Y_,l0,c0,W_,G_,q_,X_,Z_,Q_,J_,e1,t1,n1,i1,r1],i=[a1,s1,o1,l1,c1,u1,d1,f1,Ts,l0,c0,u0,h1,p1,m1,d0,Oo,x1,f0,g1],r=ws(),a=mt(r,f0);Jt(a,i,a),Jt(a,t.domain,a);const s=ws(),o=ws(),l=ws();Jt(r,t.domain,s),Jt(r,t.scheme,o),Jt(r,t.slashscheme,l),Jt(s,i,a),Jt(s,t.domain,s);const c=mt(s,pu);mt(a,pu,c),mt(o,pu,c),mt(l,pu,c);const d=mt(a,Do);Jt(d,i,a),Jt(d,t.domain,a);const f=ws();Jt(c,t.domain,f),Jt(f,t.domain,f);const p=mt(f,Do);Jt(p,t.domain,f);const m=ws(cB);Jt(p,t.tld,m),Jt(p,t.utld,m),mt(c,$0,m);const _=mt(f,Ts);mt(_,Ts,_),Jt(_,t.domain,f),Jt(m,t.domain,f),mt(m,Do,p),mt(m,Ts,_);const b=mt(m,_u);Jt(b,t.numeric,cB);const v=mt(s,Ts),x=mt(s,Do);mt(v,Ts,v),Jt(v,t.domain,s),Jt(x,i,a),Jt(x,t.domain,s);const M=ws(bb);Jt(x,t.tld,M),Jt(x,t.utld,M),Jt(M,t.domain,s),Jt(M,i,a),mt(M,Do,x),mt(M,Ts,v),mt(M,pu,c);const w=mt(M,_u),E=ws(bb);Jt(w,t.numeric,E);const T=ws(bb),P=ws();Jt(T,e,T),Jt(T,n,P),Jt(P,e,T),Jt(P,n,P),mt(M,Oo,T),mt(E,Oo,T);const N=mt(o,_u),U=mt(l,_u),R=mt(U,Oo),O=mt(R,Oo);Jt(o,t.domain,s),mt(o,Do,x),mt(o,Ts,v),Jt(l,t.domain,s),mt(l,Do,x),mt(l,Ts,v),Jt(N,t.domain,T),mt(N,Oo,T),mt(N,d0,T),Jt(O,t.domain,T),Jt(O,e,T),mt(O,Oo,T);const z=[[l0,c0],[G_,W_],[q_,X_],[K_,Y_],[Z_,Q_],[J_,e1],[t1,n1],[i1,r1]];for(let I=0;I<z.length;I++){const[G,L]=z[I],B=mt(T,G);mt(P,G,B),mt(B,L,T);const q=ws(bb);Jt(B,e,q);const W=ws();Jt(B,n),Jt(q,e,q),Jt(q,n,W),Jt(W,e,q),Jt(W,n,W),mt(q,L,T),mt(W,L,T)}return mt(r,$0,M),mt(r,lD,kMe),{start:r,tokens:R7}}function IMe(t,e,n){let i=n.length,r=0,a=[],s=[];for(;r<i;){let o=t,l=null,c=null,d=0,f=null,p=-1;for(;r<i&&!(l=o.go(n[r].t));)s.push(n[r++]);for(;r<i&&(c=l||o.go(n[r].t));)l=null,o=c,o.accepts()?(p=0,f=o):p>=0&&p++,r++,d++;if(p<0)r-=d,r<i&&(s.push(n[r]),r++);else{s.length>0&&(a.push(ZT(uB,e,s)),s=[]),r-=p,d-=p;const m=f.t,_=n.slice(r-d,r);a.push(ZT(m,e,_))}}return s.length>0&&a.push(ZT(uB,e,s)),a}function ZT(t,e,n){const i=n[0].s,r=n[n.length-1].e,a=e.slice(i,r);return new t(a,n)}const UMe=typeof console<"u"&&console&&console.warn||(()=>{}),jMe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ni={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function FMe(){return Pa.groups={},ni.scanner=null,ni.parser=null,ni.tokenQueue=[],ni.pluginQueue=[],ni.customSchemes=[],ni.initialized=!1,ni}function dB(t,e=!1){if(ni.initialized&&UMe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${jMe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);ni.customSchemes.push([t,e])}function zMe(){ni.scanner=DMe(ni.customSchemes);for(let t=0;t<ni.tokenQueue.length;t++)ni.tokenQueue[t][1]({scanner:ni.scanner});ni.parser=LMe(ni.scanner.tokens);for(let t=0;t<ni.pluginQueue.length;t++)ni.pluginQueue[t][1]({scanner:ni.scanner,parser:ni.parser});return ni.initialized=!0,ni}function pD(t){return ni.initialized||zMe(),IMe(ni.parser.start,t,P7(ni.scanner.start,t))}pD.scan=P7;function O7(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const i=new hD(n),r=pD(t),a=[];for(let s=0;s<r.length;s++){const o=r[s];o.isLink&&(!e||o.t===e)&&i.check(o)&&a.push(o.toFormattedObject(i))}return a}var mD="[\0- -\u2029 ]",BMe=new RegExp(mD),HMe=new RegExp(`${mD}$`),VMe=new RegExp(mD,"g");function $Me(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function GMe(t){return new gi({key:new or("autolink"),appendTransaction:(e,n,i)=>{const r=e.some(c=>c.docChanged)&&!n.doc.eq(i.doc),a=e.some(c=>c.getMeta("preventAutolink"));if(!r||a)return;const{tr:s}=i,o=QW(n.doc,[...e]);if(a7(o).forEach(({newRange:c})=>{const d=CSe(i.doc,c,m=>m.isTextblock);let f,p;if(d.length>1)f=d[0],p=i.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const m=i.doc.textBetween(c.from,c.to," "," ");if(!HMe.test(m))return;f=d[0],p=i.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&p){const m=p.split(BMe).filter(Boolean);if(m.length<=0)return!1;const _=m[m.length-1],b=f.pos+p.lastIndexOf(_);if(!_)return!1;const v=pD(_).map(x=>x.toObject(t.defaultProtocol));if(!$Me(v))return!1;v.filter(x=>x.isLink).map(x=>({...x,from:b+x.start+1,to:b+x.end+1})).filter(x=>i.schema.marks.code?!i.doc.rangeHasMark(x.from,x.to,i.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{nD(x.from,x.to,i.doc).some(M=>M.mark.type===t.type)||s.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!s.steps.length)return s}})}function WMe(t){return new gi({key:new or("handleClickLink"),props:{handleClick:(e,n,i)=>{var r,a;if(i.button!==0||!e.editable)return!1;let s=null;if(i.target instanceof HTMLAnchorElement)s=i.target;else{let d=i.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;s=f.find(p=>p.nodeName==="A")}if(!s)return!1;const o=r7(e.state,t.type.name),l=(r=s?.href)!=null?r:o.href,c=(a=s?.target)!=null?a:o.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),s&&l?(window.open(l,c),!0):!1}}})}function qMe(t){return new gi({key:new or("handlePasteLink"),props:{handlePaste:(e,n,i)=>{const{shouldAutoLink:r}=t,{state:a}=e,{selection:s}=a,{empty:o}=s;if(o)return!1;let l="";i.content.forEach(d=>{l+=d.textContent});const c=O7(l,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!c||r!==void 0&&!r(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Ld(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(i=>{const r=typeof i=="string"?i:i.scheme;r&&n.push(r)}),!t||t.replace(VMe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var k7=rd.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){dB(t);return}dB(t.scheme,t.optionalSlashes)})},onDestroy(){FMe()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ld(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ld(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ld(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Mi(this.options.HTMLAttributes,t),0]:["a",Mi(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const i=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:i=>!!Ld(i,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:i=>!!Ld(i,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Cf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:i}=this.options,r=O7(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!Ld(s,n),protocols:n,defaultProtocol:i}));r.length&&r.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(GMe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:i=>this.options.isAllowedUri(i,{defaultValidate:r=>!!Ld(r,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(WMe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(qMe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),XMe=k7,KMe=Object.defineProperty,YMe=(t,e)=>{for(var n in e)KMe(t,n,{get:e[n],enumerable:!0})},ZMe="listItem",fB="textStyle",hB=/^\s*([-+*])\s$/,L7=ja.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Mi(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ZMe,this.editor.getAttributes(fB)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Gp({find:hB,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:hB,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(fB),editor:this.editor})),[t]}}),I7=ja.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Mi(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(r=>r.type==="paragraph"))n=e.parseChildren(t.tokens);else{const r=t.tokens[0];if(r&&r.type==="text"&&r.tokens&&r.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(r.tokens)}],t.tokens.length>1){const s=t.tokens.slice(1),o=e.parseChildren(s);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>sD(t,e,i=>i.parentType==="bulletList"?"- ":i.parentType==="orderedList"?`${i.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),QMe={};YMe(QMe,{findListItemPos:()=>wx,getNextListDepth:()=>gD,handleBackspace:()=>P3,handleDelete:()=>D3,hasListBefore:()=>U7,hasListItemAfter:()=>JMe,hasListItemBefore:()=>j7,listItemHasSubList:()=>F7,nextListIsDeeper:()=>z7,nextListIsHigher:()=>B7});var wx=(t,e)=>{const{$from:n}=e.selection,i=qi(t,e.schema);let r=null,a=n.depth,s=n.pos,o=null;for(;a>0&&o===null;)r=n.node(a),r.type===i?o=a:(a-=1,s-=1);return o===null?null:{$pos:e.doc.resolve(s),depth:o}},gD=(t,e)=>{const n=wx(t,e);if(!n)return!1;const[,i]=jSe(e,t,n.$pos.pos+4);return i},U7=(t,e,n)=>{const{$anchor:i}=t.selection,r=Math.max(0,i.pos-2),a=t.doc.resolve(r).node();return!(!a||!n.includes(a.type.name))},j7=(t,e)=>{var n;const{$anchor:i}=e.selection,r=e.doc.resolve(i.pos-2);return!(r.index()===0||((n=r.nodeBefore)==null?void 0:n.type.name)!==t)},F7=(t,e,n)=>{if(!n)return!1;const i=qi(t,e.schema);let r=!1;return n.descendants(a=>{a.type===i&&(r=!0)}),r},P3=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!qu(t.state,e)&&U7(t.state,e,n)){const{$anchor:o}=t.state.selection,l=t.state.doc.resolve(o.before()-1),c=[];l.node().descendants((p,m)=>{p.type.name===e&&c.push({node:p,pos:m})});const d=c.at(-1);if(!d)return!1;const f=t.state.doc.resolve(l.start()+d.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!qu(t.state,e)||!HSe(t.state))return!1;const i=wx(e,t.state);if(!i)return!1;const a=t.state.doc.resolve(i.$pos.pos-2).node(i.depth),s=F7(e,t.state,a);return j7(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},z7=(t,e)=>{const n=gD(t,e),i=wx(t,e);return!i||!n?!1:n>i.depth},B7=(t,e)=>{const n=gD(t,e),i=wx(t,e);return!i||!n?!1:n<i.depth},D3=(t,e)=>{if(!qu(t.state,e)||!BSe(t.state,e))return!1;const{selection:n}=t.state,{$from:i,$to:r}=n;return!n.empty&&i.sameParent(r)?!1:z7(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():B7(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},JMe=(t,e)=>{var n;const{$anchor:i}=e.selection,r=e.doc.resolve(i.pos-i.parentOffset-2);return!(r.index()===r.parent.childCount-1||((n=r.nodeAfter)==null?void 0:n.type.name)!==t)},H7=$n.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&D3(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&D3(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:i})=>{t.state.schema.nodes[n]!==void 0&&P3(t,n,i)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:i})=>{t.state.schema.nodes[n]!==void 0&&P3(t,n,i)&&(e=!0)}),e}}}}),pB=/^(\s*)(\d+)\.\s+(.*)$/,eEe=/^\s/;function tEe(t){const e=[];let n=0,i=0;for(;n<t.length;){const r=t[n],a=r.match(pB);if(!a)break;const[,s,o,l]=a,c=s.length;let d=l,f=n+1;const p=[r];for(;f<t.length;){const m=t[f];if(m.match(pB))break;if(m.trim()==="")p.push(m),d+=`
- `,f+=1;else if(m.match(eEe))p.push(m),d+=`
- ${m.slice(c+2)}`,f+=1;else break}e.push({indent:c,number:parseInt(o,10),content:d.trim(),raw:p.join(`
- `)}),i=f,n=f}return[e,i]}function V7(t,e,n){var i;const r=[];let a=0;for(;a<t.length;){const s=t[a];if(s.indent===e){const o=s.content.split(`
- `),l=((i=o[0])==null?void 0:i.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const d=o.slice(1).join(`
- `).trim();if(d){const m=n.blockTokens(d);c.push(...m)}let f=a+1;const p=[];for(;f<t.length&&t[f].indent>e;)p.push(t[f]),f+=1;if(p.length>0){const m=Math.min(...p.map(b=>b.indent)),_=V7(p,m,n);c.push({type:"list",ordered:!0,start:p[0].number,items:_,raw:p.map(b=>b.raw).join(`
- `)})}r.push({type:"list_item",raw:s.raw,tokens:c}),a=f}else a+=1}return r}function nEe(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const i=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(r=>{if(r.type==="paragraph"||r.type==="list"||r.type==="blockquote"||r.type==="code")i.push(...e.parseChildren([r]));else if(r.type==="text"&&r.tokens){const a=e.parseChildren([r]);i.push({type:"paragraph",content:a})}else{const a=e.parseChildren([r]);a.length>0&&i.push(...a)}}),{type:"listItem",content:i}})}var iEe="listItem",mB="textStyle",gB=/^(\d+)\.\s$/,$7=ja.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Mi(this.options.HTMLAttributes,n),0]:["ol",Mi(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,i=t.items?nEe(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:i}:{type:"orderedList",content:i}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var i;const r=t.split(`
- `),[a,s]=tEe(r);if(a.length===0)return;const o=V7(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((i=a[0])==null?void 0:i.number)||1,items:o,raw:r.slice(0,s).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(iEe,this.editor.getAttributes(mB)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Gp({find:gB,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:gB,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(mB)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),rEe=/^\s*(\[([( |x])?\])\s$/,aEe=ja.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Mi(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const i=e.parseChildren(t.nestedTokens);n.push(...i)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const r=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return sD(t,e,r)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:i})=>{const r=document.createElement("li"),a=document.createElement("label"),s=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),c=d=>{var f,p;o.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!i.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=d.target;i.isEditable&&typeof n=="function"&&i.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=n();if(typeof m!="number")return!1;const _=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{..._?.attrs,checked:f}),!0}).run(),!i.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{r.setAttribute(d,f)}),r.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),r.append(a,l),Object.entries(e).forEach(([d,f])=>{r.setAttribute(d,f)}),{dom:r,contentDOM:l,update:d=>d.type!==this.type?!1:(r.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[Gp({find:rEe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),sEe=ja.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Mi(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const i=a=>{const s=_3(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:i},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},r=_3(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:i},n);if(r)return{type:"taskList",raw:r.raw,items:r.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});$n.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(L7.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(I7.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(H7.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push($7.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(aEe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(sEe.configure(this.options.taskList)),t}});var oEe=ja.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Mi(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),lEe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,cEe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,uEe=rd.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Mi(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[$p({find:lEe,type:this.type})]},addPasteRules(){return[Cf({find:cEe,type:this.type})]}}),dEe=ja.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),G7=rd.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Mi(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;const a=r[2].trim();return{type:"underline",raw:r[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),fEe=G7;function hEe(t={}){return new gi({view(e){return new pEe(e,t)}})}class pEe{constructor(e,n){var i;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(i=n.width)!==null&&i!==void 0?i:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let a=s=>{this[r](s)};return e.dom.addEventListener(r,a),{name:r,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,i,r=this.editorView.dom,a=r.getBoundingClientRect(),s=a.width/r.offsetWidth,o=a.height/r.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let _=m.getBoundingClientRect(),b=f?_.bottom:_.top;f&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*o;i={left:_.left,right:_.right,top:b-v,bottom:b+v}}}}if(!i){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;i={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let f=l.getBoundingClientRect(),p=f.width/l.offsetWidth,m=f.height/l.offsetHeight;c=f.left-l.scrollLeft*p,d=f.top-l.scrollTop*m}this.element.style.left=(i.left-c)/s+"px",this.element.style.top=(i.top-d)/o+"px",this.element.style.width=(i.right-i.left)/s+"px",this.element.style.height=(i.bottom-i.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),i=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),r=i&&i.type.spec.disableDropCursor,a=typeof r=="function"?r(this.editorView,n,e):r;if(n&&!a){let s=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=$9(this.editorView.state.doc,s,this.editorView.dragging.slice);o!=null&&(s=o)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class wi extends rn{constructor(e){super(e,e)}map(e,n){let i=e.resolve(n.map(this.head));return wi.valid(i)?new wi(i):rn.near(i)}content(){return Mt.empty}eq(e){return e instanceof wi&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new wi(e.resolve(n.pos))}getBookmark(){return new xD(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!mEe(e)||!gEe(e))return!1;let i=n.type.spec.allowGapCursor;if(i!=null)return i;let r=n.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,n,i=!1){e:for(;;){if(!i&&wi.valid(e))return e;let r=e.pos,a=null;for(let s=e.depth;;s--){let o=e.node(s);if(n>0?e.indexAfter(s)<o.childCount:e.index(s)>0){a=o.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;r+=n;let l=e.doc.resolve(r);if(wi.valid(l))return l}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!jt.isSelectable(a)){e=e.doc.resolve(r+a.nodeSize*n),i=!1;continue e}break}a=s,r+=n;let o=e.doc.resolve(r);if(wi.valid(o))return o}return null}}}wi.prototype.visible=!1;wi.findFrom=wi.findGapCursorFrom;rn.jsonID("gapcursor",wi);class xD{constructor(e){this.pos=e}map(e){return new xD(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return wi.valid(n)?new wi(n):rn.near(n)}}function W7(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function mEe(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),i=t.node(e);if(n==0){if(i.type.spec.isolating)return!0;continue}for(let r=i.child(n-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||W7(r.type))return!0;if(r.inlineContent)return!1}}return!0}function gEe(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),i=t.node(e);if(n==i.childCount){if(i.type.spec.isolating)return!0;continue}for(let r=i.child(n);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||W7(r.type))return!0;if(r.inlineContent)return!1}}return!0}function xEe(){return new gi({props:{decorations:_Ee,createSelectionBetween(t,e,n){return e.pos==n.pos&&wi.valid(n)?new wi(n):null},handleClick:yEe,handleKeyDown:vEe,handleDOMEvents:{beforeinput:bEe}}})}const vEe=$W({ArrowLeft:_b("horiz",-1),ArrowRight:_b("horiz",1),ArrowUp:_b("vert",-1),ArrowDown:_b("vert",1)});function _b(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(i,r,a){let s=i.selection,o=e>0?s.$to:s.$from,l=s.empty;if(s instanceof Ht){if(!a.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=i.doc.resolve(e>0?o.after():o.before())}let c=wi.findGapCursorFrom(o,e,l);return c?(r&&r(i.tr.setSelection(new wi(c))),!0):!1}}function yEe(t,e,n){if(!t||!t.editable)return!1;let i=t.state.doc.resolve(e);if(!wi.valid(i))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return r&&r.inside>-1&&jt.isSelectable(t.state.doc.nodeAt(r.inside))?!1:(t.dispatch(t.state.tr.setSelection(new wi(i))),!0)}function bEe(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof wi))return!1;let{$from:n}=t.state.selection,i=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!i)return!1;let r=dt.empty;for(let s=i.length-1;s>=0;s--)r=dt.from(i[s].createAndFill(null,r));let a=t.state.tr.replace(n.pos,n.pos,new Mt(r,0,0));return a.setSelection(Ht.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function _Ee(t){if(!(t.selection instanceof wi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",hi.create(t.doc,[fa.widget(t.selection.head,e,{key:"gapcursor"})])}var v1=200,Ar=function(){};Ar.prototype.append=function(e){return e.length?(e=Ar.from(e),!this.length&&e||e.length<v1&&this.leafAppend(e)||this.length<v1&&e.leafPrepend(this)||this.appendInner(e)):this};Ar.prototype.prepend=function(e){return e.length?Ar.from(e).append(this):this};Ar.prototype.appendInner=function(e){return new SEe(this,e)};Ar.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ar.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ar.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ar.prototype.forEach=function(e,n,i){n===void 0&&(n=0),i===void 0&&(i=this.length),n<=i?this.forEachInner(e,n,i,0):this.forEachInvertedInner(e,n,i,0)};Ar.prototype.map=function(e,n,i){n===void 0&&(n=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(a,s){return r.push(e(a,s))},n,i),r};Ar.from=function(e){return e instanceof Ar?e:e&&e.length?new q7(e):Ar.empty};var q7=(function(t){function e(i){t.call(this),this.values=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,a){return r==0&&a==this.length?this:new e(this.values.slice(r,a))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,a,s,o){for(var l=a;l<s;l++)if(r(this.values[l],o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,a,s,o){for(var l=a-1;l>=s;l--)if(r(this.values[l],o+l)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=v1)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=v1)return new e(r.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Ar);Ar.empty=new q7([]);var SEe=(function(t){function e(n,i){t.call(this),this.left=n,this.right=i,this.length=n.length+i.length,this.depth=Math.max(n.depth,i.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,a,s){var o=this.left.length;if(r<o&&this.left.forEachInner(i,r,Math.min(a,o),s)===!1||a>o&&this.right.forEachInner(i,Math.max(r-o,0),Math.min(this.length,a)-o,s+o)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,a,s){var o=this.left.length;if(r>o&&this.right.forEachInvertedInner(i,r-o,Math.max(a,o)-o,s+o)===!1||a<o&&this.left.forEachInvertedInner(i,Math.min(r,o),a,s)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var a=this.left.length;return r<=a?this.left.slice(i,r):i>=a?this.right.slice(i-a,r-a):this.left.slice(i,a).append(this.right.slice(0,r-a))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e})(Ar);const wEe=500;class lo{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,a;n&&(r=this.remapping(i,this.items.length),a=r.maps.length);let s=e.tr,o,l,c=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){r||(r=this.remapping(i,p+1),a=r.maps.length),a--,d.push(f);return}if(r){d.push(new ko(f.map));let m=f.step.map(r.slice(a)),_;m&&s.maybeStep(m).doc&&(_=s.mapping.maps[s.mapping.maps.length-1],c.push(new ko(_,void 0,void 0,c.length+d.length))),a--,_&&r.appendMap(_,a)}else s.maybeStep(f.step);if(f.selection)return o=r?f.selection.map(r.slice(a)):f.selection,l=new lo(this.items.slice(0,i).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:s,selection:o}}addTransform(e,n,i,r){let a=[],s=this.eventCount,o=this.items,l=!r&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),p=new ko(e.mapping.maps[d],f,n),m;(m=l&&l.merge(p))&&(p=m,d?a.pop():o=o.slice(0,o.length-1)),a.push(p),n&&(s++,n=void 0),r||(l=p)}let c=s-i.depth;return c>EEe&&(o=MEe(o,c),s-=c),new lo(o.append(a),s)}remapping(e,n){let i=new j0;return this.items.forEach((r,a)=>{let s=r.mirrorOffset!=null&&a-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,s)},e,n),i}addMaps(e){return this.eventCount==0?this:new lo(this.items.append(e.map(n=>new ko(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-n),a=e.mapping,s=e.steps.length,o=this.eventCount;this.items.forEach(p=>{p.selection&&o--},r);let l=n;this.items.forEach(p=>{let m=a.getMirror(--l);if(m==null)return;s=Math.min(s,m);let _=a.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),v=p.selection&&p.selection.map(a.slice(l+1,m));v&&o++,i.push(new ko(_,b,v))}else i.push(new ko(_))},r);let c=[];for(let p=n;p<s;p++)c.push(new ko(a.maps[p]));let d=this.items.slice(0,r).append(c).append(i),f=new lo(d,o);return f.emptyItemCount()>wEe&&(f=f.compress(this.items.length-i.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),i=n.maps.length,r=[],a=0;return this.items.forEach((s,o)=>{if(o>=e)r.push(s),s.selection&&a++;else if(s.step){let l=s.step.map(n.slice(i)),c=l&&l.getMap();if(i--,c&&n.appendMap(c,i),l){let d=s.selection&&s.selection.map(n.slice(i));d&&a++;let f=new ko(c.invert(),l,d),p,m=r.length-1;(p=r.length&&r[m].merge(f))?r[m]=p:r.push(f)}}else s.map&&i--},this.items.length,0),new lo(Ar.from(r.reverse()),a)}}lo.empty=new lo(Ar.empty,0);function MEe(t,e){let n;return t.forEach((i,r)=>{if(i.selection&&e--==0)return n=r,!1}),t.slice(n)}class ko{constructor(e,n,i,r){this.map=e,this.step=n,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new ko(n.getMap().invert(),n,this.selection)}}}class mu{constructor(e,n,i,r,a){this.done=e,this.undone=n,this.prevRanges=i,this.prevTime=r,this.prevComposition=a}}const EEe=20;function AEe(t,e,n,i){let r=n.getMeta(cf),a;if(r)return r.historyState;n.getMeta(NEe)&&(t=new mu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(cf))return s.getMeta(cf).redo?new mu(t.done.addTransform(n,void 0,i,r_(e)),t.undone,xB(n.mapping.maps),t.prevTime,t.prevComposition):new mu(t.done,t.undone.addTransform(n,void 0,i,r_(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),l=t.prevTime==0||!s&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-i.newGroupDelay||!TEe(n,t.prevRanges)),c=s?QT(t.prevRanges,n.mapping):xB(n.mapping.maps);return new mu(t.done.addTransform(n,l?e.selection.getBookmark():void 0,i,r_(e)),lo.empty,c,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new mu(t.done.rebased(n,a),t.undone.rebased(n,a),QT(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new mu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),QT(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function TEe(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((i,r)=>{for(let a=0;a<e.length;a+=2)i<=e[a+1]&&r>=e[a]&&(n=!0)}),n}function xB(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((i,r,a,s)=>e.push(a,s));return e}function QT(t,e){if(!t)return null;let n=[];for(let i=0;i<t.length;i+=2){let r=e.map(t[i],1),a=e.map(t[i+1],-1);r<=a&&n.push(r,a)}return n}function CEe(t,e,n){let i=r_(e),r=cf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,i);if(!a)return null;let s=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),r,i),l=new mu(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(cf,{redo:n,historyState:l})}let JT=!1,vB=null;function r_(t){let e=t.plugins;if(vB!=e){JT=!1,vB=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){JT=!0;break}}return JT}const cf=new or("history"),NEe=new or("closeHistory");function REe(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new gi({key:cf,state:{init(){return new mu(lo.empty,lo.empty,null,0,-1)},apply(e,n,i){return AEe(n,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let i=n.inputType,r=i=="historyUndo"?K7:i=="historyRedo"?Y7:null;return!r||!e.editable?!1:(n.preventDefault(),r(e.state,e.dispatch))}}}})}function X7(t,e){return(n,i)=>{let r=cf.getState(n);if(!r||(t?r.undone:r.done).eventCount==0)return!1;if(i){let a=CEe(r,n,t);a&&i(e?a.scrollIntoView():a)}return!0}}const K7=X7(!1,!0),Y7=X7(!0,!0);$n.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const i=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(i)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new gi({key:new or("characterCount"),appendTransaction:(e,n,i)=>{if(t)return;const r=this.options.limit;if(r==null||r===0){t=!0;return}const a=this.storage.characters({node:i.doc});if(a>r){const s=a-r,o=0,l=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const c=i.tr.deleteRange(o,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const i=this.options.limit;if(!e.docChanged||i===0||i===null||i===void 0)return!0;const r=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=i||r>i&&a>i&&a<=r)return!0;if(r>i&&a>i&&a>r||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,l=a-i,c=o-l,d=o;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>i)}})]}});var PEe=$n.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[hEe(this.options)]}});$n.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new gi({key:new or("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:i}=this.editor,{anchor:r}=e,a=[];if(!n||!i)return hi.create(t,[]);let s=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(r>=c&&r<=c+l.nodeSize-1))return!1;s+=1});let o=0;return t.descendants((l,c)=>{if(l.isText||!(r>=c&&r<=c+l.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&s-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(fa.node(c,c+l.nodeSize,{class:this.options.className}))}),hi.create(t,a)}}})]}});var DEe=$n.create({name:"gapCursor",addProseMirrorPlugins(){return[xEe()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=On(It(t,"allowGapCursor",n)))!=null?e:null}}});$n.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new gi({key:new or("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=e,r=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((s,o)=>{const l=i>=o&&i<=o+s.nodeSize,c=!s.isLeaf&&qS(s);if((l||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=fa.node(o,o+s.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:o,hasAnchor:l}):this.options.placeholder});r.push(f)}return this.options.includeChildren}),hi.create(t,r)}}})]}});$n.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new gi({key:new or("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||s7(n.selection)||t.view.dragging?null:hi.create(n.doc,[fa.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function yB({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var OEe=$n.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new or(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",i=Object.entries(this.editor.schema.nodes).map(([,r])=>r).filter(r=>(this.options.notAfter||[]).concat(n).includes(r.name));return[new gi({key:e,appendTransaction:(r,a,s)=>{const{doc:o,tr:l,schema:c}=s,d=e.getState(s),f=o.content.size,p=c.nodes[n];if(d)return l.insert(f,p.create())},state:{init:(r,a)=>{const s=a.tr.doc.lastChild;return!yB({node:s,types:i})},apply:(r,a)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return a;const s=r.doc.lastChild;return!yB({node:s,types:i})}}})]}}),kEe=$n.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>K7(t,e),redo:()=>({state:t,dispatch:e})=>Y7(t,e)}},addProseMirrorPlugins(){return[REe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),LEe=$n.create({name:"starterKit",addExtensions(){var t,e,n,i;const r=[];return this.options.bold!==!1&&r.push(lMe.configure(this.options.bold)),this.options.blockquote!==!1&&r.push(iMe.configure(this.options.blockquote)),this.options.bulletList!==!1&&r.push(L7.configure(this.options.bulletList)),this.options.code!==!1&&r.push(dMe.configure(this.options.code)),this.options.codeBlock!==!1&&r.push(pMe.configure(this.options.codeBlock)),this.options.document!==!1&&r.push(mMe.configure(this.options.document)),this.options.dropcursor!==!1&&r.push(PEe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&r.push(DEe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&r.push(gMe.configure(this.options.hardBreak)),this.options.heading!==!1&&r.push(xMe.configure(this.options.heading)),this.options.undoRedo!==!1&&r.push(kEe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&r.push(vMe.configure(this.options.horizontalRule)),this.options.italic!==!1&&r.push(wMe.configure(this.options.italic)),this.options.listItem!==!1&&r.push(I7.configure(this.options.listItem)),this.options.listKeymap!==!1&&r.push(H7.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&r.push(k7.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&r.push($7.configure(this.options.orderedList)),this.options.paragraph!==!1&&r.push(oEe.configure(this.options.paragraph)),this.options.strike!==!1&&r.push(uEe.configure(this.options.strike)),this.options.text!==!1&&r.push(dEe.configure(this.options.text)),this.options.underline!==!1&&r.push(G7.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&r.push(OEe.configure((i=this.options)==null?void 0:i.trailingNode)),r}}),IEe=LEe,UEe=$n.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),jEe=UEe,FEe=20,Z7=(t,e=0)=>{const n=[];return!t.children.length||e>FEe||Array.from(t.children).forEach(i=>{i.tagName==="SPAN"?n.push(i):i.children.length&&n.push(...Z7(i,e+1))}),n},zEe=t=>{if(!t.children.length)return;const e=Z7(t);e&&e.forEach(n=>{var i,r;const a=n.getAttribute("style"),s=(r=(i=n.parentElement)==null?void 0:i.closest("span"))==null?void 0:r.getAttribute("style");n.setAttribute("style",`${s};${a}`)})},Q7=rd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&zEe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Mi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,i)=>{if(n.isTextblock)return!0;n.marks.filter(r=>r.type===this.type).some(r=>Object.values(r.attrs).some(a=>!!a))||t.removeMark(i,i+n.nodeSize,this.type)}),!0}}}}),BEe=$n.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const i=n.split(";").map(r=>r.trim()).filter(Boolean);for(let r=i.length-1;r>=0;r-=1){const a=i[r].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="background-color")return o.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),J7=$n.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const i=n.split(";").map(r=>r.trim()).filter(Boolean);for(let r=i.length-1;r>=0;r-=1){const a=i[r].split(":");if(a.length>=2){const s=a[0].trim().toLowerCase(),o=a.slice(1).join(":").trim();if(s==="color")return o.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),HEe=$n.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),VEe=$n.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),$Ee=$n.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});$n.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(BEe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(J7.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(HEe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(VEe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push($Ee.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Q7.configure(this.options.textStyle)),t}});var GEe=J7,WEe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,qEe=ja.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Mi(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,i,r,a,s;const o=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",l=(r=(i=t.attrs)==null?void 0:i.alt)!=null?r:"",c=(s=(a=t.attrs)==null?void 0:a.title)!=null?s:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:i}=this.options.resize;return({node:r,getPos:a,HTMLAttributes:s})=>{const o=document.createElement("img");Object.entries(s).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:o.setAttribute(d,f);break}}),o.src=s.src;const l=new Awe({element:o,node:r,getPos:a,onResize:(d,f)=>{o.style.width=`${d}px`,o.style.height=`${f}px`},onCommit:(d,f)=>{const p=a();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,p)=>d.type===r.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:i===!0}}),c=l.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",o.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},l}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[_7({find:WEe,type:this.type,getAttributes:t=>{const[,,e,n,i]=t;return{src:n,alt:e,title:i}}})]}}),XEe=qEe;function bB({content:t,onChange:e,placeholder:n}){const i=Qwe({extensions:[IEe.configure({heading:!1,codeBlock:!1,code:!1}),fEe,XMe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),jEe.configure({types:["paragraph"]}),Q7,GEe,XEe.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:s})=>{e(s.getHTML())},editorProps:{attributes:{class:"prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2",placeholder:n||""}}});if(!i)return null;const r=({onClick:s,isActive:o=!1,children:l,title:c})=>g.jsx("button",{type:"button",onClick:s,title:c,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${o?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:l}),a=()=>{const s=window.prompt("Enter URL:");s&&i.chain().focus().setLink({href:s}).run()};return g.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[g.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[g.jsx(r,{onClick:()=>i.chain().focus().toggleBold().run(),isActive:i.isActive("bold"),title:"Bold",children:g.jsx(hie,{className:"w-4 h-4"})}),g.jsx(r,{onClick:()=>i.chain().focus().toggleItalic().run(),isActive:i.isActive("italic"),title:"Italic",children:g.jsx(yre,{className:"w-4 h-4"})}),g.jsx(r,{onClick:()=>i.chain().focus().toggleUnderline().run(),isActive:i.isActive("underline"),title:"Underline",children:g.jsx(Hae,{className:"w-4 h-4"})}),g.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),g.jsx(r,{onClick:()=>i.chain().focus().toggleBulletList().run(),isActive:i.isActive("bulletList"),title:"Bullet List",children:g.jsx(z$,{className:"w-4 h-4"})}),g.jsx(r,{onClick:()=>i.chain().focus().toggleOrderedList().run(),isActive:i.isActive("orderedList"),title:"Numbered List",children:g.jsx(Ore,{className:"w-4 h-4"})}),g.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),g.jsx(r,{onClick:()=>i.chain().focus().setTextAlign("left").run(),isActive:i.isActive({textAlign:"left"}),title:"Align Left",children:g.jsx(Uae,{className:"w-4 h-4"})}),g.jsx(r,{onClick:()=>i.chain().focus().setTextAlign("center").run(),isActive:i.isActive({textAlign:"center"}),title:"Align Center",children:g.jsx(Oae,{className:"w-4 h-4"})}),g.jsx(r,{onClick:()=>i.chain().focus().setTextAlign("right").run(),isActive:i.isActive({textAlign:"right"}),title:"Align Right",children:g.jsx(Lae,{className:"w-4 h-4"})}),g.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),g.jsx(r,{onClick:a,isActive:i.isActive("link"),title:"Add Link",children:g.jsx(Pre,{className:"w-4 h-4"})}),i.isActive("link")&&g.jsx(r,{onClick:()=>i.chain().focus().unsetLink().run(),title:"Remove Link",children:g.jsx($ae,{className:"w-4 h-4"})})]}),g.jsx(Gwe,{editor:i})]})}function KEe({archiveId:t,archiveName:e,onClose:n}){const i=ui(),[r,a]=A.useState(!1),[s,o]=A.useState(null),[l,c]=A.useState({}),{data:d,isLoading:f,error:p}=Bt({queryKey:["archive-project-page",t],queryFn:()=>Ze.getArchiveProjectPage(t)}),m=Ut({mutationFn:T=>Ze.updateArchiveProjectPage(t,T),onSuccess:()=>{i.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),c({})}});A.useEffect(()=>{const T=P=>{P.key==="Escape"&&(s!==null?o(null):r?x():n())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s,r,n]);const _=[...d?.model_pictures||[],...d?.profile_pictures||[]],b=()=>{c({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},v=()=>{m.mutate(l)},x=()=>{a(!1),c({})},M=T=>{const P=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],N=new DOMParser().parseFromString(T,"text/html"),U=R=>{if(R.nodeType===Node.TEXT_NODE)return R.textContent||"";if(R.nodeType===Node.ELEMENT_NODE){const O=R,z=O.tagName.toLowerCase();if(!P.includes(z))return Array.from(O.childNodes).map(U).join("");let I="";if(z==="a"&&O.getAttribute("href")){const L=O.getAttribute("href");L?.toLowerCase().startsWith("http")&&(I=` href="${L}" target="_blank" rel="noopener noreferrer"`)}if(z==="img"){const L=O.getAttribute("src");if(!L?.toLowerCase().startsWith("http"))return"";I=` src="${L}" style="max-width: 100%; height: auto;"`}const G=Array.from(O.childNodes).map(U).join("");return["br","img"].includes(z)?`<${z}${I} />`:`<${z}${I}>${G}</${z}>`}return""};return Array.from(N.body.childNodes).map(U).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||_.length>0),E=T=>{T.target===T.currentTarget&&n()};return g.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:E,children:[g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(cp,{className:"w-5 h-5 text-bambu-green"}),g.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&g.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[!r&&w&&g.jsxs(ot,{variant:"ghost",size:"sm",onClick:b,children:[g.jsx(B$,{className:"w-4 h-4 mr-1"}),"Edit"]}),r&&g.jsxs(g.Fragment,{children:[g.jsx(ot,{variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),g.jsxs(ot,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[g.jsx(mx,{className:"w-4 h-4 mr-1"}),"Save"]})]}),g.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:g.jsx(Cn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),g.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&g.jsx("div",{className:"flex items-center justify-center py-12",children:g.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),p&&g.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&g.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[g.jsx(cp,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),g.jsx("p",{children:"No project page data found in this 3MF file."}),g.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"space-y-4",children:[r?g.jsx("input",{type:"text",value:l.title||"",onChange:T=>c({...l,title:T.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&g.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),g.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[r?g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(G4,{className:"w-4 h-4 text-bambu-gray"}),g.jsx("input",{type:"text",value:l.designer||"",onChange:T=>c({...l,designer:T.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&g.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[g.jsx(G4,{className:"w-4 h-4"}),g.jsx("span",{children:d.designer}),d.designer_user_id&&g.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:g.jsx(sc,{className:"w-3 h-3"})})]}),d.creation_date&&g.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[g.jsx($o,{className:"w-4 h-4"}),g.jsx("span",{children:d.creation_date})]}),r?g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(cp,{className:"w-4 h-4 text-bambu-gray"}),g.jsx("input",{type:"text",value:l.license||"",onChange:T=>c({...l,license:T.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&g.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[g.jsx(cp,{className:"w-4 h-4"}),g.jsx("span",{children:d.license})]}),d.origin&&g.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||r)&&g.jsxs("div",{className:"space-y-2",children:[g.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),r?g.jsx(bB,{content:l.description||"",onChange:T=>c({...l,description:T}),placeholder:"Enter description..."}):g.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(d.description||"")}})]}),(d.profile_title||d.profile_description||r)&&g.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[g.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),r?g.jsxs("div",{className:"space-y-2",children:[g.jsx("input",{type:"text",value:l.profile_title||"",onChange:T=>c({...l,profile_title:T.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),g.jsx(bB,{content:l.profile_description||"",onChange:T=>c({...l,profile_description:T}),placeholder:"Profile description..."})]}):g.jsxs(g.Fragment,{children:[d.profile_title&&g.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&g.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(d.profile_description)}}),d.profile_user_name&&g.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),_.length>0&&g.jsxs("div",{className:"space-y-2",children:[g.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[g.jsx(bS,{className:"w-4 h-4"}),"Images (",_.length,")"]}),g.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:_.map((T,P)=>g.jsx("button",{onClick:()=>o(P),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:g.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),d.design_model_id&&g.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:g.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[g.jsx(sc,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&_[s]&&g.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[g.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.max(0,s-1))},disabled:s===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:g.jsx(xf,{className:"w-6 h-6 text-white"})}),g.jsx("img",{src:_[s].url,alt:_[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),g.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(_.length-1,s+1))},disabled:s===_.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:g.jsx(If,{className:"w-6 h-6 text-white"})}),g.jsx("button",{onClick:()=>o(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:g.jsx(Cn,{className:"w-6 h-6 text-white"})}),g.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",_.length]})]})]})}const YEe=[.25,.5,.75,1,1.5,2,3,4];function ZEe({src:t,title:e,downloadFilename:n,onClose:i}){const r=A.useRef(null),[a,s]=A.useState(!0),[o,l]=A.useState(.5),[c,d]=A.useState(0),[f,p]=A.useState(0);A.useEffect(()=>{const w=r.current;w&&(w.playbackRate=o)},[o]),A.useEffect(()=>{const w=E=>{E.key==="Escape"&&i()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[i]),A.useEffect(()=>{const w=r.current;if(!w)return;const E=()=>d(w.currentTime),T=()=>p(w.duration),P=()=>s(!0),N=()=>s(!1);return w.addEventListener("timeupdate",E),w.addEventListener("durationchange",T),w.addEventListener("play",P),w.addEventListener("pause",N),()=>{w.removeEventListener("timeupdate",E),w.removeEventListener("durationchange",T),w.removeEventListener("play",P),w.removeEventListener("pause",N)}},[]);const m=()=>{const w=r.current;w&&(a?w.pause():w.play())},_=w=>{const E=r.current;E&&(E.currentTime=parseFloat(w.target.value))},b=()=>{const w=r.current;w&&(w.currentTime=Math.max(0,w.currentTime-5))},v=()=>{const w=r.current;w&&(w.currentTime=Math.min(f,w.currentTime+5))},x=w=>{const E=Math.floor(w/60),T=Math.floor(w%60);return`${E}:${T.toString().padStart(2,"0")}`},M=()=>{const w=document.createElement("a");w.href=t,w.download=n,w.click()};return g.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:g.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[g.jsx(gp,{className:"w-5 h-5 text-bambu-green"}),e]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs(ot,{variant:"secondary",size:"sm",onClick:M,children:[g.jsx(Fu,{className:"w-4 h-4"}),"Download"]}),g.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:g.jsx(Cn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),g.jsxs("div",{className:"p-4",children:[g.jsx("video",{ref:r,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:m}),g.jsxs("div",{className:"mt-4 space-y-3",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:x(c)}),g.jsx("input",{type:"range",min:0,max:f||100,value:c,onChange:_,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),g.jsx("span",{className:"text-xs text-bambu-gray w-12",children:x(f)})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:g.jsx(xae,{className:"w-5 h-5 text-bambu-gray"})}),g.jsx("button",{onClick:m,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:a?g.jsx(Wre,{className:"w-5 h-5 text-white"}):g.jsx(_S,{className:"w-5 h-5 text-white"})}),g.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:g.jsx(G$,{className:"w-5 h-5 text-bambu-gray"})})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),g.jsx("div",{className:"flex gap-1",children:YEe.map(w=>g.jsxs("button",{onClick:()=>l(w),className:`px-2 py-1 text-xs rounded transition-colors ${o===w?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[w,"x"]},w))})]})]})]})]})]})})}function QEe({archiveId:t,archiveName:e,onClose:n}){const i=ui(),{showToast:r}=_o(),[a,s]=A.useState(null),[o,l]=A.useState("asap"),[c,d]=A.useState(""),[f,p]=A.useState(!1),[m,_]=A.useState(!1),{data:b}=Bt({queryKey:["printers"],queryFn:()=>Ze.getPrinters()});A.useEffect(()=>{b?.length===1&&!a&&s(b[0].id)},[b,a]),A.useEffect(()=>{const w=E=>{E.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const v=Ut({mutationFn:w=>Ze.addToQueue(w),onSuccess:()=>{i.invalidateQueries({queryKey:["queue"]}),r("Added to print queue"),n()},onError:w=>{r(w.message||"Failed to add to queue","error")}}),x=w=>{if(w.preventDefault(),!a){r("Please select a printer","error");return}const E={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:m};o==="scheduled"&&c&&(E.scheduled_time=new Date(c).toISOString()),v.mutate(E)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:g.jsx(cn,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:g.jsxs(gn,{className:"p-0",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx($o,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),g.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),g.jsx("p",{className:"text-white font-medium truncate",children:e})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),b?.length===0?g.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[g.jsx(ed,{className:"w-4 h-4"}),"No printers configured"]}):g.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:w=>s(w.target.value?Number(w.target.value):null),required:!0,children:[g.jsx("option",{value:"",children:"Select printer..."}),b?.map(w=>g.jsx("option",{value:w.id,children:w.name},w.id))]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("asap"),children:[g.jsx(fs,{className:"w-4 h-4"}),"ASAP (when idle)"]}),g.jsxs("button",{type:"button",className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-2 transition-colors ${o==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>l("scheduled"),children:[g.jsx($o,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),g.jsx("input",{type:"datetime-local",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:c,onChange:w=>d(w.target.value),min:M(),required:!0})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>p(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),g.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:m,onChange:w=>_(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),g.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[g.jsx(SS,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),g.jsx("p",{className:"text-xs text-bambu-gray",children:o==="asap"?"Print will start as soon as the printer is idle.":"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available."}),g.jsxs("div",{className:"flex gap-3 pt-2",children:[g.jsx(ot,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),g.jsx(ot,{type:"submit",className:"flex-1",disabled:v.isPending||!a||b?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function O3(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Dg(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function _B(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function JEe({archive:t,printerName:e,isSelected:n,onSelect:i,selectionMode:r}){const a=ui(),{showToast:s}=_o(),[o,l]=A.useState(!1),[c,d]=A.useState(!1),[f,p]=A.useState(!1),[m,_]=A.useState(!1),[b,v]=A.useState(!1),[x,M]=A.useState(!1),[w,E]=A.useState([]),[T,P]=A.useState(!1),[N,U]=A.useState(!1),[R,O]=A.useState(!1),[z,I]=A.useState(!1),[G,L]=A.useState(!1),[B,q]=A.useState(null),W=A.useRef(null),X=Ut({mutationFn:re=>Ze.uploadSource3mf(t.id,re),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),s(`Source 3MF attached: ${re.filename}`)},onError:re=>{s(re.message||"Failed to upload source 3MF","error")}}),Q=Ut({mutationFn:()=>Ze.deleteSource3mf(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Source 3MF removed")},onError:re=>{s(re.message||"Failed to remove source 3MF","error")}}),ie=Ut({mutationFn:()=>Ze.scanArchiveTimelapse(t.id),onSuccess:re=>{re.status==="attached"?(a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${re.filename}`)):re.status==="exists"?s("Timelapse already attached"):re.status==="not_found"&&re.available_files&&re.available_files.length>0?(E(re.available_files),M(!0)):s(re.message||"No matching timelapse found","warning")},onError:re=>{s(re.message||"Failed to scan for timelapse","error")}}),H=Ut({mutationFn:re=>Ze.selectArchiveTimelapse(t.id,re),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${re.filename}`),M(!1),E([])},onError:re=>{s(re.message||"Failed to attach timelapse","error")}}),Y=Ut({mutationFn:()=>Ze.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Archive deleted")},onError:()=>{s("Failed to delete archive","error")}}),se=Ut({mutationFn:()=>Ze.toggleFavorite(t.id),onSuccess:re=>{a.invalidateQueries({queryKey:["archives"]}),s(re.is_favorite?"Added to favorites":"Removed from favorites")}}),ue=re=>{re.preventDefault(),q({x:re.clientX,y:re.clientY})},xe=[{label:"Print",icon:g.jsx(lc,{className:"w-4 h-4"}),onClick:()=>d(!0)},{label:"Schedule",icon:g.jsx($o,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:"Open in Bambu Studio",icon:g.jsx(sc,{className:"w-4 h-4"}),onClick:()=>{const re=t.print_name||t.filename||"model",ve=`${window.location.origin}${Ze.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`}},{label:"View on MakerWorld",icon:g.jsx(KC,{className:"w-4 h-4"}),onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:"3D Preview",icon:g.jsx(b0,{className:"w-4 h-4"}),onClick:()=>l(!0)},{label:"View Timelapse",icon:g.jsx(gp,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:g.jsx(uae,{className:"w-4 h-4"}),onClick:()=>ie.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ie.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:g.jsx(z4,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const re=document.createElement("a");re.href=Ze.getSource3mfDownloadUrl(t.id),re.download=`${t.print_name||t.filename}_source.3mf`,re.click()}else W.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:g.jsx(E0,{className:"w-4 h-4"}),onClick:()=>W.current?.click()},{label:"Remove Source 3MF",icon:g.jsx(ta,{className:"w-4 h-4"}),onClick:()=>L(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:g.jsx(Fu,{className:"w-4 h-4"}),onClick:()=>{const re=document.createElement("a");re.href=Ze.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()}},{label:"Copy Download Link",icon:g.jsx(XC,{className:"w-4 h-4"}),onClick:()=>{const re=`${window.location.origin}${Ze.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(re).then(()=>{s("Link copied to clipboard")}).catch(()=>{s("Failed to copy link","error")})}},{label:"QR Code",icon:g.jsx(iae,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:g.jsx(qC,{className:"w-4 h-4"}),onClick:()=>U(!0),disabled:!t.photos?.length},{label:"Project Page",icon:g.jsx(cp,{className:"w-4 h-4"}),onClick:()=>O(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:g.jsx(w0,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>se.mutate()},{label:"Edit",icon:g.jsx(V4,{className:"w-4 h-4"}),onClick:()=>_(!0)},{label:n?"Deselect":"Select",icon:n?g.jsx(x_,{className:"w-4 h-4"}):g.jsx(S0,{className:"w-4 h-4"}),onClick:()=>i(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:g.jsx(ta,{className:"w-4 h-4"}),onClick:()=>p(!0),danger:!0}];return g.jsxs(cn,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${r?"cursor-pointer":""}`,onContextMenu:ue,onClick:r?()=>i(t.id):void 0,children:[r&&g.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),i(t.id)},children:n?g.jsx(x_,{className:"w-5 h-5 text-bambu-green"}):g.jsx(S0,{className:"w-5 h-5 text-white"})}),g.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?g.jsx("img",{src:Ze.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):g.jsx("div",{className:"w-full h-full flex items-center justify-center",children:g.jsx(bS,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),g.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:re=>{re.stopPropagation(),se.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:g.jsx(w0,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&g.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:"failed"}),t.duplicate_count>0&&g.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1",title:"This model has been printed before",children:[g.jsx(XC,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&g.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation();const ve=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Pe=`${window.location.origin}${Ze.getSource3mfForSlicer(t.id,ve)}`;window.location.href=`bambustudioopen://${encodeURIComponent(Pe)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:g.jsx(z4,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&g.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:re=>{re.stopPropagation(),v(!0)},title:"View timelapse",children:g.jsx(gp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&g.jsxs("button",{className:`absolute bottom-2 ${t.timelapse_path?"right-12":"right-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:re=>{re.stopPropagation(),U(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[g.jsx(qC,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&g.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center",children:t.photos.length})]})]}),g.jsxs(gn,{className:"p-4 flex-1 flex flex-col",children:[g.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),g.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:e}),g.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]",children:[(t.print_time_seconds||t.actual_time_seconds)&&g.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Dg(t.print_time_seconds||0)}
- Actual: ${Dg(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Dg(t.actual_time_seconds)}`:`Estimated: ${Dg(t.print_time_seconds||0)}`,children:[g.jsx(fs,{className:"w-3 h-3"}),Dg(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&g.jsxs("span",{className:`text-[10px] px-1 rounded ${t.time_accuracy>=95&&t.time_accuracy<=105?"bg-bambu-green/20 text-bambu-green":t.time_accuracy>105?"bg-blue-500/20 text-blue-400":"bg-orange-500/20 text-orange-400"}`,children:[t.time_accuracy>100?"+":"",(t.time_accuracy-100).toFixed(0),"%"]})]}),t.filament_used_grams&&g.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[g.jsx(m_,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&g.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[g.jsx(F$,{className:"w-3 h-3"}),t.total_layers&&g.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&g.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&g.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&g.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[g.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&g.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((re,ve)=>g.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:re},title:re},ve))})]})]}),(t.tags||t.notes)&&g.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&g.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs",title:t.notes,children:g.jsx(Eae,{className:"w-3 h-3"})}),t.tags?.split(",").map((re,ve)=>g.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:re.trim()},ve))]}),g.jsx("div",{className:"flex-1"}),g.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[g.jsx("span",{children:_B(t.created_at)}),g.jsx("span",{children:O3(t.file_size)})]}),g.jsxs("div",{className:"flex gap-1 mt-3",children:[g.jsxs(ot,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>d(!0),children:[g.jsx(lc,{className:"w-3 h-3 flex-shrink-0"}),g.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),g.jsx(ot,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=t.print_name||t.filename||"model",ve=`${window.location.origin}${Ze.getArchiveForSlicer(t.id,re)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ve)}`},title:"Open in Bambu Studio",children:g.jsx(sc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),g.jsx(ot,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>t.makerworld_url&&window.open(t.makerworld_url,"_blank"),disabled:!t.makerworld_url,title:t.makerworld_url?`MakerWorld: ${t.designer||"View project"}`:"Not from MakerWorld",children:g.jsx(KC,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),g.jsx(ot,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>l(!0),title:"3D Preview",children:g.jsx(b0,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),g.jsx(ot,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const re=document.createElement("a");re.href=Ze.getArchiveDownload(t.id),re.download=`${t.print_name||t.filename}.3mf`,re.click()},title:"Download",children:g.jsx(Fu,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),g.jsx(ot,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>_(!0),title:"Edit",children:g.jsx(V4,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),g.jsx(ot,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>p(!0),title:"Delete",children:g.jsx(ta,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),m&&g.jsx(Sye,{archive:t,onClose:()=>_(!1)}),o&&g.jsx(vye,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>l(!1)}),c&&g.jsx(yye,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>d(!1),onSuccess:()=>{}}),f&&g.jsx(pa,{title:"Delete Archive",message:`Are you sure you want to delete "${t.print_name||t.filename}"? This action cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{Y.mutate(),p(!1)},onCancel:()=>p(!1)}),G&&g.jsx(pa,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"? This will delete the original slicer project file.`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Q.mutate(),L(!1)},onCancel:()=>L(!1)}),B&&g.jsx(wye,{x:B.x,y:B.y,items:xe,onClose:()=>q(null)}),b&&t.timelapse_path&&g.jsx(ZEe,{src:Ze.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,onClose:()=>v(!1)}),x&&w.length>0&&g.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:g.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[g.jsxs("div",{children:[g.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),g.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),g.jsx("button",{onClick:()=>{M(!1),E([])},className:"text-gray-400 hover:text-white p-1",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:w.map(re=>g.jsxs("button",{onClick:()=>H.mutate(re.name),disabled:H.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50",children:[g.jsx(gp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"text-white font-medium truncate",children:re.name}),g.jsxs("p",{className:"text-sm text-gray-400",children:[O3(re.size),re.mtime&&` • ${_B(re.mtime)}`]})]})]},re.name))}),g.jsx("div",{className:"p-4 border-t border-gray-700",children:g.jsx(ot,{variant:"secondary",onClick:()=>{M(!1),E([])},className:"w-full",children:"Cancel"})})]})}),T&&g.jsx(Rye,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),N&&t.photos&&t.photos.length>0&&g.jsx(Pye,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>U(!1),onDelete:async re=>{try{await Ze.deleteArchivePhoto(t.id,re),a.invalidateQueries({queryKey:["archives"]}),s("Photo deleted")}catch{s("Failed to delete photo","error")}}}),R&&g.jsx(KEe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>O(!1)}),z&&g.jsx(QEe,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),g.jsx("input",{ref:W,type:"file",accept:".3mf",className:"hidden",onChange:re=>{const ve=re.target.files?.[0];ve&&X.mutate(ve),re.target.value=""}})]})}const eAe=[{id:"all",label:"All Archives",icon:g.jsx(sre,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:g.jsx(fs,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:g.jsx($o,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:g.jsx($o,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:g.jsx(w0,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:g.jsx(ed,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:g.jsx(XC,{className:"w-4 h-4"})}];function tAe(){const t=ui(),{showToast:e}=_o(),n=A.useRef(null),[i,r]=A.useState(""),[a,s]=A.useState(null),[o,l]=A.useState(null),[c,d]=A.useState(new Set),[f,p]=A.useState("or"),[m,_]=A.useState(!1),[b,v]=A.useState(null),[x,M]=A.useState(!1),[w,E]=A.useState([]),[T,P]=A.useState(!1),[N,U]=A.useState(new Set),[R,O]=A.useState(!1),[z,I]=A.useState(!1),[G,L]=A.useState(!1),[B,q]=A.useState("grid"),[W,X]=A.useState("date-desc"),[Q,ie]=A.useState("all"),{data:H,isLoading:Y}=Bt({queryKey:["archives",a],queryFn:()=>Ze.getArchives(a||void 0)}),{data:se}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),ue=Ut({mutationFn:async te=>(await Promise.all(te.map(j=>Ze.deleteArchive(j))),te.length),onSuccess:te=>{t.invalidateQueries({queryKey:["archives"]}),U(new Set),e(`${te} archive${te!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),xe=new Map(se?.map(te=>[te.id,te.name])||[]),re=[...new Set(H?.flatMap(te=>te.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ve=[...new Set(H?.flatMap(te=>te.filament_color?.split(",")||[]).filter(Boolean)||[])],Pe=[...new Set(H?.flatMap(te=>te.tags?.split(",").map(j=>j.trim())||[]).filter(Boolean)||[])].sort(),pe=H?.filter(te=>{const j=new Date,k=new Date(te.created_at);let K=!0;switch(Q){case"recent":K=j.getTime()-k.getTime()<1440*60*1e3;break;case"this-week":K=j.getTime()-k.getTime()<10080*60*1e3;break;case"this-month":K=k.getMonth()===j.getMonth()&&k.getFullYear()===j.getFullYear();break;case"favorites":K=te.is_favorite===!0;break;case"failed":K=te.status==="failed";break;case"duplicates":K=te.duplicate_count>0;break}const me=(te.print_name||te.filename).toLowerCase().includes(i.toLowerCase()),ye=!o||te.filament_type?.split(", ").includes(o),he=te.filament_color?.split(",")||[],Ye=c.size===0||(f==="or"?he.some(Ie=>c.has(Ie)):[...c].every(Ie=>he.includes(Ie))),Le=Q==="favorites"||!m||te.is_favorite,qe=te.tags?.split(",").map(Ie=>Ie.trim())||[],rt=!b||qe.includes(b);return K&&me&&ye&&Ye&&Le&&rt}).sort((te,j)=>{switch(W){case"date-desc":return new Date(j.created_at).getTime()-new Date(te.created_at).getTime();case"date-asc":return new Date(te.created_at).getTime()-new Date(j.created_at).getTime();case"name-asc":return(te.print_name||te.filename).localeCompare(j.print_name||j.filename);case"name-desc":return(j.print_name||j.filename).localeCompare(te.print_name||te.filename);case"size-desc":return j.file_size-te.file_size;case"size-asc":return te.file_size-j.file_size;default:return 0}}),we=R||N.size>0,ze=te=>{U(j=>{const k=new Set(j);return k.has(te)?k.delete(te):k.add(te),k})},ce=()=>{pe&&U(new Set(pe.map(te=>te.id)))},ft=()=>{U(new Set),O(!1)},F=te=>{d(j=>{const k=new Set(j);return k.has(te)?k.delete(te):k.add(te),k})},$=()=>{d(new Set)},ae=()=>{r(""),s(null),l(null),_(!1),v(null)},J=i||a||o||m||b,ee=A.useCallback(te=>{te.preventDefault(),te.dataTransfer.types.includes("Files")&&P(!0)},[]),oe=A.useCallback(te=>{te.preventDefault(),te.currentTarget===te.target&&P(!1)},[]),De=A.useCallback(te=>{te.preventDefault(),P(!1);const j=Array.from(te.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));j.length>0?(E(j),M(!0)):te.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Ne=A.useCallback(te=>{const j=te.target;if(j.tagName==="INPUT"||j.tagName==="TEXTAREA"||j.isContentEditable){te.key==="Escape"&&j.blur();return}switch(te.key){case"/":te.preventDefault(),n.current?.focus();break;case"u":case"U":!te.metaKey&&!te.ctrlKey&&(te.preventDefault(),M(!0));break;case"Escape":we&&ft();break}},[we]);return A.useEffect(()=>(document.addEventListener("keydown",Ne),()=>document.removeEventListener("keydown",Ne)),[Ne]),g.jsxs("div",{className:"p-8 relative min-h-full",onDragOver:ee,onDragLeave:oe,onDrop:De,children:[T&&g.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:g.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[g.jsx(E0,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),g.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),g.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),we&&g.jsxs("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4",children:[g.jsxs("span",{className:"text-white font-medium",children:[N.size," selected"]}),g.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),g.jsx(ot,{variant:"secondary",size:"sm",onClick:ce,children:"Select All"}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:ft,children:[g.jsx(Cn,{className:"w-4 h-4"}),"Clear"]}),g.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>L(!0),children:[g.jsx(M0,{className:"w-4 h-4"}),"Tags"]}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>{const te=Array.from(N);Promise.all(te.map(j=>Ze.toggleFavorite(j))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${te.length} archive${te.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[g.jsx(w0,{className:"w-4 h-4"}),"Favorite"]}),g.jsxs(ot,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>I(!0),children:[g.jsx(ta,{className:"w-4 h-4"}),"Delete"]})]}),g.jsxs("div",{className:"flex items-center justify-between mb-8",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),g.jsx("select",{className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none",value:Q,onChange:te=>ie(te.target.value),children:eAe.map(te=>g.jsx("option",{value:te.id,children:te.label},te.id))})]}),g.jsxs("p",{className:"text-bambu-gray",children:[pe?.length||0," of ",H?.length||0," prints"]})]}),g.jsxs("div",{className:"flex items-center gap-3",children:[!we&&g.jsxs(ot,{variant:"secondary",onClick:()=>O(!0),children:[g.jsx(x_,{className:"w-4 h-4"}),"Select"]}),g.jsxs(ot,{onClick:()=>M(!0),children:[g.jsx(E0,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),g.jsx(cn,{className:"mb-6",children:g.jsxs(gn,{className:"py-4",children:[g.jsxs("div",{className:"flex gap-4 items-center flex-wrap",children:[g.jsxs("div",{className:"flex-1 relative min-w-[200px]",children:[g.jsx(g_,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),g.jsx("input",{ref:n,type:"text",placeholder:"Search archives... (press /)",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:i,onChange:te=>r(te.target.value)})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ure,{className:"w-4 h-4 text-bambu-gray"}),g.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a||"",onChange:te=>s(te.target.value?Number(te.target.value):null),children:[g.jsx("option",{value:"",children:"All Printers"}),se?.map(te=>g.jsx("option",{value:te.id,children:te.name},te.id))]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(m_,{className:"w-4 h-4 text-bambu-gray"}),g.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:o||"",onChange:te=>l(te.target.value||null),children:[g.jsx("option",{value:"",children:"All Materials"}),re.map(te=>g.jsx("option",{value:te,children:te},te))]})]}),g.jsxs("button",{onClick:()=>_(!m),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${m?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:m?"Show all":"Show favorites only",children:[g.jsx(w0,{className:`w-4 h-4 ${m?"fill-yellow-400":""}`}),g.jsx("span",{className:"text-sm",children:"Favorites"})]}),Pe.length>0&&g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(M0,{className:"w-4 h-4 text-bambu-gray"}),g.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:b||"",onChange:te=>v(te.target.value||null),children:[g.jsx("option",{value:"",children:"All Tags"}),Pe.map(te=>g.jsx("option",{value:te,children:te},te))]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(lie,{className:"w-4 h-4 text-bambu-gray"}),g.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:W,onChange:te=>X(te.target.value),children:[g.jsx("option",{value:"date-desc",children:"Newest first"}),g.jsx("option",{value:"date-asc",children:"Oldest first"}),g.jsx("option",{value:"name-asc",children:"Name A-Z"}),g.jsx("option",{value:"name-desc",children:"Name Z-A"}),g.jsx("option",{value:"size-desc",children:"Largest first"}),g.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),g.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[g.jsx("button",{className:`p-2 ${B==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>q("grid"),title:"Grid view",children:g.jsx(Ere,{className:"w-4 h-4"})}),g.jsx("button",{className:`p-2 ${B==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>q("list"),title:"List view",children:g.jsx(z$,{className:"w-4 h-4"})}),g.jsx("button",{className:`p-2 ${B==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>q("calendar"),title:"Calendar view",children:g.jsx(vie,{className:"w-4 h-4"})})]}),J&&g.jsxs(ot,{variant:"ghost",size:"sm",onClick:ae,className:"text-bambu-gray hover:text-white",children:[g.jsx(Cn,{className:"w-4 h-4"}),"Reset"]})]}),ve.length>0&&g.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[g.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),c.size>1&&g.jsx("button",{onClick:()=>p(te=>te==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${f==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:f==="or"?"Match ANY selected color":"Match ALL selected colors",children:f.toUpperCase()}),g.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ve.map(te=>g.jsx("button",{onClick:()=>F(te),className:`w-6 h-6 rounded-full border-2 transition-all ${c.has(te)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:te},title:te},te))}),c.size>0&&g.jsxs("button",{onClick:$,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[g.jsx(Cn,{className:"w-3 h-3"}),"Clear"]})]})]})}),Y?g.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):pe?.length===0?g.jsx(cn,{children:g.jsxs(gn,{className:"text-center py-12",children:[g.jsx("p",{className:"text-bambu-gray",children:i?"No archives match your search":"No archives yet"}),g.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):B==="calendar"?g.jsx(cn,{className:"p-6",children:g.jsx(Nye,{archives:pe||[],onArchiveClick:te=>{r(te.print_name||te.filename),q("grid")}})}):B==="grid"?g.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:pe?.map(te=>g.jsx(JEe,{archive:te,printerName:te.printer_id?xe.get(te.printer_id)||"Unknown":"No Printer",isSelected:N.has(te.id),onSelect:ze,selectionMode:we},te.id))}):B==="list"?g.jsx(cn,{children:g.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[g.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[g.jsx("div",{className:"col-span-1"}),g.jsx("div",{className:"col-span-4",children:"Name"}),g.jsx("div",{className:"col-span-2",children:"Printer"}),g.jsx("div",{className:"col-span-2",children:"Date"}),g.jsx("div",{className:"col-span-1",children:"Size"}),g.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),pe?.map(te=>g.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${N.has(te.id)?"bg-bambu-green/10":""}`,children:[g.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[we&&g.jsx("button",{onClick:()=>ze(te.id),children:N.has(te.id)?g.jsx(x_,{className:"w-4 h-4 text-bambu-green"}):g.jsx(S0,{className:"w-4 h-4 text-bambu-gray"})}),te.thumbnail_path?g.jsx("img",{src:Ze.getArchiveThumbnail(te.id),alt:"",className:"w-10 h-10 object-cover rounded"}):g.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:g.jsx(bS,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),g.jsxs("div",{className:"col-span-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("p",{className:"text-white text-sm truncate",children:te.print_name||te.filename}),te.timelapse_path&&g.jsx("span",{title:"Has timelapse",children:g.jsx(gp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),te.filament_type&&g.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[g.jsx("span",{className:"text-xs text-bambu-gray",children:te.filament_type}),te.filament_color&&g.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:te.filament_color.split(",").map((j,k)=>g.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:j},title:j},k))})]})]}),g.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:te.printer_id?xe.get(te.printer_id)||"Unknown":"No Printer"}),g.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(te.created_at).toLocaleDateString()}),g.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:O3(te.file_size)}),g.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[g.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>{const j=te.print_name||te.filename||"model",k=`${window.location.origin}${Ze.getArchiveForSlicer(te.id,j)}`;window.location.href=`bambustudioopen://${encodeURIComponent(k)}`},title:"Open in Slicer",children:g.jsx(sc,{className:"w-4 h-4"})}),te.makerworld_url&&g.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>window.open(te.makerworld_url,"_blank"),title:"MakerWorld",children:g.jsx(KC,{className:"w-4 h-4"})}),g.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>{const j=document.createElement("a");j.href=Ze.getArchiveDownload(te.id),j.download=`${te.print_name||te.filename}.3mf`,j.click()},title:"Download",children:g.jsx(Fu,{className:"w-4 h-4"})})]})]},te.id))]})}):null,x&&g.jsx(bye,{onClose:()=>{M(!1),E([])},initialFiles:w}),z&&g.jsx(pa,{title:"Delete Archives",message:`Are you sure you want to delete ${N.size} archive${N.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${N.size}`,variant:"danger",onConfirm:()=>{ue.mutate(Array.from(N)),I(!1)},onCancel:()=>I(!1)}),G&&g.jsx(Mye,{selectedIds:Array.from(N),existingTags:Pe,onClose:()=>L(!1)})]})}function nAe(t){if(!t)return"ASAP";const e=new Date(t),n=new Date,i=e.getTime()-n.getTime();return i<-6e4?"Overdue":i<0?"Now":i<6e4?"In less than a minute":i<36e5?`In ${Math.round(i/6e4)} min`:i<864e5?`In ${Math.round(i/36e5)} hours`:e.toLocaleString()}function iAe({status:t}){const e={pending:{icon:fs,color:"text-yellow-400 bg-yellow-400/10",label:"Pending"},printing:{icon:_S,color:"text-blue-400 bg-blue-400/10",label:"Printing"},completed:{icon:td,color:"text-green-400 bg-green-400/10",label:"Completed"},failed:{icon:px,color:"text-red-400 bg-red-400/10",label:"Failed"},skipped:{icon:G$,color:"text-orange-400 bg-orange-400/10",label:"Skipped"},cancelled:{icon:Cn,color:"text-gray-400 bg-gray-400/10",label:"Cancelled"}},{icon:n,color:i,label:r}=e[t];return g.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium ${i}`,children:[g.jsx(n,{className:"w-3.5 h-3.5"}),r]})}function e2({item:t,onCancel:e,onRemove:n,onStop:i}){const[r,a]=A.useState(!1),[s,o]=A.useState(!1),[l,c]=A.useState(!1);return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex items-center gap-4 p-4 bg-bambu-dark-secondary rounded-lg",children:[t.status==="pending"&&g.jsx(nP,{className:"w-5 h-5 text-bambu-gray cursor-grab"}),g.jsx("div",{className:"w-16 h-16 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?g.jsx("img",{src:Ze.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):g.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:g.jsx($o,{className:"w-6 h-6"})})}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),g.jsx(vS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:g.jsx(sc,{className:"w-3.5 h-3.5"})})]}),g.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-bambu-gray",children:[g.jsxs("span",{className:"flex items-center gap-1",children:[g.jsx(lc,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),g.jsxs("span",{className:"flex items-center gap-1",children:[g.jsx(fs,{className:"w-3.5 h-3.5"}),nAe(t.scheduled_time)]})]}),t.require_previous_success&&g.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Requires previous print to succeed"}),t.auto_off_after&&g.jsxs("p",{className:"text-xs text-blue-400 mt-1 flex items-center gap-1",children:[g.jsx(SS,{className:"w-3 h-3"}),"Will power off when done"]}),t.error_message&&g.jsxs("p",{className:"text-xs text-red-400 mt-1 flex items-center gap-1",children:[g.jsx(ed,{className:"w-3 h-3"}),t.error_message]})]}),g.jsx(iAe,{status:t.status}),g.jsxs("div",{className:"flex items-center gap-2",children:[t.status==="printing"&&g.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Stop Print",className:"text-red-400 hover:text-red-300",children:g.jsx(Die,{className:"w-4 h-4"})}),t.status==="pending"&&g.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>a(!0),title:"Cancel",children:g.jsx(Cn,{className:"w-4 h-4"})}),["completed","failed","skipped","cancelled"].includes(t.status)&&g.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>o(!0),title:"Remove",children:g.jsx(ta,{className:"w-4 h-4"})})]})]}),r&&g.jsx(pa,{title:"Cancel Scheduled Print",message:`Are you sure you want to cancel "${t.archive_name||"this print"}"? It will be removed from the queue.`,confirmText:"Cancel Print",variant:"danger",onConfirm:()=>{e(t.id),a(!1)},onCancel:()=>a(!1)}),s&&g.jsx(pa,{title:"Remove from History",message:`Are you sure you want to remove "${t.archive_name||"this item"}" from the queue history?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{n(t.id),o(!1)},onCancel:()=>o(!1)}),l&&g.jsx(pa,{title:"Stop Print",message:`Are you sure you want to stop the current print "${t.archive_name||"this print"}"? This will cancel the print job on the printer.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{i(t.id),c(!1)},onCancel:()=>c(!1)})]})}function rAe(){const t=ui(),{showToast:e}=_o(),[n,i]=A.useState(null),[r,a]=A.useState(""),{data:s,isLoading:o}=Bt({queryKey:["queue",n,r],queryFn:()=>Ze.getQueue(n||void 0,r||void 0),refetchInterval:1e4}),{data:l}=Bt({queryKey:["printers"],queryFn:()=>Ze.getPrinters()}),c=Ut({mutationFn:b=>Ze.cancelQueueItem(b),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),d=Ut({mutationFn:b=>Ze.removeFromQueue(b),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),f=Ut({mutationFn:b=>Ze.stopQueueItem(b),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),p=s?.filter(b=>b.status==="pending")||[],m=s?.filter(b=>b.status==="printing")||[],_=s?.filter(b=>["completed","failed","skipped","cancelled"].includes(b.status))||[];return g.jsxs("div",{className:"p-8",children:[g.jsx("div",{className:"flex items-center justify-between mb-6",children:g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold text-white",children:"Print Queue"}),g.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage print jobs"})]})}),g.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[g.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:b=>i(b.target.value?Number(b.target.value):null),children:[g.jsx("option",{value:"",children:"All Printers"}),l?.map(b=>g.jsx("option",{value:b.id,children:b.name},b.id))]}),g.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:b=>a(b.target.value),children:[g.jsx("option",{value:"",children:"All Status"}),g.jsx("option",{value:"pending",children:"Pending"}),g.jsx("option",{value:"printing",children:"Printing"}),g.jsx("option",{value:"completed",children:"Completed"}),g.jsx("option",{value:"failed",children:"Failed"}),g.jsx("option",{value:"skipped",children:"Skipped"}),g.jsx("option",{value:"cancelled",children:"Cancelled"})]})]}),o?g.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):s?.length===0?g.jsxs(cn,{className:"p-12 text-center",children:[g.jsx($o,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),g.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No prints scheduled"}),g.jsx("p",{className:"text-bambu-gray",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu.'})]}):g.jsxs("div",{className:"space-y-6",children:[m.length>0&&g.jsxs("div",{children:[g.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[g.jsx(_S,{className:"w-5 h-5 text-blue-400"}),"Currently Printing"]}),g.jsx("div",{className:"space-y-2",children:m.map(b=>g.jsx(e2,{item:b,onCancel:v=>c.mutate(v),onRemove:v=>d.mutate(v),onStop:v=>f.mutate(v)},b.id))})]}),p.length>0&&g.jsxs("div",{children:[g.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[g.jsx(fs,{className:"w-5 h-5 text-yellow-400"}),"Queued (",p.length,")"]}),g.jsx("div",{className:"space-y-2",children:p.map(b=>g.jsx(e2,{item:b,onCancel:v=>c.mutate(v),onRemove:v=>d.mutate(v),onStop:v=>f.mutate(v)},b.id))})]}),_.length>0&&g.jsxs("div",{children:[g.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[g.jsx(td,{className:"w-5 h-5 text-bambu-gray"}),"History (",_.length,")"]}),g.jsx("div",{className:"space-y-2",children:_.slice(0,10).map(b=>g.jsx(e2,{item:b,onCancel:v=>c.mutate(v),onRemove:v=>d.mutate(v),onStop:v=>f.mutate(v)},b.id))})]})]})]})}function aAe({printDates:t,months:e=3}){const{weeks:n,monthLabels:i,printCounts:r}=A.useMemo(()=>{const l={};t.forEach(x=>{const M=x.split("T")[0];l[M]=(l[M]||0)+1});const c=new Date,d=new Date(c);d.setMonth(d.getMonth()-e),d.setDate(d.getDate()-d.getDay());const f=[],p=[];let m=[],_=-1;const b=new Date(d);let v=0;for(;b<=c;)b.getDay()===0&&m.length>0&&(f.push(m),m=[],v++),b.getMonth()!==_&&(p.push({month:b.toLocaleDateString("en-US",{month:"short"}),weekIndex:v}),_=b.getMonth()),m.push(new Date(b)),b.setDate(b.getDate()+1);return m.length>0&&f.push(m),{weeks:f,monthLabels:p,printCounts:l}},[t,e]),a=Math.max(1,...Object.values(r)),s=l=>{if(l===0)return"bg-bambu-dark";const c=l/a;return c<=.25?"bg-bambu-green/30":c<=.5?"bg-bambu-green/50":c<=.75?"bg-bambu-green/75":"bg-bambu-green"},o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return g.jsxs("div",{className:"overflow-x-auto",children:[g.jsx("div",{className:"flex mb-1 ml-8",children:i.map(({month:l,weekIndex:c},d)=>g.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:d===0?0:`${(c-(i[d-1]?.weekIndex||0))*14-24}px`},children:l},d))}),g.jsxs("div",{className:"flex gap-0.5",children:[g.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,c)=>g.jsx("div",{className:"h-3 text-xs text-bambu-gray flex items-center",style:{visibility:c%2===1?"visible":"hidden"},children:l},l))}),n.map((l,c)=>g.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(d=>{const f=l.find(b=>b.getDay()===d);if(!f)return g.jsx("div",{className:"w-3 h-3"},d);const p=f.toISOString().split("T")[0],m=r[p]||0,_=p===new Date().toISOString().split("T")[0];return g.jsx("div",{className:`w-3 h-3 rounded-sm ${s(m)} ${_?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${m} print${m!==1?"s":""}`},d)})},c))]}),g.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[g.jsx("span",{children:"Less"}),g.jsxs("div",{className:"flex gap-0.5",children:[g.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),g.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),g.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),g.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),g.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),g.jsx("span",{children:"More"})]})]})}function eq(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(n=eq(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function Mn(){for(var t,e,n=0,i="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=eq(t))&&(i&&(i+=" "),i+=e);return i}var sAe=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"];function vD(t){if(typeof t!="string")return!1;var e=sAe;return e.includes(t)}var oAe=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],lAe=new Set(oAe);function tq(t){return typeof t!="string"?!1:lAe.has(t)}function nq(t){return typeof t=="string"&&t.startsWith("data-")}function Ua(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(tq(n)||nq(n))&&(e[n]=t[n]);return e}function Nf(t){if(t==null)return null;if(A.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ua(e)}return typeof t=="object"&&!Array.isArray(t)?Ua(t):null}function ya(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(tq(n)||nq(n)||vD(n))&&(e[n]=t[n]);return e}function cAe(t){return t==null?null:A.isValidElement(t)?ya(t.props):typeof t=="object"&&!Array.isArray(t)?ya(t):null}var uAe=["children","width","height","viewBox","className","style","title","desc"];function k3(){return k3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},k3.apply(null,arguments)}function dAe(t,e){if(t==null)return{};var n,i,r=fAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function fAe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var yD=A.forwardRef((t,e)=>{var{children:n,width:i,height:r,viewBox:a,className:s,style:o,title:l,desc:c}=t,d=dAe(t,uAe),f=a||{width:i,height:r,x:0,y:0},p=Mn("recharts-surface",s);return A.createElement("svg",k3({},ya(d),{className:p,width:i,height:r,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),A.createElement("title",null,l),A.createElement("desc",null,c),n)}),hAe=["children","className"];function L3(){return L3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},L3.apply(null,arguments)}function pAe(t,e){if(t==null)return{};var n,i,r=mAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function mAe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var Di=A.forwardRef((t,e)=>{var{children:n,className:i}=t,r=pAe(t,hAe),a=Mn("recharts-layer",i);return A.createElement("g",L3({className:a},ya(r),{ref:e}),n)}),iq=A.createContext(null),gAe=()=>A.useContext(iq);function Yn(t){return function(){return t}}const rq=Math.cos,y1=Math.sin,wo=Math.sqrt,b1=Math.PI,ZS=2*b1,I3=Math.PI,U3=2*I3,Ud=1e-6,xAe=U3-Ud;function aq(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function vAe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return aq;const n=10**e;return function(i){this._+=i[0];for(let r=1,a=i.length;r<a;++r)this._+=Math.round(arguments[r]*n)/n+i[r]}}class yAe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?aq:vAe(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,i,r){this._append`Q${+e},${+n},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(e,n,i,r,a,s){this._append`C${+e},${+n},${+i},${+r},${this._x1=+a},${this._y1=+s}`}arcTo(e,n,i,r,a){if(e=+e,n=+n,i=+i,r=+r,a=+a,a<0)throw new Error(`negative radius: ${a}`);let s=this._x1,o=this._y1,l=i-e,c=r-n,d=s-e,f=o-n,p=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>Ud)if(!(Math.abs(f*l-c*d)>Ud)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=i-s,_=r-o,b=l*l+c*c,v=m*m+_*_,x=Math.sqrt(b),M=Math.sqrt(p),w=a*Math.tan((I3-Math.acos((b+p-v)/(2*x*M)))/2),E=w/M,T=w/x;Math.abs(E-1)>Ud&&this._append`L${e+E*d},${n+E*f}`,this._append`A${a},${a},0,0,${+(f*m>d*_)},${this._x1=e+T*l},${this._y1=n+T*c}`}}arc(e,n,i,r,a,s){if(e=+e,n=+n,i=+i,s=!!s,i<0)throw new Error(`negative radius: ${i}`);let o=i*Math.cos(r),l=i*Math.sin(r),c=e+o,d=n+l,f=1^s,p=s?r-a:a-r;this._x1===null?this._append`M${c},${d}`:(Math.abs(this._x1-c)>Ud||Math.abs(this._y1-d)>Ud)&&this._append`L${c},${d}`,i&&(p<0&&(p=p%U3+U3),p>xAe?this._append`A${i},${i},0,1,${f},${e-o},${n-l}A${i},${i},0,1,${f},${this._x1=c},${this._y1=d}`:p>Ud&&this._append`A${i},${i},0,${+(p>=I3)},${f},${this._x1=e+i*Math.cos(a)},${this._y1=n+i*Math.sin(a)}`)}rect(e,n,i,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}}function bD(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);e=i}return t},()=>new yAe(e)}function _D(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function sq(t){this._context=t}sq.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}};function QS(t){return new sq(t)}function oq(t){return t[0]}function lq(t){return t[1]}function cq(t,e){var n=Yn(!0),i=null,r=QS,a=null,s=bD(o);t=typeof t=="function"?t:t===void 0?oq:Yn(t),e=typeof e=="function"?e:e===void 0?lq:Yn(e);function o(l){var c,d=(l=_D(l)).length,f,p=!1,m;for(i==null&&(a=r(m=s())),c=0;c<=d;++c)!(c<d&&n(f=l[c],c,l))===p&&((p=!p)?a.lineStart():a.lineEnd()),p&&a.point(+t(f,c,l),+e(f,c,l));if(m)return a=null,m+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Yn(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Yn(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Yn(!!l),o):n},o.curve=function(l){return arguments.length?(r=l,i!=null&&(a=r(i)),o):r},o.context=function(l){return arguments.length?(l==null?i=a=null:a=r(i=l),o):i},o}function Sb(t,e,n){var i=null,r=Yn(!0),a=null,s=QS,o=null,l=bD(c);t=typeof t=="function"?t:t===void 0?oq:Yn(+t),e=typeof e=="function"?e:Yn(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?lq:Yn(+n);function c(f){var p,m,_,b=(f=_D(f)).length,v,x=!1,M,w=new Array(b),E=new Array(b);for(a==null&&(o=s(M=l())),p=0;p<=b;++p){if(!(p<b&&r(v=f[p],p,f))===x)if(x=!x)m=p,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),_=p-1;_>=m;--_)o.point(w[_],E[_]);o.lineEnd(),o.areaEnd()}x&&(w[p]=+t(v,p,f),E[p]=+e(v,p,f),o.point(i?+i(v,p,f):w[p],n?+n(v,p,f):E[p]))}if(M)return o=null,M+""||null}function d(){return cq().defined(r).curve(s).context(a)}return c.x=function(f){return arguments.length?(t=typeof f=="function"?f:Yn(+f),i=null,c):t},c.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Yn(+f),c):t},c.x1=function(f){return arguments.length?(i=f==null?null:typeof f=="function"?f:Yn(+f),c):i},c.y=function(f){return arguments.length?(e=typeof f=="function"?f:Yn(+f),n=null,c):e},c.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Yn(+f),c):e},c.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Yn(+f),c):n},c.lineX0=c.lineY0=function(){return d().x(t).y(e)},c.lineY1=function(){return d().x(t).y(n)},c.lineX1=function(){return d().x(i).y(e)},c.defined=function(f){return arguments.length?(r=typeof f=="function"?f:Yn(!!f),c):r},c.curve=function(f){return arguments.length?(s=f,a!=null&&(o=s(a)),c):s},c.context=function(f){return arguments.length?(f==null?a=o=null:o=s(a=f),c):a},c}class uq{constructor(e,n){this._context=e,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,n){switch(e=+e,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,n):this._context.moveTo(e,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,n,e,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,e,this._y0,e,n);break}}this._x0=e,this._y0=n}}function bAe(t){return new uq(t,!0)}function _Ae(t){return new uq(t,!1)}const SD={draw(t,e){const n=wo(e/b1);t.moveTo(n,0),t.arc(0,0,n,0,ZS)}},SAe={draw(t,e){const n=wo(e/5)/2;t.moveTo(-3*n,-n),t.lineTo(-n,-n),t.lineTo(-n,-3*n),t.lineTo(n,-3*n),t.lineTo(n,-n),t.lineTo(3*n,-n),t.lineTo(3*n,n),t.lineTo(n,n),t.lineTo(n,3*n),t.lineTo(-n,3*n),t.lineTo(-n,n),t.lineTo(-3*n,n),t.closePath()}},dq=wo(1/3),wAe=dq*2,MAe={draw(t,e){const n=wo(e/wAe),i=n*dq;t.moveTo(0,-n),t.lineTo(i,0),t.lineTo(0,n),t.lineTo(-i,0),t.closePath()}},EAe={draw(t,e){const n=wo(e),i=-n/2;t.rect(i,i,n,n)}},AAe=.8908130915292852,fq=y1(b1/10)/y1(7*b1/10),TAe=y1(ZS/10)*fq,CAe=-rq(ZS/10)*fq,NAe={draw(t,e){const n=wo(e*AAe),i=TAe*n,r=CAe*n;t.moveTo(0,-n),t.lineTo(i,r);for(let a=1;a<5;++a){const s=ZS*a/5,o=rq(s),l=y1(s);t.lineTo(l*n,-o*n),t.lineTo(o*i-l*r,l*i+o*r)}t.closePath()}},t2=wo(3),RAe={draw(t,e){const n=-wo(e/(t2*3));t.moveTo(0,n*2),t.lineTo(-t2*n,-n),t.lineTo(t2*n,-n),t.closePath()}},Ms=-.5,Es=wo(3)/2,j3=1/wo(12),PAe=(j3/2+1)*3,DAe={draw(t,e){const n=wo(e/PAe),i=n/2,r=n*j3,a=i,s=n*j3+n,o=-a,l=s;t.moveTo(i,r),t.lineTo(a,s),t.lineTo(o,l),t.lineTo(Ms*i-Es*r,Es*i+Ms*r),t.lineTo(Ms*a-Es*s,Es*a+Ms*s),t.lineTo(Ms*o-Es*l,Es*o+Ms*l),t.lineTo(Ms*i+Es*r,Ms*r-Es*i),t.lineTo(Ms*a+Es*s,Ms*s-Es*a),t.lineTo(Ms*o+Es*l,Ms*l-Es*o),t.closePath()}};function OAe(t,e){let n=null,i=bD(r);t=typeof t=="function"?t:Yn(t||SD),e=typeof e=="function"?e:Yn(e===void 0?64:+e);function r(){let a;if(n||(n=a=i()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return r.type=function(a){return arguments.length?(t=typeof a=="function"?a:Yn(a),r):t},r.size=function(a){return arguments.length?(e=typeof a=="function"?a:Yn(+a),r):e},r.context=function(a){return arguments.length?(n=a??null,r):n},r}function _1(){}function S1(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6)}function hq(t){this._context=t}hq.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:S1(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:S1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function kAe(t){return new hq(t)}function pq(t){this._context=t}pq.prototype={areaStart:_1,areaEnd:_1,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:S1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function LAe(t){return new pq(t)}function mq(t){this._context=t}mq.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,i=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,i):this._context.moveTo(n,i);break;case 3:this._point=4;default:S1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function IAe(t){return new mq(t)}function gq(t){this._context=t}gq.prototype={areaStart:_1,areaEnd:_1,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}};function UAe(t){return new gq(t)}function SB(t){return t<0?-1:1}function wB(t,e,n){var i=t._x1-t._x0,r=e-t._x1,a=(t._y1-t._y0)/(i||r<0&&-0),s=(n-t._y1)/(r||i<0&&-0),o=(a*r+s*i)/(i+r);return(SB(a)+SB(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function MB(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function n2(t,e,n){var i=t._x0,r=t._y0,a=t._x1,s=t._y1,o=(a-i)/3;t._context.bezierCurveTo(i+o,r+o*e,a-o,s-o*n,a,s)}function w1(t){this._context=t}w1.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:n2(this,this._t0,MB(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(t=+t,e=+e,!(t===this._x1&&e===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,n2(this,MB(this,n=wB(this,t,e)),n);break;default:n2(this,this._t0,n=wB(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function xq(t){this._context=new vq(t)}(xq.prototype=Object.create(w1.prototype)).point=function(t,e){w1.prototype.point.call(this,e,t)};function vq(t){this._context=t}vq.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,i,r,a){this._context.bezierCurveTo(e,t,i,n,a,r)}};function jAe(t){return new w1(t)}function FAe(t){return new xq(t)}function yq(t){this._context=t}yq.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),n===2)this._context.lineTo(t[1],e[1]);else for(var i=EB(t),r=EB(e),a=0,s=1;s<n;++a,++s)this._context.bezierCurveTo(i[0][a],r[0][a],i[1][a],r[1][a],t[s],e[s]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function EB(t){var e,n=t.length-1,i,r=new Array(n),a=new Array(n),s=new Array(n);for(r[0]=0,a[0]=2,s[0]=t[0]+2*t[1],e=1;e<n-1;++e)r[e]=1,a[e]=4,s[e]=4*t[e]+2*t[e+1];for(r[n-1]=2,a[n-1]=7,s[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)i=r[e]/a[e-1],a[e]-=i,s[e]-=i*s[e-1];for(r[n-1]=s[n-1]/a[n-1],e=n-2;e>=0;--e)r[e]=(s[e]-r[e+1])/a[e];for(a[n-1]=(t[n]+r[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-r[e+1];return[r,a]}function zAe(t){return new yq(t)}function JS(t,e){this._context=t,this._t=e}JS.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}break}}this._x=t,this._y=e}};function BAe(t){return new JS(t,.5)}function HAe(t){return new JS(t,0)}function VAe(t){return new JS(t,1)}function Wp(t,e){if((s=t.length)>1)for(var n=1,i,r,a=t[e[0]],s,o=a.length;n<s;++n)for(r=a,a=t[e[n]],i=0;i<o;++i)a[i][1]+=a[i][0]=isNaN(r[i][1])?r[i][0]:r[i][1]}function F3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function $Ae(t,e){return t[e]}function GAe(t){const e=[];return e.key=t,e}function WAe(){var t=Yn([]),e=F3,n=Wp,i=$Ae;function r(a){var s=Array.from(t.apply(this,arguments),GAe),o,l=s.length,c=-1,d;for(const f of a)for(o=0,++c;o<l;++o)(s[o][c]=[0,+i(f,s[o].key,c,a)]).data=f;for(o=0,d=_D(e(s));o<l;++o)s[d[o]].index=o;return n(s,d),s}return r.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Yn(Array.from(a)),r):t},r.value=function(a){return arguments.length?(i=typeof a=="function"?a:Yn(+a),r):i},r.order=function(a){return arguments.length?(e=a==null?F3:typeof a=="function"?a:Yn(Array.from(a)),r):e},r.offset=function(a){return arguments.length?(n=a??Wp,r):n},r}function qAe(t,e){if((i=t.length)>0){for(var n,i,r=0,a=t[0].length,s;r<a;++r){for(s=n=0;n<i;++n)s+=t[n][r][1]||0;if(s)for(n=0;n<i;++n)t[n][r][1]/=s}Wp(t,e)}}function XAe(t,e){if((r=t.length)>0){for(var n=0,i=t[e[0]],r,a=i.length;n<a;++n){for(var s=0,o=0;s<r;++s)o+=t[s][n][1]||0;i[n][1]+=i[n][0]=-o/2}Wp(t,e)}}function KAe(t,e){if(!(!((s=t.length)>0)||!((a=(r=t[e[0]]).length)>0))){for(var n=0,i=1,r,a,s;i<a;++i){for(var o=0,l=0,c=0;o<s;++o){for(var d=t[e[o]],f=d[i][1]||0,p=d[i-1][1]||0,m=(f-p)/2,_=0;_<o;++_){var b=t[e[_]],v=b[i][1]||0,x=b[i-1][1]||0;m+=v-x}l+=f,c+=m*f}r[i-1][1]+=r[i-1][0]=n,l&&(n-=c/l)}r[i-1][1]+=r[i-1][0]=n,Wp(t,e)}}var i2={},r2={},AB;function YAe(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(r2)),r2}var a2={},TB;function bq(){return TB||(TB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){switch(typeof n){case"number":case"symbol":return!1;case"string":return n.includes(".")||n.includes("[")||n.includes("]")}}t.isDeepKey=e})(a2)),a2}var s2={},CB;function wD(){return CB||(CB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="string"||typeof n=="symbol"?n:Object.is(n?.valueOf?.(),-0)?"-0":String(n)}t.toKey=e})(s2)),s2}var o2={},l2={},NB;function ZAe(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(n==null)return"";if(typeof n=="string")return n;if(Array.isArray(n))return n.map(e).join(",");const i=String(n);return i==="0"&&Object.is(Number(n),-0)?"-0":i}t.toString=e})(l2)),l2}var RB;function MD(){return RB||(RB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZAe(),n=wD();function i(r){if(Array.isArray(r))return r.map(n.toKey);if(typeof r=="symbol")return[r];r=e.toString(r);const a=[],s=r.length;if(s===0)return a;let o=0,l="",c="",d=!1;for(r.charCodeAt(0)===46&&(a.push(""),o++);o<s;){const f=r[o];c?f==="\\"&&o+1<s?(o++,l+=r[o]):f===c?c="":l+=f:d?f==='"'||f==="'"?c=f:f==="]"?(d=!1,a.push(l),l=""):l+=f:f==="["?(d=!0,l&&(a.push(l),l="")):f==="."?l&&(a.push(l),l=""):l+=f,o++}return l&&a.push(l),a}t.toPath=i})(o2)),o2}var PB;function ED(){return PB||(PB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YAe(),n=bq(),i=wD(),r=MD();function a(o,l,c){if(o==null)return c;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return c;const d=o[l];return d===void 0?n.isDeepKey(l)?a(o,r.toPath(l),c):c:d}case"number":case"symbol":{typeof l=="number"&&(l=i.toKey(l));const d=o[l];return d===void 0?c:d}default:{if(Array.isArray(l))return s(o,l,c);if(Object.is(l?.valueOf(),-0)?l="-0":l=String(l),e.isUnsafeProperty(l))return c;const d=o[l];return d===void 0?c:d}}}function s(o,l,c){if(l.length===0)return c;let d=o;for(let f=0;f<l.length;f++){if(d==null||e.isUnsafeProperty(l[f]))return c;d=d[l[f]]}return d===void 0?c:d}t.get=a})(i2)),i2}var c2,DB;function QAe(){return DB||(DB=1,c2=ED().get),c2}var JAe=QAe();const Rf=qs(JAe);var Mr=t=>t===0?0:t>0?1:-1,$s=t=>typeof t=="number"&&t!=+t,dc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Et=t=>(typeof t=="number"||t instanceof Number)&&!$s(t),Ko=t=>Et(t)||typeof t=="string",eTe=0,W0=t=>{var e=++eTe;return"".concat(t||"").concat(e)},na=function(e,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Et(e)&&typeof e!="string")return i;var a;if(dc(e)){if(n==null)return i;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return $s(a)&&(a=i),r&&n!=null&&a>n&&(a=n),a},_q=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},i=0;i<e;i++)if(!n[t[i]])n[t[i]]=!0;else return!0;return!1};function ri(t,e,n){return Et(t)&&Et(e)?t+n*(e-t):e}function Sq(t,e,n){if(!(!t||!t.length))return t.find(i=>i&&(typeof e=="function"?e(i):Rf(i,e))===n)}var mi=t=>t===null||typeof t>"u",Mx=t=>mi(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function tTe(t){return t!=null}function Ex(){}var nTe=["type","size","sizeType"];function z3(){return z3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},z3.apply(null,arguments)}function OB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function kB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OB(Object(n),!0).forEach(function(i){iTe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OB(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function iTe(t,e,n){return(e=rTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rTe(t){var e=aTe(t,"string");return typeof e=="symbol"?e:e+""}function aTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function sTe(t,e){if(t==null)return{};var n,i,r=oTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function oTe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var wq={symbolCircle:SD,symbolCross:SAe,symbolDiamond:MAe,symbolSquare:EAe,symbolStar:NAe,symbolTriangle:RAe,symbolWye:DAe},lTe=Math.PI/180,cTe=t=>{var e="symbol".concat(Mx(t));return wq[e]||SD},uTe=(t,e,n)=>{if(e==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var i=18*lTe;return 1.25*t*t*(Math.tan(i)-Math.tan(i*2)*Math.tan(i)**2)}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},dTe=(t,e)=>{wq["symbol".concat(Mx(t))]=e},AD=t=>{var{type:e="circle",size:n=64,sizeType:i="area"}=t,r=sTe(t,nTe),a=kB(kB({},r),{},{type:e,size:n,sizeType:i}),s="circle";typeof e=="string"&&(s=e);var o=()=>{var p=cTe(s),m=OAe().type(p).size(uTe(n,i,s)),_=m();if(_!==null)return _},{className:l,cx:c,cy:d}=a,f=ya(a);return Et(c)&&Et(d)&&Et(n)?A.createElement("path",z3({},f,{className:Mn("recharts-symbols",l),transform:"translate(".concat(c,", ").concat(d,")"),d:o()})):null};AD.registerSymbol=dTe;var Mq=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,TD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(A.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var i={};return Object.keys(n).forEach(r=>{vD(r)&&(i[r]=(a=>n[r](n,a)))}),i},fTe=(t,e,n)=>i=>(t(e,n,i),null),Ax=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var i=null;return Object.keys(t).forEach(r=>{var a=t[r];vD(r)&&typeof a=="function"&&(i||(i={}),i[r]=fTe(a,e,n))}),i};function LB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function hTe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LB(Object(n),!0).forEach(function(i){pTe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LB(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function pTe(t,e,n){return(e=mTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mTe(t){var e=gTe(t,"string");return typeof e=="symbol"?e:e+""}function gTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xi(t,e){var n=hTe({},t),i=e,r=Object.keys(e),a=r.reduce((s,o)=>(s[o]===void 0&&i[o]!==void 0&&(s[o]=i[o]),s),n);return a}function M1(){return M1=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},M1.apply(null,arguments)}function IB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function xTe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IB(Object(n),!0).forEach(function(i){vTe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IB(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function vTe(t,e,n){return(e=yTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yTe(t){var e=bTe(t,"string");return typeof e=="symbol"?e:e+""}function bTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Cs=32,_Te={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function STe(t){var{data:e,iconType:n,inactiveColor:i}=t,r=Cs/2,a=Cs/6,s=Cs/3,o=e.inactive?i:e.color,l=n??e.type;if(l==="none")return null;if(l==="plainline"){var c;return A.createElement("line",{strokeWidth:4,fill:"none",stroke:o,strokeDasharray:(c=e.payload)===null||c===void 0?void 0:c.strokeDasharray,x1:0,y1:r,x2:Cs,y2:r,className:"recharts-legend-icon"})}if(l==="line")return A.createElement("path",{strokeWidth:4,fill:"none",stroke:o,d:"M0,".concat(r,"h").concat(s,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*s,",").concat(r,`
- H`).concat(Cs,"M").concat(2*s,",").concat(r,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(s,",").concat(r),className:"recharts-legend-icon"});if(l==="rect")return A.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Cs/8,"h").concat(Cs,"v").concat(Cs*3/4,"h").concat(-Cs,"z"),className:"recharts-legend-icon"});if(A.isValidElement(e.legendIcon)){var d=xTe({},e);return delete d.legendIcon,A.cloneElement(e.legendIcon,d)}return A.createElement(AD,{fill:o,cx:r,cy:r,size:Cs,sizeType:"diameter",type:l})}function wTe(t){var{payload:e,iconSize:n,layout:i,formatter:r,inactiveColor:a,iconType:s}=t,o={x:0,y:0,width:Cs,height:Cs},l={display:i==="horizontal"?"inline-block":"block",marginRight:10},c={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var p=d.formatter||r,m=Mn({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var _=d.inactive?a:d.color,b=p?p(d.value,d,f):d.value;return A.createElement("li",M1({className:m,style:l,key:"legend-item-".concat(f)},Ax(t,d,f)),A.createElement(yD,{width:n,height:n,viewBox:o,style:c,"aria-label":"".concat(b," legend icon")},A.createElement(STe,{data:d,iconType:s,inactiveColor:a})),A.createElement("span",{className:"recharts-legend-item-text",style:{color:_}},b))})}var MTe=t=>{var e=Xi(t,_Te),{payload:n,layout:i,align:r}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:i==="horizontal"?r:"left"};return A.createElement("ul",{className:"recharts-default-legend",style:a},A.createElement(wTe,M1({},e,{payload:n})))},u2={},d2={},UB;function ETe(){return UB||(UB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,i){const r=new Map;for(let a=0;a<n.length;a++){const s=n[a],o=i(s);r.has(o)||r.set(o,s)}return Array.from(r.values())}t.uniqBy=e})(d2)),d2}var f2={},jB;function Eq(){return jB||(jB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(f2)),f2}var h2={},p2={},m2={},FB;function ATe(){return FB||(FB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(m2)),m2}var zB;function CD(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ATe();function n(i){return i!=null&&typeof i!="function"&&e.isLength(i.length)}t.isArrayLike=n})(p2)),p2}var g2={},BB;function TTe(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(g2)),g2}var HB;function CTe(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CD(),n=TTe();function i(r){return n.isObjectLike(r)&&e.isArrayLike(r)}t.isArrayLikeObject=i})(h2)),h2}var x2={},v2={},VB;function NTe(){return VB||(VB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ED();function n(i){return function(r){return e.get(r,i)}}t.property=n})(v2)),v2}var y2={},b2={},_2={},S2={},$B;function Aq(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(S2)),S2}var w2={},GB;function Tq(){return GB||(GB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null||typeof n!="object"&&typeof n!="function"}t.isPrimitive=e})(w2)),w2}var M2={},WB;function Cq(){return WB||(WB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,i){return n===i||Number.isNaN(n)&&Number.isNaN(i)}t.eq=e})(M2)),M2}var qB;function RTe(){return qB||(qB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Aq(),n=Tq(),i=Cq();function r(d,f,p){return typeof p!="function"?r(d,f,()=>{}):a(d,f,function m(_,b,v,x,M,w){const E=p(_,b,v,x,M,w);return E!==void 0?!!E:a(_,b,m,w)},new Map)}function a(d,f,p,m){if(f===d)return!0;switch(typeof f){case"object":return s(d,f,p,m);case"function":return Object.keys(f).length>0?a(d,{...f},p,m):i.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:i.eq(d,f)}}function s(d,f,p,m){if(f==null)return!0;if(Array.isArray(f))return l(d,f,p,m);if(f instanceof Map)return o(d,f,p,m);if(f instanceof Set)return c(d,f,p,m);const _=Object.keys(f);if(d==null)return _.length===0;if(_.length===0)return!0;if(m?.has(f))return m.get(f)===d;m?.set(f,d);try{for(let b=0;b<_.length;b++){const v=_[b];if(!n.isPrimitive(d)&&!(v in d)||f[v]===void 0&&d[v]!==void 0||f[v]===null&&d[v]!==null||!p(d[v],f[v],v,d,f,m))return!1}return!0}finally{m?.delete(f)}}function o(d,f,p,m){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[_,b]of f.entries()){const v=d.get(_);if(p(v,b,_,d,f,m)===!1)return!1}return!0}function l(d,f,p,m){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const _=new Set;for(let b=0;b<f.length;b++){const v=f[b];let x=!1;for(let M=0;M<d.length;M++){if(_.has(M))continue;const w=d[M];let E=!1;if(p(w,v,b,d,f,m)&&(E=!0),E){_.add(M),x=!0;break}}if(!x)return!1}return!0}function c(d,f,p,m){return f.size===0?!0:d instanceof Set?l([...d],[...f],p,m):!1}t.isMatchWith=r,t.isSetMatch=c})(_2)),_2}var XB;function Nq(){return XB||(XB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RTe();function n(i,r){return e.isMatchWith(i,r,()=>{})}t.isMatch=n})(b2)),b2}var E2={},A2={},T2={},KB;function PTe(){return KB||(KB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Object.getOwnPropertySymbols(n).filter(i=>Object.prototype.propertyIsEnumerable.call(n,i))}t.getSymbols=e})(T2)),T2}var C2={},YB;function Rq(){return YB||(YB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}t.getTag=e})(C2)),C2}var N2={},ZB;function Pq(){return ZB||(ZB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",i="[object Number]",r="[object Boolean]",a="[object Arguments]",s="[object Symbol]",o="[object Date]",l="[object Map]",c="[object Set]",d="[object Array]",f="[object Function]",p="[object ArrayBuffer]",m="[object Object]",_="[object Error]",b="[object DataView]",v="[object Uint8Array]",x="[object Uint8ClampedArray]",M="[object Uint16Array]",w="[object Uint32Array]",E="[object BigUint64Array]",T="[object Int8Array]",P="[object Int16Array]",N="[object Int32Array]",U="[object BigInt64Array]",R="[object Float32Array]",O="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=U,t.bigUint64ArrayTag=E,t.booleanTag=r,t.dataViewTag=b,t.dateTag=o,t.errorTag=_,t.float32ArrayTag=R,t.float64ArrayTag=O,t.functionTag=f,t.int16ArrayTag=P,t.int32ArrayTag=N,t.int8ArrayTag=T,t.mapTag=l,t.numberTag=i,t.objectTag=m,t.regexpTag=e,t.setTag=c,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=M,t.uint32ArrayTag=w,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=x})(N2)),N2}var R2={},QB;function DTe(){return QB||(QB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(R2)),R2}var JB;function Dq(){return JB||(JB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=PTe(),n=Rq(),i=Pq(),r=Tq(),a=DTe();function s(d,f){return o(d,void 0,d,new Map,f)}function o(d,f,p,m=new Map,_=void 0){const b=_?.(d,f,p,m);if(b!==void 0)return b;if(r.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const v=new Array(d.length);m.set(d,v);for(let x=0;x<d.length;x++)v[x]=o(d[x],x,p,m,_);return Object.hasOwn(d,"index")&&(v.index=d.index),Object.hasOwn(d,"input")&&(v.input=d.input),v}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const v=new RegExp(d.source,d.flags);return v.lastIndex=d.lastIndex,v}if(d instanceof Map){const v=new Map;m.set(d,v);for(const[x,M]of d)v.set(x,o(M,x,p,m,_));return v}if(d instanceof Set){const v=new Set;m.set(d,v);for(const x of d)v.add(o(x,void 0,p,m,_));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const v=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,v);for(let x=0;x<d.length;x++)v[x]=o(d[x],x,p,m,_);return v}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const v=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,v),l(v,d,p,m,_),v}if(typeof File<"u"&&d instanceof File){const v=new File([d],d.name,{type:d.type});return m.set(d,v),l(v,d,p,m,_),v}if(typeof Blob<"u"&&d instanceof Blob){const v=new Blob([d],{type:d.type});return m.set(d,v),l(v,d,p,m,_),v}if(d instanceof Error){const v=new d.constructor;return m.set(d,v),v.message=d.message,v.name=d.name,v.stack=d.stack,v.cause=d.cause,l(v,d,p,m,_),v}if(d instanceof Boolean){const v=new Boolean(d.valueOf());return m.set(d,v),l(v,d,p,m,_),v}if(d instanceof Number){const v=new Number(d.valueOf());return m.set(d,v),l(v,d,p,m,_),v}if(d instanceof String){const v=new String(d.valueOf());return m.set(d,v),l(v,d,p,m,_),v}if(typeof d=="object"&&c(d)){const v=Object.create(Object.getPrototypeOf(d));return m.set(d,v),l(v,d,p,m,_),v}return d}function l(d,f,p=d,m,_){const b=[...Object.keys(f),...e.getSymbols(f)];for(let v=0;v<b.length;v++){const x=b[v],M=Object.getOwnPropertyDescriptor(d,x);(M==null||M.writable)&&(d[x]=o(f[x],x,p,m,_))}}function c(d){switch(n.getTag(d)){case i.argumentsTag:case i.arrayTag:case i.arrayBufferTag:case i.dataViewTag:case i.booleanTag:case i.dateTag:case i.float32ArrayTag:case i.float64ArrayTag:case i.int8ArrayTag:case i.int16ArrayTag:case i.int32ArrayTag:case i.mapTag:case i.numberTag:case i.objectTag:case i.regexpTag:case i.setTag:case i.stringTag:case i.symbolTag:case i.uint8ArrayTag:case i.uint8ClampedArrayTag:case i.uint16ArrayTag:case i.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=s,t.cloneDeepWithImpl=o,t.copyProperties=l})(A2)),A2}var eH;function OTe(){return eH||(eH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dq();function n(i){return e.cloneDeepWithImpl(i,void 0,i,new Map,void 0)}t.cloneDeep=n})(E2)),E2}var tH;function kTe(){return tH||(tH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Nq(),n=OTe();function i(r){return r=n.cloneDeep(r),a=>e.isMatch(a,r)}t.matches=i})(y2)),y2}var P2={},D2={},O2={},nH;function LTe(){return nH||(nH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dq(),n=Pq();function i(r,a){return e.cloneDeepWith(r,(s,o,l,c)=>{const d=a?.(s,o,l,c);if(d!==void 0)return d;if(typeof r=="object")switch(Object.prototype.toString.call(r)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new r.constructor(r?.valueOf());return e.copyProperties(f,r),f}case n.argumentsTag:{const f={};return e.copyProperties(f,r),f.length=r.length,f[Symbol.iterator]=r[Symbol.iterator],f}default:return}})}t.cloneDeepWith=i})(O2)),O2}var iH;function ITe(){return iH||(iH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=LTe();function n(i){return e.cloneDeepWith(i)}t.cloneDeep=n})(D2)),D2}var k2={},L2={},rH;function Oq(){return rH||(rH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(i,r=Number.MAX_SAFE_INTEGER){switch(typeof i){case"number":return Number.isInteger(i)&&i>=0&&i<r;case"symbol":return!1;case"string":return e.test(i)}}t.isIndex=n})(L2)),L2}var I2={},aH;function UTe(){return aH||(aH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rq();function n(i){return i!==null&&typeof i=="object"&&e.getTag(i)==="[object Arguments]"}t.isArguments=n})(I2)),I2}var sH;function jTe(){return sH||(sH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bq(),n=Oq(),i=UTe(),r=MD();function a(s,o){let l;if(Array.isArray(o)?l=o:typeof o=="string"&&e.isDeepKey(o)&&s?.[o]==null?l=r.toPath(o):l=[o],l.length===0)return!1;let c=s;for(let d=0;d<l.length;d++){const f=l[d];if((c==null||!Object.hasOwn(c,f))&&!((Array.isArray(c)||i.isArguments(c))&&n.isIndex(f)&&f<c.length))return!1;c=c[f]}return!0}t.has=a})(k2)),k2}var oH;function FTe(){return oH||(oH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Nq(),n=wD(),i=ITe(),r=ED(),a=jTe();function s(o,l){switch(typeof o){case"object":{Object.is(o?.valueOf(),-0)&&(o="-0");break}case"number":{o=n.toKey(o);break}}return l=i.cloneDeep(l),function(c){const d=r.get(c,o);return d===void 0?a.has(c,o):l===void 0?d===void 0:e.isMatch(d,l)}}t.matchesProperty=s})(P2)),P2}var lH;function zTe(){return lH||(lH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Eq(),n=NTe(),i=kTe(),r=FTe();function a(s){if(s==null)return e.identity;switch(typeof s){case"function":return s;case"object":return Array.isArray(s)&&s.length===2?r.matchesProperty(s[0],s[1]):i.matches(s);case"string":case"symbol":case"number":return n.property(s)}}t.iteratee=a})(x2)),x2}var cH;function BTe(){return cH||(cH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ETe(),n=Eq(),i=CTe(),r=zTe();function a(s,o=n.identity){return i.isArrayLikeObject(s)?e.uniqBy(Array.from(s),r.iteratee(o)):[]}t.uniqBy=a})(u2)),u2}var U2,uH;function HTe(){return uH||(uH=1,U2=BTe().uniqBy),U2}var VTe=HTe();const dH=qs(VTe);function kq(t,e,n){return e===!0?dH(t,n):typeof e=="function"?dH(t,e):t}var ND=A.createContext(null),$Te=t=>t,Qn=()=>{var t=A.useContext(ND);return t?t.store.dispatch:$Te},a_=()=>{},GTe=()=>a_,WTe=(t,e)=>t===e;function At(t){var e=A.useContext(ND);return w7.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:GTe,e?e.store.getState:a_,e?e.store.getState:a_,e?t:a_,WTe)}function qTe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function XTe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function KTe(t,e="expected all items to be functions, instead received the following types: "){if(!t.every(n=>typeof n=="function")){const n=t.map(i=>typeof i=="function"?`function ${i.name||"unnamed"}()`:typeof i).join(", ");throw new TypeError(`${e}[${n}]`)}}var fH=t=>Array.isArray(t)?t:[t];function YTe(t){const e=Array.isArray(t[0])?t[0]:t;return KTe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function ZTe(t,e){const n=[],{length:i}=t;for(let r=0;r<i;r++)n.push(t[r].apply(null,e));return n}var QTe=class{constructor(t){this.value=t}deref(){return this.value}},JTe=typeof WeakRef<"u"?WeakRef:QTe,e2e=0,hH=1;function wb(){return{s:e2e,v:void 0,o:null,p:null}}function Lq(t,e={}){let n=wb();const{resultEqualityCheck:i}=e;let r,a=0;function s(){let o=n;const{length:l}=arguments;for(let f=0,p=l;f<p;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let _=o.o;_===null&&(o.o=_=new WeakMap);const b=_.get(m);b===void 0?(o=wb(),_.set(m,o)):o=b}else{let _=o.p;_===null&&(o.p=_=new Map);const b=_.get(m);b===void 0?(o=wb(),_.set(m,o)):o=b}}const c=o;let d;if(o.s===hH)d=o.v;else if(d=t.apply(null,arguments),a++,i){const f=r?.deref?.()??r;f!=null&&i(f,d)&&(d=f,a!==0&&a--),r=typeof d=="object"&&d!==null||typeof d=="function"?new JTe(d):d}return c.s=hH,c.v=d,d}return s.clearCache=()=>{n=wb(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function t2e(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,i=(...r)=>{let a=0,s=0,o,l={},c=r.pop();typeof c=="object"&&(l=c,c=r.pop()),qTe(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const d={...n,...l},{memoize:f,memoizeOptions:p=[],argsMemoize:m=Lq,argsMemoizeOptions:_=[]}=d,b=fH(p),v=fH(_),x=YTe(r),M=f(function(){return a++,c.apply(null,arguments)},...b),w=m(function(){s++;const T=ZTe(x,arguments);return o=M.apply(null,T),o},...v);return Object.assign(w,{resultFunc:c,memoizedResultFunc:M,dependencies:x,dependencyRecomputations:()=>s,resetDependencyRecomputations:()=>{s=0},lastResult:()=>o,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:m})};return Object.assign(i,{withTypes:()=>i}),i}var He=t2e(Lq),n2e=Object.assign((t,e=He)=>{XTe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),i=n.map(a=>t[a]);return e(i,(...a)=>a.reduce((s,o,l)=>(s[n[l]]=o,s),{}))},{withTypes:()=>n2e}),j2={},F2={},z2={},pH;function i2e(){return pH||(pH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(i){return typeof i=="symbol"?1:i===null?2:i===void 0?3:i!==i?4:0}const n=(i,r,a)=>{if(i!==r){const s=e(i),o=e(r);if(s===o&&s===0){if(i<r)return a==="desc"?1:-1;if(i>r)return a==="desc"?-1:1}return a==="desc"?o-s:s-o}return 0};t.compareValues=n})(z2)),z2}var B2={},H2={},mH;function Iq(){return mH||(mH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(H2)),H2}var gH;function r2e(){return gH||(gH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Iq(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function r(a,s){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(i.test(a)||!n.test(a))||s!=null&&Object.hasOwn(s,a)}t.isKey=r})(B2)),B2}var xH;function a2e(){return xH||(xH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=i2e(),n=r2e(),i=MD();function r(a,s,o,l){if(a==null)return[];o=l?void 0:o,Array.isArray(a)||(a=Object.values(a)),Array.isArray(s)||(s=s==null?[null]:[s]),s.length===0&&(s=[null]),Array.isArray(o)||(o=o==null?[]:[o]),o=o.map(m=>String(m));const c=(m,_)=>{let b=m;for(let v=0;v<_.length&&b!=null;++v)b=b[_[v]];return b},d=(m,_)=>_==null||m==null?_:typeof m=="object"&&"key"in m?Object.hasOwn(_,m.key)?_[m.key]:c(_,m.path):typeof m=="function"?m(_):Array.isArray(m)?c(_,m):typeof _=="object"?_[m]:_,f=s.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:i.toPath(m)}));return a.map(m=>({original:m,criteria:f.map(_=>d(_,m))})).slice().sort((m,_)=>{for(let b=0;b<f.length;b++){const v=e.compareValues(m.criteria[b],_.criteria[b],o[b]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=r})(F2)),F2}var V2={},vH;function s2e(){return vH||(vH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,i=1){const r=[],a=Math.floor(i),s=(o,l)=>{for(let c=0;c<o.length;c++){const d=o[c];Array.isArray(d)&&l<a?s(d,l+1):r.push(d)}};return s(n,0),r}t.flatten=e})(V2)),V2}var $2={},yH;function Uq(){return yH||(yH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Oq(),n=CD(),i=Aq(),r=Cq();function a(s,o,l){return i.isObject(l)&&(typeof o=="number"&&n.isArrayLike(l)&&e.isIndex(o)&&o<l.length||typeof o=="string"&&o in l)?r.eq(l[o],s):!1}t.isIterateeCall=a})($2)),$2}var bH;function o2e(){return bH||(bH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=a2e(),n=s2e(),i=Uq();function r(a,...s){const o=s.length;return o>1&&i.isIterateeCall(a,s[0],s[1])?s=[]:o>2&&i.isIterateeCall(s[0],s[1],s[2])&&(s=[s[0]]),e.orderBy(a,n.flatten(s),["asc"])}t.sortBy=r})(j2)),j2}var G2,_H;function l2e(){return _H||(_H=1,G2=o2e().sortBy),G2}var c2e=l2e();const ew=qs(c2e);var jq=t=>t.legend.settings,u2e=t=>t.legend.size,d2e=t=>t.legend.payload,f2e=He([d2e,jq],(t,e)=>{var{itemSorter:n}=e,i=t.flat(1);return n?ew(i,n):i});function h2e(){return At(f2e)}var Mb=1;function Fq(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=A.useState({height:0,left:0,top:0,width:0}),i=A.useCallback(r=>{if(r!=null){var a=r.getBoundingClientRect(),s={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(s.height-e.height)>Mb||Math.abs(s.left-e.left)>Mb||Math.abs(s.top-e.top)>Mb||Math.abs(s.width-e.width)>Mb)&&n({height:s.height,left:s.left,top:s.top,width:s.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,i]}function Ur(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var p2e=typeof Symbol=="function"&&Symbol.observable||"@@observable",SH=p2e,W2=()=>Math.random().toString(36).substring(7).split("").join("."),m2e={INIT:`@@redux/INIT${W2()}`,REPLACE:`@@redux/REPLACE${W2()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${W2()}`},E1=m2e;function RD(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function zq(t,e,n){if(typeof t!="function")throw new Error(Ur(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Ur(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Ur(1));return n(zq)(t,e)}let i=t,r=e,a=new Map,s=a,o=0,l=!1;function c(){s===a&&(s=new Map,a.forEach((v,x)=>{s.set(x,v)}))}function d(){if(l)throw new Error(Ur(3));return r}function f(v){if(typeof v!="function")throw new Error(Ur(4));if(l)throw new Error(Ur(5));let x=!0;c();const M=o++;return s.set(M,v),function(){if(x){if(l)throw new Error(Ur(6));x=!1,c(),s.delete(M),a=null}}}function p(v){if(!RD(v))throw new Error(Ur(7));if(typeof v.type>"u")throw new Error(Ur(8));if(typeof v.type!="string")throw new Error(Ur(17));if(l)throw new Error(Ur(9));try{l=!0,r=i(r,v)}finally{l=!1}return(a=s).forEach(M=>{M()}),v}function m(v){if(typeof v!="function")throw new Error(Ur(10));i=v,p({type:E1.REPLACE})}function _(){const v=f;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(Ur(11));function M(){const E=x;E.next&&E.next(d())}return M(),{unsubscribe:v(M)}},[SH](){return this}}}return p({type:E1.INIT}),{dispatch:p,subscribe:f,getState:d,replaceReducer:m,[SH]:_}}function g2e(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:E1.INIT})>"u")throw new Error(Ur(12));if(typeof n(void 0,{type:E1.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Ur(13))})}function Bq(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const s=e[a];typeof t[s]=="function"&&(n[s]=t[s])}const i=Object.keys(n);let r;try{g2e(n)}catch(a){r=a}return function(s={},o){if(r)throw r;let l=!1;const c={};for(let d=0;d<i.length;d++){const f=i[d],p=n[f],m=s[f],_=p(m,o);if(typeof _>"u")throw o&&o.type,new Error(Ur(14));c[f]=_,l=l||_!==m}return l=l||i.length!==Object.keys(s).length,l?c:s}}function A1(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...i)=>e(n(...i)))}function x2e(...t){return e=>(n,i)=>{const r=e(n,i);let a=()=>{throw new Error(Ur(15))};const s={getState:r.getState,dispatch:(l,...c)=>a(l,...c)},o=t.map(l=>l(s));return a=A1(...o)(r.dispatch),{...r,dispatch:a}}}function Hq(t){return RD(t)&&"type"in t&&typeof t.type=="string"}var Vq=Symbol.for("immer-nothing"),wH=Symbol.for("immer-draftable"),ba=Symbol.for("immer-state");function co(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var rs=Object,qp=rs.getPrototypeOf,T1="constructor",tw="prototype",B3="configurable",C1="enumerable",s_="writable",q0="value",fc=t=>!!t&&!!t[ba];function yo(t){return t?$q(t)||nw(t)||!!t[wH]||!!t[T1]?.[wH]||iw(t)||rw(t):!1}var v2e=rs[tw][T1].toString(),MH=new WeakMap;function $q(t){if(!t||!PD(t))return!1;const e=qp(t);if(e===null||e===rs[tw])return!0;const n=rs.hasOwnProperty.call(e,T1)&&e[T1];if(n===Object)return!0;if(!lp(n))return!1;let i=MH.get(n);return i===void 0&&(i=Function.toString.call(n),MH.set(n,i)),i===v2e}function Tx(t,e,n=!0){Cx(t)===0?(n?Reflect.ownKeys(t):rs.keys(t)).forEach(r=>{e(r,t[r],t)}):t.forEach((i,r)=>e(r,i,t))}function Cx(t){const e=t[ba];return e?e.type_:nw(t)?1:iw(t)?2:rw(t)?3:0}var EH=(t,e,n=Cx(t))=>n===2?t.has(e):rs[tw].hasOwnProperty.call(t,e),H3=(t,e,n=Cx(t))=>n===2?t.get(e):t[e],N1=(t,e,n,i=Cx(t))=>{i===2?t.set(e,n):i===3?t.add(n):t[e]=n};function y2e(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var nw=Array.isArray,iw=t=>t instanceof Map,rw=t=>t instanceof Set,PD=t=>typeof t=="object",lp=t=>typeof t=="function",q2=t=>typeof t=="boolean",zl=t=>t.copy_||t.base_,DD=t=>t.modified_?t.copy_:t.base_;function V3(t,e){if(iw(t))return new Map(t);if(rw(t))return new Set(t);if(nw(t))return Array[tw].slice.call(t);const n=$q(t);if(e===!0||e==="class_only"&&!n){const i=rs.getOwnPropertyDescriptors(t);delete i[ba];let r=Reflect.ownKeys(i);for(let a=0;a<r.length;a++){const s=r[a],o=i[s];o[s_]===!1&&(o[s_]=!0,o[B3]=!0),(o.get||o.set)&&(i[s]={[B3]:!0,[s_]:!0,[C1]:o[C1],[q0]:t[s]})}return rs.create(qp(t),i)}else{const i=qp(t);if(i!==null&&n)return{...t};const r=rs.create(i);return rs.assign(r,t)}}function OD(t,e=!1){return aw(t)||fc(t)||!yo(t)||(Cx(t)>1&&rs.defineProperties(t,{set:Eb,add:Eb,clear:Eb,delete:Eb}),rs.freeze(t),e&&Tx(t,(n,i)=>{OD(i,!0)},!1)),t}function b2e(){co(2)}var Eb={[q0]:b2e};function aw(t){return t===null||!PD(t)?!0:rs.isFrozen(t)}var R1="MapSet",$3="Patches",Gq={};function Xp(t){const e=Gq[t];return e||co(0,t),e}var _2e=t=>!!Gq[t],X0,Wq=()=>X0,S2e=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:_2e(R1)?Xp(R1):void 0});function AH(t,e){e&&(t.patchPlugin_=Xp($3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function G3(t){W3(t),t.drafts_.forEach(w2e),t.drafts_=null}function W3(t){t===X0&&(X0=t.parent_)}var TH=t=>X0=S2e(X0,t);function w2e(t){const e=t[ba];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function CH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[ba].modified_&&(G3(e),co(4)),yo(t)&&(t=NH(e,t));const{patchPlugin_:r}=e;r&&r.generateReplacementPatches_(n[ba].base_,t,e)}else t=NH(e,n);return M2e(e,t,!0),G3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Vq?t:void 0}function NH(t,e){if(aw(e))return e;const n=e[ba];if(!n)return kD(e,t.handledSet_,t);if(!sw(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:i}=n;if(i)for(;i.length>0;)i.pop()(t);Kq(n,t)}return n.copy_}function M2e(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&OD(e,n)}function qq(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var sw=(t,e)=>t.scope_===e,E2e=[];function Xq(t,e,n,i){const r=zl(t),a=t.type_;if(i!==void 0&&H3(r,i,a)===e){N1(r,i,n,a);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;Tx(r,(l,c)=>{if(fc(c)){const d=o.get(c)||[];d.push(l),o.set(c,d)}})}const s=t.draftLocations_.get(e)??E2e;for(const o of s)N1(r,o,n,a)}function A2e(t,e,n){t.callbacks_.push(function(r){const a=e;if(!a||!sw(a,r))return;r.mapSetPlugin_?.fixSetContents(a);const s=DD(a);Xq(t,a.draft_??a,s,n),Kq(a,r)})}function Kq(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:i}=e;if(i){const r=i.getPath(t);r&&i.generatePatches_(t,r,e)}qq(t)}}function T2e(t,e,n){const{scope_:i}=t;if(fc(n)){const r=n[ba];sw(r,i)&&r.callbacks_.push(function(){o_(t);const s=DD(r);Xq(t,n,s,e)})}else yo(n)&&t.callbacks_.push(function(){const a=zl(t);H3(a,e,t.type_)===n&&i.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&kD(H3(t.copy_,e,t.type_),i.handledSet_,i)})}function kD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||fc(t)||e.has(t)||!yo(t)||aw(t)||(e.add(t),Tx(t,(i,r)=>{if(fc(r)){const a=r[ba];if(sw(a,n)){const s=DD(a);N1(t,i,s,t.type_),qq(a)}}else yo(r)&&kD(r,e,n)})),t}function C2e(t,e){const n=nw(t),i={type_:n?1:0,scope_:e?e.scope_:Wq(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let r=i,a=LD;n&&(r=[i],a=K0);const{revoke:s,proxy:o}=Proxy.revocable(r,a);return i.draft_=o,i.revoke_=s,[o,i]}var LD={get(t,e){if(e===ba)return t;const n=zl(t);if(!EH(n,e,t.type_))return N2e(t,n,e);const i=n[e];if(t.finalized_||!yo(i))return i;if(i===X2(t.base_,e)){o_(t);const r=t.type_===1?+e:e,a=X3(t.scope_,i,t,r);return t.copy_[r]=a}return i},has(t,e){return e in zl(t)},ownKeys(t){return Reflect.ownKeys(zl(t))},set(t,e,n){const i=Yq(zl(t),e);if(i?.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const r=X2(zl(t),e),a=r?.[ba];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(y2e(n,r)&&(n!==void 0||EH(t.base_,e,t.type_)))return!0;o_(t),q3(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),T2e(t,e,n)),!0},deleteProperty(t,e){return o_(t),X2(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),q3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=zl(t),i=Reflect.getOwnPropertyDescriptor(n,e);return i&&{[s_]:!0,[B3]:t.type_!==1||e!=="length",[C1]:i[C1],[q0]:n[e]}},defineProperty(){co(11)},getPrototypeOf(t){return qp(t.base_)},setPrototypeOf(){co(12)}},K0={};Tx(LD,(t,e)=>{K0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});K0.deleteProperty=function(t,e){return K0.set.call(this,t,e,void 0)};K0.set=function(t,e,n){return LD.set.call(this,t[0],e,n,t[0])};function X2(t,e){const n=t[ba];return(n?zl(n):t)[e]}function N2e(t,e,n){const i=Yq(e,n);return i?q0 in i?i[q0]:i.get?.call(t.draft_):void 0}function Yq(t,e){if(!(e in t))return;let n=qp(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,e);if(i)return i;n=qp(n)}}function q3(t){t.modified_||(t.modified_=!0,t.parent_&&q3(t.parent_))}function o_(t){t.copy_||(t.assigned_=new Map,t.copy_=V3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var R2e=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,i,r)=>{if(lp(n)&&!lp(i)){const s=i;i=n;const o=this;return function(c=s,...d){return o.produce(c,f=>i.call(this,f,...d))}}lp(i)||co(6),r!==void 0&&!lp(r)&&co(7);let a;if(yo(n)){const s=TH(this),o=X3(s,n,void 0);let l=!0;try{a=i(o),l=!1}finally{l?G3(s):W3(s)}return AH(s,r),CH(a,s)}else if(!n||!PD(n)){if(a=i(n),a===void 0&&(a=n),a===Vq&&(a=void 0),this.autoFreeze_&&OD(a,!0),r){const s=[],o=[];Xp($3).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:o}),r(s,o)}return a}else co(1,n)},this.produceWithPatches=(n,i)=>{if(lp(n))return(o,...l)=>this.produceWithPatches(o,c=>n(c,...l));let r,a;return[this.produce(n,i,(o,l)=>{r=o,a=l}),r,a]},q2(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),q2(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),q2(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){yo(e)||co(8),fc(e)&&(e=xo(e));const n=TH(this),i=X3(n,e,void 0);return i[ba].isManual_=!0,W3(n),i}finishDraft(e,n){const i=e&&e[ba];(!i||!i.isManual_)&&co(9);const{scope_:r}=i;return AH(r,n),CH(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let i;for(i=n.length-1;i>=0;i--){const a=n[i];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}i>-1&&(n=n.slice(i+1));const r=Xp($3).applyPatches_;return fc(e)?r(e,n):this.produce(e,a=>r(a,n))}};function X3(t,e,n,i){const[r,a]=iw(e)?Xp(R1).proxyMap_(e,n):rw(e)?Xp(R1).proxySet_(e,n):C2e(e,n);return(n?.scope_??Wq()).drafts_.push(r),a.callbacks_=n?.callbacks_??[],a.key_=i,n&&i!==void 0?A2e(n,a,i):a.callbacks_.push(function(l){l.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:c}=l;a.modified_&&c&&c.generatePatches_(a,[],l)}),r}function xo(t){return fc(t)||co(10,t),Zq(t)}function Zq(t){if(!yo(t)||aw(t))return t;const e=t[ba];let n,i=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=V3(t,e.scope_.immer_.useStrictShallowCopy_),i=e.scope_.immer_.shouldUseStrictIteration()}else n=V3(t,!0);return Tx(n,(r,a)=>{N1(n,r,Zq(a))},i),e&&(e.finalized_=!1),n}var P2e=new R2e,Qq=P2e.produce;function Jq(t){return({dispatch:n,getState:i})=>r=>a=>typeof a=="function"?a(n,i,t):r(a)}var D2e=Jq(),O2e=Jq,k2e=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?A1:A1.apply(null,arguments)};function Gs(t,e){function n(...i){if(e){let r=e(...i);if(!r)throw new Error(cs(0));return{type:t,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:t,payload:i[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=i=>Hq(i)&&i.type===t,n}var eX=class Kg extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Kg.prototype)}static get[Symbol.species](){return Kg}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new Kg(...e[0].concat(this)):new Kg(...e.concat(this))}};function RH(t){return yo(t)?Qq(t,()=>{}):t}function Ab(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function L2e(t){return typeof t=="boolean"}var I2e=()=>function(e){const{thunk:n=!0,immutableCheck:i=!0,serializableCheck:r=!0,actionCreatorCheck:a=!0}=e??{};let s=new eX;return n&&(L2e(n)?s.push(D2e):s.push(O2e(n.extraArgument))),s},tX="RTK_autoBatch",oi=()=>t=>({payload:t,meta:{[tX]:!0}}),PH=t=>e=>{setTimeout(e,t)},nX=(t={type:"raf"})=>e=>(...n)=>{const i=e(...n);let r=!0,a=!1,s=!1;const o=new Set,l=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:PH(10):t.type==="callback"?t.queueNotification:PH(t.timeout),c=()=>{s=!1,a&&(a=!1,o.forEach(d=>d()))};return Object.assign({},i,{subscribe(d){const f=()=>r&&d(),p=i.subscribe(f);return o.add(d),()=>{p(),o.delete(d)}},dispatch(d){try{return r=!d?.meta?.[tX],a=!r,a&&(s||(s=!0,l(c))),i.dispatch(d)}finally{r=!0}}})},U2e=t=>function(n){const{autoBatch:i=!0}=n??{};let r=new eX(t);return i&&r.push(nX(typeof i=="object"?i:void 0)),r};function j2e(t){const e=I2e(),{reducer:n=void 0,middleware:i,devTools:r=!0,preloadedState:a=void 0,enhancers:s=void 0}=t||{};let o;if(typeof n=="function")o=n;else if(RD(n))o=Bq(n);else throw new Error(cs(1));let l;typeof i=="function"?l=i(e):l=e();let c=A1;r&&(c=k2e({trace:!1,...typeof r=="object"&&r}));const d=x2e(...l),f=U2e(d);let p=typeof s=="function"?s(f):f();const m=c(...p);return zq(o,a,m)}function iX(t){const e={},n=[];let i;const r={addCase(a,s){const o=typeof a=="string"?a:a.type;if(!o)throw new Error(cs(28));if(o in e)throw new Error(cs(29));return e[o]=s,r},addAsyncThunk(a,s){return s.pending&&(e[a.pending.type]=s.pending),s.rejected&&(e[a.rejected.type]=s.rejected),s.fulfilled&&(e[a.fulfilled.type]=s.fulfilled),s.settled&&n.push({matcher:a.settled,reducer:s.settled}),r},addMatcher(a,s){return n.push({matcher:a,reducer:s}),r},addDefaultCase(a){return i=a,r}};return t(r),[e,n,i]}function F2e(t){return typeof t=="function"}function z2e(t,e){let[n,i,r]=iX(e),a;if(F2e(t))a=()=>RH(t());else{const o=RH(t);a=()=>o}function s(o=a(),l){let c=[n[l.type],...i.filter(({matcher:d})=>d(l)).map(({reducer:d})=>d)];return c.filter(d=>!!d).length===0&&(c=[r]),c.reduce((d,f)=>{if(f)if(fc(d)){const m=f(d,l);return m===void 0?d:m}else{if(yo(d))return Qq(d,p=>f(p,l));{const p=f(d,l);if(p===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return d},o)}return s.getInitialState=a,s}var B2e="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",H2e=(t=21)=>{let e="",n=t;for(;n--;)e+=B2e[Math.random()*64|0];return e},V2e=Symbol.for("rtk-slice-createasyncthunk");function $2e(t,e){return`${t}/${e}`}function G2e({creators:t}={}){const e=t?.asyncThunk?.[V2e];return function(i){const{name:r,reducerPath:a=r}=i;if(!r)throw new Error(cs(11));const s=(typeof i.reducers=="function"?i.reducers(q2e()):i.reducers)||{},o=Object.keys(s),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(w,E){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(cs(12));if(T in l.sliceCaseReducersByType)throw new Error(cs(13));return l.sliceCaseReducersByType[T]=E,c},addMatcher(w,E){return l.sliceMatchers.push({matcher:w,reducer:E}),c},exposeAction(w,E){return l.actionCreators[w]=E,c},exposeCaseReducer(w,E){return l.sliceCaseReducersByName[w]=E,c}};o.forEach(w=>{const E=s[w],T={reducerName:w,type:$2e(r,w),createNotation:typeof i.reducers=="function"};K2e(E)?Z2e(T,E,c,e):X2e(T,E,c)});function d(){const[w={},E=[],T=void 0]=typeof i.extraReducers=="function"?iX(i.extraReducers):[i.extraReducers],P={...w,...l.sliceCaseReducersByType};return z2e(i.initialState,N=>{for(let U in P)N.addCase(U,P[U]);for(let U of l.sliceMatchers)N.addMatcher(U.matcher,U.reducer);for(let U of E)N.addMatcher(U.matcher,U.reducer);T&&N.addDefaultCase(T)})}const f=w=>w,p=new Map,m=new WeakMap;let _;function b(w,E){return _||(_=d()),_(w,E)}function v(){return _||(_=d()),_.getInitialState()}function x(w,E=!1){function T(N){let U=N[w];return typeof U>"u"&&E&&(U=Ab(m,T,v)),U}function P(N=f){const U=Ab(p,E,()=>new WeakMap);return Ab(U,N,()=>{const R={};for(const[O,z]of Object.entries(i.selectors??{}))R[O]=W2e(z,N,()=>Ab(m,N,v),E);return R})}return{reducerPath:w,getSelectors:P,get selectors(){return P(T)},selectSlice:T}}const M={name:r,reducer:b,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:v,...x(a),injectInto(w,{reducerPath:E,...T}={}){const P=E??a;return w.inject({reducerPath:P,reducer:b},T),{...M,...x(P,!0)}}};return M}}function W2e(t,e,n,i){function r(a,...s){let o=e(a);return typeof o>"u"&&i&&(o=n()),t(o,...s)}return r.unwrapped=t,r}var Fa=G2e();function q2e(){function t(e,n){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...n}}return t.withTypes=()=>t,{reducer(e){return Object.assign({[e.name](...n){return e(...n)}}[e.name],{_reducerDefinitionType:"reducer"})},preparedReducer(e,n){return{_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:n}},asyncThunk:t}}function X2e({type:t,reducerName:e,createNotation:n},i,r){let a,s;if("reducer"in i){if(n&&!Y2e(i))throw new Error(cs(17));a=i.reducer,s=i.prepare}else a=i;r.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?Gs(t,s):Gs(t))}function K2e(t){return t._reducerDefinitionType==="asyncThunk"}function Y2e(t){return t._reducerDefinitionType==="reducerWithPrepare"}function Z2e({type:t,reducerName:e},n,i,r){if(!r)throw new Error(cs(18));const{payloadCreator:a,fulfilled:s,pending:o,rejected:l,settled:c,options:d}=n,f=r(t,a,d);i.exposeAction(e,f),s&&i.addCase(f.fulfilled,s),o&&i.addCase(f.pending,o),l&&i.addCase(f.rejected,l),c&&i.addMatcher(f.settled,c),i.exposeCaseReducer(e,{fulfilled:s||Tb,pending:o||Tb,rejected:l||Tb,settled:c||Tb})}function Tb(){}var Q2e="task",rX="listener",aX="completed",ID="cancelled",J2e=`task-${ID}`,eCe=`task-${aX}`,K3=`${rX}-${ID}`,tCe=`${rX}-${aX}`,ow=class{constructor(t){this.code=t,this.message=`${Q2e} ${ID} (reason: ${t})`}name="TaskAbortError";message},UD=(t,e)=>{if(typeof t!="function")throw new TypeError(cs(32))},P1=()=>{},sX=(t,e=P1)=>(t.catch(e),t),oX=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),uf=(t,e)=>{const n=t.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:e,configurable:!0,writable:!0}),t.abort(e))},df=t=>{if(t.aborted){const{reason:e}=t;throw new ow(e)}};function lX(t,e){let n=P1;return new Promise((i,r)=>{const a=()=>r(new ow(t.reason));if(t.aborted){a();return}n=oX(t,a),e.finally(()=>n()).then(i,r)}).finally(()=>{n=P1})}var nCe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof ow?"cancelled":"rejected",error:n}}finally{e?.()}},D1=t=>e=>sX(lX(t,e).then(n=>(df(t),n))),cX=t=>{const e=D1(t);return n=>e(new Promise(i=>setTimeout(i,n)))},{assign:Ep}=Object,DH={},lw="listenerMiddleware",iCe=(t,e)=>{const n=i=>oX(t,()=>uf(i,t.reason));return(i,r)=>{UD(i);const a=new AbortController;n(a);const s=nCe(async()=>{df(t),df(a.signal);const o=await i({pause:D1(a.signal),delay:cX(a.signal),signal:a.signal});return df(a.signal),o},()=>uf(a,eCe));return r?.autoJoin&&e.push(s.catch(P1)),{result:D1(t)(s),cancel(){uf(a,J2e)}}}},rCe=(t,e)=>{const n=async(i,r)=>{df(e);let a=()=>{};const o=[new Promise((l,c)=>{let d=t({predicate:i,effect:(f,p)=>{p.unsubscribe(),l([f,p.getState(),p.getOriginalState()])}});a=()=>{d(),c()}})];r!=null&&o.push(new Promise(l=>setTimeout(l,r,null)));try{const l=await lX(e,Promise.race(o));return df(e),l}finally{a()}};return(i,r)=>sX(n(i,r))},uX=t=>{let{type:e,actionCreator:n,matcher:i,predicate:r,effect:a}=t;if(e)r=Gs(e).match;else if(n)e=n.type,r=n.match;else if(i)r=i;else if(!r)throw new Error(cs(21));return UD(a),{predicate:r,type:e,effect:a}},dX=Ep(t=>{const{type:e,predicate:n,effect:i}=uX(t);return{id:H2e(),effect:i,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(cs(22))}}},{withTypes:()=>dX}),OH=(t,e)=>{const{type:n,effect:i,predicate:r}=uX(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===r)&&a.effect===i)},Y3=t=>{t.pending.forEach(e=>{uf(e,K3)})},aCe=(t,e)=>()=>{for(const n of e.keys())Y3(n);t.clear()},kH=(t,e,n)=>{try{t(e,n)}catch(i){setTimeout(()=>{throw i},0)}},fX=Ep(Gs(`${lw}/add`),{withTypes:()=>fX}),sCe=Gs(`${lw}/removeAll`),hX=Ep(Gs(`${lw}/remove`),{withTypes:()=>hX}),oCe=(...t)=>{console.error(`${lw}/error`,...t)},Nx=(t={})=>{const e=new Map,n=new Map,i=m=>{const _=n.get(m)??0;n.set(m,_+1)},r=m=>{const _=n.get(m)??1;_===1?n.delete(m):n.set(m,_-1)},{extra:a,onError:s=oCe}=t;UD(s);const o=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),_=>{m.unsubscribe(),_?.cancelActive&&Y3(m)}),l=m=>{const _=OH(e,m)??dX(m);return o(_)};Ep(l,{withTypes:()=>l});const c=m=>{const _=OH(e,m);return _&&(_.unsubscribe(),m.cancelActive&&Y3(_)),!!_};Ep(c,{withTypes:()=>c});const d=async(m,_,b,v)=>{const x=new AbortController,M=rCe(l,x.signal),w=[];try{m.pending.add(x),i(m),await Promise.resolve(m.effect(_,Ep({},b,{getOriginalState:v,condition:(E,T)=>M(E,T).then(Boolean),take:M,delay:cX(x.signal),pause:D1(x.signal),extra:a,signal:x.signal,fork:iCe(x.signal,w),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((E,T,P)=>{E!==x&&(uf(E,K3),P.delete(E))})},cancel:()=>{uf(x,K3),m.pending.delete(x)},throwIfCancelled:()=>{df(x.signal)}})))}catch(E){E instanceof ow||kH(s,E,{raisedBy:"effect"})}finally{await Promise.all(w),uf(x,tCe),r(m),m.pending.delete(x)}},f=aCe(e,n);return{middleware:m=>_=>b=>{if(!Hq(b))return _(b);if(fX.match(b))return l(b.payload);if(sCe.match(b)){f();return}if(hX.match(b))return c(b.payload);let v=m.getState();const x=()=>{if(v===DH)throw new Error(cs(23));return v};let M;try{if(M=_(b),e.size>0){const w=m.getState(),E=Array.from(e.values());for(const T of E){let P=!1;try{P=T.predicate(b,w,v)}catch(N){P=!1,kH(s,N,{raisedBy:"predicate"})}P&&d(T,b,m,x)}}}finally{v=DH}return M},startListening:l,stopListening:c,clearListeners:f}};function cs(t){return`Minified Redux Toolkit error #${t}; visit https://redux-toolkit.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var lCe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},pX=Fa({name:"chartLayout",initialState:lCe,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,i,r,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(i=e.payload.right)!==null&&i!==void 0?i:0,t.margin.bottom=(r=e.payload.bottom)!==null&&r!==void 0?r:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:cCe,setLayout:uCe,setChartSize:dCe,setScale:fCe}=pX.actions,hCe=pX.reducer;function mX(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function LH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function hp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LH(Object(n),!0).forEach(function(i){pCe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function pCe(t,e,n){return(e=mCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mCe(t){var e=gCe(t,"string");return typeof e=="symbol"?e:e+""}function gCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xn(t,e,n){return mi(t)||mi(e)?n:Ko(e)?Rf(t,e,n):typeof e=="function"?e(t):n}var xCe=(t,e,n)=>{if(e&&n){var{width:i,height:r}=n,{align:a,verticalAlign:s,layout:o}=e;if((o==="vertical"||o==="horizontal"&&s==="middle")&&a!=="center"&&Et(t[a]))return hp(hp({},t),{},{[a]:t[a]+(i||0)});if((o==="horizontal"||o==="vertical"&&a==="center")&&s!=="middle"&&Et(t[s]))return hp(hp({},t),{},{[s]:t[s]+(r||0)})}return t},yc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",gX=(t,e,n,i)=>{if(i)return t.map(o=>o.coordinate);var r,a,s=t.map(o=>(o.coordinate===e&&(r=!0),o.coordinate===n&&(a=!0),o.coordinate));return r||s.push(e),a||s.push(n),s},xX=(t,e,n)=>{if(!t)return null;var{duplicateDomain:i,type:r,range:a,scale:s,realScaleType:o,isCategorical:l,categoricalDomain:c,tickCount:d,ticks:f,niceTicks:p,axisType:m}=t;if(!s)return null;var _=o==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,b=r==="category"&&s.bandwidth?s.bandwidth()/_:0;if(b=m==="angleAxis"&&a&&a.length>=2?Mr(a[0]-a[1])*2*b:b,f||p){var v=(f||p||[]).map((x,M)=>{var w=i?i.indexOf(x):x;return{coordinate:s(w)+b,value:x,offset:b,index:M}});return v.filter(x=>!$s(x.coordinate))}return l&&c?c.map((x,M)=>({coordinate:s(x)+b,value:x,index:M,offset:b})):s.ticks&&d!=null?s.ticks(d).map((x,M)=>({coordinate:s(x)+b,value:x,offset:b,index:M})):s.domain().map((x,M)=>({coordinate:s(x)+b,value:i?i[x]:x,index:M,offset:b}))},IH=1e-4,vCe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,i=t.range(),r=Math.min(i[0],i[1])-IH,a=Math.max(i[0],i[1])+IH,s=t(e[0]),o=t(e[n-1]);(s<r||s>a||o<r||o>a)&&t.domain([e[0],e[n-1]])}},yCe=(t,e)=>{if(!e||e.length!==2||!Et(e[0])||!Et(e[1]))return t;var n=Math.min(e[0],e[1]),i=Math.max(e[0],e[1]),r=[t[0],t[1]];return(!Et(t[0])||t[0]<n)&&(r[0]=n),(!Et(t[1])||t[1]>i)&&(r[1]=i),r[0]>i&&(r[0]=i),r[1]<n&&(r[1]=n),r},bCe=t=>{var e=t.length;if(!(e<=0))for(var n=0,i=t[0].length;n<i;++n)for(var r=0,a=0,s=0;s<e;++s){var o=$s(t[s][n][1])?t[s][n][0]:t[s][n][1];o>=0?(t[s][n][0]=r,t[s][n][1]=r+o,r=t[s][n][1]):(t[s][n][0]=a,t[s][n][1]=a+o,a=t[s][n][1])}},_Ce=t=>{var e=t.length;if(!(e<=0))for(var n=0,i=t[0].length;n<i;++n)for(var r=0,a=0;a<e;++a){var s=$s(t[a][n][1])?t[a][n][0]:t[a][n][1];s>=0?(t[a][n][0]=r,t[a][n][1]=r+s,r=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},SCe={sign:bCe,expand:qAe,none:Wp,silhouette:XAe,wiggle:KAe,positive:_Ce},wCe=(t,e,n)=>{var i=SCe[n],r=WAe().keys(e).value((a,s)=>Number(Xn(a,s,0))).order(F3).offset(i);return r(t)};function vX(t){return t==null?void 0:String(t)}function UH(t){var{axis:e,ticks:n,bandSize:i,entry:r,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!mi(r[e.dataKey])){var o=Sq(n,"value",r[e.dataKey]);if(o)return o.coordinate+i/2}return n[a]?n[a].coordinate+i/2:null}var l=Xn(r,mi(s)?e.dataKey:s);return mi(l)?null:e.scale(l)}var jH=t=>{var{axis:e,ticks:n,offset:i,bandSize:r,entry:a,index:s}=t;if(e.type==="category")return n[s]?n[s].coordinate+i:null;var o=Xn(a,e.dataKey,e.scale.domain()[s]);return mi(o)?null:e.scale(o)-r/2+i},MCe=t=>{var{numericAxis:e}=t,n=e.scale.domain();if(e.type==="number"){var i=Math.min(n[0],n[1]),r=Math.max(n[0],n[1]);return i<=0&&r>=0?0:r<0?r:i}return n[0]},ECe=t=>{var e=t.flat(2).filter(Et);return[Math.min(...e),Math.max(...e)]},ACe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],TCe=(t,e,n)=>{if(t!=null)return ACe(Object.keys(t).reduce((i,r)=>{var a=t[r],{stackedData:s}=a,o=s.reduce((l,c)=>{var d=mX(c,e,n),f=ECe(d);return[Math.min(l[0],f[0]),Math.max(l[1],f[1])]},[1/0,-1/0]);return[Math.min(o[0],i[0]),Math.max(o[1],i[1])]},[1/0,-1/0]))},FH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,zH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Kp=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var i=t.scale.bandwidth();if(!n||i>0)return i}if(t&&e&&e.length>=2){for(var r=ew(e,d=>d.coordinate),a=1/0,s=1,o=r.length;s<o;s++){var l=r[s],c=r[s-1];a=Math.min((l.coordinate||0)-(c.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function BH(t){var{tooltipEntrySettings:e,dataKey:n,payload:i,value:r,name:a}=t;return hp(hp({},e),{},{dataKey:n,payload:i,value:r,name:a})}function dm(t,e){if(t)return String(t);if(typeof e=="string")return e}var CCe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},NCe=(t,e)=>e==="centric"?t.angle:t.radius,bc=t=>t.layout.width,_c=t=>t.layout.height,RCe=t=>t.layout.scale,yX=t=>t.layout.margin,cw=He(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),uw=He(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),bX="data-recharts-item-index",_X="data-recharts-item-data-key",Rx=60;function HH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Cb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HH(Object(n),!0).forEach(function(i){PCe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function PCe(t,e,n){return(e=DCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DCe(t){var e=OCe(t,"string");return typeof e=="symbol"?e:e+""}function OCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var kCe=t=>t.brush.height;function LCe(t){var e=uw(t);return e.reduce((n,i)=>{if(i.orientation==="left"&&!i.mirror&&!i.hide){var r=typeof i.width=="number"?i.width:Rx;return n+r}return n},0)}function ICe(t){var e=uw(t);return e.reduce((n,i)=>{if(i.orientation==="right"&&!i.mirror&&!i.hide){var r=typeof i.width=="number"?i.width:Rx;return n+r}return n},0)}function UCe(t){var e=cw(t);return e.reduce((n,i)=>i.orientation==="top"&&!i.mirror&&!i.hide?n+i.height:n,0)}function jCe(t){var e=cw(t);return e.reduce((n,i)=>i.orientation==="bottom"&&!i.mirror&&!i.hide?n+i.height:n,0)}var lr=He([bc,_c,yX,kCe,LCe,ICe,UCe,jCe,jq,u2e],(t,e,n,i,r,a,s,o,l,c)=>{var d={left:(n.left||0)+r,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+o},p=Cb(Cb({},f),d),m=p.bottom;p.bottom+=i,p=xCe(p,l,c);var _=t-p.left-p.right,b=e-p.top-p.bottom;return Cb(Cb({brushBottom:m},p),{},{width:Math.max(_,0),height:Math.max(b,0)})}),FCe=He(lr,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),jD=He(bc,_c,(t,e)=>({x:0,y:0,width:t,height:e})),zCe=A.createContext(null),aa=()=>A.useContext(zCe)!=null,dw=t=>t.brush,fw=He([dw,lr,yX],(t,e,n)=>({height:t.height,x:Et(t.x)?t.x:e.left,y:Et(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Et(t.width)?t.width:e.width})),K2={},Y2={},Z2={},VH;function BCe(){return VH||(VH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,i,{signal:r,edges:a}={}){let s,o=null;const l=a!=null&&a.includes("leading"),c=a==null||a.includes("trailing"),d=()=>{o!==null&&(n.apply(s,o),s=void 0,o=null)},f=()=>{c&&d(),b()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,f()},i)},_=()=>{p!==null&&(clearTimeout(p),p=null)},b=()=>{_(),s=void 0,o=null},v=()=>{d()},x=function(...M){if(r?.aborted)return;s=this,o=M;const w=p==null;m(),l&&w&&d()};return x.schedule=m,x.cancel=b,x.flush=v,r?.addEventListener("abort",b,{once:!0}),x}t.debounce=e})(Z2)),Z2}var $H;function HCe(){return $H||($H=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=BCe();function n(i,r=0,a={}){typeof a!="object"&&(a={});const{leading:s=!1,trailing:o=!0,maxWait:l}=a,c=Array(2);s&&(c[0]="leading"),o&&(c[1]="trailing");let d,f=null;const p=e.debounce(function(...b){d=i.apply(this,b),f=null},r,{edges:c}),m=function(...b){return l!=null&&(f===null&&(f=Date.now()),Date.now()-f>=l)?(d=i.apply(this,b),f=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,b),d)},_=()=>(p.flush(),d);return m.cancel=p.cancel,m.flush=_,m}t.debounce=n})(Y2)),Y2}var GH;function VCe(){return GH||(GH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=HCe();function n(i,r=0,a={}){const{leading:s=!0,trailing:o=!0}=a;return e.debounce(i,r,{leading:s,maxWait:r,trailing:o})}t.throttle=n})(K2)),K2}var Q2,WH;function $Ce(){return WH||(WH=1,Q2=VCe().throttle),Q2}var GCe=$Ce();const WCe=qs(GCe);var O1=function(e,n){for(var i=arguments.length,r=new Array(i>2?i-2:0),a=2;a<i;a++)r[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=0;console.warn(n.replace(/%s/g,()=>r[s++]))}},SX=(t,e,n)=>{var{width:i="100%",height:r="100%",aspect:a,maxHeight:s}=n,o=dc(i)?t:Number(i),l=dc(r)?e:Number(r);return a&&a>0&&(o?l=o/a:l&&(o=l*a),s&&l!=null&&l>s&&(l=s)),{calculatedWidth:o,calculatedHeight:l}},qCe={width:0,height:0,overflow:"visible"},XCe={width:0,overflowX:"visible"},KCe={height:0,overflowY:"visible"},YCe={},ZCe=t=>{var{width:e,height:n}=t,i=dc(e),r=dc(n);return i&&r?qCe:i?XCe:r?KCe:YCe};function QCe(t){var{width:e,height:n,aspect:i}=t,r=e,a=n;return r===void 0&&a===void 0?(r="100%",a="100%"):r===void 0?r=i&&i>0?void 0:"100%":a===void 0&&(a=i&&i>0?void 0:"100%"),{width:r,height:a}}function ai(t){return Number.isFinite(t)}function Yo(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function Z3(){return Z3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Z3.apply(null,arguments)}function qH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function XH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qH(Object(n),!0).forEach(function(i){JCe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function JCe(t,e,n){return(e=eNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eNe(t){var e=tNe(t,"string");return typeof e=="symbol"?e:e+""}function tNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var wX=A.createContext({width:-1,height:-1});function nNe(t){return Yo(t.width)&&Yo(t.height)}function MX(t){var{children:e,width:n,height:i}=t,r=A.useMemo(()=>({width:n,height:i}),[n,i]);return nNe(r)?A.createElement(wX.Provider,{value:r},e):null}var FD=()=>A.useContext(wX),iNe=A.forwardRef((t,e)=>{var{aspect:n,initialDimension:i={width:-1,height:-1},width:r,height:a,minWidth:s=0,minHeight:o,maxHeight:l,children:c,debounce:d=0,id:f,className:p,onResize:m,style:_={}}=t,b=A.useRef(null),v=A.useRef();v.current=m,A.useImperativeHandle(e,()=>b.current);var[x,M]=A.useState({containerWidth:i.width,containerHeight:i.height}),w=A.useCallback((U,R)=>{M(O=>{var z=Math.round(U),I=Math.round(R);return O.containerWidth===z&&O.containerHeight===I?O:{containerWidth:z,containerHeight:I}})},[]);A.useEffect(()=>{if(b.current==null||typeof ResizeObserver>"u")return Ex;var U=I=>{var G,{width:L,height:B}=I[0].contentRect;w(L,B),(G=v.current)===null||G===void 0||G.call(v,L,B)};d>0&&(U=WCe(U,d,{trailing:!0,leading:!1}));var R=new ResizeObserver(U),{width:O,height:z}=b.current.getBoundingClientRect();return w(O,z),R.observe(b.current),()=>{R.disconnect()}},[w,d]);var{containerWidth:E,containerHeight:T}=x;O1(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:P,calculatedHeight:N}=SX(E,T,{width:r,height:a,aspect:n,maxHeight:l});return O1(P!=null&&P>0||N!=null&&N>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,P,N,r,a,s,o,n),A.createElement("div",{id:f?"".concat(f):void 0,className:Mn("recharts-responsive-container",p),style:XH(XH({},_),{},{width:r,height:a,minWidth:s,minHeight:o,maxHeight:l}),ref:b},A.createElement("div",{style:ZCe({width:r,height:a})},A.createElement(MX,{width:P,height:N},c)))}),J2=A.forwardRef((t,e)=>{var n=FD();if(Yo(n.width)&&Yo(n.height))return t.children;var{width:i,height:r}=QCe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=SX(void 0,void 0,{width:i,height:r,aspect:t.aspect,maxHeight:t.maxHeight});return Et(a)&&Et(s)?A.createElement(MX,{width:a,height:s},t.children):A.createElement(iNe,Z3({},t,{width:i,height:r,ref:e}))});function EX(t){if(t)return{x:t.x,y:t.y,upperWidth:"upperWidth"in t?t.upperWidth:t.width,lowerWidth:"lowerWidth"in t?t.lowerWidth:t.width,width:t.width,height:t.height}}var hw=()=>{var t,e=aa(),n=At(FCe),i=At(fw),r=(t=At(dw))===null||t===void 0?void 0:t.padding;return!e||!i||!r?n:{width:i.width-r.left-r.right,height:i.height-r.top-r.bottom,x:r.left,y:r.top}},rNe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},AX=()=>{var t;return(t=At(lr))!==null&&t!==void 0?t:rNe},zD=()=>At(bc),BD=()=>At(_c),aNe=()=>At(t=>t.layout.margin),bn=t=>t.layout.layoutType,fm=()=>At(bn),sNe=()=>{var t=fm();if(t==="horizontal"||t==="vertical")return t},oNe=()=>{var t=fm();return t!==void 0},pw=t=>{var e=Qn(),n=aa(),{width:i,height:r}=t,a=FD(),s=i,o=r;return a&&(s=a.width>0?a.width:i,o=a.height>0?a.height:r),A.useEffect(()=>{!n&&Yo(s)&&Yo(o)&&e(dCe({width:s,height:o}))},[e,n,s,o]),null},TX=Symbol.for("immer-nothing"),KH=Symbol.for("immer-draftable"),ds=Symbol.for("immer-state");function uo(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Y0=Object.getPrototypeOf;function Yp(t){return!!t&&!!t[ds]}function Pf(t){return t?CX(t)||Array.isArray(t)||!!t[KH]||!!t.constructor?.[KH]||Px(t)||gw(t):!1}var lNe=Object.prototype.constructor.toString(),YH=new WeakMap;function CX(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(n===Object)return!0;if(typeof n!="function")return!1;let i=YH.get(n);return i===void 0&&(i=Function.toString.call(n),YH.set(n,i)),i===lNe}function k1(t,e,n=!0){mw(t)===0?(n?Reflect.ownKeys(t):Object.keys(t)).forEach(r=>{e(r,t[r],t)}):t.forEach((i,r)=>e(r,i,t))}function mw(t){const e=t[ds];return e?e.type_:Array.isArray(t)?1:Px(t)?2:gw(t)?3:0}function Q3(t,e){return mw(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function NX(t,e,n){const i=mw(t);i===2?t.set(e,n):i===3?t.add(n):t[e]=n}function cNe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Px(t){return t instanceof Map}function gw(t){return t instanceof Set}function jd(t){return t.copy_||t.base_}function J3(t,e){if(Px(t))return new Map(t);if(gw(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=CX(t);if(e===!0||e==="class_only"&&!n){const i=Object.getOwnPropertyDescriptors(t);delete i[ds];let r=Reflect.ownKeys(i);for(let a=0;a<r.length;a++){const s=r[a],o=i[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(i[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[s]})}return Object.create(Y0(t),i)}else{const i=Y0(t);if(i!==null&&n)return{...t};const r=Object.create(i);return Object.assign(r,t)}}function HD(t,e=!1){return xw(t)||Yp(t)||!Pf(t)||(mw(t)>1&&Object.defineProperties(t,{set:Nb,add:Nb,clear:Nb,delete:Nb}),Object.freeze(t),e&&Object.values(t).forEach(n=>HD(n,!0))),t}function uNe(){uo(2)}var Nb={value:uNe};function xw(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var dNe={};function Df(t){const e=dNe[t];return e||uo(0,t),e}var Z0;function RX(){return Z0}function fNe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ZH(t,e){e&&(Df("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function eR(t){tR(t),t.drafts_.forEach(hNe),t.drafts_=null}function tR(t){t===Z0&&(Z0=t.parent_)}function QH(t){return Z0=fNe(Z0,t)}function hNe(t){const e=t[ds];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function JH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[ds].modified_&&(eR(e),uo(4)),Pf(t)&&(t=L1(e,t),e.parent_||I1(e,t)),e.patches_&&Df("Patches").generateReplacementPatches_(n[ds].base_,t,e.patches_,e.inversePatches_)):t=L1(e,n,[]),eR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==TX?t:void 0}function L1(t,e,n){if(xw(e))return e;const i=t.immer_.shouldUseStrictIteration(),r=e[ds];if(!r)return k1(e,(a,s)=>e6(t,r,e,a,s,n),i),e;if(r.scope_!==t)return e;if(!r.modified_)return I1(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const a=r.copy_;let s=a,o=!1;r.type_===3&&(s=new Set(a),a.clear(),o=!0),k1(s,(l,c)=>e6(t,r,a,l,c,n,o),i),I1(t,a,!1),n&&t.patches_&&Df("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function e6(t,e,n,i,r,a,s){if(r==null||typeof r!="object"&&!s)return;const o=xw(r);if(!(o&&!s)){if(Yp(r)){const l=a&&e&&e.type_!==3&&!Q3(e.assigned_,i)?a.concat(i):void 0,c=L1(t,r,l);if(NX(n,i,c),Yp(c))t.canAutoFreeze_=!1;else return}else s&&n.add(r);if(Pf(r)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[i]===r&&o)return;L1(t,r),(!e||!e.scope_.parent_)&&typeof i!="symbol"&&(Px(n)?n.has(i):Object.prototype.propertyIsEnumerable.call(n,i))&&I1(t,r)}}}function I1(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&HD(e,n)}function pNe(t,e){const n=Array.isArray(t),i={type_:n?1:0,scope_:e?e.scope_:RX(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=i,a=VD;n&&(r=[i],a=Q0);const{revoke:s,proxy:o}=Proxy.revocable(r,a);return i.draft_=o,i.revoke_=s,o}var VD={get(t,e){if(e===ds)return t;const n=jd(t);if(!Q3(n,e))return mNe(t,n,e);const i=n[e];return t.finalized_||!Pf(i)?i:i===eC(t.base_,e)?(tC(t),t.copy_[e]=iR(i,t)):i},has(t,e){return e in jd(t)},ownKeys(t){return Reflect.ownKeys(jd(t))},set(t,e,n){const i=PX(jd(t),e);if(i?.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const r=eC(jd(t),e),a=r?.[ds];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(cNe(n,r)&&(n!==void 0||Q3(t.base_,e)))return!0;tC(t),nR(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return eC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,tC(t),nR(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=jd(t),i=Reflect.getOwnPropertyDescriptor(n,e);return i&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:i.enumerable,value:n[e]}},defineProperty(){uo(11)},getPrototypeOf(t){return Y0(t.base_)},setPrototypeOf(){uo(12)}},Q0={};k1(VD,(t,e)=>{Q0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});Q0.deleteProperty=function(t,e){return Q0.set.call(this,t,e,void 0)};Q0.set=function(t,e,n){return VD.set.call(this,t[0],e,n,t[0])};function eC(t,e){const n=t[ds];return(n?jd(n):t)[e]}function mNe(t,e,n){const i=PX(e,n);return i?"value"in i?i.value:i.get?.call(t.draft_):void 0}function PX(t,e){if(!(e in t))return;let n=Y0(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,e);if(i)return i;n=Y0(n)}}function nR(t){t.modified_||(t.modified_=!0,t.parent_&&nR(t.parent_))}function tC(t){t.copy_||(t.copy_=J3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var gNe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,i)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const s=this;return function(l=a,...c){return s.produce(l,d=>n.call(this,d,...c))}}typeof n!="function"&&uo(6),i!==void 0&&typeof i!="function"&&uo(7);let r;if(Pf(e)){const a=QH(this),s=iR(e,void 0);let o=!0;try{r=n(s),o=!1}finally{o?eR(a):tR(a)}return ZH(a,i),JH(r,a)}else if(!e||typeof e!="object"){if(r=n(e),r===void 0&&(r=e),r===TX&&(r=void 0),this.autoFreeze_&&HD(r,!0),i){const a=[],s=[];Df("Patches").generateReplacementPatches_(e,r,a,s),i(a,s)}return r}else uo(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(s,...o)=>this.produceWithPatches(s,l=>e(l,...o));let i,r;return[this.produce(e,n,(s,o)=>{i=s,r=o}),i,r]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Pf(t)||uo(8),Yp(t)&&(t=xNe(t));const e=QH(this),n=iR(t,void 0);return n[ds].isManual_=!0,tR(e),n}finishDraft(t,e){const n=t&&t[ds];(!n||!n.isManual_)&&uo(9);const{scope_:i}=n;return ZH(i,e),JH(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const r=e[n];if(r.path.length===0&&r.op==="replace"){t=r.value;break}}n>-1&&(e=e.slice(n+1));const i=Df("Patches").applyPatches_;return Yp(t)?i(t,e):this.produce(t,r=>i(r,e))}};function iR(t,e){const n=Px(t)?Df("MapSet").proxyMap_(t,e):gw(t)?Df("MapSet").proxySet_(t,e):pNe(t,e);return(e?e.scope_:RX()).drafts_.push(n),n}function xNe(t){return Yp(t)||uo(10,t),DX(t)}function DX(t){if(!Pf(t)||xw(t))return t;const e=t[ds];let n,i=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=J3(t,e.scope_.immer_.useStrictShallowCopy_),i=e.scope_.immer_.shouldUseStrictIteration()}else n=J3(t,!0);return k1(n,(r,a)=>{NX(n,r,DX(a))},i),e&&(e.finalized_=!1),n}var vNe=new gNe;vNe.produce;var yNe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},OX=Fa({name:"legend",initialState:yNe,reducers:{setLegendSize(t,e){t.size.width=e.payload.width,t.size.height=e.payload.height},setLegendSettings(t,e){t.settings.align=e.payload.align,t.settings.layout=e.payload.layout,t.settings.verticalAlign=e.payload.verticalAlign,t.settings.itemSorter=e.payload.itemSorter},addLegendPayload:{reducer(t,e){t.payload.push(e.payload)},prepare:oi()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:i}=e.payload,r=xo(t).payload.indexOf(n);r>-1&&(t.payload[r]=i)},prepare:oi()},removeLegendPayload:{reducer(t,e){var n=xo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:oi()}}}),{setLegendSize:t6,setLegendSettings:bNe,addLegendPayload:kX,replaceLegendPayload:LX,removeLegendPayload:IX}=OX.actions,_Ne=OX.reducer,SNe=["contextPayload"];function rR(){return rR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},rR.apply(null,arguments)}function n6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Zp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n6(Object(n),!0).forEach(function(i){wNe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function wNe(t,e,n){return(e=MNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MNe(t){var e=ENe(t,"string");return typeof e=="symbol"?e:e+""}function ENe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ANe(t,e){if(t==null)return{};var n,i,r=TNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function TNe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function CNe(t){return t.value}function NNe(t){var{contextPayload:e}=t,n=ANe(t,SNe),i=kq(e,t.payloadUniqBy,CNe),r=Zp(Zp({},n),{},{payload:i});return A.isValidElement(t.content)?A.cloneElement(t.content,r):typeof t.content=="function"?A.createElement(t.content,r):A.createElement(MTe,r)}function RNe(t,e,n,i,r,a){var{layout:s,align:o,verticalAlign:l}=e,c,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(o==="center"&&s==="vertical"?c={left:((i||0)-a.width)/2}:c=o==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(l==="middle"?d={top:((r||0)-a.height)/2}:d=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Zp(Zp({},c),d)}function PNe(t){var e=Qn();return A.useEffect(()=>{e(bNe(t))},[e,t]),null}function DNe(t){var e=Qn();return A.useEffect(()=>(e(t6(t)),()=>{e(t6({width:0,height:0}))}),[e,t]),null}function ONe(t,e,n,i){return t==="vertical"&&Et(e)?{height:e}:t==="horizontal"?{width:n||i}:null}var kNe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function UX(t){var e=Xi(t,kNe),n=h2e(),i=gAe(),r=aNe(),{width:a,height:s,wrapperStyle:o,portal:l}=e,[c,d]=Fq([n]),f=zD(),p=BD();if(f==null||p==null)return null;var m=f-(r?.left||0)-(r?.right||0),_=ONe(e.layout,s,a,m),b=l?o:Zp(Zp({position:"absolute",width:_?.width||a||"auto",height:_?.height||s||"auto"},RNe(o,e,r,f,p,c)),o),v=l??i;if(v==null||n==null)return null;var x=A.createElement("div",{className:"recharts-legend-wrapper",style:b,ref:d},A.createElement(PNe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&A.createElement(DNe,{width:c.width,height:c.height}),A.createElement(NNe,rR({},e,_,{margin:r,chartWidth:f,chartHeight:p,contextPayload:n})));return $l.createPortal(x,v)}UX.displayName="Legend";function aR(){return aR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},aR.apply(null,arguments)}function i6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function nC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i6(Object(n),!0).forEach(function(i){LNe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function LNe(t,e,n){return(e=INe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function INe(t){var e=UNe(t,"string");return typeof e=="symbol"?e:e+""}function UNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function jNe(t){return Array.isArray(t)&&Ko(t[0])&&Ko(t[1])?t.join(" ~ "):t}var FNe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:i={},labelStyle:r={},payload:a,formatter:s,itemSorter:o,wrapperClassName:l,labelClassName:c,label:d,labelFormatter:f,accessibilityLayer:p=!1}=t,m=()=>{if(a&&a.length){var T={padding:0,margin:0},P=(o?ew(a,o):a).map((N,U)=>{if(N.type==="none")return null;var R=N.formatter||s||jNe,{value:O,name:z}=N,I=O,G=z;if(R){var L=R(O,z,N,U,a);if(Array.isArray(L))[I,G]=L;else if(L!=null)I=L;else return null}var B=nC({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},i);return A.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(U),style:B},Ko(G)?A.createElement("span",{className:"recharts-tooltip-item-name"},G):null,Ko(G)?A.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,A.createElement("span",{className:"recharts-tooltip-item-value"},I),A.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return A.createElement("ul",{className:"recharts-tooltip-item-list",style:T},P)}return null},_=nC({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),b=nC({margin:0},r),v=!mi(d),x=v?d:"",M=Mn("recharts-default-tooltip",l),w=Mn("recharts-tooltip-label",c);v&&f&&a!==void 0&&a!==null&&(x=f(d,a));var E=p?{role:"status","aria-live":"assertive"}:{};return A.createElement("div",aR({className:M,style:_},E),A.createElement("p",{className:w,style:b},A.isValidElement(x)?x:"".concat(x)),m())},Og="recharts-tooltip-wrapper",zNe={visibility:"hidden"};function BNe(t){var{coordinate:e,translateX:n,translateY:i}=t;return Mn(Og,{["".concat(Og,"-right")]:Et(n)&&e&&Et(e.x)&&n>=e.x,["".concat(Og,"-left")]:Et(n)&&e&&Et(e.x)&&n<e.x,["".concat(Og,"-bottom")]:Et(i)&&e&&Et(e.y)&&i>=e.y,["".concat(Og,"-top")]:Et(i)&&e&&Et(e.y)&&i<e.y})}function r6(t){var{allowEscapeViewBox:e,coordinate:n,key:i,offsetTopLeft:r,position:a,reverseDirection:s,tooltipDimension:o,viewBox:l,viewBoxDimension:c}=t;if(a&&Et(a[i]))return a[i];var d=n[i]-o-(r>0?r:0),f=n[i]+r;if(e[i])return s[i]?d:f;var p=l[i];if(p==null)return 0;if(s[i]){var m=d,_=p;return m<_?Math.max(f,p):Math.max(d,p)}if(c==null)return 0;var b=f+o,v=p+c;return b>v?Math.max(d,p):Math.max(f,p)}function HNe(t){var{translateX:e,translateY:n,useTranslate3d:i}=t;return{transform:i?"translate3d(".concat(e,"px, ").concat(n,"px, 0)"):"translate(".concat(e,"px, ").concat(n,"px)")}}function VNe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:i,position:r,reverseDirection:a,tooltipBox:s,useTranslate3d:o,viewBox:l}=t,c,d,f;return s.height>0&&s.width>0&&n?(d=r6({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:i,position:r,reverseDirection:a,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=r6({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:i,position:r,reverseDirection:a,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),c=HNe({translateX:d,translateY:f,useTranslate3d:o})):c=zNe,{cssProperties:c,cssClasses:BNe({translateX:d,translateY:f,coordinate:n})}}function a6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Rb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a6(Object(n),!0).forEach(function(i){sR(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function sR(t,e,n){return(e=$Ne(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Ne(t){var e=GNe(t,"string");return typeof e=="symbol"?e:e+""}function GNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class WNe extends A.PureComponent{constructor(){super(...arguments),sR(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),sR(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,i,r,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(i=this.props.coordinate)===null||i===void 0?void 0:i.x)!==null&&n!==void 0?n:0,y:(r=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&r!==void 0?r:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:i,animationEasing:r,children:a,coordinate:s,hasPayload:o,isAnimationActive:l,offset:c,position:d,reverseDirection:f,useTranslate3d:p,viewBox:m,wrapperStyle:_,lastBoundingBox:b,innerRef:v,hasPortalFromProps:x}=this.props,{cssClasses:M,cssProperties:w}=VNe({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:c,position:d,reverseDirection:f,tooltipBox:{height:b.height,width:b.width},useTranslate3d:p,viewBox:m}),E=x?{}:Rb(Rb({transition:l&&e?"transform ".concat(i,"ms ").concat(r):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&o?"visible":"hidden",position:"absolute",top:0,left:0}),T=Rb(Rb({},E),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},_);return A.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:T,ref:v},a)}}var jX=()=>{var t;return(t=At(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function oR(){return oR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},oR.apply(null,arguments)}function s6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function o6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s6(Object(n),!0).forEach(function(i){qNe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function qNe(t,e,n){return(e=XNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XNe(t){var e=KNe(t,"string");return typeof e=="symbol"?e:e+""}function KNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var l6={curveBasisClosed:LAe,curveBasisOpen:IAe,curveBasis:kAe,curveBumpX:bAe,curveBumpY:_Ae,curveLinearClosed:UAe,curveLinear:QS,curveMonotoneX:jAe,curveMonotoneY:FAe,curveNatural:zAe,curveStep:BAe,curveStepAfter:VAe,curveStepBefore:HAe},U1=t=>ai(t.x)&&ai(t.y),c6=t=>t.base!=null&&U1(t.base)&&U1(t),kg=t=>t.x,Lg=t=>t.y,YNe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Mx(t));return(n==="curveMonotone"||n==="curveBump")&&e?l6["".concat(n).concat(e==="vertical"?"Y":"X")]:l6[n]||QS},ZNe=t=>{var{type:e="linear",points:n=[],baseLine:i,layout:r,connectNulls:a=!1}=t,s=YNe(e,r),o=a?n.filter(U1):n,l;if(Array.isArray(i)){var c=n.map((m,_)=>o6(o6({},m),{},{base:i[_]}));r==="vertical"?l=Sb().y(Lg).x1(kg).x0(m=>m.base.x):l=Sb().x(kg).y1(Lg).y0(m=>m.base.y);var d=l.defined(c6).curve(s),f=a?c.filter(c6):c;return d(f)}r==="vertical"&&Et(i)?l=Sb().y(Lg).x1(kg).x0(i):Et(i)?l=Sb().x(kg).y1(Lg).y0(i):l=cq().x(kg).y(Lg);var p=l.defined(U1).curve(s);return p(o)},Ap=t=>{var{className:e,points:n,path:i,pathRef:r}=t;if((!n||!n.length)&&!i)return null;var a=n&&n.length?ZNe(t):i;return A.createElement("path",oR({},Ua(t),TD(t),{className:Mn("recharts-curve",e),d:a===null?void 0:a,ref:r}))},QNe=["x","y","top","left","width","height","className"];function lR(){return lR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},lR.apply(null,arguments)}function u6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function JNe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?u6(Object(n),!0).forEach(function(i){e3e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function e3e(t,e,n){return(e=t3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function t3e(t){var e=n3e(t,"string");return typeof e=="symbol"?e:e+""}function n3e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function i3e(t,e){if(t==null)return{};var n,i,r=r3e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function r3e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var a3e=(t,e,n,i,r,a)=>"M".concat(t,",").concat(r,"v").concat(i,"M").concat(a,",").concat(e,"h").concat(n),s3e=t=>{var{x:e=0,y:n=0,top:i=0,left:r=0,width:a=0,height:s=0,className:o}=t,l=i3e(t,QNe),c=JNe({x:e,y:n,top:i,left:r,width:a,height:s},l);return!Et(e)||!Et(n)||!Et(a)||!Et(s)||!Et(i)||!Et(r)?null:A.createElement("path",lR({},ya(c),{className:Mn("recharts-cross",o),d:a3e(e,n,a,s,i,r)}))};function o3e(t,e,n,i){var r=i/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-r:n.left+.5,y:t==="horizontal"?n.top+.5:e.y-r,width:t==="horizontal"?i:n.width-1,height:t==="horizontal"?n.height-1:i}}function d6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function f6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d6(Object(n),!0).forEach(function(i){l3e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function l3e(t,e,n){return(e=c3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c3e(t){var e=u3e(t,"string");return typeof e=="symbol"?e:e+""}function u3e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var d3e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),FX=(t,e,n)=>t.map(i=>"".concat(d3e(i)," ").concat(e,"ms ").concat(n)).join(","),f3e=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,i)=>n.filter(r=>i.includes(r))),J0=(t,e)=>Object.keys(e).reduce((n,i)=>f6(f6({},n),{},{[i]:t(i,e[i])}),{});function h6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function er(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h6(Object(n),!0).forEach(function(i){h3e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function h3e(t,e,n){return(e=p3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p3e(t){var e=m3e(t,"string");return typeof e=="symbol"?e:e+""}function m3e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var j1=(t,e,n)=>t+(e-t)*n,cR=t=>{var{from:e,to:n}=t;return e!==n},zX=(t,e,n)=>{var i=J0((r,a)=>{if(cR(a)){var[s,o]=t(a.from,a.to,a.velocity);return er(er({},a),{},{from:s,velocity:o})}return a},e);return n<1?J0((r,a)=>cR(a)?er(er({},a),{},{velocity:j1(a.velocity,i[r].velocity,n),from:j1(a.from,i[r].from,n)}):a,e):zX(t,i,n-1)};function g3e(t,e,n,i,r,a){var s,o=i.reduce((p,m)=>er(er({},p),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),l=()=>J0((p,m)=>m.from,o),c=()=>!Object.values(o).filter(cR).length,d=null,f=p=>{s||(s=p);var m=p-s,_=m/n.dt;o=zX(n,o,_),r(er(er(er({},t),e),l())),s=p,c()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var p;(p=d)===null||p===void 0||p()})}function x3e(t,e,n,i,r,a,s){var o=null,l=r.reduce((f,p)=>er(er({},f),{},{[p]:[t[p],e[p]]}),{}),c,d=f=>{c||(c=f);var p=(f-c)/i,m=J0((b,v)=>j1(...v,n(p)),l);if(a(er(er(er({},t),e),m)),p<1)o=s.setTimeout(d);else{var _=J0((b,v)=>j1(...v,n(1)),l);a(er(er(er({},t),e),_))}};return()=>(o=s.setTimeout(d),()=>{var f;(f=o)===null||f===void 0||f()})}const v3e=(t,e,n,i,r,a)=>{var s=f3e(t,e);return n==null?()=>(r(er(er({},t),e)),()=>{}):n.isStepper===!0?g3e(t,e,n,s,r,a):x3e(t,e,n,i,s,r,a)};var F1=1e-4,BX=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],HX=(t,e)=>t.map((n,i)=>n*e**i).reduce((n,i)=>n+i),p6=(t,e)=>n=>{var i=BX(t,e);return HX(i,n)},y3e=(t,e)=>n=>{var i=BX(t,e),r=[...i.map((a,s)=>a*s).slice(1),0];return HX(r,n)},b3e=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var r,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((r=a[1])===null||r===void 0?void 0:r.split(")")[0].split(",").length)===4){var s=a[1].split(")")[0].split(",").map(o=>parseFloat(o));return[s[0],s[1],s[2],s[3]]}}}return n.length===4?n:[0,0,1,1]},_3e=(t,e,n,i)=>{var r=p6(t,n),a=p6(e,i),s=y3e(t,n),o=c=>c>1?1:c<0?0:c,l=c=>{for(var d=c>1?1:c,f=d,p=0;p<8;++p){var m=r(f)-d,_=s(f);if(Math.abs(m-d)<F1||_<F1)return a(f);f=o(f-m/_)}return a(f)};return l.isStepper=!1,l},m6=function(){return _3e(...b3e(...arguments))},S3e=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:i=8,dt:r=17}=e,a=(s,o,l)=>{var c=-(s-o)*n,d=l*i,f=l+(c-d)*r/1e3,p=l*r/1e3+s;return Math.abs(p-o)<F1&&Math.abs(f)<F1?[o,0]:[p,f]};return a.isStepper=!0,a.dt=r,a},w3e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return m6(t);case"spring":return S3e();default:if(t.split("(")[0]==="cubic-bezier")return m6(t)}return typeof t=="function"?t:null};function M3e(t){var e,n=()=>null,i=!1,r=null,a=s=>{if(!i){if(Array.isArray(s)){if(!s.length)return;var o=s,[l,...c]=o;if(typeof l=="number"){r=t.setTimeout(a.bind(null,c),l);return}a(l),r=t.setTimeout(a.bind(null,c));return}typeof s=="string"&&(e=s,n(e)),typeof s=="object"&&(e=s,n(e)),typeof s=="function"&&s()}};return{stop:()=>{i=!0},start:s=>{i=!1,r&&(r(),r=null),a(s)},subscribe:s=>(n=s,()=>{n=()=>null}),getTimeoutController:()=>t}}class E3e{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=performance.now(),r=null,a=s=>{s-i>=n?e(s):typeof requestAnimationFrame=="function"&&(r=requestAnimationFrame(a))};return r=requestAnimationFrame(a),()=>{r!=null&&cancelAnimationFrame(r)}}}function A3e(){return M3e(new E3e)}var T3e=A.createContext(A3e);function C3e(t,e){var n=A.useContext(T3e);return A.useMemo(()=>e??n(t),[t,e,n])}var N3e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),hm={devToolsEnabled:!1,isSsr:N3e()},R3e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},g6={t:0},iC={t:1};function Dx(t){var e=Xi(t,R3e),{isActive:n,canBegin:i,duration:r,easing:a,begin:s,onAnimationEnd:o,onAnimationStart:l,children:c}=e,d=n==="auto"?!hm.isSsr:n,f=C3e(e.animationId,e.animationManager),[p,m]=A.useState(d?g6:iC),_=A.useRef(null);return A.useEffect(()=>{d||m(iC)},[d]),A.useEffect(()=>{if(!d||!i)return Ex;var b=v3e(g6,iC,w3e(a),r,m,f.getTimeoutController()),v=()=>{_.current=b()};return f.start([l,s,v,r,o]),()=>{f.stop(),_.current&&_.current(),o()}},[d,i,r,a,s,l,o,f]),c(p.t)}function Ox(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=A.useRef(W0(e)),i=A.useRef(t);return i.current!==t&&(n.current=W0(e),i.current=t),n.current}var P3e=["radius"],D3e=["radius"];function x6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function v6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x6(Object(n),!0).forEach(function(i){O3e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function O3e(t,e,n){return(e=k3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function k3e(t){var e=L3e(t,"string");return typeof e=="symbol"?e:e+""}function L3e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function z1(){return z1=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},z1.apply(null,arguments)}function y6(t,e){if(t==null)return{};var n,i,r=I3e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function I3e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var b6=(t,e,n,i,r)=>{var a=Math.min(Math.abs(n)/2,Math.abs(i)/2),s=i>=0?1:-1,o=n>=0?1:-1,l=i>=0&&n>=0||i<0&&n<0?1:0,c;if(a>0&&r instanceof Array){for(var d=[0,0,0,0],f=0,p=4;f<p;f++)d[f]=r[f]>a?a:r[f];c="M".concat(t,",").concat(e+s*d[0]),d[0]>0&&(c+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(l,",").concat(t+o*d[0],",").concat(e)),c+="L ".concat(t+n-o*d[1],",").concat(e),d[1]>0&&(c+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(l,`,
- `).concat(t+n,",").concat(e+s*d[1])),c+="L ".concat(t+n,",").concat(e+i-s*d[2]),d[2]>0&&(c+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(l,`,
- `).concat(t+n-o*d[2],",").concat(e+i)),c+="L ".concat(t+o*d[3],",").concat(e+i),d[3]>0&&(c+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(l,`,
- `).concat(t,",").concat(e+i-s*d[3])),c+="Z"}else if(a>0&&r===+r&&r>0){var m=Math.min(a,r);c="M ".concat(t,",").concat(e+s*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+o*m,",").concat(e,`
- L `).concat(t+n-o*m,",").concat(e,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n,",").concat(e+s*m,`
- L `).concat(t+n,",").concat(e+i-s*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t+n-o*m,",").concat(e+i,`
- L `).concat(t+o*m,",").concat(e+i,`
- A `).concat(m,",").concat(m,",0,0,").concat(l,",").concat(t,",").concat(e+i-s*m," Z")}else c="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(i," h ").concat(-n," Z");return c},_6={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},VX=t=>{var e=Xi(t,_6),n=A.useRef(null),[i,r]=A.useState(-1);A.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var W=n.current.getTotalLength();W&&r(W)}catch{}},[]);var{x:a,y:s,width:o,height:l,radius:c,className:d}=e,{animationEasing:f,animationDuration:p,animationBegin:m,isAnimationActive:_,isUpdateAnimationActive:b}=e,v=A.useRef(o),x=A.useRef(l),M=A.useRef(a),w=A.useRef(s),E=A.useMemo(()=>({x:a,y:s,width:o,height:l,radius:c}),[a,s,o,l,c]),T=Ox(E,"rectangle-");if(a!==+a||s!==+s||o!==+o||l!==+l||o===0||l===0)return null;var P=Mn("recharts-rectangle",d);if(!b){var N=ya(e),{radius:U}=N,R=y6(N,P3e);return A.createElement("path",z1({},R,{radius:typeof c=="number"?c:void 0,className:P,d:b6(a,s,o,l,c)}))}var O=v.current,z=x.current,I=M.current,G=w.current,L="0px ".concat(i===-1?1:i,"px"),B="".concat(i,"px 0px"),q=FX(["strokeDasharray"],p,typeof f=="string"?f:_6.animationEasing);return A.createElement(Dx,{animationId:T,key:T,canBegin:i>0,duration:p,easing:f,isActive:b,begin:m},W=>{var X=ri(O,o,W),Q=ri(z,l,W),ie=ri(I,a,W),H=ri(G,s,W);n.current&&(v.current=X,x.current=Q,M.current=ie,w.current=H);var Y;_?W>0?Y={transition:q,strokeDasharray:B}:Y={strokeDasharray:L}:Y={strokeDasharray:B};var se=ya(e),{radius:ue}=se,xe=y6(se,D3e);return A.createElement("path",z1({},xe,{radius:typeof c=="number"?c:void 0,className:P,d:b6(ie,H,X,Q,c),ref:n,style:v6(v6({},Y),e.style)}))})};function S6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function w6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S6(Object(n),!0).forEach(function(i){U3e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function U3e(t,e,n){return(e=j3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j3e(t){var e=F3e(t,"string");return typeof e=="symbol"?e:e+""}function F3e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var B1=Math.PI/180,z3e=t=>t*180/Math.PI,Vi=(t,e,n,i)=>({x:t+Math.cos(-B1*i)*n,y:e+Math.sin(-B1*i)*n}),$X=function(e,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(e-(i.left||0)-(i.right||0)),Math.abs(n-(i.top||0)-(i.bottom||0)))/2},B3e=(t,e)=>{var{x:n,y:i}=t,{x:r,y:a}=e;return Math.sqrt((n-r)**2+(i-a)**2)},H3e=(t,e)=>{var{x:n,y:i}=t,{cx:r,cy:a}=e,s=B3e({x:n,y:i},{x:r,y:a});if(s<=0)return{radius:s,angle:0};var o=(n-r)/s,l=Math.acos(o);return i>a&&(l=2*Math.PI-l),{radius:s,angle:z3e(l),angleInRadian:l}},V3e=t=>{var{startAngle:e,endAngle:n}=t,i=Math.floor(e/360),r=Math.floor(n/360),a=Math.min(i,r);return{startAngle:e-a*360,endAngle:n-a*360}},$3e=(t,e)=>{var{startAngle:n,endAngle:i}=e,r=Math.floor(n/360),a=Math.floor(i/360),s=Math.min(r,a);return t+s*360},G3e=(t,e)=>{var{chartX:n,chartY:i}=t,{radius:r,angle:a}=H3e({x:n,y:i},e),{innerRadius:s,outerRadius:o}=e;if(r<s||r>o||r===0)return null;var{startAngle:l,endAngle:c}=V3e(e),d=a,f;if(l<=c){for(;d>c;)d-=360;for(;d<l;)d+=360;f=d>=l&&d<=c}else{for(;d>l;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=l}return f?w6(w6({},e),{},{radius:r,angle:$3e(d,e)}):null};function GX(t){var{cx:e,cy:n,radius:i,startAngle:r,endAngle:a}=t,s=Vi(e,n,i,r),o=Vi(e,n,i,a);return{points:[s,o],cx:e,cy:n,radius:i,startAngle:r,endAngle:a}}function uR(){return uR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},uR.apply(null,arguments)}var W3e=(t,e)=>{var n=Mr(e-t),i=Math.min(Math.abs(e-t),359.999);return n*i},Pb=t=>{var{cx:e,cy:n,radius:i,angle:r,sign:a,isExternal:s,cornerRadius:o,cornerIsExternal:l}=t,c=o*(s?1:-1)+i,d=Math.asin(o/c)/B1,f=l?r:r+a*d,p=Vi(e,n,c,f),m=Vi(e,n,i,f),_=l?r-a*d:r,b=Vi(e,n,c*Math.cos(d*B1),_);return{center:p,circleTangency:m,lineTangency:b,theta:d}},WX=t=>{var{cx:e,cy:n,innerRadius:i,outerRadius:r,startAngle:a,endAngle:s}=t,o=W3e(a,s),l=a+o,c=Vi(e,n,r,a),d=Vi(e,n,r,l),f="M ".concat(c.x,",").concat(c.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(a>l),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(i>0){var p=Vi(e,n,i,a),m=Vi(e,n,i,l);f+="L ".concat(m.x,",").concat(m.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(a<=l),`,
- `).concat(p.x,",").concat(p.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},q3e=t=>{var{cx:e,cy:n,innerRadius:i,outerRadius:r,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:o,startAngle:l,endAngle:c}=t,d=Mr(c-l),{circleTangency:f,lineTangency:p,theta:m}=Pb({cx:e,cy:n,radius:r,angle:l,sign:d,cornerRadius:a,cornerIsExternal:o}),{circleTangency:_,lineTangency:b,theta:v}=Pb({cx:e,cy:n,radius:r,angle:c,sign:-d,cornerRadius:a,cornerIsExternal:o}),x=o?Math.abs(l-c):Math.abs(l-c)-m-v;if(x<0)return s?"M ".concat(p.x,",").concat(p.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):WX({cx:e,cy:n,innerRadius:i,outerRadius:r,startAngle:l,endAngle:c});var M="M ".concat(p.x,",").concat(p.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(x>180),",").concat(+(d<0),",").concat(_.x,",").concat(_.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
- `);if(i>0){var{circleTangency:w,lineTangency:E,theta:T}=Pb({cx:e,cy:n,radius:i,angle:l,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),{circleTangency:P,lineTangency:N,theta:U}=Pb({cx:e,cy:n,radius:i,angle:c,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),R=o?Math.abs(l-c):Math.abs(l-c)-T-U;if(R<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(N.x,",").concat(N.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(P.x,",").concat(P.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(R>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(E.x,",").concat(E.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},X3e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},qX=t=>{var e=Xi(t,X3e),{cx:n,cy:i,innerRadius:r,outerRadius:a,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d,className:f}=e;if(a<r||c===d)return null;var p=Mn("recharts-sector",f),m=a-r,_=na(s,m,0,!0),b;return _>0&&Math.abs(c-d)<360?b=q3e({cx:n,cy:i,innerRadius:r,outerRadius:a,cornerRadius:Math.min(_,m/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:d}):b=WX({cx:n,cy:i,innerRadius:r,outerRadius:a,startAngle:c,endAngle:d}),A.createElement("path",uR({},ya(e),{className:p,d:b}))};function K3e(t,e,n){if(t==="horizontal")return[{x:e.x,y:n.top},{x:e.x,y:n.top+n.height}];if(t==="vertical")return[{x:n.left,y:e.y},{x:n.left+n.width,y:e.y}];if(Mq(e)){if(t==="centric"){var{cx:i,cy:r,innerRadius:a,outerRadius:s,angle:o}=e,l=Vi(i,r,a,o),c=Vi(i,r,s,o);return[{x:l.x,y:l.y},{x:c.x,y:c.y}]}return GX(e)}}var rC={},aC={},sC={},M6;function Y3e(){return M6||(M6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Iq();function n(i){return e.isSymbol(i)?NaN:Number(i)}t.toNumber=n})(sC)),sC}var E6;function Z3e(){return E6||(E6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Y3e();function n(i){return i?(i=e.toNumber(i),i===1/0||i===-1/0?(i<0?-1:1)*Number.MAX_VALUE:i===i?i:0):i===0?i:0}t.toFinite=n})(aC)),aC}var A6;function Q3e(){return A6||(A6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Uq(),n=Z3e();function i(r,a,s){s&&typeof s!="number"&&e.isIterateeCall(r,a,s)&&(a=s=void 0),r=n.toFinite(r),a===void 0?(a=r,r=0):a=n.toFinite(a),s=s===void 0?r<a?1:-1:n.toFinite(s);const o=Math.max(Math.ceil((a-r)/(s||1)),0),l=new Array(o);for(let c=0;c<o;c++)l[c]=r,r+=s;return l}t.range=i})(rC)),rC}var oC,T6;function J3e(){return T6||(T6=1,oC=Q3e().range),oC}var eRe=J3e();const XX=qs(eRe);function ju(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function tRe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function $D(t){let e,n,i;t.length!==2?(e=ju,n=(o,l)=>ju(t(o),l),i=(o,l)=>t(o)-l):(e=t===ju||t===tRe?t:nRe,n=t,i=t);function r(o,l,c=0,d=o.length){if(c<d){if(e(l,l)!==0)return d;do{const f=c+d>>>1;n(o[f],l)<0?c=f+1:d=f}while(c<d)}return c}function a(o,l,c=0,d=o.length){if(c<d){if(e(l,l)!==0)return d;do{const f=c+d>>>1;n(o[f],l)<=0?c=f+1:d=f}while(c<d)}return c}function s(o,l,c=0,d=o.length){const f=r(o,l,c,d-1);return f>c&&i(o[f-1],l)>-i(o[f],l)?f-1:f}return{left:r,center:s,right:a}}function nRe(){return 0}function KX(t){return t===null?NaN:+t}function*iRe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const rRe=$D(ju),kx=rRe.right;$D(KX).center;class C6 extends Map{constructor(e,n=oRe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[i,r]of e)this.set(i,r)}get(e){return super.get(N6(this,e))}has(e){return super.has(N6(this,e))}set(e,n){return super.set(aRe(this,e),n)}delete(e){return super.delete(sRe(this,e))}}function N6({_intern:t,_key:e},n){const i=e(n);return t.has(i)?t.get(i):n}function aRe({_intern:t,_key:e},n){const i=e(n);return t.has(i)?t.get(i):(t.set(i,n),n)}function sRe({_intern:t,_key:e},n){const i=e(n);return t.has(i)&&(n=t.get(i),t.delete(i)),n}function oRe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function lRe(t=ju){if(t===ju)return YX;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{const i=t(e,n);return i||i===0?i:(t(n,n)===0)-(t(e,e)===0)}}function YX(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const cRe=Math.sqrt(50),uRe=Math.sqrt(10),dRe=Math.sqrt(2);function H1(t,e,n){const i=(e-t)/Math.max(0,n),r=Math.floor(Math.log10(i)),a=i/Math.pow(10,r),s=a>=cRe?10:a>=uRe?5:a>=dRe?2:1;let o,l,c;return r<0?(c=Math.pow(10,-r)/s,o=Math.round(t*c),l=Math.round(e*c),o/c<t&&++o,l/c>e&&--l,c=-c):(c=Math.pow(10,r)*s,o=Math.round(t/c),l=Math.round(e/c),o*c<t&&++o,l*c>e&&--l),l<o&&.5<=n&&n<2?H1(t,e,n*2):[o,l,c]}function dR(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const i=e<t,[r,a,s]=i?H1(e,t,n):H1(t,e,n);if(!(a>=r))return[];const o=a-r+1,l=new Array(o);if(i)if(s<0)for(let c=0;c<o;++c)l[c]=(a-c)/-s;else for(let c=0;c<o;++c)l[c]=(a-c)*s;else if(s<0)for(let c=0;c<o;++c)l[c]=(r+c)/-s;else for(let c=0;c<o;++c)l[c]=(r+c)*s;return l}function fR(t,e,n){return e=+e,t=+t,n=+n,H1(t,e,n)[2]}function hR(t,e,n){e=+e,t=+t,n=+n;const i=e<t,r=i?fR(e,t,n):fR(t,e,n);return(i?-1:1)*(r<0?1/-r:r)}function R6(t,e){let n;for(const i of t)i!=null&&(n<i||n===void 0&&i>=i)&&(n=i);return n}function P6(t,e){let n;for(const i of t)i!=null&&(n>i||n===void 0&&i>=i)&&(n=i);return n}function ZX(t,e,n=0,i=1/0,r){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),i=Math.floor(Math.min(t.length-1,i)),!(n<=e&&e<=i))return t;for(r=r===void 0?YX:lRe(r);i>n;){if(i-n>600){const l=i-n+1,c=e-n+1,d=Math.log(l),f=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*f*(l-f)/l)*(c-l/2<0?-1:1),m=Math.max(n,Math.floor(e-c*f/l+p)),_=Math.min(i,Math.floor(e+(l-c)*f/l+p));ZX(t,e,m,_,r)}const a=t[e];let s=n,o=i;for(Ig(t,n,e),r(t[i],a)>0&&Ig(t,n,i);s<o;){for(Ig(t,s,o),++s,--o;r(t[s],a)<0;)++s;for(;r(t[o],a)>0;)--o}r(t[n],a)===0?Ig(t,n,o):(++o,Ig(t,o,i)),o<=e&&(n=o+1),e<=o&&(i=o-1)}return t}function Ig(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function fRe(t,e,n){if(t=Float64Array.from(iRe(t)),!(!(i=t.length)||isNaN(e=+e))){if(e<=0||i<2)return P6(t);if(e>=1)return R6(t);var i,r=(i-1)*e,a=Math.floor(r),s=R6(ZX(t,a).subarray(0,a+1)),o=P6(t.subarray(a+1));return s+(o-s)*(r-a)}}function hRe(t,e,n=KX){if(!(!(i=t.length)||isNaN(e=+e))){if(e<=0||i<2)return+n(t[0],0,t);if(e>=1)return+n(t[i-1],i-1,t);var i,r=(i-1)*e,a=Math.floor(r),s=+n(t[a],a,t),o=+n(t[a+1],a+1,t);return s+(o-s)*(r-a)}}function pRe(t,e,n){t=+t,e=+e,n=(r=arguments.length)<2?(e=t,t=0,1):r<3?1:+n;for(var i=-1,r=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(r);++i<r;)a[i]=t+i*n;return a}function Xs(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Sc(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const pR=Symbol("implicit");function GD(){var t=new C6,e=[],n=[],i=pR;function r(a){let s=t.get(a);if(s===void 0){if(i!==pR)return i;t.set(a,s=e.push(a)-1)}return n[s%n.length]}return r.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new C6;for(const s of a)t.has(s)||t.set(s,e.push(s)-1);return r},r.range=function(a){return arguments.length?(n=Array.from(a),r):n.slice()},r.unknown=function(a){return arguments.length?(i=a,r):i},r.copy=function(){return GD(e,n).unknown(i)},Xs.apply(r,arguments),r}function WD(){var t=GD().unknown(void 0),e=t.domain,n=t.range,i=0,r=1,a,s,o=!1,l=0,c=0,d=.5;delete t.unknown;function f(){var p=e().length,m=r<i,_=m?r:i,b=m?i:r;a=(b-_)/Math.max(1,p-l+c*2),o&&(a=Math.floor(a)),_+=(b-_-a*(p-l))*d,s=a*(1-l),o&&(_=Math.round(_),s=Math.round(s));var v=pRe(p).map(function(x){return _+a*x});return n(m?v.reverse():v)}return t.domain=function(p){return arguments.length?(e(p),f()):e()},t.range=function(p){return arguments.length?([i,r]=p,i=+i,r=+r,f()):[i,r]},t.rangeRound=function(p){return[i,r]=p,i=+i,r=+r,o=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(p){return arguments.length?(o=!!p,f()):o},t.padding=function(p){return arguments.length?(l=Math.min(1,c=+p),f()):l},t.paddingInner=function(p){return arguments.length?(l=Math.min(1,p),f()):l},t.paddingOuter=function(p){return arguments.length?(c=+p,f()):c},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),f()):d},t.copy=function(){return WD(e(),[i,r]).round(o).paddingInner(l).paddingOuter(c).align(d)},Xs.apply(f(),arguments)}function QX(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return QX(e())},t}function mRe(){return QX(WD.apply(null,arguments).paddingInner(1))}function qD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function JX(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function Lx(){}var ex=.7,V1=1/ex,Tp="\\s*([+-]?\\d+)\\s*",tx="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Vo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gRe=/^#([0-9a-f]{3,8})$/,xRe=new RegExp(`^rgb\\(${Tp},${Tp},${Tp}\\)$`),vRe=new RegExp(`^rgb\\(${Vo},${Vo},${Vo}\\)$`),yRe=new RegExp(`^rgba\\(${Tp},${Tp},${Tp},${tx}\\)$`),bRe=new RegExp(`^rgba\\(${Vo},${Vo},${Vo},${tx}\\)$`),_Re=new RegExp(`^hsl\\(${tx},${Vo},${Vo}\\)$`),SRe=new RegExp(`^hsla\\(${tx},${Vo},${Vo},${tx}\\)$`),D6={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};qD(Lx,nx,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:O6,formatHex:O6,formatHex8:wRe,formatHsl:MRe,formatRgb:k6,toString:k6});function O6(){return this.rgb().formatHex()}function wRe(){return this.rgb().formatHex8()}function MRe(){return eK(this).formatHsl()}function k6(){return this.rgb().formatRgb()}function nx(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=gRe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?L6(e):n===3?new Da(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Db(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Db(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=xRe.exec(t))?new Da(e[1],e[2],e[3],1):(e=vRe.exec(t))?new Da(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=yRe.exec(t))?Db(e[1],e[2],e[3],e[4]):(e=bRe.exec(t))?Db(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=_Re.exec(t))?j6(e[1],e[2]/100,e[3]/100,1):(e=SRe.exec(t))?j6(e[1],e[2]/100,e[3]/100,e[4]):D6.hasOwnProperty(t)?L6(D6[t]):t==="transparent"?new Da(NaN,NaN,NaN,0):null}function L6(t){return new Da(t>>16&255,t>>8&255,t&255,1)}function Db(t,e,n,i){return i<=0&&(t=e=n=NaN),new Da(t,e,n,i)}function ERe(t){return t instanceof Lx||(t=nx(t)),t?(t=t.rgb(),new Da(t.r,t.g,t.b,t.opacity)):new Da}function mR(t,e,n,i){return arguments.length===1?ERe(t):new Da(t,e,n,i??1)}function Da(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}qD(Da,mR,JX(Lx,{brighter(t){return t=t==null?V1:Math.pow(V1,t),new Da(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ex:Math.pow(ex,t),new Da(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Da(ff(this.r),ff(this.g),ff(this.b),$1(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:I6,formatHex:I6,formatHex8:ARe,formatRgb:U6,toString:U6}));function I6(){return`#${Qd(this.r)}${Qd(this.g)}${Qd(this.b)}`}function ARe(){return`#${Qd(this.r)}${Qd(this.g)}${Qd(this.b)}${Qd((isNaN(this.opacity)?1:this.opacity)*255)}`}function U6(){const t=$1(this.opacity);return`${t===1?"rgb(":"rgba("}${ff(this.r)}, ${ff(this.g)}, ${ff(this.b)}${t===1?")":`, ${t})`}`}function $1(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ff(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Qd(t){return t=ff(t),(t<16?"0":"")+t.toString(16)}function j6(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new fo(t,e,n,i)}function eK(t){if(t instanceof fo)return new fo(t.h,t.s,t.l,t.opacity);if(t instanceof Lx||(t=nx(t)),!t)return new fo;if(t instanceof fo)return t;t=t.rgb();var e=t.r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),a=Math.max(e,n,i),s=NaN,o=a-r,l=(a+r)/2;return o?(e===a?s=(n-i)/o+(n<i)*6:n===a?s=(i-e)/o+2:s=(e-n)/o+4,o/=l<.5?a+r:2-a-r,s*=60):o=l>0&&l<1?0:s,new fo(s,o,l,t.opacity)}function TRe(t,e,n,i){return arguments.length===1?eK(t):new fo(t,e,n,i??1)}function fo(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}qD(fo,TRe,JX(Lx,{brighter(t){return t=t==null?V1:Math.pow(V1,t),new fo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ex:Math.pow(ex,t),new fo(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new Da(lC(t>=240?t-240:t+120,r,i),lC(t,r,i),lC(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new fo(F6(this.h),Ob(this.s),Ob(this.l),$1(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=$1(this.opacity);return`${t===1?"hsl(":"hsla("}${F6(this.h)}, ${Ob(this.s)*100}%, ${Ob(this.l)*100}%${t===1?")":`, ${t})`}`}}));function F6(t){return t=(t||0)%360,t<0?t+360:t}function Ob(t){return Math.max(0,Math.min(1,t||0))}function lC(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const XD=t=>()=>t;function CRe(t,e){return function(n){return t+n*e}}function NRe(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}function RRe(t){return(t=+t)==1?tK:function(e,n){return n-e?NRe(e,n,t):XD(isNaN(e)?n:e)}}function tK(t,e){var n=e-t;return n?CRe(t,n):XD(isNaN(t)?e:t)}const z6=(function t(e){var n=RRe(e);function i(r,a){var s=n((r=mR(r)).r,(a=mR(a)).r),o=n(r.g,a.g),l=n(r.b,a.b),c=tK(r.opacity,a.opacity);return function(d){return r.r=s(d),r.g=o(d),r.b=l(d),r.opacity=c(d),r+""}}return i.gamma=t,i})(1);function PRe(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,i=e.slice(),r;return function(a){for(r=0;r<n;++r)i[r]=t[r]*(1-a)+e[r]*a;return i}}function DRe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function ORe(t,e){var n=e?e.length:0,i=t?Math.min(n,t.length):0,r=new Array(i),a=new Array(n),s;for(s=0;s<i;++s)r[s]=pm(t[s],e[s]);for(;s<n;++s)a[s]=e[s];return function(o){for(s=0;s<i;++s)a[s]=r[s](o);return a}}function kRe(t,e){var n=new Date;return t=+t,e=+e,function(i){return n.setTime(t*(1-i)+e*i),n}}function G1(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function LRe(t,e){var n={},i={},r;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(r in e)r in t?n[r]=pm(t[r],e[r]):i[r]=e[r];return function(a){for(r in n)i[r]=n[r](a);return i}}var gR=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,cC=new RegExp(gR.source,"g");function IRe(t){return function(){return t}}function URe(t){return function(e){return t(e)+""}}function jRe(t,e){var n=gR.lastIndex=cC.lastIndex=0,i,r,a,s=-1,o=[],l=[];for(t=t+"",e=e+"";(i=gR.exec(t))&&(r=cC.exec(e));)(a=r.index)>n&&(a=e.slice(n,a),o[s]?o[s]+=a:o[++s]=a),(i=i[0])===(r=r[0])?o[s]?o[s]+=r:o[++s]=r:(o[++s]=null,l.push({i:s,x:G1(i,r)})),n=cC.lastIndex;return n<e.length&&(a=e.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?l[0]?URe(l[0].x):IRe(e):(e=l.length,function(c){for(var d=0,f;d<e;++d)o[(f=l[d]).i]=f.x(c);return o.join("")})}function pm(t,e){var n=typeof e,i;return e==null||n==="boolean"?XD(e):(n==="number"?G1:n==="string"?(i=nx(e))?(e=i,z6):jRe:e instanceof nx?z6:e instanceof Date?kRe:DRe(e)?PRe:Array.isArray(e)?ORe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?LRe:G1)(t,e)}function KD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function FRe(t,e){e===void 0&&(e=t,t=pm);for(var n=0,i=e.length-1,r=e[0],a=new Array(i<0?0:i);n<i;)a[n]=t(r,r=e[++n]);return function(s){var o=Math.max(0,Math.min(i-1,Math.floor(s*=i)));return a[o](s-o)}}function zRe(t){return function(){return t}}function W1(t){return+t}var B6=[0,1];function ha(t){return t}function xR(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:zRe(isNaN(e)?NaN:.5)}function BRe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(i){return Math.max(t,Math.min(e,i))}}function HRe(t,e,n){var i=t[0],r=t[1],a=e[0],s=e[1];return r<i?(i=xR(r,i),a=n(s,a)):(i=xR(i,r),a=n(a,s)),function(o){return a(i(o))}}function VRe(t,e,n){var i=Math.min(t.length,e.length)-1,r=new Array(i),a=new Array(i),s=-1;for(t[i]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++s<i;)r[s]=xR(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(o){var l=kx(t,o,1,i)-1;return a[l](r[l](o))}}function Ix(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function vw(){var t=B6,e=B6,n=pm,i,r,a,s=ha,o,l,c;function d(){var p=Math.min(t.length,e.length);return s!==ha&&(s=BRe(t[0],t[p-1])),o=p>2?VRe:HRe,l=c=null,f}function f(p){return p==null||isNaN(p=+p)?a:(l||(l=o(t.map(i),e,n)))(i(s(p)))}return f.invert=function(p){return s(r((c||(c=o(e,t.map(i),G1)))(p)))},f.domain=function(p){return arguments.length?(t=Array.from(p,W1),d()):t.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),n=KD,d()},f.clamp=function(p){return arguments.length?(s=p?!0:ha,d()):s!==ha},f.interpolate=function(p){return arguments.length?(n=p,d()):n},f.unknown=function(p){return arguments.length?(a=p,f):a},function(p,m){return i=p,r=m,d()}}function YD(){return vw()(ha,ha)}function $Re(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function q1(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,i=t.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+t.slice(n+1)]}function Qp(t){return t=q1(Math.abs(t)),t?t[1]:NaN}function GRe(t,e){return function(n,i){for(var r=n.length,a=[],s=0,o=t[0],l=0;r>0&&o>0&&(l+o+1>i&&(o=Math.max(1,i-l)),a.push(n.substring(r-=o,r+o)),!((l+=o+1)>i));)o=t[s=(s+1)%t.length];return a.reverse().join(e)}}function WRe(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var qRe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ix(t){if(!(e=qRe.exec(t)))throw new Error("invalid format: "+t);var e;return new ZD({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}ix.prototype=ZD.prototype;function ZD(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}ZD.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function XRe(t){e:for(var e=t.length,n=1,i=-1,r;n<e;++n)switch(t[n]){case".":i=r=n;break;case"0":i===0&&(i=n),r=n;break;default:if(!+t[n])break e;i>0&&(i=0);break}return i>0?t.slice(0,i)+t.slice(r+1):t}var nK;function KRe(t,e){var n=q1(t,e);if(!n)return t+"";var i=n[0],r=n[1],a=r-(nK=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,s=i.length;return a===s?i:a>s?i+new Array(a-s+1).join("0"):a>0?i.slice(0,a)+"."+i.slice(a):"0."+new Array(1-a).join("0")+q1(t,Math.max(0,e+a-1))[0]}function H6(t,e){var n=q1(t,e);if(!n)return t+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const V6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:$Re,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>H6(t*100,e),r:H6,s:KRe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function $6(t){return t}var G6=Array.prototype.map,W6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function YRe(t){var e=t.grouping===void 0||t.thousands===void 0?$6:GRe(G6.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",i=t.currency===void 0?"":t.currency[1]+"",r=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?$6:WRe(G6.call(t.numerals,String)),s=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",l=t.nan===void 0?"NaN":t.nan+"";function c(f){f=ix(f);var p=f.fill,m=f.align,_=f.sign,b=f.symbol,v=f.zero,x=f.width,M=f.comma,w=f.precision,E=f.trim,T=f.type;T==="n"?(M=!0,T="g"):V6[T]||(w===void 0&&(w=12),E=!0,T="g"),(v||p==="0"&&m==="=")&&(v=!0,p="0",m="=");var P=b==="$"?n:b==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",N=b==="$"?i:/[%p]/.test(T)?s:"",U=V6[T],R=/[defgprs%]/.test(T);w=w===void 0?6:/[gprs]/.test(T)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function O(z){var I=P,G=N,L,B,q;if(T==="c")G=U(z)+G,z="";else{z=+z;var W=z<0||1/z<0;if(z=isNaN(z)?l:U(Math.abs(z),w),E&&(z=XRe(z)),W&&+z==0&&_!=="+"&&(W=!1),I=(W?_==="("?_:o:_==="-"||_==="("?"":_)+I,G=(T==="s"?W6[8+nK/3]:"")+G+(W&&_==="("?")":""),R){for(L=-1,B=z.length;++L<B;)if(q=z.charCodeAt(L),48>q||q>57){G=(q===46?r+z.slice(L+1):z.slice(L))+G,z=z.slice(0,L);break}}}M&&!v&&(z=e(z,1/0));var X=I.length+z.length+G.length,Q=X<x?new Array(x-X+1).join(p):"";switch(M&&v&&(z=e(Q+z,Q.length?x-G.length:1/0),Q=""),m){case"<":z=I+z+G+Q;break;case"=":z=I+Q+z+G;break;case"^":z=Q.slice(0,X=Q.length>>1)+I+z+G+Q.slice(X);break;default:z=Q+I+z+G;break}return a(z)}return O.toString=function(){return f+""},O}function d(f,p){var m=c((f=ix(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(Qp(p)/3)))*3,b=Math.pow(10,-_),v=W6[8+_/3];return function(x){return m(b*x)+v}}return{format:c,formatPrefix:d}}var kb,QD,iK;ZRe({thousands:",",grouping:[3],currency:["$",""]});function ZRe(t){return kb=YRe(t),QD=kb.format,iK=kb.formatPrefix,kb}function QRe(t){return Math.max(0,-Qp(Math.abs(t)))}function JRe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Qp(e)/3)))*3-Qp(Math.abs(t)))}function ePe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Qp(e)-Qp(t))+1}function rK(t,e,n,i){var r=hR(t,e,n),a;switch(i=ix(i??",f"),i.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return i.precision==null&&!isNaN(a=JRe(r,s))&&(i.precision=a),iK(i,s)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(a=ePe(r,Math.max(Math.abs(t),Math.abs(e))))&&(i.precision=a-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(a=QRe(r))&&(i.precision=a-(i.type==="%")*2);break}}return QD(i)}function ad(t){var e=t.domain;return t.ticks=function(n){var i=e();return dR(i[0],i[i.length-1],n??10)},t.tickFormat=function(n,i){var r=e();return rK(r[0],r[r.length-1],n??10,i)},t.nice=function(n){n==null&&(n=10);var i=e(),r=0,a=i.length-1,s=i[r],o=i[a],l,c,d=10;for(o<s&&(c=s,s=o,o=c,c=r,r=a,a=c);d-- >0;){if(c=fR(s,o,n),c===l)return i[r]=s,i[a]=o,e(i);if(c>0)s=Math.floor(s/c)*c,o=Math.ceil(o/c)*c;else if(c<0)s=Math.ceil(s*c)/c,o=Math.floor(o*c)/c;else break;l=c}return t},t}function aK(){var t=YD();return t.copy=function(){return Ix(t,aK())},Xs.apply(t,arguments),ad(t)}function sK(t){var e;function n(i){return i==null||isNaN(i=+i)?e:i}return n.invert=n,n.domain=n.range=function(i){return arguments.length?(t=Array.from(i,W1),n):t.slice()},n.unknown=function(i){return arguments.length?(e=i,n):e},n.copy=function(){return sK(t).unknown(e)},t=arguments.length?Array.from(t,W1):[0,1],ad(n)}function oK(t,e){t=t.slice();var n=0,i=t.length-1,r=t[n],a=t[i],s;return a<r&&(s=n,n=i,i=s,s=r,r=a,a=s),t[n]=e.floor(r),t[i]=e.ceil(a),t}function q6(t){return Math.log(t)}function X6(t){return Math.exp(t)}function tPe(t){return-Math.log(-t)}function nPe(t){return-Math.exp(-t)}function iPe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function rPe(t){return t===10?iPe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function aPe(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function K6(t){return(e,n)=>-t(-e,n)}function JD(t){const e=t(q6,X6),n=e.domain;let i=10,r,a;function s(){return r=aPe(i),a=rPe(i),n()[0]<0?(r=K6(r),a=K6(a),t(tPe,nPe)):t(q6,X6),e}return e.base=function(o){return arguments.length?(i=+o,s()):i},e.domain=function(o){return arguments.length?(n(o),s()):n()},e.ticks=o=>{const l=n();let c=l[0],d=l[l.length-1];const f=d<c;f&&([c,d]=[d,c]);let p=r(c),m=r(d),_,b;const v=o==null?10:+o;let x=[];if(!(i%1)&&m-p<v){if(p=Math.floor(p),m=Math.ceil(m),c>0){for(;p<=m;++p)for(_=1;_<i;++_)if(b=p<0?_/a(-p):_*a(p),!(b<c)){if(b>d)break;x.push(b)}}else for(;p<=m;++p)for(_=i-1;_>=1;--_)if(b=p>0?_/a(-p):_*a(p),!(b<c)){if(b>d)break;x.push(b)}x.length*2<v&&(x=dR(c,d,v))}else x=dR(p,m,Math.min(m-p,v)).map(a);return f?x.reverse():x},e.tickFormat=(o,l)=>{if(o==null&&(o=10),l==null&&(l=i===10?"s":","),typeof l!="function"&&(!(i%1)&&(l=ix(l)).precision==null&&(l.trim=!0),l=QD(l)),o===1/0)return l;const c=Math.max(1,i*o/e.ticks().length);return d=>{let f=d/a(Math.round(r(d)));return f*i<i-.5&&(f*=i),f<=c?l(d):""}},e.nice=()=>n(oK(n(),{floor:o=>a(Math.floor(r(o))),ceil:o=>a(Math.ceil(r(o)))})),e}function lK(){const t=JD(vw()).domain([1,10]);return t.copy=()=>Ix(t,lK()).base(t.base()),Xs.apply(t,arguments),t}function Y6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Z6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function eO(t){var e=1,n=t(Y6(e),Z6(e));return n.constant=function(i){return arguments.length?t(Y6(e=+i),Z6(e)):e},ad(n)}function cK(){var t=eO(vw());return t.copy=function(){return Ix(t,cK()).constant(t.constant())},Xs.apply(t,arguments)}function Q6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function sPe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function oPe(t){return t<0?-t*t:t*t}function tO(t){var e=t(ha,ha),n=1;function i(){return n===1?t(ha,ha):n===.5?t(sPe,oPe):t(Q6(n),Q6(1/n))}return e.exponent=function(r){return arguments.length?(n=+r,i()):n},ad(e)}function nO(){var t=tO(vw());return t.copy=function(){return Ix(t,nO()).exponent(t.exponent())},Xs.apply(t,arguments),t}function lPe(){return nO.apply(null,arguments).exponent(.5)}function J6(t){return Math.sign(t)*t*t}function cPe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function uK(){var t=YD(),e=[0,1],n=!1,i;function r(a){var s=cPe(t(a));return isNaN(s)?i:n?Math.round(s):s}return r.invert=function(a){return t.invert(J6(a))},r.domain=function(a){return arguments.length?(t.domain(a),r):t.domain()},r.range=function(a){return arguments.length?(t.range((e=Array.from(a,W1)).map(J6)),r):e.slice()},r.rangeRound=function(a){return r.range(a).round(!0)},r.round=function(a){return arguments.length?(n=!!a,r):n},r.clamp=function(a){return arguments.length?(t.clamp(a),r):t.clamp()},r.unknown=function(a){return arguments.length?(i=a,r):i},r.copy=function(){return uK(t.domain(),e).round(n).clamp(t.clamp()).unknown(i)},Xs.apply(r,arguments),ad(r)}function dK(){var t=[],e=[],n=[],i;function r(){var s=0,o=Math.max(1,e.length);for(n=new Array(o-1);++s<o;)n[s-1]=hRe(t,s/o);return a}function a(s){return s==null||isNaN(s=+s)?i:e[kx(n,s)]}return a.invertExtent=function(s){var o=e.indexOf(s);return o<0?[NaN,NaN]:[o>0?n[o-1]:t[0],o<n.length?n[o]:t[t.length-1]]},a.domain=function(s){if(!arguments.length)return t.slice();t=[];for(let o of s)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(ju),r()},a.range=function(s){return arguments.length?(e=Array.from(s),r()):e.slice()},a.unknown=function(s){return arguments.length?(i=s,a):i},a.quantiles=function(){return n.slice()},a.copy=function(){return dK().domain(t).range(e).unknown(i)},Xs.apply(a,arguments)}function fK(){var t=0,e=1,n=1,i=[.5],r=[0,1],a;function s(l){return l!=null&&l<=l?r[kx(i,l,0,n)]:a}function o(){var l=-1;for(i=new Array(n);++l<n;)i[l]=((l+1)*e-(l-n)*t)/(n+1);return s}return s.domain=function(l){return arguments.length?([t,e]=l,t=+t,e=+e,o()):[t,e]},s.range=function(l){return arguments.length?(n=(r=Array.from(l)).length-1,o()):r.slice()},s.invertExtent=function(l){var c=r.indexOf(l);return c<0?[NaN,NaN]:c<1?[t,i[0]]:c>=n?[i[n-1],e]:[i[c-1],i[c]]},s.unknown=function(l){return arguments.length&&(a=l),s},s.thresholds=function(){return i.slice()},s.copy=function(){return fK().domain([t,e]).range(r).unknown(a)},Xs.apply(ad(s),arguments)}function hK(){var t=[.5],e=[0,1],n,i=1;function r(a){return a!=null&&a<=a?e[kx(t,a,0,i)]:n}return r.domain=function(a){return arguments.length?(t=Array.from(a),i=Math.min(t.length,e.length-1),r):t.slice()},r.range=function(a){return arguments.length?(e=Array.from(a),i=Math.min(t.length,e.length-1),r):e.slice()},r.invertExtent=function(a){var s=e.indexOf(a);return[t[s-1],t[s]]},r.unknown=function(a){return arguments.length?(n=a,r):n},r.copy=function(){return hK().domain(t).range(e).unknown(n)},Xs.apply(r,arguments)}const uC=new Date,dC=new Date;function cr(t,e,n,i){function r(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return r.floor=a=>(t(a=new Date(+a)),a),r.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),r.round=a=>{const s=r(a),o=r.ceil(a);return a-s<o-a?s:o},r.offset=(a,s)=>(e(a=new Date(+a),s==null?1:Math.floor(s)),a),r.range=(a,s,o)=>{const l=[];if(a=r.ceil(a),o=o==null?1:Math.floor(o),!(a<s)||!(o>0))return l;let c;do l.push(c=new Date(+a)),e(a,o),t(a);while(c<a&&a<s);return l},r.filter=a=>cr(s=>{if(s>=s)for(;t(s),!a(s);)s.setTime(s-1)},(s,o)=>{if(s>=s)if(o<0)for(;++o<=0;)for(;e(s,-1),!a(s););else for(;--o>=0;)for(;e(s,1),!a(s););}),n&&(r.count=(a,s)=>(uC.setTime(+a),dC.setTime(+s),t(uC),t(dC),Math.floor(n(uC,dC))),r.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?r.filter(i?s=>i(s)%a===0:s=>r.count(0,s)%a===0):r)),r}const X1=cr(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);X1.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?cr(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):X1);X1.range;const Kl=1e3,Fs=Kl*60,Yl=Fs*60,hc=Yl*24,iO=hc*7,e8=hc*30,fC=hc*365,Jd=cr(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Kl)},(t,e)=>(e-t)/Kl,t=>t.getUTCSeconds());Jd.range;const rO=cr(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Kl)},(t,e)=>{t.setTime(+t+e*Fs)},(t,e)=>(e-t)/Fs,t=>t.getMinutes());rO.range;const aO=cr(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Fs)},(t,e)=>(e-t)/Fs,t=>t.getUTCMinutes());aO.range;const sO=cr(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Kl-t.getMinutes()*Fs)},(t,e)=>{t.setTime(+t+e*Yl)},(t,e)=>(e-t)/Yl,t=>t.getHours());sO.range;const oO=cr(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Yl)},(t,e)=>(e-t)/Yl,t=>t.getUTCHours());oO.range;const Ux=cr(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Fs)/hc,t=>t.getDate()-1);Ux.range;const yw=cr(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/hc,t=>t.getUTCDate()-1);yw.range;const pK=cr(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/hc,t=>Math.floor(t/hc));pK.range;function zf(t){return cr(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,n)=>{e.setDate(e.getDate()+n*7)},(e,n)=>(n-e-(n.getTimezoneOffset()-e.getTimezoneOffset())*Fs)/iO)}const bw=zf(0),K1=zf(1),uPe=zf(2),dPe=zf(3),Jp=zf(4),fPe=zf(5),hPe=zf(6);bw.range;K1.range;uPe.range;dPe.range;Jp.range;fPe.range;hPe.range;function Bf(t){return cr(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCDate(e.getUTCDate()+n*7)},(e,n)=>(n-e)/iO)}const _w=Bf(0),Y1=Bf(1),pPe=Bf(2),mPe=Bf(3),em=Bf(4),gPe=Bf(5),xPe=Bf(6);_w.range;Y1.range;pPe.range;mPe.range;em.range;gPe.range;xPe.range;const lO=cr(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());lO.range;const cO=cr(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());cO.range;const pc=cr(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());pc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:cr(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,n)=>{e.setFullYear(e.getFullYear()+n*t)});pc.range;const mc=cr(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());mc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:cr(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,n)=>{e.setUTCFullYear(e.getUTCFullYear()+n*t)});mc.range;function mK(t,e,n,i,r,a){const s=[[Jd,1,Kl],[Jd,5,5*Kl],[Jd,15,15*Kl],[Jd,30,30*Kl],[a,1,Fs],[a,5,5*Fs],[a,15,15*Fs],[a,30,30*Fs],[r,1,Yl],[r,3,3*Yl],[r,6,6*Yl],[r,12,12*Yl],[i,1,hc],[i,2,2*hc],[n,1,iO],[e,1,e8],[e,3,3*e8],[t,1,fC]];function o(c,d,f){const p=d<c;p&&([c,d]=[d,c]);const m=f&&typeof f.range=="function"?f:l(c,d,f),_=m?m.range(c,+d+1):[];return p?_.reverse():_}function l(c,d,f){const p=Math.abs(d-c)/f,m=$D(([,,v])=>v).right(s,p);if(m===s.length)return t.every(hR(c/fC,d/fC,f));if(m===0)return X1.every(Math.max(hR(c,d,f),1));const[_,b]=s[p/s[m-1][2]<s[m][2]/p?m-1:m];return _.every(b)}return[o,l]}const[vPe,yPe]=mK(mc,cO,_w,pK,oO,aO),[bPe,_Pe]=mK(pc,lO,bw,Ux,sO,rO);function hC(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function pC(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Ug(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function SPe(t){var e=t.dateTime,n=t.date,i=t.time,r=t.periods,a=t.days,s=t.shortDays,o=t.months,l=t.shortMonths,c=jg(r),d=Fg(r),f=jg(a),p=Fg(a),m=jg(s),_=Fg(s),b=jg(o),v=Fg(o),x=jg(l),M=Fg(l),w={a:W,A:X,b:Q,B:ie,c:null,d:s8,e:s8,f:GPe,g:tDe,G:iDe,H:HPe,I:VPe,j:$Pe,L:gK,m:WPe,M:qPe,p:H,q:Y,Q:c8,s:u8,S:XPe,u:KPe,U:YPe,V:ZPe,w:QPe,W:JPe,x:null,X:null,y:eDe,Y:nDe,Z:rDe,"%":l8},E={a:se,A:ue,b:xe,B:re,c:null,d:o8,e:o8,f:lDe,g:vDe,G:bDe,H:aDe,I:sDe,j:oDe,L:vK,m:cDe,M:uDe,p:ve,q:Pe,Q:c8,s:u8,S:dDe,u:fDe,U:hDe,V:pDe,w:mDe,W:gDe,x:null,X:null,y:xDe,Y:yDe,Z:_De,"%":l8},T={a:O,A:z,b:I,B:G,c:L,d:r8,e:r8,f:jPe,g:i8,G:n8,H:a8,I:a8,j:kPe,L:UPe,m:OPe,M:LPe,p:R,q:DPe,Q:zPe,s:BPe,S:IPe,u:TPe,U:CPe,V:NPe,w:APe,W:RPe,x:B,X:q,y:i8,Y:n8,Z:PPe,"%":FPe};w.x=P(n,w),w.X=P(i,w),w.c=P(e,w),E.x=P(n,E),E.X=P(i,E),E.c=P(e,E);function P(pe,we){return function(ze){var ce=[],ft=-1,F=0,$=pe.length,ae,J,ee;for(ze instanceof Date||(ze=new Date(+ze));++ft<$;)pe.charCodeAt(ft)===37&&(ce.push(pe.slice(F,ft)),(J=t8[ae=pe.charAt(++ft)])!=null?ae=pe.charAt(++ft):J=ae==="e"?" ":"0",(ee=we[ae])&&(ae=ee(ze,J)),ce.push(ae),F=ft+1);return ce.push(pe.slice(F,ft)),ce.join("")}}function N(pe,we){return function(ze){var ce=Ug(1900,void 0,1),ft=U(ce,pe,ze+="",0),F,$;if(ft!=ze.length)return null;if("Q"in ce)return new Date(ce.Q);if("s"in ce)return new Date(ce.s*1e3+("L"in ce?ce.L:0));if(we&&!("Z"in ce)&&(ce.Z=0),"p"in ce&&(ce.H=ce.H%12+ce.p*12),ce.m===void 0&&(ce.m="q"in ce?ce.q:0),"V"in ce){if(ce.V<1||ce.V>53)return null;"w"in ce||(ce.w=1),"Z"in ce?(F=pC(Ug(ce.y,0,1)),$=F.getUTCDay(),F=$>4||$===0?Y1.ceil(F):Y1(F),F=yw.offset(F,(ce.V-1)*7),ce.y=F.getUTCFullYear(),ce.m=F.getUTCMonth(),ce.d=F.getUTCDate()+(ce.w+6)%7):(F=hC(Ug(ce.y,0,1)),$=F.getDay(),F=$>4||$===0?K1.ceil(F):K1(F),F=Ux.offset(F,(ce.V-1)*7),ce.y=F.getFullYear(),ce.m=F.getMonth(),ce.d=F.getDate()+(ce.w+6)%7)}else("W"in ce||"U"in ce)&&("w"in ce||(ce.w="u"in ce?ce.u%7:"W"in ce?1:0),$="Z"in ce?pC(Ug(ce.y,0,1)).getUTCDay():hC(Ug(ce.y,0,1)).getDay(),ce.m=0,ce.d="W"in ce?(ce.w+6)%7+ce.W*7-($+5)%7:ce.w+ce.U*7-($+6)%7);return"Z"in ce?(ce.H+=ce.Z/100|0,ce.M+=ce.Z%100,pC(ce)):hC(ce)}}function U(pe,we,ze,ce){for(var ft=0,F=we.length,$=ze.length,ae,J;ft<F;){if(ce>=$)return-1;if(ae=we.charCodeAt(ft++),ae===37){if(ae=we.charAt(ft++),J=T[ae in t8?we.charAt(ft++):ae],!J||(ce=J(pe,ze,ce))<0)return-1}else if(ae!=ze.charCodeAt(ce++))return-1}return ce}function R(pe,we,ze){var ce=c.exec(we.slice(ze));return ce?(pe.p=d.get(ce[0].toLowerCase()),ze+ce[0].length):-1}function O(pe,we,ze){var ce=m.exec(we.slice(ze));return ce?(pe.w=_.get(ce[0].toLowerCase()),ze+ce[0].length):-1}function z(pe,we,ze){var ce=f.exec(we.slice(ze));return ce?(pe.w=p.get(ce[0].toLowerCase()),ze+ce[0].length):-1}function I(pe,we,ze){var ce=x.exec(we.slice(ze));return ce?(pe.m=M.get(ce[0].toLowerCase()),ze+ce[0].length):-1}function G(pe,we,ze){var ce=b.exec(we.slice(ze));return ce?(pe.m=v.get(ce[0].toLowerCase()),ze+ce[0].length):-1}function L(pe,we,ze){return U(pe,e,we,ze)}function B(pe,we,ze){return U(pe,n,we,ze)}function q(pe,we,ze){return U(pe,i,we,ze)}function W(pe){return s[pe.getDay()]}function X(pe){return a[pe.getDay()]}function Q(pe){return l[pe.getMonth()]}function ie(pe){return o[pe.getMonth()]}function H(pe){return r[+(pe.getHours()>=12)]}function Y(pe){return 1+~~(pe.getMonth()/3)}function se(pe){return s[pe.getUTCDay()]}function ue(pe){return a[pe.getUTCDay()]}function xe(pe){return l[pe.getUTCMonth()]}function re(pe){return o[pe.getUTCMonth()]}function ve(pe){return r[+(pe.getUTCHours()>=12)]}function Pe(pe){return 1+~~(pe.getUTCMonth()/3)}return{format:function(pe){var we=P(pe+="",w);return we.toString=function(){return pe},we},parse:function(pe){var we=N(pe+="",!1);return we.toString=function(){return pe},we},utcFormat:function(pe){var we=P(pe+="",E);return we.toString=function(){return pe},we},utcParse:function(pe){var we=N(pe+="",!0);return we.toString=function(){return pe},we}}}var t8={"-":"",_:" ",0:"0"},Tr=/^\s*\d+/,wPe=/^%/,MPe=/[\\^$*+?|[\]().{}]/g;function En(t,e,n){var i=t<0?"-":"",r=(i?-t:t)+"",a=r.length;return i+(a<n?new Array(n-a+1).join(e)+r:r)}function EPe(t){return t.replace(MPe,"\\$&")}function jg(t){return new RegExp("^(?:"+t.map(EPe).join("|")+")","i")}function Fg(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function APe(t,e,n){var i=Tr.exec(e.slice(n,n+1));return i?(t.w=+i[0],n+i[0].length):-1}function TPe(t,e,n){var i=Tr.exec(e.slice(n,n+1));return i?(t.u=+i[0],n+i[0].length):-1}function CPe(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.U=+i[0],n+i[0].length):-1}function NPe(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.V=+i[0],n+i[0].length):-1}function RPe(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.W=+i[0],n+i[0].length):-1}function n8(t,e,n){var i=Tr.exec(e.slice(n,n+4));return i?(t.y=+i[0],n+i[0].length):-1}function i8(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function PPe(t,e,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return i?(t.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function DPe(t,e,n){var i=Tr.exec(e.slice(n,n+1));return i?(t.q=i[0]*3-3,n+i[0].length):-1}function OPe(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.m=i[0]-1,n+i[0].length):-1}function r8(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.d=+i[0],n+i[0].length):-1}function kPe(t,e,n){var i=Tr.exec(e.slice(n,n+3));return i?(t.m=0,t.d=+i[0],n+i[0].length):-1}function a8(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.H=+i[0],n+i[0].length):-1}function LPe(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.M=+i[0],n+i[0].length):-1}function IPe(t,e,n){var i=Tr.exec(e.slice(n,n+2));return i?(t.S=+i[0],n+i[0].length):-1}function UPe(t,e,n){var i=Tr.exec(e.slice(n,n+3));return i?(t.L=+i[0],n+i[0].length):-1}function jPe(t,e,n){var i=Tr.exec(e.slice(n,n+6));return i?(t.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function FPe(t,e,n){var i=wPe.exec(e.slice(n,n+1));return i?n+i[0].length:-1}function zPe(t,e,n){var i=Tr.exec(e.slice(n));return i?(t.Q=+i[0],n+i[0].length):-1}function BPe(t,e,n){var i=Tr.exec(e.slice(n));return i?(t.s=+i[0],n+i[0].length):-1}function s8(t,e){return En(t.getDate(),e,2)}function HPe(t,e){return En(t.getHours(),e,2)}function VPe(t,e){return En(t.getHours()%12||12,e,2)}function $Pe(t,e){return En(1+Ux.count(pc(t),t),e,3)}function gK(t,e){return En(t.getMilliseconds(),e,3)}function GPe(t,e){return gK(t,e)+"000"}function WPe(t,e){return En(t.getMonth()+1,e,2)}function qPe(t,e){return En(t.getMinutes(),e,2)}function XPe(t,e){return En(t.getSeconds(),e,2)}function KPe(t){var e=t.getDay();return e===0?7:e}function YPe(t,e){return En(bw.count(pc(t)-1,t),e,2)}function xK(t){var e=t.getDay();return e>=4||e===0?Jp(t):Jp.ceil(t)}function ZPe(t,e){return t=xK(t),En(Jp.count(pc(t),t)+(pc(t).getDay()===4),e,2)}function QPe(t){return t.getDay()}function JPe(t,e){return En(K1.count(pc(t)-1,t),e,2)}function eDe(t,e){return En(t.getFullYear()%100,e,2)}function tDe(t,e){return t=xK(t),En(t.getFullYear()%100,e,2)}function nDe(t,e){return En(t.getFullYear()%1e4,e,4)}function iDe(t,e){var n=t.getDay();return t=n>=4||n===0?Jp(t):Jp.ceil(t),En(t.getFullYear()%1e4,e,4)}function rDe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+En(e/60|0,"0",2)+En(e%60,"0",2)}function o8(t,e){return En(t.getUTCDate(),e,2)}function aDe(t,e){return En(t.getUTCHours(),e,2)}function sDe(t,e){return En(t.getUTCHours()%12||12,e,2)}function oDe(t,e){return En(1+yw.count(mc(t),t),e,3)}function vK(t,e){return En(t.getUTCMilliseconds(),e,3)}function lDe(t,e){return vK(t,e)+"000"}function cDe(t,e){return En(t.getUTCMonth()+1,e,2)}function uDe(t,e){return En(t.getUTCMinutes(),e,2)}function dDe(t,e){return En(t.getUTCSeconds(),e,2)}function fDe(t){var e=t.getUTCDay();return e===0?7:e}function hDe(t,e){return En(_w.count(mc(t)-1,t),e,2)}function yK(t){var e=t.getUTCDay();return e>=4||e===0?em(t):em.ceil(t)}function pDe(t,e){return t=yK(t),En(em.count(mc(t),t)+(mc(t).getUTCDay()===4),e,2)}function mDe(t){return t.getUTCDay()}function gDe(t,e){return En(Y1.count(mc(t)-1,t),e,2)}function xDe(t,e){return En(t.getUTCFullYear()%100,e,2)}function vDe(t,e){return t=yK(t),En(t.getUTCFullYear()%100,e,2)}function yDe(t,e){return En(t.getUTCFullYear()%1e4,e,4)}function bDe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?em(t):em.ceil(t),En(t.getUTCFullYear()%1e4,e,4)}function _De(){return"+0000"}function l8(){return"%"}function c8(t){return+t}function u8(t){return Math.floor(+t/1e3)}var ep,bK,_K;SDe({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function SDe(t){return ep=SPe(t),bK=ep.format,ep.parse,_K=ep.utcFormat,ep.utcParse,ep}function wDe(t){return new Date(t)}function MDe(t){return t instanceof Date?+t:+new Date(+t)}function uO(t,e,n,i,r,a,s,o,l,c){var d=YD(),f=d.invert,p=d.domain,m=c(".%L"),_=c(":%S"),b=c("%I:%M"),v=c("%I %p"),x=c("%a %d"),M=c("%b %d"),w=c("%B"),E=c("%Y");function T(P){return(l(P)<P?m:o(P)<P?_:s(P)<P?b:a(P)<P?v:i(P)<P?r(P)<P?x:M:n(P)<P?w:E)(P)}return d.invert=function(P){return new Date(f(P))},d.domain=function(P){return arguments.length?p(Array.from(P,MDe)):p().map(wDe)},d.ticks=function(P){var N=p();return t(N[0],N[N.length-1],P??10)},d.tickFormat=function(P,N){return N==null?T:c(N)},d.nice=function(P){var N=p();return(!P||typeof P.range!="function")&&(P=e(N[0],N[N.length-1],P??10)),P?p(oK(N,P)):d},d.copy=function(){return Ix(d,uO(t,e,n,i,r,a,s,o,l,c))},d}function EDe(){return Xs.apply(uO(bPe,_Pe,pc,lO,bw,Ux,sO,rO,Jd,bK).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function ADe(){return Xs.apply(uO(vPe,yPe,mc,cO,_w,yw,oO,aO,Jd,_K).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Sw(){var t=0,e=1,n,i,r,a,s=ha,o=!1,l;function c(f){return f==null||isNaN(f=+f)?l:s(r===0?.5:(f=(a(f)-n)*r,o?Math.max(0,Math.min(1,f)):f))}c.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),i=a(e=+e),r=n===i?0:1/(i-n),c):[t,e]},c.clamp=function(f){return arguments.length?(o=!!f,c):o},c.interpolator=function(f){return arguments.length?(s=f,c):s};function d(f){return function(p){var m,_;return arguments.length?([m,_]=p,s=f(m,_),c):[s(0),s(1)]}}return c.range=d(pm),c.rangeRound=d(KD),c.unknown=function(f){return arguments.length?(l=f,c):l},function(f){return a=f,n=f(t),i=f(e),r=n===i?0:1/(i-n),c}}function sd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function SK(){var t=ad(Sw()(ha));return t.copy=function(){return sd(t,SK())},Sc.apply(t,arguments)}function wK(){var t=JD(Sw()).domain([1,10]);return t.copy=function(){return sd(t,wK()).base(t.base())},Sc.apply(t,arguments)}function MK(){var t=eO(Sw());return t.copy=function(){return sd(t,MK()).constant(t.constant())},Sc.apply(t,arguments)}function dO(){var t=tO(Sw());return t.copy=function(){return sd(t,dO()).exponent(t.exponent())},Sc.apply(t,arguments)}function TDe(){return dO.apply(null,arguments).exponent(.5)}function EK(){var t=[],e=ha;function n(i){if(i!=null&&!isNaN(i=+i))return e((kx(t,i,1)-1)/(t.length-1))}return n.domain=function(i){if(!arguments.length)return t.slice();t=[];for(let r of i)r!=null&&!isNaN(r=+r)&&t.push(r);return t.sort(ju),n},n.interpolator=function(i){return arguments.length?(e=i,n):e},n.range=function(){return t.map((i,r)=>e(r/(t.length-1)))},n.quantiles=function(i){return Array.from({length:i+1},(r,a)=>fRe(t,a/i))},n.copy=function(){return EK(e).domain(t)},Sc.apply(n,arguments)}function ww(){var t=0,e=.5,n=1,i=1,r,a,s,o,l,c=ha,d,f=!1,p;function m(b){return isNaN(b=+b)?p:(b=.5+((b=+d(b))-a)*(i*b<i*a?o:l),c(f?Math.max(0,Math.min(1,b)):b))}m.domain=function(b){return arguments.length?([t,e,n]=b,r=d(t=+t),a=d(e=+e),s=d(n=+n),o=r===a?0:.5/(a-r),l=a===s?0:.5/(s-a),i=a<r?-1:1,m):[t,e,n]},m.clamp=function(b){return arguments.length?(f=!!b,m):f},m.interpolator=function(b){return arguments.length?(c=b,m):c};function _(b){return function(v){var x,M,w;return arguments.length?([x,M,w]=v,c=FRe(b,[x,M,w]),m):[c(0),c(.5),c(1)]}}return m.range=_(pm),m.rangeRound=_(KD),m.unknown=function(b){return arguments.length?(p=b,m):p},function(b){return d=b,r=b(t),a=b(e),s=b(n),o=r===a?0:.5/(a-r),l=a===s?0:.5/(s-a),i=a<r?-1:1,m}}function AK(){var t=ad(ww()(ha));return t.copy=function(){return sd(t,AK())},Sc.apply(t,arguments)}function TK(){var t=JD(ww()).domain([.1,1,10]);return t.copy=function(){return sd(t,TK()).base(t.base())},Sc.apply(t,arguments)}function CK(){var t=eO(ww());return t.copy=function(){return sd(t,CK()).constant(t.constant())},Sc.apply(t,arguments)}function fO(){var t=tO(ww());return t.copy=function(){return sd(t,fO()).exponent(t.exponent())},Sc.apply(t,arguments)}function CDe(){return fO.apply(null,arguments).exponent(.5)}const Yg=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:WD,scaleDiverging:AK,scaleDivergingLog:TK,scaleDivergingPow:fO,scaleDivergingSqrt:CDe,scaleDivergingSymlog:CK,scaleIdentity:sK,scaleImplicit:pR,scaleLinear:aK,scaleLog:lK,scaleOrdinal:GD,scalePoint:mRe,scalePow:nO,scaleQuantile:dK,scaleQuantize:fK,scaleRadial:uK,scaleSequential:SK,scaleSequentialLog:wK,scaleSequentialPow:dO,scaleSequentialQuantile:EK,scaleSequentialSqrt:TDe,scaleSequentialSymlog:MK,scaleSqrt:lPe,scaleSymlog:cK,scaleThreshold:hK,scaleTime:EDe,scaleUtc:ADe,tickFormat:rK},Symbol.toStringTag,{value:"Module"}));var od=t=>t.chartData,hO=He([od],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Mw=(t,e,n,i)=>i?hO(t):od(t);function Xu(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(ai(e)&&ai(n))return!0}return!1}function d8(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function NK(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,i]=t,r,a;if(ai(n))r=n;else if(typeof n=="function")return;if(ai(i))a=i;else if(typeof i=="function")return;var s=[r,a];if(Xu(s))return s}}function NDe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var i=t(e,n);if(Xu(i))return d8(i,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[r,a]=t,s,o;if(r==="auto")e!=null&&(s=Math.min(...e));else if(Et(r))s=r;else if(typeof r=="function")try{e!=null&&(s=r(e?.[0]))}catch{}else if(typeof r=="string"&&FH.test(r)){var l=FH.exec(r);if(l==null||e==null)s=void 0;else{var c=+l[1];s=e[0]-c}}else s=e?.[0];if(a==="auto")e!=null&&(o=Math.max(...e));else if(Et(a))o=a;else if(typeof a=="function")try{e!=null&&(o=a(e?.[1]))}catch{}else if(typeof a=="string"&&zH.test(a)){var d=zH.exec(a);if(d==null||e==null)o=void 0;else{var f=+d[1];o=e[1]+f}}else o=e?.[1];var p=[s,o];if(Xu(p))return e==null?p:d8(p,e,n)}}}var mm=1e9,RDe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},mO,ci=!0,Ws="[DecimalError] ",hf=Ws+"Invalid argument: ",pO=Ws+"Exponent out of range: ",gm=Math.floor,Fd=Math.pow,PDe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,is,_r=1e7,ii=7,RK=9007199254740991,Z1=gm(RK/ii),Tt={};Tt.absoluteValue=Tt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};Tt.comparedTo=Tt.cmp=function(t){var e,n,i,r,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(i=a.d.length,r=t.d.length,e=0,n=i<r?i:r;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return i===r?0:i>r^a.s<0?1:-1};Tt.decimalPlaces=Tt.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*ii;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};Tt.dividedBy=Tt.div=function(t){return ic(this,new this.constructor(t))};Tt.dividedToIntegerBy=Tt.idiv=function(t){var e=this,n=e.constructor;return Kn(ic(e,new n(t),0,1),n.precision)};Tt.equals=Tt.eq=function(t){return!this.cmp(t)};Tt.exponent=function(){return Wi(this)};Tt.greaterThan=Tt.gt=function(t){return this.cmp(t)>0};Tt.greaterThanOrEqualTo=Tt.gte=function(t){return this.cmp(t)>=0};Tt.isInteger=Tt.isint=function(){return this.e>this.d.length-2};Tt.isNegative=Tt.isneg=function(){return this.s<0};Tt.isPositive=Tt.ispos=function(){return this.s>0};Tt.isZero=function(){return this.s===0};Tt.lessThan=Tt.lt=function(t){return this.cmp(t)<0};Tt.lessThanOrEqualTo=Tt.lte=function(t){return this.cmp(t)<1};Tt.logarithm=Tt.log=function(t){var e,n=this,i=n.constructor,r=i.precision,a=r+5;if(t===void 0)t=new i(10);else if(t=new i(t),t.s<1||t.eq(is))throw Error(Ws+"NaN");if(n.s<1)throw Error(Ws+(n.s?"NaN":"-Infinity"));return n.eq(is)?new i(0):(ci=!1,e=ic(rx(n,a),rx(t,a),a),ci=!0,Kn(e,r))};Tt.minus=Tt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?OK(e,t):PK(e,(t.s=-t.s,t))};Tt.modulo=Tt.mod=function(t){var e,n=this,i=n.constructor,r=i.precision;if(t=new i(t),!t.s)throw Error(Ws+"NaN");return n.s?(ci=!1,e=ic(n,t,0,1).times(t),ci=!0,n.minus(e)):Kn(new i(n),r)};Tt.naturalExponential=Tt.exp=function(){return DK(this)};Tt.naturalLogarithm=Tt.ln=function(){return rx(this)};Tt.negated=Tt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Tt.plus=Tt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?PK(e,t):OK(e,(t.s=-t.s,t))};Tt.precision=Tt.sd=function(t){var e,n,i,r=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(hf+t);if(e=Wi(r)+1,i=r.d.length-1,n=i*ii+1,i=r.d[i],i){for(;i%10==0;i/=10)n--;for(i=r.d[0];i>=10;i/=10)n++}return t&&e>n?e:n};Tt.squareRoot=Tt.sqrt=function(){var t,e,n,i,r,a,s,o=this,l=o.constructor;if(o.s<1){if(!o.s)return new l(0);throw Error(Ws+"NaN")}for(t=Wi(o),ci=!1,r=Math.sqrt(+o),r==0||r==1/0?(e=zo(o.d),(e.length+t)%2==0&&(e+="0"),r=Math.sqrt(e),t=gm((t+1)/2)-(t<0||t%2),r==1/0?e="5e"+t:(e=r.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),i=new l(e)):i=new l(r.toString()),n=l.precision,r=s=n+3;;)if(a=i,i=a.plus(ic(o,a,s+2)).times(.5),zo(a.d).slice(0,s)===(e=zo(i.d)).slice(0,s)){if(e=e.slice(s-3,s+1),r==s&&e=="4999"){if(Kn(a,n+1,0),a.times(a).eq(o)){i=a;break}}else if(e!="9999")break;s+=4}return ci=!0,Kn(i,n)};Tt.times=Tt.mul=function(t){var e,n,i,r,a,s,o,l,c,d=this,f=d.constructor,p=d.d,m=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,l=p.length,c=m.length,l<c&&(a=p,p=m,m=a,s=l,l=c,c=s),a=[],s=l+c,i=s;i--;)a.push(0);for(i=c;--i>=0;){for(e=0,r=l+i;r>i;)o=a[r]+m[i]*p[r-i-1]+e,a[r--]=o%_r|0,e=o/_r|0;a[r]=(a[r]+e)%_r|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,ci?Kn(t,f.precision):t};Tt.toDecimalPlaces=Tt.todp=function(t,e){var n=this,i=n.constructor;return n=new i(n),t===void 0?n:(Zo(t,0,mm),e===void 0?e=i.rounding:Zo(e,0,8),Kn(n,t+Wi(n)+1,e))};Tt.toExponential=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=Of(i,!0):(Zo(t,0,mm),e===void 0?e=r.rounding:Zo(e,0,8),i=Kn(new r(i),t+1,e),n=Of(i,!0,t+1)),n};Tt.toFixed=function(t,e){var n,i,r=this,a=r.constructor;return t===void 0?Of(r):(Zo(t,0,mm),e===void 0?e=a.rounding:Zo(e,0,8),i=Kn(new a(r),t+Wi(r)+1,e),n=Of(i.abs(),!1,t+Wi(i)+1),r.isneg()&&!r.isZero()?"-"+n:n)};Tt.toInteger=Tt.toint=function(){var t=this,e=t.constructor;return Kn(new e(t),Wi(t)+1,e.rounding)};Tt.toNumber=function(){return+this};Tt.toPower=Tt.pow=function(t){var e,n,i,r,a,s,o=this,l=o.constructor,c=12,d=+(t=new l(t));if(!t.s)return new l(is);if(o=new l(o),!o.s){if(t.s<1)throw Error(Ws+"Infinity");return o}if(o.eq(is))return o;if(i=l.precision,t.eq(is))return Kn(o,i);if(e=t.e,n=t.d.length-1,s=e>=n,a=o.s,s){if((n=d<0?-d:d)<=RK){for(r=new l(is),e=Math.ceil(i/ii+4),ci=!1;n%2&&(r=r.times(o),h8(r.d,e)),n=gm(n/2),n!==0;)o=o.times(o),h8(o.d,e);return ci=!0,t.s<0?new l(is).div(r):Kn(r,i)}}else if(a<0)throw Error(Ws+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,ci=!1,r=t.times(rx(o,i+c)),ci=!0,r=DK(r),r.s=a,r};Tt.toPrecision=function(t,e){var n,i,r=this,a=r.constructor;return t===void 0?(n=Wi(r),i=Of(r,n<=a.toExpNeg||n>=a.toExpPos)):(Zo(t,1,mm),e===void 0?e=a.rounding:Zo(e,0,8),r=Kn(new a(r),t,e),n=Wi(r),i=Of(r,t<=n||n<=a.toExpNeg,t)),i};Tt.toSignificantDigits=Tt.tosd=function(t,e){var n=this,i=n.constructor;return t===void 0?(t=i.precision,e=i.rounding):(Zo(t,1,mm),e===void 0?e=i.rounding:Zo(e,0,8)),Kn(new i(n),t,e)};Tt.toString=Tt.valueOf=Tt.val=Tt.toJSON=Tt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Wi(t),n=t.constructor;return Of(t,e<=n.toExpNeg||e>=n.toExpPos)};function PK(t,e){var n,i,r,a,s,o,l,c,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),ci?Kn(e,f):e;if(l=t.d,c=e.d,s=t.e,r=e.e,l=l.slice(),a=s-r,a){for(a<0?(i=l,a=-a,o=c.length):(i=c,r=s,o=l.length),s=Math.ceil(f/ii),o=s>o?s+1:o+1,a>o&&(a=o,i.length=1),i.reverse();a--;)i.push(0);i.reverse()}for(o=l.length,a=c.length,o-a<0&&(a=o,i=c,c=l,l=i),n=0;a;)n=(l[--a]=l[a]+c[a]+n)/_r|0,l[a]%=_r;for(n&&(l.unshift(n),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=r,ci?Kn(e,f):e}function Zo(t,e,n){if(t!==~~t||t<e||t>n)throw Error(hf+t)}function zo(t){var e,n,i,r=t.length-1,a="",s=t[0];if(r>0){for(a+=s,e=1;e<r;e++)i=t[e]+"",n=ii-i.length,n&&(a+=gu(n)),a+=i;s=t[e],i=s+"",n=ii-i.length,n&&(a+=gu(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var ic=(function(){function t(i,r){var a,s=0,o=i.length;for(i=i.slice();o--;)a=i[o]*r+s,i[o]=a%_r|0,s=a/_r|0;return s&&i.unshift(s),i}function e(i,r,a,s){var o,l;if(a!=s)l=a>s?1:-1;else for(o=l=0;o<a;o++)if(i[o]!=r[o]){l=i[o]>r[o]?1:-1;break}return l}function n(i,r,a){for(var s=0;a--;)i[a]-=s,s=i[a]<r[a]?1:0,i[a]=s*_r+i[a]-r[a];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,a,s){var o,l,c,d,f,p,m,_,b,v,x,M,w,E,T,P,N,U,R=i.constructor,O=i.s==r.s?1:-1,z=i.d,I=r.d;if(!i.s)return new R(i);if(!r.s)throw Error(Ws+"Division by zero");for(l=i.e-r.e,N=I.length,T=z.length,m=new R(O),_=m.d=[],c=0;I[c]==(z[c]||0);)++c;if(I[c]>(z[c]||0)&&--l,a==null?M=a=R.precision:s?M=a+(Wi(i)-Wi(r))+1:M=a,M<0)return new R(0);if(M=M/ii+2|0,c=0,N==1)for(d=0,I=I[0],M++;(c<T||d)&&M--;c++)w=d*_r+(z[c]||0),_[c]=w/I|0,d=w%I|0;else{for(d=_r/(I[0]+1)|0,d>1&&(I=t(I,d),z=t(z,d),N=I.length,T=z.length),E=N,b=z.slice(0,N),v=b.length;v<N;)b[v++]=0;U=I.slice(),U.unshift(0),P=I[0],I[1]>=_r/2&&++P;do d=0,o=e(I,b,N,v),o<0?(x=b[0],N!=v&&(x=x*_r+(b[1]||0)),d=x/P|0,d>1?(d>=_r&&(d=_r-1),f=t(I,d),p=f.length,v=b.length,o=e(f,b,p,v),o==1&&(d--,n(f,N<p?U:I,p))):(d==0&&(o=d=1),f=I.slice()),p=f.length,p<v&&f.unshift(0),n(b,f,v),o==-1&&(v=b.length,o=e(I,b,N,v),o<1&&(d++,n(b,N<v?U:I,v))),v=b.length):o===0&&(d++,b=[0]),_[c++]=d,o&&b[0]?b[v++]=z[E]||0:(b=[z[E]],v=1);while((E++<T||b[0]!==void 0)&&M--)}return _[0]||_.shift(),m.e=l,Kn(m,s?a+Wi(m)+1:a)}})();function DK(t,e){var n,i,r,a,s,o,l=0,c=0,d=t.constructor,f=d.precision;if(Wi(t)>16)throw Error(pO+Wi(t));if(!t.s)return new d(is);for(ci=!1,o=f,s=new d(.03125);t.abs().gte(.1);)t=t.times(s),c+=5;for(i=Math.log(Fd(2,c))/Math.LN10*2+5|0,o+=i,n=r=a=new d(is),d.precision=o;;){if(r=Kn(r.times(t),o),n=n.times(++l),s=a.plus(ic(r,n,o)),zo(s.d).slice(0,o)===zo(a.d).slice(0,o)){for(;c--;)a=Kn(a.times(a),o);return d.precision=f,e==null?(ci=!0,Kn(a,f)):a}a=s}}function Wi(t){for(var e=t.e*ii,n=t.d[0];n>=10;n/=10)e++;return e}function mC(t,e,n){if(e>t.LN10.sd())throw ci=!0,n&&(t.precision=n),Error(Ws+"LN10 precision limit exceeded");return Kn(new t(t.LN10),e)}function gu(t){for(var e="";t--;)e+="0";return e}function rx(t,e){var n,i,r,a,s,o,l,c,d,f=1,p=10,m=t,_=m.d,b=m.constructor,v=b.precision;if(m.s<1)throw Error(Ws+(m.s?"NaN":"-Infinity"));if(m.eq(is))return new b(0);if(e==null?(ci=!1,c=v):c=e,m.eq(10))return e==null&&(ci=!0),mC(b,c);if(c+=p,b.precision=c,n=zo(_),i=n.charAt(0),a=Wi(m),Math.abs(a)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)m=m.times(t),n=zo(m.d),i=n.charAt(0),f++;a=Wi(m),i>1?(m=new b("0."+n),a++):m=new b(i+"."+n.slice(1))}else return l=mC(b,c+2,v).times(a+""),m=rx(new b(i+"."+n.slice(1)),c-p).plus(l),b.precision=v,e==null?(ci=!0,Kn(m,v)):m;for(o=s=m=ic(m.minus(is),m.plus(is),c),d=Kn(m.times(m),c),r=3;;){if(s=Kn(s.times(d),c),l=o.plus(ic(s,new b(r),c)),zo(l.d).slice(0,c)===zo(o.d).slice(0,c))return o=o.times(2),a!==0&&(o=o.plus(mC(b,c+2,v).times(a+""))),o=ic(o,new b(f),c),b.precision=v,e==null?(ci=!0,Kn(o,v)):o;o=l,r+=2}}function f8(t,e){var n,i,r;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(n<0&&(n=i),n+=+e.slice(i+1),e=e.substring(0,i)):n<0&&(n=e.length),i=0;e.charCodeAt(i)===48;)++i;for(r=e.length;e.charCodeAt(r-1)===48;)--r;if(e=e.slice(i,r),e){if(r-=i,n=n-i-1,t.e=gm(n/ii),t.d=[],i=(n+1)%ii,n<0&&(i+=ii),i<r){for(i&&t.d.push(+e.slice(0,i)),r-=ii;i<r;)t.d.push(+e.slice(i,i+=ii));e=e.slice(i),i=ii-e.length}else i-=r;for(;i--;)e+="0";if(t.d.push(+e),ci&&(t.e>Z1||t.e<-Z1))throw Error(pO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Kn(t,e,n){var i,r,a,s,o,l,c,d,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(i=e-s,i<0)i+=ii,r=e,c=f[d=0];else{if(d=Math.ceil((i+1)/ii),a=f.length,d>=a)return t;for(c=a=f[d],s=1;a>=10;a/=10)s++;i%=ii,r=i-ii+s}if(n!==void 0&&(a=Fd(10,s-r-1),o=c/a%10|0,l=e<0||f[d+1]!==void 0||c%a,l=n<4?(o||l)&&(n==0||n==(t.s<0?3:2)):o>5||o==5&&(n==4||l||n==6&&(i>0?r>0?c/Fd(10,s-r):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return l?(a=Wi(t),f.length=1,e=e-a-1,f[0]=Fd(10,(ii-e%ii)%ii),t.e=gm(-e/ii)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(i==0?(f.length=d,a=1,d--):(f.length=d+1,a=Fd(10,ii-i),f[d]=r>0?(c/Fd(10,s-r)%Fd(10,r)|0)*a:0),l)for(;;)if(d==0){(f[0]+=a)==_r&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=_r)break;f[d--]=0,a=1}for(i=f.length;f[--i]===0;)f.pop();if(ci&&(t.e>Z1||t.e<-Z1))throw Error(pO+Wi(t));return t}function OK(t,e){var n,i,r,a,s,o,l,c,d,f,p=t.constructor,m=p.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new p(t),ci?Kn(e,m):e;if(l=t.d,f=e.d,i=e.e,c=t.e,l=l.slice(),s=c-i,s){for(d=s<0,d?(n=l,s=-s,o=f.length):(n=f,i=c,o=l.length),r=Math.max(Math.ceil(m/ii),o)+2,s>r&&(s=r,n.length=1),n.reverse(),r=s;r--;)n.push(0);n.reverse()}else{for(r=l.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){d=l[r]<f[r];break}s=0}for(d&&(n=l,l=f,f=n,e.s=-e.s),o=l.length,r=f.length-o;r>0;--r)l[o++]=0;for(r=f.length;r>s;){if(l[--r]<f[r]){for(a=r;a&&l[--a]===0;)l[a]=_r-1;--l[a],l[r]+=_r}l[r]-=f[r]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--i;return l[0]?(e.d=l,e.e=i,ci?Kn(e,m):e):new p(0)}function Of(t,e,n){var i,r=Wi(t),a=zo(t.d),s=a.length;return e?(n&&(i=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+gu(i):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(r<0?"e":"e+")+r):r<0?(a="0."+gu(-r-1)+a,n&&(i=n-s)>0&&(a+=gu(i))):r>=s?(a+=gu(r+1-s),n&&(i=n-r-1)>0&&(a=a+"."+gu(i))):((i=r+1)<s&&(a=a.slice(0,i)+"."+a.slice(i)),n&&(i=n-s)>0&&(r+1===s&&(a+="."),a+=gu(i))),t.s<0?"-"+a:a}function h8(t,e){if(t.length>e)return t.length=e,!0}function kK(t){var e,n,i;function r(a){var s=this;if(!(s instanceof r))return new r(a);if(s.constructor=r,a instanceof r){s.s=a.s,s.e=a.e,s.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(hf+a);if(a>0)s.s=1;else if(a<0)a=-a,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(a===~~a&&a<1e7){s.e=0,s.d=[a];return}return f8(s,a.toString())}else if(typeof a!="string")throw Error(hf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,PDe.test(a))f8(s,a);else throw Error(hf+a)}if(r.prototype=Tt,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.clone=kK,r.config=r.set=DDe,t===void 0&&(t={}),t)for(i=["precision","rounding","toExpNeg","toExpPos","LN10"],e=0;e<i.length;)t.hasOwnProperty(n=i[e++])||(t[n]=this[n]);return r.config(t),r}function DDe(t){if(!t||typeof t!="object")throw Error(Ws+"Object expected");var e,n,i,r=["precision",1,mm,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<r.length;e+=3)if((i=t[n=r[e]])!==void 0)if(gm(i)===i&&i>=r[e+1]&&i<=r[e+2])this[n]=i;else throw Error(hf+n+": "+i);if((i=t[n="LN10"])!==void 0)if(i==Math.LN10)this[n]=new this(i);else throw Error(hf+n+": "+i);return this}var mO=kK(RDe);is=new mO(1);const kn=mO;var ODe=t=>t,LK={},IK=t=>t===LK,p8=t=>function e(){return arguments.length===0||arguments.length===1&&IK(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},UK=(t,e)=>t===1?e:p8(function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];var a=i.filter(s=>s!==LK).length;return a>=t?e(...i):UK(t-a,p8(function(){for(var s=arguments.length,o=new Array(s),l=0;l<s;l++)o[l]=arguments[l];var c=i.map(d=>IK(d)?o.shift():d);return e(...c,...o)}))}),kDe=t=>UK(t.length,t),vR=(t,e)=>{for(var n=[],i=t;i<e;++i)n[i-t]=i;return n},LDe=kDe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),IDe=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];if(!n.length)return ODe;var r=n.reverse(),a=r[0],s=r.slice(1);return function(){return s.reduce((o,l)=>l(o),a(...arguments))}},yR=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function jK(t){var e;return t===0?e=1:e=Math.floor(new kn(t).abs().log(10).toNumber())+1,e}function FK(t,e,n){for(var i=new kn(t),r=0,a=[];i.lt(e)&&r<1e5;)a.push(i.toNumber()),i=i.add(n),r++;return a}var zK=t=>{var[e,n]=t,[i,r]=[e,n];return e>n&&([i,r]=[n,e]),[i,r]},BK=(t,e,n)=>{if(t.lte(0))return new kn(0);var i=jK(t.toNumber()),r=new kn(10).pow(i),a=t.div(r),s=i!==1?.05:.1,o=new kn(Math.ceil(a.div(s).toNumber())).add(n).mul(s),l=o.mul(r);return e?new kn(l.toNumber()):new kn(Math.ceil(l.toNumber()))},UDe=(t,e,n)=>{var i=new kn(1),r=new kn(t);if(!r.isint()&&n){var a=Math.abs(t);a<1?(i=new kn(10).pow(jK(t)-1),r=new kn(Math.floor(r.div(i).toNumber())).mul(i)):a>1&&(r=new kn(Math.floor(t)))}else t===0?r=new kn(Math.floor((e-1)/2)):n||(r=new kn(Math.floor(t)));var s=Math.floor((e-1)/2),o=IDe(LDe(l=>r.add(new kn(l-s).mul(i)).toNumber()),vR);return o(0,e)},HK=function(e,n,i,r){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(i-1)))return{step:new kn(0),tickMin:new kn(0),tickMax:new kn(0)};var s=BK(new kn(n).sub(e).div(i-1),r,a),o;e<=0&&n>=0?o=new kn(0):(o=new kn(e).add(n).div(2),o=o.sub(new kn(o).mod(s)));var l=Math.ceil(o.sub(e).div(s).toNumber()),c=Math.ceil(new kn(n).sub(o).div(s).toNumber()),d=l+c+1;return d>i?HK(e,n,i,r,a+1):(d<i&&(c=n>0?c+(i-d):c,l=n>0?l:l+(i-d)),{step:s,tickMin:o.sub(new kn(l).mul(s)),tickMax:o.add(new kn(c).mul(s))})},jDe=function(e){var[n,i]=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(r,2),[o,l]=zK([n,i]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...vR(0,r-1).map(()=>1/0)]:[...vR(0,r-1).map(()=>-1/0),l];return n>i?yR(c):c}if(o===l)return UDe(o,r,a);var{step:d,tickMin:f,tickMax:p}=HK(o,l,s,a,0),m=FK(f,p.add(new kn(.1).mul(d)),d);return n>i?yR(m):m},FDe=function(e,n){var[i,r]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=zK([i,r]);if(s===-1/0||o===1/0)return[i,r];if(s===o)return[s];var l=Math.max(n,2),c=BK(new kn(o).sub(s).div(l-1),a,0),d=[...FK(new kn(s),new kn(o),c),o];return a===!1&&(d=d.map(f=>Math.round(f))),i>r?yR(d):d},VK=t=>t.rootProps.maxBarSize,zDe=t=>t.rootProps.barGap,$K=t=>t.rootProps.barCategoryGap,BDe=t=>t.rootProps.barSize,jx=t=>t.rootProps.stackOffset,GK=t=>t.rootProps.reverseStackOrder,gO=t=>t.options.chartName,xO=t=>t.rootProps.syncId,WK=t=>t.rootProps.syncMethod,vO=t=>t.options.eventEmitter,HDe=t=>t.rootProps.baseValue,$i={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Hl={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},es={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},Ew=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},VDe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Hl.angleAxisId,includeHidden:!1,name:void 0,reversed:Hl.reversed,scale:Hl.scale,tick:Hl.tick,tickCount:void 0,ticks:void 0,type:Hl.type,unit:void 0},$De={allowDataOverflow:es.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:es.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:es.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:es.scale,tick:es.tick,tickCount:es.tickCount,ticks:void 0,type:es.type,unit:void 0},GDe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Hl.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Hl.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Hl.scale,tick:Hl.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},WDe={allowDataOverflow:es.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:es.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:es.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:es.scale,tick:es.tick,tickCount:es.tickCount,ticks:void 0,type:"category",unit:void 0},yO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?GDe:VDe,bO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?WDe:$De,Aw=t=>t.polarOptions,_O=He([bc,_c,lr],$X),qK=He([Aw,_O],(t,e)=>{if(t!=null)return na(t.innerRadius,e,0)}),XK=He([Aw,_O],(t,e)=>{if(t!=null)return na(t.outerRadius,e,e*.8)}),qDe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},KK=He([Aw],qDe);He([yO,KK],Ew);var YK=He([_O,qK,XK],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});He([bO,YK],Ew);var ZK=He([bn,Aw,qK,XK,bc,_c],(t,e,n,i,r,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||i==null)){var{cx:s,cy:o,startAngle:l,endAngle:c}=e;return{cx:na(s,r,r/2),cy:na(o,a,a/2),innerRadius:n,outerRadius:i,startAngle:l,endAngle:c,clockWise:!1}}}),di=(t,e)=>e,Fx=(t,e,n)=>n;function Tw(t){return t?.id}function QK(t,e,n){var{chartData:i=[]}=e,{allowDuplicatedCategory:r,dataKey:a}=n,s=new Map;return t.forEach(o=>{var l,c=(l=o.data)!==null&&l!==void 0?l:i;if(!(c==null||c.length===0)){var d=Tw(o);c.forEach((f,p)=>{var m=a==null||r?p:String(Xn(f,a,null)),_=Xn(f,o.dataKey,0),b;s.has(m)?b=s.get(m):b={},Object.assign(b,{[d]:_}),s.set(m,b)})}}),Array.from(s.values())}function Cw(t){return t.stackId!=null&&t.dataKey!=null}var Nw=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function Rw(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function XDe(t,e){if(t.length===e.length){for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return!1}var ur=t=>{var e=bn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},xm=t=>t.tooltip.settings.axisId;function m8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Q1(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m8(Object(n),!0).forEach(function(i){KDe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function KDe(t,e,n){return(e=YDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YDe(t){var e=ZDe(t,"string");return typeof e=="symbol"?e:e+""}function ZDe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var bR=[0,"auto"],yr={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"bottom",padding:{left:0,right:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"category",unit:void 0},JK=(t,e)=>t.cartesianAxis.xAxis[e],wc=(t,e)=>{var n=JK(t,e);return n??yr},br={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:bR,hide:!0,id:0,includeHidden:!1,interval:"preserveEnd",minTickGap:5,mirror:!1,name:void 0,orientation:"left",padding:{top:0,bottom:0},reversed:!1,scale:"auto",tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:"number",unit:void 0,width:Rx},eY=(t,e)=>t.cartesianAxis.yAxis[e],Mc=(t,e)=>{var n=eY(t,e);return n??br},QDe={domain:[0,"auto"],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:"",range:[64,64],scale:"auto",type:"number",unit:""},SO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??QDe},xi=(t,e,n)=>{switch(e){case"xAxis":return wc(t,n);case"yAxis":return Mc(t,n);case"zAxis":return SO(t,n);case"angleAxis":return yO(t,n);case"radiusAxis":return bO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},JDe=(t,e,n)=>{switch(e){case"xAxis":return wc(t,n);case"yAxis":return Mc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},zx=(t,e,n)=>{switch(e){case"xAxis":return wc(t,n);case"yAxis":return Mc(t,n);case"angleAxis":return yO(t,n);case"radiusAxis":return bO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},tY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function wO(t,e){return n=>{switch(t){case"xAxis":return"xAxisId"in n&&n.xAxisId===e;case"yAxis":return"yAxisId"in n&&n.yAxisId===e;case"zAxis":return"zAxisId"in n&&n.zAxisId===e;case"angleAxis":return"angleAxisId"in n&&n.angleAxisId===e;case"radiusAxis":return"radiusAxisId"in n&&n.radiusAxisId===e;default:return!1}}}var Pw=t=>t.graphicalItems.cartesianItems,eOe=He([di,Fx],wO),MO=(t,e,n)=>t.filter(n).filter(i=>e?.includeHidden===!0?!0:!i.hide),Bx=He([Pw,xi,eOe],MO,{memoizeOptions:{resultEqualityCheck:Rw}}),nY=He([Bx],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(Cw)),iY=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),tOe=He([Bx],iY),EO=t=>t.map(e=>e.data).filter(Boolean).flat(1),nOe=He([Bx],EO,{memoizeOptions:{resultEqualityCheck:Rw}}),AO=(t,e)=>{var{chartData:n=[],dataStartIndex:i,dataEndIndex:r}=e;return t.length>0?t:n.slice(i,r+1)},TO=He([nOe,Mw],AO),CO=(t,e,n)=>e?.dataKey!=null?t.map(i=>({value:Xn(i,e.dataKey)})):n.length>0?n.map(i=>i.dataKey).flatMap(i=>t.map(r=>({value:Xn(r,i)}))):t.map(i=>({value:i})),Dw=He([TO,xi,Bx],CO);function rY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function l_(t){if(Ko(t)||t instanceof Date){var e=Number(t);if(ai(e))return e}}function g8(t){if(Array.isArray(t)){var e=[l_(t[0]),l_(t[1])];return Xu(e)?e:void 0}var n=l_(t);if(n!=null)return[n,n]}function gc(t){return t.map(l_).filter(tTe)}function iOe(t,e,n){return!n||typeof e!="number"||$s(e)?[]:n.length?gc(n.flatMap(i=>{var r=Xn(t,i.dataKey),a,s;if(Array.isArray(r)?[a,s]=r:a=s=r,!(!ai(a)||!ai(s)))return[e-a,e+s]})):[]}var dr=t=>{var e=ur(t),n=xm(t);return zx(t,e,n)},Hx=He([dr],t=>t?.dataKey),rOe=He([nY,Mw,dr],QK),aY=(t,e,n,i)=>{var r={},a=e.reduce((s,o)=>(o.stackId==null||(s[o.stackId]==null&&(s[o.stackId]=[]),s[o.stackId].push(o)),s),r);return Object.fromEntries(Object.entries(a).map(s=>{var[o,l]=s,c=i?[...l].reverse():l,d=c.map(Tw);return[o,{stackedData:wCe(t,d,n),graphicalItems:c}]}))},ax=He([rOe,nY,jx,GK],aY),sY=(t,e,n,i)=>{var{dataStartIndex:r,dataEndIndex:a}=e;if(i==null&&n!=="zAxis"){var s=TCe(t,r,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},aOe=He([xi],t=>t.allowDataOverflow),NO=t=>{var e;if(t==null||!("domain"in t))return bR;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=gc(t.ticks);return[Math.min(...n),Math.max(...n)]}if(t.type==="category")return t.ticks.map(String)}return(e=t?.domain)!==null&&e!==void 0?e:bR},RO=He([xi],NO),PO=He([RO,aOe],NK),sOe=He([ax,od,di,PO],sY,{memoizeOptions:{resultEqualityCheck:Nw}}),Ow=t=>t.errorBars,oOe=(t,e,n)=>t.flatMap(i=>e[i.id]).filter(Boolean).filter(i=>rY(n,i)),J1=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var r=n.filter(Boolean);if(r.length!==0){var a=r.flat(),s=Math.min(...a),o=Math.max(...a);return[s,o]}},DO=(t,e,n,i,r)=>{var a,s;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var c,d,f=(c=i[l.id])===null||c===void 0?void 0:c.filter(x=>rY(r,x)),p=Xn(o,(d=e.dataKey)!==null&&d!==void 0?d:l.dataKey),m=iOe(o,p,f);if(m.length>=2){var _=Math.min(...m),b=Math.max(...m);(a==null||_<a)&&(a=_),(s==null||b>s)&&(s=b)}var v=g8(p);v!=null&&(a=a==null?v[0]:Math.min(a,v[0]),s=s==null?v[1]:Math.max(s,v[1]))})}),e?.dataKey!=null&&t.forEach(o=>{var l=g8(Xn(o,e.dataKey));l!=null&&(a=a==null?l[0]:Math.min(a,l[0]),s=s==null?l[1]:Math.max(s,l[1]))}),ai(a)&&ai(s))return[a,s]},lOe=He([TO,xi,tOe,Ow,di],DO,{memoizeOptions:{resultEqualityCheck:Nw}});function cOe(t){var{value:e}=t;if(Ko(e)||e instanceof Date)return e}var uOe=(t,e,n)=>{var i=t.map(cOe).filter(r=>r!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&_q(i))?XX(0,t.length):e.allowDuplicatedCategory?i:Array.from(new Set(i))},oY=t=>t.referenceElements.dots,vm=(t,e,n)=>t.filter(i=>i.ifOverflow==="extendDomain").filter(i=>e==="xAxis"?i.xAxisId===n:i.yAxisId===n),dOe=He([oY,di,Fx],vm),lY=t=>t.referenceElements.areas,fOe=He([lY,di,Fx],vm),cY=t=>t.referenceElements.lines,hOe=He([cY,di,Fx],vm),uY=(t,e)=>{var n=gc(t.map(i=>e==="xAxis"?i.x:i.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},pOe=He(dOe,di,uY),dY=(t,e)=>{var n=gc(t.flatMap(i=>[e==="xAxis"?i.x1:i.y1,e==="xAxis"?i.x2:i.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},mOe=He([fOe,di],dY);function gOe(t){var e;if(t.x!=null)return gc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(i=>i.x);return n==null||n.length===0?[]:gc(n)}function xOe(t){var e;if(t.y!=null)return gc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(i=>i.y);return n==null||n.length===0?[]:gc(n)}var fY=(t,e)=>{var n=t.flatMap(i=>e==="xAxis"?gOe(i):xOe(i));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},vOe=He([hOe,di],fY),yOe=He(pOe,vOe,mOe,(t,e,n)=>J1(t,n,e)),OO=(t,e,n,i,r,a,s,o)=>{if(n!=null)return n;var l=s==="vertical"&&o==="xAxis"||s==="horizontal"&&o==="yAxis",c=l?J1(i,a,r):J1(a,r);return NDe(e,c,t.allowDataOverflow)},bOe=He([xi,RO,PO,sOe,lOe,yOe,bn,di],OO,{memoizeOptions:{resultEqualityCheck:Nw}}),_Oe=[0,1],kO=(t,e,n,i,r,a,s)=>{if(!((t==null||n==null||n.length===0)&&s===void 0)){var{dataKey:o,type:l}=t,c=yc(e,a);if(c&&o==null){var d;return XX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return l==="category"?uOe(i,t,c):r==="expand"?_Oe:s}},LO=He([xi,bn,TO,Dw,jx,di,bOe],kO),hY=(t,e,n,i,r)=>{if(t!=null){var{scale:a,type:s}=t;if(a==="auto")return e==="radial"&&r==="radiusAxis"?"band":e==="radial"&&r==="angleAxis"?"linear":s==="category"&&i&&(i.indexOf("LineChart")>=0||i.indexOf("AreaChart")>=0||i.indexOf("ComposedChart")>=0&&!n)?"point":s==="category"?"band":"linear";if(typeof a=="string"){var o="scale".concat(Mx(a));return o in Yg?o:"point"}}},ym=He([xi,bn,tY,gO,di],hY);function SOe(t){if(t!=null){if(t in Yg)return Yg[t]();var e="scale".concat(Mx(t));if(e in Yg)return Yg[e]()}}function IO(t,e,n,i){if(!(n==null||i==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(i);var r=SOe(e);if(r!=null){var a=r.domain(n).range(i);return vCe(a),a}}}var UO=(t,e,n)=>{var i=NO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(i)&&(i[0]==="auto"||i[1]==="auto")&&Xu(t))return jDe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Xu(t))return FDe(t,e.tickCount,e.allowDecimals)}},jO=He([LO,zx,ym],UO),FO=(t,e,n,i)=>{if(i!=="angleAxis"&&t?.type==="number"&&Xu(e)&&Array.isArray(n)&&n.length>0){var r=e[0],a=n[0],s=e[1],o=n[n.length-1];return[Math.min(r,a),Math.max(s,o)]}return e},wOe=He([xi,LO,jO,di],FO),MOe=He(Dw,xi,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,i=Array.from(gc(t.map(o=>o.value))).sort((o,l)=>o-l);if(i.length<2)return 1/0;var r=i[i.length-1]-i[0];if(r===0)return 1/0;for(var a=0;a<i.length-1;a++){var s=i[a+1]-i[a];n=Math.min(n,s)}return n/r}}),pY=He(MOe,bn,$K,lr,(t,e,n,i)=>i,(t,e,n,i,r)=>{if(!ai(t))return 0;var a=e==="vertical"?i.height:i.width;if(r==="gap")return t*a/2;if(r==="no-gap"){var s=na(n,t*a),o=t*a/2;return o-s-(o-s)/a*s}return 0}),EOe=(t,e)=>{var n=wc(t,e);return n==null||typeof n.padding!="string"?0:pY(t,"xAxis",e,n.padding)},AOe=(t,e)=>{var n=Mc(t,e);return n==null||typeof n.padding!="string"?0:pY(t,"yAxis",e,n.padding)},TOe=He(wc,EOe,(t,e)=>{var n,i;if(t==null)return{left:0,right:0};var{padding:r}=t;return typeof r=="string"?{left:e,right:e}:{left:((n=r.left)!==null&&n!==void 0?n:0)+e,right:((i=r.right)!==null&&i!==void 0?i:0)+e}}),COe=He(Mc,AOe,(t,e)=>{var n,i;if(t==null)return{top:0,bottom:0};var{padding:r}=t;return typeof r=="string"?{top:e,bottom:e}:{top:((n=r.top)!==null&&n!==void 0?n:0)+e,bottom:((i=r.bottom)!==null&&i!==void 0?i:0)+e}}),NOe=He([lr,TOe,fw,dw,(t,e,n)=>n],(t,e,n,i,r)=>{var{padding:a}=i;return r?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),ROe=He([lr,bn,COe,fw,dw,(t,e,n)=>n],(t,e,n,i,r,a)=>{var{padding:s}=r;return a?[i.height-s.bottom,s.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),Vx=(t,e,n,i)=>{var r;switch(e){case"xAxis":return NOe(t,n,i);case"yAxis":return ROe(t,n,i);case"zAxis":return(r=SO(t,n))===null||r===void 0?void 0:r.range;case"angleAxis":return KK(t);case"radiusAxis":return YK(t,n);default:return}},mY=He([xi,Vx],Ew),bm=He([xi,ym,wOe,mY],IO);He([Bx,Ow,di],oOe);function gY(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var kw=(t,e)=>e,Lw=(t,e,n)=>n,POe=He(cw,kw,Lw,(t,e,n)=>t.filter(i=>i.orientation===e).filter(i=>i.mirror===n).sort(gY)),DOe=He(uw,kw,Lw,(t,e,n)=>t.filter(i=>i.orientation===e).filter(i=>i.mirror===n).sort(gY)),xY=(t,e)=>({width:t.width,height:e.height}),OOe=(t,e)=>{var n=typeof e.width=="number"?e.width:Rx;return{width:n,height:t.height}},vY=He(lr,wc,xY),kOe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},LOe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},IOe=He(_c,lr,POe,kw,Lw,(t,e,n,i,r)=>{var a={},s;return n.forEach(o=>{var l=xY(e,o);s==null&&(s=kOe(e,i,t));var c=i==="top"&&!r||i==="bottom"&&r;a[o.id]=s-Number(c)*l.height,s+=(c?-1:1)*l.height}),a}),UOe=He(bc,lr,DOe,kw,Lw,(t,e,n,i,r)=>{var a={},s;return n.forEach(o=>{var l=OOe(e,o);s==null&&(s=LOe(e,i,t));var c=i==="left"&&!r||i==="right"&&r;a[o.id]=s-Number(c)*l.width,s+=(c?-1:1)*l.width}),a}),jOe=(t,e)=>{var n=wc(t,e);if(n!=null)return IOe(t,n.orientation,n.mirror)},FOe=He([lr,wc,jOe,(t,e)=>e],(t,e,n,i)=>{if(e!=null){var r=n?.[i];return r==null?{x:t.left,y:0}:{x:t.left,y:r}}}),zOe=(t,e)=>{var n=Mc(t,e);if(n!=null)return UOe(t,n.orientation,n.mirror)},BOe=He([lr,Mc,zOe,(t,e)=>e],(t,e,n,i)=>{if(e!=null){var r=n?.[i];return r==null?{x:0,y:t.top}:{x:r,y:t.top}}}),yY=He(lr,Mc,(t,e)=>{var n=typeof e.width=="number"?e.width:Rx;return{width:n,height:t.height}}),x8=(t,e,n)=>{switch(e){case"xAxis":return vY(t,n).width;case"yAxis":return yY(t,n).height;default:return}},bY=(t,e,n,i)=>{if(n!=null){var{allowDuplicatedCategory:r,type:a,dataKey:s}=n,o=yc(t,i),l=e.map(c=>c.value);if(s&&o&&a==="category"&&r&&_q(l))return l}},zO=He([bn,Dw,xi,di],bY),_Y=(t,e,n,i)=>{if(!(n==null||n.dataKey==null)){var{type:r,scale:a}=n,s=yc(t,i);if(s&&(r==="number"||a!=="auto"))return e.map(o=>o.value)}},BO=He([bn,Dw,zx,di],_Y),v8=He([bn,JDe,ym,bm,zO,BO,Vx,jO,di],(t,e,n,i,r,a,s,o,l)=>{if(e!=null){var c=yc(t,l);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:l,categoricalDomain:a,duplicateDomain:r,isCategorical:c,niceTicks:o,range:s,realScaleType:n,scale:i}}}),HOe=(t,e,n,i,r,a,s,o,l)=>{if(!(e==null||i==null)){var c=yc(t,l),{type:d,ticks:f,tickCount:p}=e,m=n==="scaleBand"&&typeof i.bandwidth=="function"?i.bandwidth()/2:2,_=d==="category"&&i.bandwidth?i.bandwidth()/m:0;_=l==="angleAxis"&&a!=null&&a.length>=2?Mr(a[0]-a[1])*2*_:_;var b=f||r;if(b){var v=b.map((x,M)=>{var w=s?s.indexOf(x):x;return{index:M,coordinate:i(w)+_,value:x,offset:_}});return v.filter(x=>ai(x.coordinate))}return c&&o?o.map((x,M)=>({coordinate:i(x)+_,value:x,index:M,offset:_})).filter(x=>ai(x.coordinate)):i.ticks?i.ticks(p).map(x=>({coordinate:i(x)+_,value:x,offset:_})):i.domain().map((x,M)=>({coordinate:i(x)+_,value:s?s[x]:x,index:M,offset:_}))}},SY=He([bn,zx,ym,bm,jO,Vx,zO,BO,di],HOe),VOe=(t,e,n,i,r,a,s)=>{if(!(e==null||n==null||i==null||i[0]===i[1])){var o=yc(t,s),{tickCount:l}=e,c=0;return c=s==="angleAxis"&&i?.length>=2?Mr(i[0]-i[1])*2*c:c,o&&a?a.map((d,f)=>({coordinate:n(d)+c,value:d,index:f,offset:c})):n.ticks?n.ticks(l).map(d=>({coordinate:n(d)+c,value:d,offset:c})):n.domain().map((d,f)=>({coordinate:n(d)+c,value:r?r[d]:d,index:f,offset:c}))}},Ku=He([bn,zx,bm,Vx,zO,BO,di],VOe),Yu=He(xi,bm,(t,e)=>{if(!(t==null||e==null))return Q1(Q1({},t),{},{scale:e})}),$Oe=He([xi,ym,LO,mY],IO);He((t,e,n)=>SO(t,n),$Oe,(t,e)=>{if(!(t==null||e==null))return Q1(Q1({},t),{},{scale:e})});var GOe=He([bn,cw,uw],(t,e,n)=>{switch(t){case"horizontal":return e.some(i=>i.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(i=>i.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),wY=t=>t.options.defaultTooltipEventType,MY=t=>t.options.validateTooltipEventTypes;function EY(t,e,n){if(t==null)return e;var i=t?"axis":"item";return n==null?e:n.includes(i)?i:e}function HO(t,e){var n=wY(t),i=MY(t);return EY(e,n,i)}function WOe(t){return At(e=>HO(e,t))}var AY=(t,e)=>{var n,i=Number(e);if(!($s(i)||e==null))return i>=0?t==null||(n=t[i])===null||n===void 0?void 0:n.value:void 0},qOe=t=>t.tooltip.settings,Su={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},XOe={itemInteraction:{click:Su,hover:Su},axisInteraction:{click:Su,hover:Su},keyboardInteraction:Su,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:"hover",axisId:0,active:!1,defaultIndex:void 0}},TY=Fa({name:"tooltip",initialState:XOe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:oi()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:i}=e.payload,r=xo(t).tooltipItemPayloads.indexOf(n);r>-1&&(t.tooltipItemPayloads[r]=i)},prepare:oi()},removeTooltipEntrySettings:{reducer(t,e){var n=xo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:oi()},setTooltipSettingsState(t,e){t.settings=e.payload},setActiveMouseOverItemIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.itemInteraction.hover.active=!0,t.itemInteraction.hover.index=e.payload.activeIndex,t.itemInteraction.hover.dataKey=e.payload.activeDataKey,t.itemInteraction.hover.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.hover.coordinate=e.payload.activeCoordinate},mouseLeaveChart(t){t.itemInteraction.hover.active=!1,t.axisInteraction.hover.active=!1},mouseLeaveItem(t){t.itemInteraction.hover.active=!1},setActiveClickItemIndex(t,e){t.syncInteraction.active=!1,t.itemInteraction.click.active=!0,t.keyboardInteraction.active=!1,t.itemInteraction.click.index=e.payload.activeIndex,t.itemInteraction.click.dataKey=e.payload.activeDataKey,t.itemInteraction.click.graphicalItemId=e.payload.activeGraphicalItemId,t.itemInteraction.click.coordinate=e.payload.activeCoordinate},setMouseOverAxisIndex(t,e){t.syncInteraction.active=!1,t.axisInteraction.hover.active=!0,t.keyboardInteraction.active=!1,t.axisInteraction.hover.index=e.payload.activeIndex,t.axisInteraction.hover.dataKey=e.payload.activeDataKey,t.axisInteraction.hover.coordinate=e.payload.activeCoordinate},setMouseClickAxisIndex(t,e){t.syncInteraction.active=!1,t.keyboardInteraction.active=!1,t.axisInteraction.click.active=!0,t.axisInteraction.click.index=e.payload.activeIndex,t.axisInteraction.click.dataKey=e.payload.activeDataKey,t.axisInteraction.click.coordinate=e.payload.activeCoordinate},setSyncInteraction(t,e){t.syncInteraction=e.payload},setKeyboardInteraction(t,e){t.keyboardInteraction.active=e.payload.active,t.keyboardInteraction.index=e.payload.activeIndex,t.keyboardInteraction.coordinate=e.payload.activeCoordinate,t.keyboardInteraction.dataKey=e.payload.activeDataKey}}}),{addTooltipEntrySettings:KOe,replaceTooltipEntrySettings:YOe,removeTooltipEntrySettings:ZOe,setTooltipSettingsState:QOe,setActiveMouseOverItemIndex:CY,mouseLeaveItem:JOe,mouseLeaveChart:NY,setActiveClickItemIndex:eke,setMouseOverAxisIndex:RY,setMouseClickAxisIndex:tke,setSyncInteraction:_R,setKeyboardInteraction:SR}=TY.actions,nke=TY.reducer;function y8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Lb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y8(Object(n),!0).forEach(function(i){ike(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function ike(t,e,n){return(e=rke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rke(t){var e=ake(t,"string");return typeof e=="symbol"?e:e+""}function ake(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ske(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function oke(t){return t.index!=null}var PY=(t,e,n,i)=>{if(e==null)return Su;var r=ske(t,e,n);if(r==null)return Su;if(r.active)return r;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var a=t.settings.active===!0;if(oke(r)){if(a)return Lb(Lb({},r),{},{active:!0})}else if(i!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:i,graphicalItemId:void 0};return Lb(Lb({},Su),{},{coordinate:r.coordinate})};function lke(t){if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(t instanceof Date){var e=t.valueOf();return Number.isFinite(e)?e:void 0}var n=Number(t);return Number.isFinite(n)?n:void 0}function cke(t,e){var n=lke(t),i=e[0],r=e[1];if(n===void 0)return!1;var a=Math.min(i,r),s=Math.max(i,r);return n>=a&&n<=s}function uke(t,e,n){if(n==null||e==null)return!0;var i=Xn(t,e);return i==null||!Xu(n)?!0:cke(i,n)}var VO=(t,e,n,i)=>{var r=t?.index;if(r==null)return null;var a=Number(r);if(!ai(a))return r;var s=0,o=1/0;e.length>0&&(o=e.length-1);var l=Math.max(s,Math.min(a,o)),c=e[l];return c==null||uke(c,n,i)?String(l):null},DY=(t,e,n,i,r,a,s,o)=>{if(!(a==null||o==null)){var l=s[0],c=l==null?void 0:o(l.positions,a);if(c!=null)return c;var d=r?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(i.top+e)/2};default:return{x:(i.left+t)/2,y:d.coordinate}}}},OY=(t,e,n,i)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var r;return n==="hover"?r=t.itemInteraction.hover.dataKey:r=t.itemInteraction.click.dataKey,r==null&&i!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var s;return((s=a.settings)===null||s===void 0?void 0:s.dataKey)===r})},$x=t=>t.options.tooltipPayloadSearcher,_m=t=>t.tooltip;function b8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function _8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b8(Object(n),!0).forEach(function(i){dke(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function dke(t,e,n){return(e=fke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fke(t){var e=hke(t,"string");return typeof e=="symbol"?e:e+""}function hke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function pke(t,e){return t??e}var kY=(t,e,n,i,r,a,s)=>{if(!(e==null||a==null)){var{chartData:o,computedData:l,dataStartIndex:c,dataEndIndex:d}=n,f=[];return t.reduce((p,m)=>{var _,{dataDefinedOnItem:b,settings:v}=m,x=pke(b,o),M=Array.isArray(x)?mX(x,c,d):x,w=(_=v?.dataKey)!==null&&_!==void 0?_:i,E=v?.nameKey,T;if(i&&Array.isArray(M)&&!Array.isArray(M[0])&&s==="axis"?T=Sq(M,i,r):T=a(M,e,l,E),Array.isArray(T))T.forEach(N=>{var U=_8(_8({},v),{},{name:N.name,unit:N.unit,color:void 0,fill:void 0});p.push(BH({tooltipEntrySettings:U,dataKey:N.dataKey,payload:N.payload,value:Xn(N.payload,N.dataKey),name:N.name}))});else{var P;p.push(BH({tooltipEntrySettings:v,dataKey:w,payload:T,value:Xn(T,w),name:(P=Xn(T,E))!==null&&P!==void 0?P:v?.name}))}return p},f)}},$O=He([dr,bn,tY,gO,ur],hY),mke=He([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),gke=He([ur,xm],wO),Gx=He([mke,dr,gke],MO,{memoizeOptions:{resultEqualityCheck:Rw}}),xke=He([Gx],t=>t.filter(Cw)),vke=He([Gx],EO,{memoizeOptions:{resultEqualityCheck:Rw}}),Sm=He([vke,od],AO),yke=He([xke,od,dr],QK),GO=He([Sm,dr,Gx],CO),LY=He([dr],NO),bke=He([dr],t=>t.allowDataOverflow),IY=He([LY,bke],NK),_ke=He([Gx],t=>t.filter(Cw)),Ske=He([yke,_ke,jx,GK],aY),wke=He([Ske,od,ur,IY],sY),Mke=He([Gx],iY),Eke=He([Sm,dr,Mke,Ow,ur],DO,{memoizeOptions:{resultEqualityCheck:Nw}}),Ake=He([oY,ur,xm],vm),Tke=He([Ake,ur],uY),Cke=He([lY,ur,xm],vm),Nke=He([Cke,ur],dY),Rke=He([cY,ur,xm],vm),Pke=He([Rke,ur],fY),Dke=He([Tke,Pke,Nke],J1),Oke=He([dr,LY,IY,wke,Eke,Dke,bn,ur],OO),Wx=He([dr,bn,Sm,GO,jx,ur,Oke],kO),kke=He([Wx,dr,$O],UO),Lke=He([dr,Wx,kke,ur],FO),UY=t=>{var e=ur(t),n=xm(t),i=!1;return Vx(t,e,n,i)},jY=He([dr,UY],Ew),FY=He([dr,$O,Lke,jY],IO),Ike=He([bn,GO,dr,ur],bY),Uke=He([bn,GO,dr,ur],_Y),jke=(t,e,n,i,r,a,s,o)=>{if(e){var{type:l}=e,c=yc(t,o);if(i){var d=n==="scaleBand"&&i.bandwidth?i.bandwidth()/2:2,f=l==="category"&&i.bandwidth?i.bandwidth()/d:0;return f=o==="angleAxis"&&r!=null&&r?.length>=2?Mr(r[0]-r[1])*2*f:f,c&&s?s.map((p,m)=>({coordinate:i(p)+f,value:p,index:m,offset:f})):i.domain().map((p,m)=>({coordinate:i(p)+f,value:a?a[p]:p,index:m,offset:f}))}}},Ec=He([bn,dr,$O,FY,UY,Ike,Uke,ur],jke),WO=He([wY,MY,qOe],(t,e,n)=>EY(n.shared,t,e)),zY=t=>t.tooltip.settings.trigger,qO=t=>t.tooltip.settings.defaultIndex,qx=He([_m,WO,zY,qO],PY),Zu=He([qx,Sm,Hx,Wx],VO),BY=He([Ec,Zu],AY),XO=He([qx],t=>{if(t)return t.dataKey}),Fke=He([qx],t=>{if(t)return t.graphicalItemId}),HY=He([_m,WO,zY,qO],OY),zke=He([bc,_c,bn,lr,Ec,qO,HY,$x],DY),Bke=He([qx,zke],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),Hke=He([qx],t=>t.active),Vke=He([HY,Zu,od,Hx,BY,$x,WO],kY),$ke=He([Vke],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function S8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function w8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S8(Object(n),!0).forEach(function(i){Gke(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function Gke(t,e,n){return(e=Wke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Wke(t){var e=qke(t,"string");return typeof e=="symbol"?e:e+""}function qke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Xke=()=>At(dr),Kke=()=>{var t=Xke(),e=At(Ec),n=At(FY);return Kp(!t||!n?void 0:w8(w8({},t),{},{scale:n}),e)};function M8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function tp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M8(Object(n),!0).forEach(function(i){Yke(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function Yke(t,e,n){return(e=Zke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Zke(t){var e=Qke(t,"string");return typeof e=="symbol"?e:e+""}function Qke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Jke=(t,e,n,i)=>{var r=e.find(a=>a&&a.index===n);if(r){if(t==="horizontal")return{x:r.coordinate,y:i.chartY};if(t==="vertical")return{x:i.chartX,y:r.coordinate}}return{x:0,y:0}},eLe=(t,e,n,i)=>{var r=e.find(c=>c&&c.index===n);if(r){if(t==="centric"){var a=r.coordinate,{radius:s}=i;return tp(tp(tp({},i),Vi(i.cx,i.cy,s,a)),{},{angle:a,radius:s})}var o=r.coordinate,{angle:l}=i;return tp(tp(tp({},i),Vi(i.cx,i.cy,o,l)),{},{angle:l,radius:o})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function tLe(t,e){var{chartX:n,chartY:i}=t;return n>=e.left&&n<=e.left+e.width&&i>=e.top&&i<=e.top+e.height}var VY=(t,e,n,i,r)=>{var a,s=-1,o=(a=e?.length)!==null&&a!==void 0?a:0;if(o<=1||t==null)return 0;if(i==="angleAxis"&&r!=null&&Math.abs(Math.abs(r[1]-r[0])-360)<=1e-6)for(var l=0;l<o;l++){var c=l>0?n[l-1].coordinate:n[o-1].coordinate,d=n[l].coordinate,f=l>=o-1?n[0].coordinate:n[l+1].coordinate,p=void 0;if(Mr(d-c)!==Mr(f-d)){var m=[];if(Mr(f-d)===Mr(r[1]-r[0])){p=f;var _=d+r[1]-r[0];m[0]=Math.min(_,(_+c)/2),m[1]=Math.max(_,(_+c)/2)}else{p=c;var b=f+r[1]-r[0];m[0]=Math.min(d,(b+d)/2),m[1]=Math.max(d,(b+d)/2)}var v=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>v[0]&&t<=v[1]||t>=m[0]&&t<=m[1]){({index:s}=n[l]);break}}else{var x=Math.min(c,f),M=Math.max(c,f);if(t>(x+d)/2&&t<=(M+d)/2){({index:s}=n[l]);break}}}else if(e){for(var w=0;w<o;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===o-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:s}=e[w]);break}}return s},$Y=()=>At(gO),KO=(t,e)=>e,GY=(t,e,n)=>n,YO=(t,e,n,i)=>i,nLe=He(Ec,t=>ew(t,e=>e.coordinate)),ZO=He([_m,KO,GY,YO],PY),QO=He([ZO,Sm,Hx,Wx],VO),iLe=(t,e,n)=>{if(e!=null){var i=_m(t);return e==="axis"?n==="hover"?i.axisInteraction.hover.dataKey:i.axisInteraction.click.dataKey:n==="hover"?i.itemInteraction.hover.dataKey:i.itemInteraction.click.dataKey}},WY=He([_m,KO,GY,YO],OY),eS=He([bc,_c,bn,lr,Ec,YO,WY,$x],DY),rLe=He([ZO,eS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),qY=He([Ec,QO],AY),aLe=He([WY,QO,od,Hx,qY,$x,KO],kY),sLe=He([ZO,QO],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),oLe=(t,e,n,i,r,a,s)=>{if(!(!t||!n||!i||!r)&&tLe(t,s)){var o=CCe(t,e),l=VY(o,a,r,n,i),c=Jke(e,r,l,t);return{activeIndex:String(l),activeCoordinate:c}}},lLe=(t,e,n,i,r,a,s)=>{if(!(!t||!i||!r||!a||!n)){var o=G3e(t,n);if(o){var l=NCe(o,e),c=VY(l,s,a,i,r),d=eLe(e,a,c,o);return{activeIndex:String(c),activeCoordinate:d}}}},cLe=(t,e,n,i,r,a,s,o)=>{if(!(!t||!e||!i||!r||!a))return e==="horizontal"||e==="vertical"?oLe(t,e,i,r,a,s,o):lLe(t,e,n,i,r,a,s)},uLe=He(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var i=t[e];if(i!=null)return n?i.panoramaElementId:i.elementId}}),dLe=He(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(i=>parseInt(i,10)).concat(Object.values($i)),n=Array.from(new Set(e));return n.sort((i,r)=>i-r)},{memoizeOptions:{resultEqualityCheck:XDe}});function E8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function A8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?E8(Object(n),!0).forEach(function(i){fLe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function fLe(t,e,n){return(e=hLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hLe(t){var e=pLe(t,"string");return typeof e=="symbol"?e:e+""}function pLe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var mLe={},gLe={zIndexMap:Object.values($i).reduce((t,e)=>A8(A8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),mLe)},xLe=new Set(Object.values($i));function vLe(t){return xLe.has(t)}var XY=Fa({name:"zIndex",initialState:gLe,reducers:{registerZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]?t.zIndexMap[n].consumers+=1:t.zIndexMap[n]={consumers:1,elementId:void 0,panoramaElementId:void 0}},prepare:oi()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!vLe(n)&&delete t.zIndexMap[n])},prepare:oi()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:i,isPanorama:r}=e.payload;t.zIndexMap[n]?r?t.zIndexMap[n].panoramaElementId=i:t.zIndexMap[n].elementId=i:t.zIndexMap[n]={consumers:0,elementId:r?void 0:i,panoramaElementId:r?i:void 0}},prepare:oi()},unregisterZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(e.payload.isPanorama?t.zIndexMap[n].panoramaElementId=void 0:t.zIndexMap[n].elementId=void 0)},prepare:oi()}}}),{registerZIndexPortal:yLe,unregisterZIndexPortal:bLe,registerZIndexPortalId:_Le,unregisterZIndexPortalId:SLe}=XY.actions,wLe=XY.reducer;function za(t){var{zIndex:e,children:n}=t,i=oNe(),r=i&&e!==void 0&&e!==0,a=aa(),s=Qn();A.useLayoutEffect(()=>r?(s(yLe({zIndex:e})),()=>{s(bLe({zIndex:e}))}):Ex,[s,e,r]);var o=At(c=>uLe(c,e,a));if(!r)return n;if(!o)return null;var l=document.getElementById(o);return l?$l.createPortal(n,l):null}function wR(){return wR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},wR.apply(null,arguments)}function T8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Ib(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T8(Object(n),!0).forEach(function(i){MLe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function MLe(t,e,n){return(e=ELe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ELe(t){var e=ALe(t,"string");return typeof e=="symbol"?e:e+""}function ALe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function TLe(t){var{cursor:e,cursorComp:n,cursorProps:i}=t;return A.isValidElement(e)?A.cloneElement(e,i):A.createElement(n,i)}function CLe(t){var e,{coordinate:n,payload:i,index:r,offset:a,tooltipAxisBandSize:s,layout:o,cursor:l,tooltipEventType:c,chartName:d}=t,f=n,p=i,m=r;if(!l||!f||d!=="ScatterChart"&&c!=="axis")return null;var _,b,v;if(d==="ScatterChart")_=f,b=s3e,v=$i.cursorLine;else if(d==="BarChart")_=o3e(o,f,a,s),b=VX,v=$i.cursorRectangle;else if(o==="radial"&&Mq(f)){var{cx:x,cy:M,radius:w,startAngle:E,endAngle:T}=GX(f);_={cx:x,cy:M,startAngle:E,endAngle:T,innerRadius:w,outerRadius:w},b=qX,v=$i.cursorLine}else _={points:K3e(o,f,a)},b=Ap,v=$i.cursorLine;var P=typeof l=="object"&&"className"in l?l.className:void 0,N=Ib(Ib(Ib(Ib({stroke:"#ccc",pointerEvents:"none"},a),_),Nf(l)),{},{payload:p,payloadIndex:m,className:Mn("recharts-tooltip-cursor",P)});return A.createElement(za,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},A.createElement(TLe,{cursor:l,cursorComp:b,cursorProps:N}))}function NLe(t){var e=Kke(),n=AX(),i=fm(),r=$Y();return e==null||n==null||i==null||r==null?null:A.createElement(CLe,wR({},t,{offset:n,layout:i,tooltipAxisBandSize:e,chartName:r}))}var KY=A.createContext(null),RLe=()=>A.useContext(KY),gC={exports:{}},C8;function PLe(){return C8||(C8=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1));function r(l,c,d){this.fn=l,this.context=c,this.once=d||!1}function a(l,c,d,f,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new r(d,f||l,p),_=n?n+c:c;return l._events[_]?l._events[_].fn?l._events[_]=[l._events[_],m]:l._events[_].push(m):(l._events[_]=m,l._eventsCount++),l}function s(l,c){--l._eventsCount===0?l._events=new i:delete l._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],d,f;if(this._eventsCount===0)return c;for(f in d=this._events)e.call(d,f)&&c.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(d)):c},o.prototype.listeners=function(c){var d=n?n+c:c,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,m=f.length,_=new Array(m);p<m;p++)_[p]=f[p].fn;return _},o.prototype.listenerCount=function(c){var d=n?n+c:c,f=this._events[d];return f?f.fn?1:f.length:0},o.prototype.emit=function(c,d,f,p,m,_){var b=n?n+c:c;if(!this._events[b])return!1;var v=this._events[b],x=arguments.length,M,w;if(v.fn){switch(v.once&&this.removeListener(c,v.fn,void 0,!0),x){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,f),!0;case 4:return v.fn.call(v.context,d,f,p),!0;case 5:return v.fn.call(v.context,d,f,p,m),!0;case 6:return v.fn.call(v.context,d,f,p,m,_),!0}for(w=1,M=new Array(x-1);w<x;w++)M[w-1]=arguments[w];v.fn.apply(v.context,M)}else{var E=v.length,T;for(w=0;w<E;w++)switch(v[w].once&&this.removeListener(c,v[w].fn,void 0,!0),x){case 1:v[w].fn.call(v[w].context);break;case 2:v[w].fn.call(v[w].context,d);break;case 3:v[w].fn.call(v[w].context,d,f);break;case 4:v[w].fn.call(v[w].context,d,f,p);break;default:if(!M)for(T=1,M=new Array(x-1);T<x;T++)M[T-1]=arguments[T];v[w].fn.apply(v[w].context,M)}}return!0},o.prototype.on=function(c,d,f){return a(this,c,d,f,!1)},o.prototype.once=function(c,d,f){return a(this,c,d,f,!0)},o.prototype.removeListener=function(c,d,f,p){var m=n?n+c:c;if(!this._events[m])return this;if(!d)return s(this,m),this;var _=this._events[m];if(_.fn)_.fn===d&&(!p||_.once)&&(!f||_.context===f)&&s(this,m);else{for(var b=0,v=[],x=_.length;b<x;b++)(_[b].fn!==d||p&&!_[b].once||f&&_[b].context!==f)&&v.push(_[b]);v.length?this._events[m]=v.length===1?v[0]:v:s(this,m)}return this},o.prototype.removeAllListeners=function(c){var d;return c?(d=n?n+c:c,this._events[d]&&s(this,d)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(gC)),gC.exports}var DLe=PLe();const OLe=qs(DLe);var sx=new OLe,MR="recharts.syncEvent.tooltip",N8="recharts.syncEvent.brush";function JO(t,e){if(e){var n=Number.parseInt(e,10);if(!$s(n))return t?.[n]}}var kLe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},YY=Fa({name:"options",initialState:kLe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),LLe=YY.reducer,{createEventEmitter:ILe}=YY.actions;function ULe(t){return t.tooltip.syncInteraction}var jLe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},ZY=Fa({name:"chartData",initialState:jLe,reducers:{setChartData(t,e){if(t.chartData=e.payload,e.payload==null){t.dataStartIndex=0,t.dataEndIndex=0;return}e.payload.length>0&&t.dataEndIndex!==e.payload.length-1&&(t.dataEndIndex=e.payload.length-1)},setComputedData(t,e){t.computedData=e.payload},setDataStartEndIndexes(t,e){var{startIndex:n,endIndex:i}=e.payload;n!=null&&(t.dataStartIndex=n),i!=null&&(t.dataEndIndex=i)}}}),{setChartData:R8,setDataStartEndIndexes:FLe,setComputedData:j8e}=ZY.actions,zLe=ZY.reducer,BLe=["x","y"];function P8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function np(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P8(Object(n),!0).forEach(function(i){HLe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function HLe(t,e,n){return(e=VLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VLe(t){var e=$Le(t,"string");return typeof e=="symbol"?e:e+""}function $Le(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function GLe(t,e){if(t==null)return{};var n,i,r=WLe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function WLe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function qLe(){var t=At(xO),e=At(vO),n=Qn(),i=At(WK),r=At(Ec),a=fm(),s=hw(),o=At(l=>l.rootProps.className);A.useEffect(()=>{if(t==null)return Ex;var l=(c,d,f)=>{if(e!==f&&t===c){if(i==="index"){var p;if(s&&d!==null&&d!==void 0&&(p=d.payload)!==null&&p!==void 0&&p.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x:_,y:b}=m,v=GLe(m,BLe),{x,y:M,width:w,height:E}=d.payload.sourceViewBox,T=np(np({},v),{},{x:s.x+(w?(_-x)/w:0)*s.width,y:s.y+(E?(b-M)/E:0)*s.height});n(np(np({},d),{},{payload:np(np({},d.payload),{},{coordinate:T})}))}else n(d);return}if(r!=null){var P;if(typeof i=="function"){var N={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},U=i(r,N);P=r[U]}else i==="value"&&(P=r.find(q=>String(q.value)===d.payload.label));var{coordinate:R}=d.payload;if(P==null||d.payload.active===!1||R==null||s==null){n(_R({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:O,y:z}=R,I=Math.min(O,s.x+s.width),G=Math.min(z,s.y+s.height),L={x:a==="horizontal"?P.coordinate:I,y:a==="horizontal"?G:P.coordinate},B=_R({active:d.payload.active,coordinate:L,dataKey:d.payload.dataKey,index:String(P.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(B)}}};return sx.on(MR,l),()=>{sx.off(MR,l)}},[o,n,e,t,i,r,a,s])}function XLe(){var t=At(xO),e=At(vO),n=Qn();A.useEffect(()=>{if(t==null)return Ex;var i=(r,a,s)=>{e!==s&&t===r&&n(FLe(a))};return sx.on(N8,i),()=>{sx.off(N8,i)}},[n,e,t])}function KLe(){var t=Qn();A.useEffect(()=>{t(ILe())},[t]),qLe(),XLe()}function YLe(t,e,n,i,r,a){var s=At(m=>iLe(m,t,e)),o=At(vO),l=At(xO),c=At(WK),d=At(ULe),f=d?.active,p=hw();A.useEffect(()=>{if(!f&&l!=null&&o!=null){var m=_R({active:a,coordinate:n,dataKey:s,index:r,label:typeof i=="number"?String(i):i,sourceViewBox:p,graphicalItemId:void 0});sx.emit(MR,l,m,o)}},[f,n,s,r,i,o,l,c,a,p])}function D8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function O8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?D8(Object(n),!0).forEach(function(i){ZLe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):D8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function ZLe(t,e,n){return(e=QLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QLe(t){var e=JLe(t,"string");return typeof e=="symbol"?e:e+""}function JLe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eIe(t){return t.dataKey}function tIe(t,e){return A.isValidElement(t)?A.cloneElement(t,e):typeof t=="function"?A.createElement(t,e):A.createElement(FNe,e)}var k8=[],nIe={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",axisId:0,contentStyle:{},cursor:!0,filterNull:!0,isAnimationActive:"auto",itemSorter:"name",itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,wrapperStyle:{}};function xC(t){var e,n,i=Xi(t,nIe),{active:r,allowEscapeViewBox:a,animationDuration:s,animationEasing:o,content:l,filterNull:c,isAnimationActive:d,offset:f,payloadUniqBy:p,position:m,reverseDirection:_,useTranslate3d:b,wrapperStyle:v,cursor:x,shared:M,trigger:w,defaultIndex:E,portal:T,axisId:P}=i,N=Qn(),U=typeof E=="number"?String(E):E;A.useEffect(()=>{N(QOe({shared:M,trigger:w,axisId:P,active:r,defaultIndex:U}))},[N,M,w,P,r,U]);var R=hw(),O=jX(),z=WOe(M),{activeIndex:I,isActive:G}=(e=At(ve=>sLe(ve,z,w,U)))!==null&&e!==void 0?e:{},L=At(ve=>aLe(ve,z,w,U)),B=At(ve=>qY(ve,z,w,U)),q=At(ve=>rLe(ve,z,w,U)),W=L,X=RLe(),Q=(n=r??G)!==null&&n!==void 0?n:!1,[ie,H]=Fq([W,Q]),Y=z==="axis"?B:void 0;YLe(z,w,q,Y,I,Q);var se=T??X;if(se==null||R==null||z==null)return null;var ue=W??k8;Q||(ue=k8),c&&ue.length&&(ue=kq(ue.filter(ve=>ve.value!=null&&(ve.hide!==!0||i.includeHidden)),p,eIe));var xe=ue.length>0,re=A.createElement(WNe,{allowEscapeViewBox:a,animationDuration:s,animationEasing:o,isAnimationActive:d,active:Q,coordinate:q,hasPayload:xe,offset:f,position:m,reverseDirection:_,useTranslate3d:b,viewBox:R,wrapperStyle:v,lastBoundingBox:ie,innerRef:H,hasPortalFromProps:!!T},tIe(l,O8(O8({},i),{},{payload:ue,label:Y,active:Q,activeIndex:I,coordinate:q,accessibilityLayer:O})));return A.createElement(A.Fragment,null,$l.createPortal(re,se),Q&&A.createElement(NLe,{cursor:x,tooltipEventType:z,coordinate:q,payload:ue,index:I}))}var Xx=t=>null;Xx.displayName="Cell";function iIe(t,e,n){return(e=rIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rIe(t){var e=aIe(t,"string");return typeof e=="symbol"?e:e+""}function aIe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class sIe{constructor(e){iIe(this,"cache",new Map),this.maxSize=e}get(e){var n=this.cache.get(e);return n!==void 0&&(this.cache.delete(e),this.cache.set(e,n)),n}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var i=this.cache.keys().next().value;i!=null&&this.cache.delete(i)}this.cache.set(e,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function L8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function oIe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L8(Object(n),!0).forEach(function(i){lIe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function lIe(t,e,n){return(e=cIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cIe(t){var e=uIe(t,"string");return typeof e=="symbol"?e:e+""}function uIe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var dIe={cacheSize:2e3,enableCache:!0},QY=oIe({},dIe),I8=new sIe(QY.cacheSize),fIe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},U8="recharts_measurement_span";function hIe(t,e){var n=e.fontSize||"",i=e.fontFamily||"",r=e.fontWeight||"",a=e.fontStyle||"",s=e.letterSpacing||"",o=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(i,"|").concat(r,"|").concat(a,"|").concat(s,"|").concat(o)}var j8=(t,e)=>{try{var n=document.getElementById(U8);n||(n=document.createElement("span"),n.setAttribute("id",U8),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,fIe,e),n.textContent="".concat(t);var i=n.getBoundingClientRect();return{width:i.width,height:i.height}}catch{return{width:0,height:0}}},h0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||hm.isSsr)return{width:0,height:0};if(!QY.enableCache)return j8(e,n);var i=hIe(e,n),r=I8.get(i);if(r)return r;var a=j8(e,n);return I8.set(i,a),a},F8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,z8=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,pIe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,mIe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,JY={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},gIe=Object.keys(JY),pp="NaN";function xIe(t,e){return t*JY[e]}class Na{static parse(e){var n,[,i,r]=(n=mIe.exec(e))!==null&&n!==void 0?n:[];return new Na(parseFloat(i),r??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,$s(e)&&(this.unit=""),n!==""&&!pIe.test(n)&&(this.num=NaN,this.unit=""),gIe.includes(n)&&(this.num=xIe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Na(NaN,""):new Na(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Na(NaN,""):new Na(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Na(NaN,""):new Na(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Na(NaN,""):new Na(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return $s(this.num)}}function eZ(t){if(t.includes(pp))return pp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,i,r,a]=(n=F8.exec(e))!==null&&n!==void 0?n:[],s=Na.parse(i??""),o=Na.parse(a??""),l=r==="*"?s.multiply(o):s.divide(o);if(l.isNaN())return pp;e=e.replace(F8,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var c,[,d,f,p]=(c=z8.exec(e))!==null&&c!==void 0?c:[],m=Na.parse(d??""),_=Na.parse(p??""),b=f==="+"?m.add(_):m.subtract(_);if(b.isNaN())return pp;e=e.replace(z8,b.toString())}return e}var B8=/\(([^()]*)\)/;function vIe(t){for(var e=t,n;(n=B8.exec(e))!=null;){var[,i]=n;e=e.replace(B8,eZ(i))}return e}function yIe(t){var e=t.replace(/\s+/g,"");return e=vIe(e),e=eZ(e),e}function bIe(t){try{return yIe(t)}catch{return pp}}function vC(t){var e=bIe(t.slice(5,-1));return e===pp?"":e}var _Ie=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],SIe=["dx","dy","angle","className","breakAll"];function ER(){return ER=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},ER.apply(null,arguments)}function H8(t,e){if(t==null)return{};var n,i,r=wIe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function wIe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var tZ=/[ \f\n\r\t\v\u2028\u2029]+/,nZ=t=>{var{children:e,breakAll:n,style:i}=t;try{var r=[];mi(e)||(n?r=e.toString().split(""):r=e.toString().split(tZ));var a=r.map(o=>({word:o,width:h0(o,i).width})),s=n?0:h0(" ",i).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function MIe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var iZ=(t,e,n,i)=>t.reduce((r,a)=>{var{word:s,width:o}=a,l=r[r.length-1];if(l&&o!=null&&(e==null||i||l.width+o+n<Number(e)))l.words.push(s),l.width+=o+n;else{var c={words:[s],width:o};r.push(c)}return r},[]),rZ=t=>t.reduce((e,n)=>e.width>n.width?e:n),EIe="…",V8=(t,e,n,i,r,a,s,o)=>{var l=t.slice(0,e),c=nZ({breakAll:n,style:i,children:l+EIe});if(!c)return[!1,[]];var d=iZ(c.wordsWithComputedWidth,a,s,o),f=d.length>r||rZ(d).width>Number(a);return[f,d]},AIe=(t,e,n,i,r)=>{var{maxLines:a,children:s,style:o,breakAll:l}=t,c=Et(a),d=String(s),f=iZ(e,i,n,r);if(!c||r)return f;var p=f.length>a||rZ(f).width>Number(i);if(!p)return f;for(var m=0,_=d.length-1,b=0,v;m<=_&&b<=d.length-1;){var x=Math.floor((m+_)/2),M=x-1,[w,E]=V8(d,M,l,o,a,i,n,r),[T]=V8(d,x,l,o,a,i,n,r);if(!w&&!T&&(m=x+1),w&&T&&(_=x-1),!w&&T){v=E;break}b++}return v||f},$8=t=>{var e=mi(t)?[]:t.toString().split(tZ);return[{words:e,width:void 0}]},TIe=t=>{var{width:e,scaleToFit:n,children:i,style:r,breakAll:a,maxLines:s}=t;if((e||n)&&!hm.isSsr){var o,l,c=nZ({breakAll:a,children:i,style:r});if(c){var{wordsWithComputedWidth:d,spaceWidth:f}=c;o=d,l=f}else return $8(i);return AIe({breakAll:a,children:i,maxLines:s,style:r},o,l,e,!!n)}return $8(i)},aZ="#808080",CIe={angle:0,breakAll:!1,capHeight:"0.71em",fill:aZ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},Iw=A.forwardRef((t,e)=>{var n=Xi(t,CIe),{x:i,y:r,lineHeight:a,capHeight:s,fill:o,scaleToFit:l,textAnchor:c,verticalAnchor:d}=n,f=H8(n,_Ie),p=A.useMemo(()=>TIe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:l,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,l,f.style,f.width]),{dx:m,dy:_,angle:b,className:v,breakAll:x}=f,M=H8(f,SIe);if(!Ko(i)||!Ko(r)||p.length===0)return null;var w=Number(i)+(Et(m)?m:0),E=Number(r)+(Et(_)?_:0);if(!ai(w)||!ai(E))return null;var T;switch(d){case"start":T=vC("calc(".concat(s,")"));break;case"middle":T=vC("calc(".concat((p.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=vC("calc(".concat(p.length-1," * -").concat(a,")"));break}var P=[];if(l){var N=p[0].width,{width:U}=f;P.push("scale(".concat(Et(U)&&Et(N)?U/N:1,")"))}return b&&P.push("rotate(".concat(b,", ").concat(w,", ").concat(E,")")),P.length&&(M.transform=P.join(" ")),A.createElement("text",ER({},ya(M),{ref:e,x:w,y:E,className:Mn("recharts-text",v),textAnchor:c,fill:o.includes("url")?aZ:o}),p.map((R,O)=>{var z=R.words.join(x?"":" ");return A.createElement("tspan",{x:w,dy:O===0?T:a,key:"".concat(z,"-").concat(O)},z)}))});Iw.displayName="Text";var NIe=["labelRef"];function RIe(t,e){if(t==null)return{};var n,i,r=PIe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function PIe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function G8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Ni(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G8(Object(n),!0).forEach(function(i){DIe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function DIe(t,e,n){return(e=OIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function OIe(t){var e=kIe(t,"string");return typeof e=="symbol"?e:e+""}function kIe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Vl(){return Vl=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Vl.apply(null,arguments)}var sZ=A.createContext(null),LIe=t=>{var{x:e,y:n,upperWidth:i,lowerWidth:r,width:a,height:s,children:o}=t,l=A.useMemo(()=>({x:e,y:n,upperWidth:i,lowerWidth:r,width:a,height:s}),[e,n,i,r,a,s]);return A.createElement(sZ.Provider,{value:l},o)},oZ=()=>{var t=A.useContext(sZ),e=hw();return t||EX(e)},IIe=A.createContext(null),UIe=()=>{var t=A.useContext(IIe),e=At(ZK);return t||e},jIe=t=>{var{value:e,formatter:n}=t,i=mi(t.children)?e:t.children;return typeof n=="function"?n(i):i},ek=t=>t!=null&&typeof t=="function",FIe=(t,e)=>{var n=Mr(e-t),i=Math.min(Math.abs(e-t),360);return n*i},zIe=(t,e,n,i,r)=>{var{offset:a,className:s}=t,{cx:o,cy:l,innerRadius:c,outerRadius:d,startAngle:f,endAngle:p,clockWise:m}=r,_=(c+d)/2,b=FIe(f,p),v=b>=0?1:-1,x,M;switch(e){case"insideStart":x=f+v*a,M=m;break;case"insideEnd":x=p-v*a,M=!m;break;case"end":x=p+v*a,M=m;break;default:throw new Error("Unsupported position ".concat(e))}M=b<=0?M:!M;var w=Vi(o,l,_,x),E=Vi(o,l,_,x+(M?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
- A`).concat(_,",").concat(_,",0,1,").concat(M?0:1,`,
- `).concat(E.x,",").concat(E.y),P=mi(t.id)?W0("recharts-radial-line-"):t.id;return A.createElement("text",Vl({},i,{dominantBaseline:"central",className:Mn("recharts-radial-bar-label",s)}),A.createElement("defs",null,A.createElement("path",{id:P,d:T})),A.createElement("textPath",{xlinkHref:"#".concat(P)},n))},BIe=(t,e,n)=>{var{cx:i,cy:r,innerRadius:a,outerRadius:s,startAngle:o,endAngle:l}=t,c=(o+l)/2;if(n==="outside"){var{x:d,y:f}=Vi(i,r,s+e,c);return{x:d,y:f,textAnchor:d>=i?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:i,y:r,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:i,y:r,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:i,y:r,textAnchor:"middle",verticalAnchor:"end"};var p=(a+s)/2,{x:m,y:_}=Vi(i,r,p,c);return{x:m,y:_,textAnchor:"middle",verticalAnchor:"middle"}},AR=t=>"cx"in t&&Et(t.cx),HIe=(t,e)=>{var{parentViewBox:n,offset:i,position:r}=t,a;n!=null&&!AR(n)&&(a=n);var{x:s,y:o,upperWidth:l,lowerWidth:c,height:d}=e,f=s,p=s+(l-c)/2,m=(f+p)/2,_=(l+c)/2,b=f+l/2,v=d>=0?1:-1,x=v*i,M=v>0?"end":"start",w=v>0?"start":"end",E=l>=0?1:-1,T=E*i,P=E>0?"end":"start",N=E>0?"start":"end";if(r==="top"){var U={x:f+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return Ni(Ni({},U),a?{height:Math.max(o-a.y,0),width:l}:{})}if(r==="bottom"){var R={x:p+c/2,y:o+d+x,textAnchor:"middle",verticalAnchor:w};return Ni(Ni({},R),a?{height:Math.max(a.y+a.height-(o+d),0),width:c}:{})}if(r==="left"){var O={x:m-T,y:o+d/2,textAnchor:P,verticalAnchor:"middle"};return Ni(Ni({},O),a?{width:Math.max(O.x-a.x,0),height:d}:{})}if(r==="right"){var z={x:m+_+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"};return Ni(Ni({},z),a?{width:Math.max(a.x+a.width-z.x,0),height:d}:{})}var I=a?{width:_,height:d}:{};return r==="insideLeft"?Ni({x:m+T,y:o+d/2,textAnchor:N,verticalAnchor:"middle"},I):r==="insideRight"?Ni({x:m+_-T,y:o+d/2,textAnchor:P,verticalAnchor:"middle"},I):r==="insideTop"?Ni({x:f+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},I):r==="insideBottom"?Ni({x:p+c/2,y:o+d-x,textAnchor:"middle",verticalAnchor:M},I):r==="insideTopLeft"?Ni({x:f+T,y:o+x,textAnchor:N,verticalAnchor:w},I):r==="insideTopRight"?Ni({x:f+l-T,y:o+x,textAnchor:P,verticalAnchor:w},I):r==="insideBottomLeft"?Ni({x:p+T,y:o+d-x,textAnchor:N,verticalAnchor:M},I):r==="insideBottomRight"?Ni({x:p+c-T,y:o+d-x,textAnchor:P,verticalAnchor:M},I):r&&typeof r=="object"&&(Et(r.x)||dc(r.x))&&(Et(r.y)||dc(r.y))?Ni({x:s+na(r.x,_),y:o+na(r.y,d),textAnchor:"end",verticalAnchor:"end"},I):Ni({x:b,y:o+d/2,textAnchor:"middle",verticalAnchor:"middle"},I)},VIe={angle:0,offset:5,zIndex:$i.label,position:"middle",textBreakAll:!1};function xu(t){var e=Xi(t,VIe),{viewBox:n,position:i,value:r,children:a,content:s,className:o="",textBreakAll:l,labelRef:c}=e,d=UIe(),f=oZ(),p=i==="center"?f:d??f,m,_,b;if(n==null?m=p:AR(n)?m=n:m=EX(n),!m||mi(r)&&mi(a)&&!A.isValidElement(s)&&typeof s!="function")return null;var v=Ni(Ni({},e),{},{viewBox:m});if(A.isValidElement(s)){var{labelRef:x}=v,M=RIe(v,NIe);return A.cloneElement(s,M)}if(typeof s=="function"){if(_=A.createElement(s,v),A.isValidElement(_))return _}else _=jIe(e);var w=ya(e);if(AR(m)){if(i==="insideStart"||i==="insideEnd"||i==="end")return zIe(e,i,_,w,m);b=BIe(m,e.offset,e.position)}else b=HIe(e,m);return A.createElement(za,{zIndex:e.zIndex},A.createElement(Iw,Vl({ref:c,className:Mn("recharts-label",o)},w,b,{textAnchor:MIe(w.textAnchor)?w.textAnchor:b.textAnchor,breakAll:l}),_))}xu.displayName="Label";var $Ie=(t,e,n)=>{if(!t)return null;var i={viewBox:e,labelRef:n};return t===!0?A.createElement(xu,Vl({key:"label-implicit"},i)):Ko(t)?A.createElement(xu,Vl({key:"label-implicit",value:t},i)):A.isValidElement(t)?t.type===xu?A.cloneElement(t,Ni({key:"label-implicit"},i)):A.createElement(xu,Vl({key:"label-implicit",content:t},i)):ek(t)?A.createElement(xu,Vl({key:"label-implicit",content:t},i)):t&&typeof t=="object"?A.createElement(xu,Vl({},t,{key:"label-implicit"},i)):null};function GIe(t){var{label:e,labelRef:n}=t,i=oZ();return $Ie(e,i,n)||null}var yC={},bC={},W8;function WIe(){return W8||(W8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(bC)),bC}var _C={},q8;function qIe(){return q8||(q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(_C)),_C}var X8;function XIe(){return X8||(X8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WIe(),n=qIe(),i=CD();function r(a){if(i.isArrayLike(a))return e.last(n.toArray(a))}t.last=r})(yC)),yC}var SC,K8;function KIe(){return K8||(K8=1,SC=XIe().last),SC}var YIe=KIe();const ZIe=qs(YIe);var QIe=["valueAccessor"],JIe=["dataKey","clockWise","id","textBreakAll","zIndex"];function tS(){return tS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},tS.apply(null,arguments)}function Y8(t,e){if(t==null)return{};var n,i,r=eUe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function eUe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var tUe=t=>Array.isArray(t.value)?ZIe(t.value):t.value,lZ=A.createContext(void 0),cZ=lZ.Provider,uZ=A.createContext(void 0),nUe=uZ.Provider;function iUe(){return A.useContext(lZ)}function rUe(){return A.useContext(uZ)}function c_(t){var{valueAccessor:e=tUe}=t,n=Y8(t,QIe),{dataKey:i,clockWise:r,id:a,textBreakAll:s,zIndex:o}=n,l=Y8(n,JIe),c=iUe(),d=rUe(),f=c||d;return!f||!f.length?null:A.createElement(za,{zIndex:o??$i.label},A.createElement(Di,{className:"recharts-label-list"},f.map((p,m)=>{var _,b=mi(i)?e(p,m):Xn(p&&p.payload,i),v=mi(a)?{}:{id:"".concat(a,"-").concat(m)};return A.createElement(xu,tS({key:"label-".concat(m)},ya(p),l,v,{fill:(_=n.fill)!==null&&_!==void 0?_:p.fill,parentViewBox:p.parentViewBox,value:b,textBreakAll:s,viewBox:p.viewBox,index:m,zIndex:0}))})))}c_.displayName="LabelList";function tk(t){var{label:e}=t;return e?e===!0?A.createElement(c_,{key:"labelList-implicit"}):A.isValidElement(e)||ek(e)?A.createElement(c_,{key:"labelList-implicit",content:e}):typeof e=="object"?A.createElement(c_,tS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function TR(){return TR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},TR.apply(null,arguments)}var dZ=t=>{var{cx:e,cy:n,r:i,className:r}=t,a=Mn("recharts-dot",r);return Et(e)&&Et(n)&&Et(i)?A.createElement("circle",TR({},Ua(t),TD(t),{className:a,cx:e,cy:n,r:i})):null},fZ=t=>t.graphicalItems.polarItems,aUe=He([di,Fx],wO),Uw=He([fZ,xi,aUe],MO),sUe=He([Uw],EO),jw=He([sUe,hO],AO),oUe=He([jw,xi,Uw],CO);He([jw,xi,Uw],(t,e,n)=>n.length>0?t.flatMap(i=>n.flatMap(r=>{var a,s=Xn(i,(a=e.dataKey)!==null&&a!==void 0?a:r.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(i=>({value:Xn(i,e.dataKey),errorDomain:[]})):t.map(i=>({value:i,errorDomain:[]})));var Z8=()=>{},lUe=He([jw,xi,Uw,Ow,di],DO),cUe=He([xi,RO,PO,Z8,lUe,Z8,bn,di],OO),hZ=He([xi,bn,jw,oUe,jx,di,cUe],kO),uUe=He([hZ,xi,ym],UO);He([xi,hZ,uUe,di],FO);var dUe={radiusAxis:{},angleAxis:{}},pZ=Fa({name:"polarAxis",initialState:dUe,reducers:{addRadiusAxis(t,e){t.radiusAxis[e.payload.id]=e.payload},removeRadiusAxis(t,e){delete t.radiusAxis[e.payload.id]},addAngleAxis(t,e){t.angleAxis[e.payload.id]=e.payload},removeAngleAxis(t,e){delete t.angleAxis[e.payload.id]}}}),{addRadiusAxis:F8e,removeRadiusAxis:z8e,addAngleAxis:B8e,removeAngleAxis:H8e}=pZ.actions,fUe=pZ.reducer;function Q8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function J8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q8(Object(n),!0).forEach(function(i){hUe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function hUe(t,e,n){return(e=pUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pUe(t){var e=mUe(t,"string");return typeof e=="symbol"?e:e+""}function mUe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var gUe=(t,e)=>e,nk=He([fZ,gUe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),xUe=[],ik=(t,e,n)=>n?.length===0?xUe:n,mZ=He([hO,nk,ik],(t,e,n)=>{var{chartData:i}=t;if(e!=null){var r;if(e?.data!=null&&e.data.length>0?r=e.data:r=i,(!r||!r.length)&&n!=null&&(r=n.map(a=>J8(J8({},e.presentationProps),a.props))),r!=null)return r}}),vUe=He([mZ,nk,ik],(t,e,n)=>{if(!(t==null||e==null))return t.map((i,r)=>{var a,s=Xn(i,e.nameKey,e.name),o;return n!=null&&(a=n[r])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?o=n[r].props.fill:typeof i=="object"&&i!=null&&"fill"in i?o=i.fill:o=e.fill,{value:dm(s,e.dataKey),color:o,payload:i,type:e.legendType}})}),yUe=He([mZ,nk,ik,lr],(t,e,n,i)=>{if(!(e==null||t==null))return b4e({offset:i,pieSettings:e,displayedData:t,cells:n})}),wC={exports:{}},jn={};var eV;function bUe(){if(eV)return jn;eV=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function _(b){if(typeof b=="object"&&b!==null){var v=b.$$typeof;switch(v){case t:switch(b=b.type,b){case n:case r:case i:case l:case c:case p:return b;default:switch(b=b&&b.$$typeof,b){case s:case o:case f:case d:return b;case a:return b;default:return v}}case e:return v}}}return jn.ContextConsumer=a,jn.ContextProvider=s,jn.Element=t,jn.ForwardRef=o,jn.Fragment=n,jn.Lazy=f,jn.Memo=d,jn.Portal=e,jn.Profiler=r,jn.StrictMode=i,jn.Suspense=l,jn.SuspenseList=c,jn.isContextConsumer=function(b){return _(b)===a},jn.isContextProvider=function(b){return _(b)===s},jn.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===t},jn.isForwardRef=function(b){return _(b)===o},jn.isFragment=function(b){return _(b)===n},jn.isLazy=function(b){return _(b)===f},jn.isMemo=function(b){return _(b)===d},jn.isPortal=function(b){return _(b)===e},jn.isProfiler=function(b){return _(b)===r},jn.isStrictMode=function(b){return _(b)===i},jn.isSuspense=function(b){return _(b)===l},jn.isSuspenseList=function(b){return _(b)===c},jn.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===r||b===i||b===l||b===c||typeof b=="object"&&b!==null&&(b.$$typeof===f||b.$$typeof===d||b.$$typeof===s||b.$$typeof===a||b.$$typeof===o||b.$$typeof===m||b.getModuleId!==void 0)},jn.typeOf=_,jn}var tV;function _Ue(){return tV||(tV=1,wC.exports=bUe()),wC.exports}var SUe=_Ue(),nV=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",iV=null,MC=null,gZ=t=>{if(t===iV&&Array.isArray(MC))return MC;var e=[];return A.Children.forEach(t,n=>{mi(n)||(SUe.isFragment(n)?e=e.concat(gZ(n.props.children)):e.push(n))}),MC=e,iV=t,e};function rk(t,e){var n=[],i=[];return Array.isArray(e)?i=e.map(r=>nV(r)):i=[nV(e)],gZ(t).forEach(r=>{var a=Rf(r,"type.displayName")||Rf(r,"type.name");a&&i.indexOf(a)!==-1&&n.push(r)}),n}var xZ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,EC={},rV;function wUe(){return rV||(rV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const r=n[Symbol.toStringTag];return r==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${r}]`}let i=n;for(;Object.getPrototypeOf(i)!==null;)i=Object.getPrototypeOf(i);return Object.getPrototypeOf(n)===i}t.isPlainObject=e})(EC)),EC}var AC,aV;function MUe(){return aV||(aV=1,AC=wUe().isPlainObject),AC}var EUe=MUe();const AUe=qs(EUe);function sV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function oV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sV(Object(n),!0).forEach(function(i){TUe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function TUe(t,e,n){return(e=CUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CUe(t){var e=NUe(t,"string");return typeof e=="symbol"?e:e+""}function NUe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function nS(){return nS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},nS.apply(null,arguments)}var lV=(t,e,n,i,r)=>{var a=n-i,s;return s="M ".concat(t,",").concat(e),s+="L ".concat(t+n,",").concat(e),s+="L ".concat(t+n-a/2,",").concat(e+r),s+="L ".concat(t+n-a/2-i,",").concat(e+r),s+="L ".concat(t,",").concat(e," Z"),s},RUe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},PUe=t=>{var e=Xi(t,RUe),{x:n,y:i,upperWidth:r,lowerWidth:a,height:s,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:d,isUpdateAnimationActive:f}=e,p=A.useRef(null),[m,_]=A.useState(-1),b=A.useRef(r),v=A.useRef(a),x=A.useRef(s),M=A.useRef(n),w=A.useRef(i),E=Ox(t,"trapezoid-");if(A.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var L=p.current.getTotalLength();L&&_(L)}catch{}},[]),n!==+n||i!==+i||r!==+r||a!==+a||s!==+s||r===0&&a===0||s===0)return null;var T=Mn("recharts-trapezoid",o);if(!f)return A.createElement("g",null,A.createElement("path",nS({},ya(e),{className:T,d:lV(n,i,r,a,s)})));var P=b.current,N=v.current,U=x.current,R=M.current,O=w.current,z="0px ".concat(m===-1?1:m,"px"),I="".concat(m,"px 0px"),G=FX(["strokeDasharray"],c,l);return A.createElement(Dx,{animationId:E,key:E,canBegin:m>0,duration:c,easing:l,isActive:f,begin:d},L=>{var B=ri(P,r,L),q=ri(N,a,L),W=ri(U,s,L),X=ri(R,n,L),Q=ri(O,i,L);p.current&&(b.current=B,v.current=q,x.current=W,M.current=X,w.current=Q);var ie=L>0?{transition:G,strokeDasharray:I}:{strokeDasharray:z};return A.createElement("path",nS({},ya(e),{className:T,d:lV(X,Q,B,q,W),ref:p,style:oV(oV({},ie),e.style)}))})},DUe=["option","shapeType","propTransformer","activeClassName"];function OUe(t,e){if(t==null)return{};var n,i,r=kUe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function kUe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function cV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function iS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cV(Object(n),!0).forEach(function(i){LUe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function LUe(t,e,n){return(e=IUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IUe(t){var e=UUe(t,"string");return typeof e=="symbol"?e:e+""}function UUe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function jUe(t,e){return iS(iS({},e),t)}function FUe(t,e){return t==="symbols"}function uV(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return A.createElement(VX,n);case"trapezoid":return A.createElement(PUe,n);case"sector":return A.createElement(qX,n);case"symbols":if(FUe(e))return A.createElement(AD,n);break;case"curve":return A.createElement(Ap,n);default:return null}}function zUe(t){return A.isValidElement(t)?t.props:t}function vZ(t){var{option:e,shapeType:n,propTransformer:i=jUe,activeClassName:r="recharts-active-shape"}=t,a=OUe(t,DUe),s;if(A.isValidElement(e))s=A.cloneElement(e,iS(iS({},a),zUe(e)));else if(typeof e=="function")s=e(a,a.index);else if(AUe(e)&&typeof e!="boolean"){var o=i(e,a);s=A.createElement(uV,{shapeType:n,elementProps:o})}else{var l=a;s=A.createElement(uV,{shapeType:n,elementProps:l})}return a.isActive?A.createElement(Di,{className:r},s):s}var ak=(t,e,n)=>{var i=Qn();return(r,a)=>s=>{t?.(r,a,s),i(CY({activeIndex:String(a),activeDataKey:e,activeCoordinate:r.tooltipPosition,activeGraphicalItemId:n}))}},sk=t=>{var e=Qn();return(n,i)=>r=>{t?.(n,i,r),e(JOe())}},ok=(t,e,n)=>{var i=Qn();return(r,a)=>s=>{t?.(r,a,s),i(eke({activeIndex:String(a),activeDataKey:e,activeCoordinate:r.tooltipPosition,activeGraphicalItemId:n}))}};function lk(t){var{tooltipEntrySettings:e}=t,n=Qn(),i=aa(),r=A.useRef(null);return A.useLayoutEffect(()=>{i||(r.current===null?n(KOe(e)):r.current!==e&&n(YOe({prev:r.current,next:e})),r.current=e)},[e,n,i]),A.useLayoutEffect(()=>()=>{r.current&&(n(ZOe(r.current)),r.current=null)},[n]),null}function yZ(t){var{legendPayload:e}=t,n=Qn(),i=aa(),r=A.useRef(null);return A.useLayoutEffect(()=>{i||(r.current===null?n(kX(e)):r.current!==e&&n(LX({prev:r.current,next:e})),r.current=e)},[n,i,e]),A.useLayoutEffect(()=>()=>{r.current&&(n(IX(r.current)),r.current=null)},[n]),null}function BUe(t){var{legendPayload:e}=t,n=Qn(),i=At(bn),r=A.useRef(null);return A.useLayoutEffect(()=>{i!=="centric"&&i!=="radial"||(r.current===null?n(kX(e)):r.current!==e&&n(LX({prev:r.current,next:e})),r.current=e)},[n,i,e]),A.useLayoutEffect(()=>()=>{r.current&&(n(IX(r.current)),r.current=null)},[n]),null}var TC,HUe=()=>{var[t]=A.useState(()=>W0("uid-"));return t},VUe=(TC=jee.useId)!==null&&TC!==void 0?TC:HUe;function bZ(t,e){var n=VUe();return e||(t?"".concat(t,"-").concat(n):n)}var $Ue=A.createContext(void 0),ck=t=>{var{id:e,type:n,children:i}=t,r=bZ("recharts-".concat(n),e);return A.createElement($Ue.Provider,{value:r},i(r))},GUe={cartesianItems:[],polarItems:[]},_Z=Fa({name:"graphicalItems",initialState:GUe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:oi()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:i}=e.payload,r=xo(t).cartesianItems.indexOf(n);r>-1&&(t.cartesianItems[r]=i)},prepare:oi()},removeCartesianGraphicalItem:{reducer(t,e){var n=xo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:oi()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:oi()},removePolarGraphicalItem:{reducer(t,e){var n=xo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:oi()}}}),{addCartesianGraphicalItem:WUe,replaceCartesianGraphicalItem:qUe,removeCartesianGraphicalItem:XUe,addPolarGraphicalItem:KUe,removePolarGraphicalItem:YUe}=_Z.actions,ZUe=_Z.reducer,QUe=t=>{var e=Qn(),n=A.useRef(null);return A.useLayoutEffect(()=>{n.current===null?e(WUe(t)):n.current!==t&&e(qUe({prev:n.current,next:t})),n.current=t},[e,t]),A.useLayoutEffect(()=>()=>{n.current&&(e(XUe(n.current)),n.current=null)},[e]),null},SZ=A.memo(QUe);function JUe(t){var e=Qn();return A.useLayoutEffect(()=>(e(KUe(t)),()=>{e(YUe(t))}),[e,t]),null}var e4e=["key"],t4e=["onMouseEnter","onClick","onMouseLeave"],n4e=["id"],i4e=["id"];function dV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Si(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dV(Object(n),!0).forEach(function(i){r4e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function r4e(t,e,n){return(e=a4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a4e(t){var e=s4e(t,"string");return typeof e=="symbol"?e:e+""}function s4e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Qu(){return Qu=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Qu.apply(null,arguments)}function Fw(t,e){if(t==null)return{};var n,i,r=o4e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function o4e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function l4e(t){var e=A.useMemo(()=>rk(t.children,Xx),[t.children]),n=At(i=>vUe(i,t.id,e));return n==null?null:A.createElement(BUe,{legendPayload:n})}var c4e=A.memo(t=>{var{dataKey:e,nameKey:n,sectors:i,stroke:r,strokeWidth:a,fill:s,name:o,hide:l,tooltipType:c}=t,d={dataDefinedOnItem:i.map(f=>f.tooltipPayload),positions:i.map(f=>f.tooltipPosition),settings:{stroke:r,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:dm(o,e),hide:l,type:c,color:s,unit:""}};return A.createElement(lk,{tooltipEntrySettings:d})}),u4e=(t,e)=>t>e?"start":t<e?"end":"middle",d4e=(t,e,n)=>na(typeof e=="function"?e(t):e,n,n*.8),f4e=(t,e,n)=>{var{top:i,left:r,width:a,height:s}=e,o=$X(a,s),l=r+na(t.cx,a,a/2),c=i+na(t.cy,s,s/2),d=na(t.innerRadius,o,0),f=d4e(n,t.outerRadius,o),p=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:l,cy:c,innerRadius:d,outerRadius:f,maxRadius:p}},h4e=(t,e)=>{var n=Mr(e-t),i=Math.min(Math.abs(e-t),360);return n*i};function p4e(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var m4e=(t,e)=>{if(A.isValidElement(t))return A.cloneElement(t,e);if(typeof t=="function")return t(e);var n=Mn("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:i}=e,r=Fw(e,e4e);return A.createElement(Ap,Qu({},r,{type:"linear",className:n}))},g4e=(t,e,n)=>{if(A.isValidElement(t))return A.cloneElement(t,e);var i=n;if(typeof t=="function"&&(i=t(e),A.isValidElement(i)))return i;var r=Mn("recharts-pie-label-text",p4e(t));return A.createElement(Iw,Qu({},e,{alignmentBaseline:"middle",className:r}),i)};function x4e(t){var{sectors:e,props:n,showLabels:i}=t,{label:r,labelLine:a,dataKey:s}=n;if(!i||!r||!e)return null;var o=Ua(n),l=Nf(r),c=Nf(a),d=typeof r=="object"&&"offsetRadius"in r&&typeof r.offsetRadius=="number"&&r.offsetRadius||20,f=e.map((p,m)=>{var _=(p.startAngle+p.endAngle)/2,b=Vi(p.cx,p.cy,p.outerRadius+d,_),v=Si(Si(Si(Si({},o),p),{},{stroke:"none"},l),{},{index:m,textAnchor:u4e(b.x,p.cx)},b),x=Si(Si(Si(Si({},o),p),{},{fill:"none",stroke:p.fill},c),{},{index:m,points:[Vi(p.cx,p.cy,p.outerRadius,_),b],key:"line"});return A.createElement(za,{zIndex:$i.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(m)},A.createElement(Di,null,a&&m4e(a,x),g4e(r,v,Xn(p,s))))});return A.createElement(Di,{className:"recharts-pie-labels"},f)}function v4e(t){var{sectors:e,props:n,showLabels:i}=t,{label:r}=n;return typeof r=="object"&&r!=null&&"position"in r?A.createElement(tk,{label:r}):A.createElement(x4e,{sectors:e,props:n,showLabels:i})}function y4e(t){var{sectors:e,activeShape:n,inactiveShape:i,allOtherPieProps:r,shape:a,id:s}=t,o=At(Zu),l=At(XO),c=At(Fke),{onMouseEnter:d,onClick:f,onMouseLeave:p}=r,m=Fw(r,t4e),_=ak(d,r.dataKey,s),b=sk(p),v=ok(f,r.dataKey,s);return e==null||e.length===0?null:A.createElement(A.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var w=c==null||c===s,E=String(M)===o&&(l==null||r.dataKey===l)&&w,T=o?i:null,P=n&&E?n:T,N=Si(Si({},x),{},{stroke:x.stroke,tabIndex:-1,[bX]:M,[_X]:r.dataKey});return A.createElement(Di,Qu({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},Ax(m,x,M),{onMouseEnter:_(x,M),onMouseLeave:b(x,M),onClick:v(x,M)}),A.createElement(vZ,Qu({option:a??P,index:M,shapeType:"sector",isActive:E},N)))}))}function b4e(t){var e,{pieSettings:n,displayedData:i,cells:r,offset:a}=t,{cornerRadius:s,startAngle:o,endAngle:l,dataKey:c,nameKey:d,tooltipType:f}=n,p=Math.abs(n.minAngle),m=h4e(o,l),_=Math.abs(m),b=i.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=i.filter(P=>Xn(P,c,0)!==0).length,x=(_>=360?v:v-1)*b,M=_-v*p-x,w=i.reduce((P,N)=>{var U=Xn(N,c,0);return P+(Et(U)?U:0)},0),E;if(w>0){var T;E=i.map((P,N)=>{var U=Xn(P,c,0),R=Xn(P,d,N),O=f4e(n,a,P),z=(Et(U)?U:0)/w,I,G=Si(Si({},P),r&&r[N]&&r[N].props);N?I=T.endAngle+Mr(m)*b*(U!==0?1:0):I=o;var L=I+Mr(m)*((U!==0?p:0)+z*M),B=(I+L)/2,q=(O.innerRadius+O.outerRadius)/2,W=[{name:R,value:U,payload:G,dataKey:c,type:f}],X=Vi(O.cx,O.cy,q,B);return T=Si(Si(Si(Si({},n.presentationProps),{},{percent:z,cornerRadius:typeof s=="string"?parseFloat(s):s,name:R,tooltipPayload:W,midAngle:B,middleRadius:q,tooltipPosition:X},G),O),{},{value:U,dataKey:c,startAngle:I,endAngle:L,payload:G,paddingAngle:Mr(m)*b}),T})}return E}function _4e(t){var{showLabels:e,sectors:n,children:i}=t,r=A.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return A.createElement(nUe,{value:e?r:void 0},i)}function S4e(t){var{props:e,previousSectorsRef:n,id:i}=t,{sectors:r,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:d,onAnimationStart:f,onAnimationEnd:p}=e,m=Ox(e,"recharts-pie-"),_=n.current,[b,v]=A.useState(!1),x=A.useCallback(()=>{typeof p=="function"&&p(),v(!1)},[p]),M=A.useCallback(()=>{typeof f=="function"&&f(),v(!0)},[f]);return A.createElement(_4e,{showLabels:!b,sectors:r},A.createElement(Dx,{animationId:m,begin:s,duration:o,isActive:a,easing:l,onAnimationStart:M,onAnimationEnd:x,key:m},w=>{var E=[],T=r&&r[0],P=T?.startAngle;return r?.forEach((N,U)=>{var R=_&&_[U],O=U>0?Rf(N,"paddingAngle",0):0;if(R){var z=ri(R.endAngle-R.startAngle,N.endAngle-N.startAngle,w),I=Si(Si({},N),{},{startAngle:P+O,endAngle:P+z+O});E.push(I),P=I.endAngle}else{var{endAngle:G,startAngle:L}=N,B=ri(0,G-L,w),q=Si(Si({},N),{},{startAngle:P+O,endAngle:P+B+O});E.push(q),P=q.endAngle}}),n.current=E,A.createElement(Di,null,A.createElement(y4e,{sectors:E,activeShape:c,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:i}))}),A.createElement(v4e,{showLabels:!b,sectors:r,props:e}),e.children)}var w4e={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:$i.area};function M4e(t){var{id:e}=t,n=Fw(t,n4e),{hide:i,className:r,rootTabIndex:a}=t,s=A.useMemo(()=>rk(t.children,Xx),[t.children]),o=At(d=>yUe(d,e,s)),l=A.useRef(null),c=Mn("recharts-pie",r);return i||o==null?(l.current=null,A.createElement(Di,{tabIndex:a,className:c})):A.createElement(za,{zIndex:t.zIndex},A.createElement(c4e,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:o,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),A.createElement(Di,{tabIndex:a,className:c},A.createElement(S4e,{props:Si(Si({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function wZ(t){var e=Xi(t,w4e),{id:n}=e,i=Fw(e,i4e),r=Ua(i);return A.createElement(ck,{id:n,type:"pie"},a=>A.createElement(A.Fragment,null,A.createElement(JUe,{type:"pie",id:a,data:i.data,dataKey:i.dataKey,hide:i.hide,angleAxisId:0,radiusAxisId:0,name:i.name,nameKey:i.nameKey,tooltipType:i.tooltipType,legendType:i.legendType,fill:i.fill,cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,paddingAngle:i.paddingAngle,minAngle:i.minAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,cornerRadius:i.cornerRadius,presentationProps:r,maxRadius:e.maxRadius}),A.createElement(l4e,Qu({},i,{id:a})),A.createElement(M4e,Qu({},i,{id:a}))))}wZ.displayName="Pie";var E4e=["points"];function fV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function CC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fV(Object(n),!0).forEach(function(i){A4e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function A4e(t,e,n){return(e=T4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function T4e(t){var e=C4e(t,"string");return typeof e=="symbol"?e:e+""}function C4e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function rS(){return rS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},rS.apply(null,arguments)}function N4e(t,e){if(t==null)return{};var n,i,r=R4e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function R4e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function P4e(t){var{option:e,dotProps:n,className:i}=t;if(A.isValidElement(e))return A.cloneElement(e,n);if(typeof e=="function")return e(n);var r=Mn(i,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,o=N4e(a,E4e);return A.createElement(dZ,rS({},o,{className:r}))}function D4e(t,e){return t==null?!1:e?!0:t.length===1}function O4e(t){var{points:e,dot:n,className:i,dotClassName:r,dataKey:a,baseProps:s,needClip:o,clipPathId:l,zIndex:c=$i.scatter}=t;if(!D4e(e,n))return null;var d=xZ(n),f=cAe(n),p=e.map((_,b)=>{var v,x,M=CC(CC(CC({r:3},s),f),{},{index:b,cx:(v=_.x)!==null&&v!==void 0?v:void 0,cy:(x=_.y)!==null&&x!==void 0?x:void 0,dataKey:a,value:_.value,payload:_.payload,points:e});return A.createElement(P4e,{key:"dot-".concat(b),option:n,dotProps:M,className:r})}),m={};return o&&l!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(l,")")),A.createElement(za,{zIndex:c},A.createElement(Di,rS({className:i},m),p))}function hV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function pV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hV(Object(n),!0).forEach(function(i){k4e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function k4e(t,e,n){return(e=L4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L4e(t){var e=I4e(t,"string");return typeof e=="symbol"?e:e+""}function I4e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var U4e={xAxis:{},yAxis:{},zAxis:{}},MZ=Fa({name:"cartesianAxis",initialState:U4e,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:oi()},replaceXAxis:{reducer(t,e){var{prev:n,next:i}=e.payload;t.xAxis[n.id]!==void 0&&(n.id!==i.id&&delete t.xAxis[n.id],t.xAxis[i.id]=i)},prepare:oi()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:oi()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:oi()},replaceYAxis:{reducer(t,e){var{prev:n,next:i}=e.payload;t.yAxis[n.id]!==void 0&&(n.id!==i.id&&delete t.yAxis[n.id],t.yAxis[i.id]=i)},prepare:oi()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:oi()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:oi()},replaceZAxis:{reducer(t,e){var{prev:n,next:i}=e.payload;t.zAxis[n.id]!==void 0&&(n.id!==i.id&&delete t.zAxis[n.id],t.zAxis[i.id]=i)},prepare:oi()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:oi()},updateYAxisWidth(t,e){var{id:n,width:i}=e.payload,r=t.yAxis[n];if(r){var a=r.widthHistory||[];if(a.length===3&&a[0]===a[2]&&i===a[1]&&i!==r.width&&Math.abs(i-a[0])<=1)return;var s=[...a,i].slice(-3);t.yAxis[n]=pV(pV({},t.yAxis[n]),{},{width:i,widthHistory:s})}}}}),{addXAxis:j4e,replaceXAxis:F4e,removeXAxis:z4e,addYAxis:B4e,replaceYAxis:H4e,removeYAxis:V4e,addZAxis:V8e,replaceZAxis:$8e,removeZAxis:G8e,updateYAxisWidth:$4e}=MZ.actions,G4e=MZ.reducer,W4e=He([lr],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),q4e=He([W4e,bc,_c],(t,e,n)=>{if(!(!t||e==null||n==null))return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}),uk=()=>At(q4e),X4e=()=>At($ke);function mV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function NC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mV(Object(n),!0).forEach(function(i){K4e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function K4e(t,e,n){return(e=Y4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Y4e(t){var e=Z4e(t,"string");return typeof e=="symbol"?e:e+""}function Z4e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Q4e=t=>{var{point:e,childIndex:n,mainColor:i,activeDot:r,dataKey:a,clipPath:s}=t;if(r===!1||e.x==null||e.y==null)return null;var o={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:i??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},l=NC(NC(NC({},o),Nf(r)),TD(r)),c;return A.isValidElement(r)?c=A.cloneElement(r,l):typeof r=="function"?c=r(l):c=A.createElement(dZ,l),A.createElement(Di,{className:"recharts-active-dot",clipPath:s},c)};function gV(t){var{points:e,mainColor:n,activeDot:i,itemDataKey:r,clipPath:a,zIndex:s=$i.activeDot}=t,o=At(Zu),l=X4e();if(e==null||l==null)return null;var c=e.find(d=>l.includes(d.payload));return mi(c)?null:A.createElement(za,{zIndex:s},A.createElement(Q4e,{point:c,childIndex:Number(o),mainColor:n,dataKey:r,activeDot:i,clipPath:a}))}var J4e="Invariant failed";function eje(t,e){throw new Error(J4e)}var tje=["x","y"];function CR(){return CR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},CR.apply(null,arguments)}function xV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function zg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?xV(Object(n),!0).forEach(function(i){nje(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):xV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function nje(t,e,n){return(e=ije(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ije(t){var e=rje(t,"string");return typeof e=="symbol"?e:e+""}function rje(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function aje(t,e){if(t==null)return{};var n,i,r=sje(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function sje(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function oje(t,e){var{x:n,y:i}=t,r=aje(t,tje),a="".concat(n),s=parseInt(a,10),o="".concat(i),l=parseInt(o,10),c="".concat(e.height||r.height),d=parseInt(c,10),f="".concat(e.width||r.width),p=parseInt(f,10);return zg(zg(zg(zg(zg({},e),r),s?{x:s}:{}),l?{y:l}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function aS(t){return A.createElement(vZ,CR({shapeType:"rectangle",propTransformer:oje,activeClassName:"recharts-active-bar"},t))}var lje=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(i,r)=>{if(Et(e))return e;var a=Et(i)||mi(i);return a?e(i,r):(a||eje(),n)}},cje={},EZ=Fa({name:"errorBars",initialState:cje,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:i}=e.payload;t[n]||(t[n]=[]),t[n].push(i)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:i,next:r}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===i.dataKey&&a.direction===i.direction?r:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:i}=e.payload;t[n]&&(t[n]=t[n].filter(r=>r.dataKey!==i.dataKey||r.direction!==i.direction))}}}),{addErrorBar:W8e,replaceErrorBar:q8e,removeErrorBar:X8e}=EZ.actions,uje=EZ.reducer,dje=["children"];function fje(t,e){if(t==null)return{};var n,i,r=hje(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function hje(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var pje={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},mje=A.createContext(pje);function gje(t){var{children:e}=t,n=fje(t,dje);return A.createElement(mje.Provider,{value:n},e)}function dk(t,e){var n,i,r=At(c=>wc(c,t)),a=At(c=>Mc(c,e)),s=(n=r?.allowDataOverflow)!==null&&n!==void 0?n:yr.allowDataOverflow,o=(i=a?.allowDataOverflow)!==null&&i!==void 0?i:br.allowDataOverflow,l=s||o;return{needClip:l,needClipX:s,needClipY:o}}function AZ(t){var{xAxisId:e,yAxisId:n,clipPathId:i}=t,r=uk(),{needClipX:a,needClipY:s,needClip:o}=dk(e,n);if(!o||!r)return null;var{x:l,y:c,width:d,height:f}=r;return A.createElement("clipPath",{id:"clipPath-".concat(i)},A.createElement("rect",{x:a?l:l-d/2,y:s?c:c-f/2,width:a?d:d*2,height:s?f:f*2}))}function xje(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&ai(t.zIndex)?t.zIndex:e}var RC={exports:{}},PC={};var vV;function vje(){if(vV)return PC;vV=1;var t=tm();function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var n=typeof Object.is=="function"?Object.is:e,i=t.useSyncExternalStore,r=t.useRef,a=t.useEffect,s=t.useMemo,o=t.useDebugValue;return PC.useSyncExternalStoreWithSelector=function(l,c,d,f,p){var m=r(null);if(m.current===null){var _={hasValue:!1,value:null};m.current=_}else _=m.current;m=s(function(){function v(T){if(!x){if(x=!0,M=T,T=f(T),p!==void 0&&_.hasValue){var P=_.value;if(p(P,T))return w=P}return w=T}if(P=w,n(M,T))return P;var N=f(T);return p!==void 0&&p(P,N)?(M=T,P):(M=T,w=N)}var x=!1,M,w,E=d===void 0?null:d;return[function(){return v(c())},E===null?void 0:function(){return v(E())}]},[c,d,f,p]);var b=i(l,m[0],m[1]);return a(function(){_.hasValue=!0,_.value=b},[b]),o(b),b},PC}var yV;function yje(){return yV||(yV=1,RC.exports=vje()),RC.exports}yje();function bje(t){t()}function _je(){let t=null,e=null;return{clear(){t=null,e=null},notify(){bje(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let i=t;for(;i;)n.push(i),i=i.next;return n},subscribe(n){let i=!0;const r=e={callback:n,next:null,prev:e};return r.prev?r.prev.next=r:t=r,function(){!i||t===null||(i=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:t=r.next)}}}}var bV={notify(){},get:()=>[]};function Sje(t,e){let n,i=bV,r=0,a=!1;function s(b){d();const v=i.subscribe(b);let x=!1;return()=>{x||(x=!0,v(),f())}}function o(){i.notify()}function l(){_.onStateChange&&_.onStateChange()}function c(){return a}function d(){r++,n||(n=t.subscribe(l),i=_je())}function f(){r--,n&&r===0&&(n(),n=void 0,i.clear(),i=bV)}function p(){a||(a=!0,d())}function m(){a&&(a=!1,f())}const _={addNestedSub:s,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>i};return _}var wje=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Mje=wje(),Eje=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Aje=Eje(),Tje=()=>Mje||Aje?A.useLayoutEffect:A.useEffect,Cje=Tje();function _V(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function Nje(t,e){if(_V(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(e,n[r])||!_V(t[n[r]],e[n[r]]))return!1;return!0}var Rje=Symbol.for("react-redux-context"),Pje=typeof globalThis<"u"?globalThis:{};function Dje(){if(!A.createContext)return{};const t=Pje[Rje]??=new Map;let e=t.get(A.createContext);return e||(e=A.createContext(null),t.set(A.createContext,e)),e}var Oje=Dje();function kje(t){const{children:e,context:n,serverState:i,store:r}=t,a=A.useMemo(()=>{const l=Sje(r);return{store:r,subscription:l,getServerState:i?()=>i:void 0}},[r,i]),s=A.useMemo(()=>r.getState(),[r]);Cje(()=>{const{subscription:l}=a;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),s!==r.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[a,s]);const o=n||Oje;return A.createElement(o.Provider,{value:a},e)}var Lje=kje,Ije=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function Uje(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function zw(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var i of n)if(Ije.has(i)){if(t[i]==null&&e[i]==null)continue;if(!Nje(t[i],e[i]))return!1}else if(!Uje(t[i],e[i]))return!1;return!0}var jje=["onMouseEnter","onMouseLeave","onClick"],Fje=["value","background","tooltipPosition"],zje=["id"],Bje=["onMouseEnter","onClick","onMouseLeave"];function xc(){return xc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},xc.apply(null,arguments)}function SV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function da(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SV(Object(n),!0).forEach(function(i){Hje(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function Hje(t,e,n){return(e=Vje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Vje(t){var e=$je(t,"string");return typeof e=="symbol"?e:e+""}function $je(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function sS(t,e){if(t==null)return{};var n,i,r=Gje(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Gje(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var Wje=t=>{var{dataKey:e,name:n,fill:i,legendType:r,hide:a}=t;return[{inactive:a,dataKey:e,type:r,color:i,value:dm(n,e),payload:t}]},qje=A.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:i,fill:r,name:a,hide:s,unit:o,tooltipType:l}=t,c={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:i,fill:r,dataKey:e,nameKey:void 0,name:dm(a,e),hide:s,type:l,color:r,unit:o}};return A.createElement(lk,{tooltipEntrySettings:c})});function Xje(t){var e=At(Zu),{data:n,dataKey:i,background:r,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:o,onClick:l}=a,c=sS(a,jje),d=ak(s,i),f=sk(o),p=ok(l,i);if(!r||n==null)return null;var m=Nf(r);return A.createElement(za,{zIndex:xje(r,$i.barBackground)},n.map((_,b)=>{var{value:v,background:x,tooltipPosition:M}=_,w=sS(_,Fje);if(!x)return null;var E=d(_,b),T=f(_,b),P=p(_,b),N=da(da(da(da(da({option:r,isActive:String(b)===e},w),{},{fill:"#eee"},x),m),Ax(c,_,b)),{},{onMouseEnter:E,onMouseLeave:T,onClick:P,dataKey:i,index:b,className:"recharts-bar-background-rectangle"});return A.createElement(aS,xc({key:"background-bar-".concat(b)},N))}))}function Kje(t){var{showLabels:e,children:n,rects:i}=t,r=i?.map(a=>{var s={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return da(da({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return A.createElement(cZ,{value:e?r:void 0},n)}function Yje(t){var{shape:e,activeBar:n,baseProps:i,entry:r,index:a,dataKey:s}=t,o=At(Zu),l=At(XO),c=n&&String(a)===o&&(l==null||s===l),d=c?n:e;return c?A.createElement(za,{zIndex:$i.activeBar},A.createElement(aS,xc({},i,{name:String(i.name)},r,{isActive:c,option:d,index:a,dataKey:s}))):A.createElement(aS,xc({},i,{name:String(i.name)},r,{isActive:c,option:d,index:a,dataKey:s}))}function Zje(t){var{shape:e,baseProps:n,entry:i,index:r,dataKey:a}=t;return A.createElement(aS,xc({},n,{name:String(n.name)},i,{isActive:!1,option:e,index:r,dataKey:a}))}function Qje(t){var e,{data:n,props:i}=t,r=(e=Ua(i))!==null&&e!==void 0?e:{},{id:a}=r,s=sS(r,zje),{shape:o,dataKey:l,activeBar:c}=i,{onMouseEnter:d,onClick:f,onMouseLeave:p}=i,m=sS(i,Bje),_=ak(d,l),b=sk(p),v=ok(f,l);return n?A.createElement(A.Fragment,null,n.map((x,M)=>A.createElement(Di,xc({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},Ax(m,x,M),{onMouseEnter:_(x,M),onMouseLeave:b(x,M),onClick:v(x,M)}),c?A.createElement(Yje,{shape:o,activeBar:c,baseProps:s,entry:x,index:M,dataKey:l}):A.createElement(Zje,{shape:o,baseProps:s,entry:x,index:M,dataKey:l})))):null}function Jje(t){var{props:e,previousRectanglesRef:n}=t,{data:i,layout:r,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:d}=e,f=n.current,p=Ox(e,"recharts-bar-"),[m,_]=A.useState(!1),b=!m,v=A.useCallback(()=>{typeof c=="function"&&c(),_(!1)},[c]),x=A.useCallback(()=>{typeof d=="function"&&d(),_(!0)},[d]);return A.createElement(Kje,{showLabels:b,rects:i},A.createElement(Dx,{animationId:p,begin:s,duration:o,isActive:a,easing:l,onAnimationEnd:v,onAnimationStart:x,key:p},M=>{var w=M===1?i:i?.map((E,T)=>{var P=f&&f[T];if(P)return da(da({},E),{},{x:ri(P.x,E.x,M),y:ri(P.y,E.y,M),width:ri(P.width,E.width,M),height:ri(P.height,E.height,M)});if(r==="horizontal"){var N=ri(0,E.height,M),U=ri(E.stackedBarStart,E.y,M);return da(da({},E),{},{y:U,height:N})}var R=ri(0,E.width,M),O=ri(E.stackedBarStart,E.x,M);return da(da({},E),{},{width:R,x:O})});return M>0&&(n.current=w??null),w==null?null:A.createElement(Di,null,A.createElement(Qje,{props:e,data:w}))}),A.createElement(tk,{label:e.label}),e.children)}function eFe(t){var e=A.useRef(null);return A.createElement(Jje,{previousRectanglesRef:e,props:t})}var TZ=0,tFe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Xn(t,e)}};class nFe extends A.PureComponent{render(){var{hide:e,data:n,dataKey:i,className:r,xAxisId:a,yAxisId:s,needClip:o,background:l,id:c}=this.props;if(e||n==null)return null;var d=Mn("recharts-bar",r),f=c;return A.createElement(Di,{className:d,id:c},o&&A.createElement("defs",null,A.createElement(AZ,{clipPathId:f,xAxisId:a,yAxisId:s})),A.createElement(Di,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},A.createElement(Xje,{data:n,dataKey:i,background:l,allOtherBarProps:this.props}),A.createElement(eFe,this.props)))}}var iFe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:TZ,xAxisId:0,yAxisId:0,zIndex:$i.bar};function rFe(t){var{xAxisId:e,yAxisId:n,hide:i,legendType:r,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d}=t,{needClip:f}=dk(e,n),p=fm(),m=aa(),_=rk(t.children,Xx),b=At(M=>DFe(M,e,n,m,t.id,_));if(p!=="vertical"&&p!=="horizontal")return null;var v,x=b?.[0];return x==null||x.height==null||x.width==null?v=0:v=p==="vertical"?x.height/2:x.width/2,A.createElement(gje,{xAxisId:e,yAxisId:n,data:b,dataPointFormatter:tFe,errorBarOffset:v},A.createElement(nFe,xc({},t,{layout:p,needClip:f,data:b,xAxisId:e,yAxisId:n,hide:i,legendType:r,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:d})))}function aFe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:i},pos:r,bandSize:a,xAxis:s,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:d,displayedData:f,offset:p,cells:m,parentViewBox:_,dataStartIndex:b}=t,v=e==="horizontal"?o:s,x=d?v.scale.domain():null,M=MCe({numericAxis:v}),w=v.scale(M);return f.map((E,T)=>{var P,N,U,R,O,z;d?P=yCe(d[T+b],x):(P=Xn(E,n),Array.isArray(P)||(P=[M,P]));var I=lje(i,TZ)(P[1],T);if(e==="horizontal"){var G,[L,B]=[o.scale(P[0]),o.scale(P[1])];N=jH({axis:s,ticks:l,bandSize:a,offset:r.offset,entry:E,index:T}),U=(G=B??L)!==null&&G!==void 0?G:void 0,R=r.size;var q=L-B;if(O=$s(q)?0:q,z={x:N,y:p.top,width:R,height:p.height},Math.abs(I)>0&&Math.abs(O)<Math.abs(I)){var W=Mr(O||I)*(Math.abs(I)-Math.abs(O));U-=W,O+=W}}else{var[X,Q]=[s.scale(P[0]),s.scale(P[1])];if(N=X,U=jH({axis:o,ticks:c,bandSize:a,offset:r.offset,entry:E,index:T}),R=Q-X,O=r.size,z={x:p.left,y:U,width:p.width,height:O},Math.abs(I)>0&&Math.abs(R)<Math.abs(I)){var ie=Mr(R||I)*(Math.abs(I)-Math.abs(R));R+=ie}}if(N==null||U==null||R==null||O==null)return null;var H=da(da({},E),{},{stackedBarStart:w,x:N,y:U,width:R,height:O,value:d?P:P[1],payload:E,background:z,tooltipPosition:{x:N+R/2,y:U+O/2},parentViewBox:_},m&&m[T]&&m[T].props);return H}).filter(Boolean)}function sFe(t){var e=Xi(t,iFe),n=aa();return A.createElement(ck,{id:e.id,type:"bar"},i=>A.createElement(A.Fragment,null,A.createElement(yZ,{legendPayload:Wje(e)}),A.createElement(qje,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),A.createElement(SZ,{type:"bar",id:i,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:vX(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),A.createElement(za,{zIndex:e.zIndex},A.createElement(rFe,xc({},e,{id:i})))))}var CZ=A.memo(sFe,zw);CZ.displayName="Bar";function wV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Ub(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wV(Object(n),!0).forEach(function(i){oFe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function oFe(t,e,n){return(e=lFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lFe(t){var e=cFe(t,"string");return typeof e=="symbol"?e:e+""}function cFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var uFe=(t,e)=>e,dFe=(t,e,n)=>n,fFe=(t,e,n,i)=>i,hFe=(t,e,n,i,r)=>r,Kx=He([Pw,hFe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),pFe=He([Kx],t=>t?.maxBarSize),mFe=(t,e,n,i,r,a)=>a,MV=(t,e,n)=>{var i=n??t;if(!mi(i))return na(i,e,0)},gFe=He([bn,Pw,uFe,dFe,fFe],(t,e,n,i,r)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===i).filter(a=>a.isPanorama===r).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),xFe=(t,e,n,i)=>{var r=bn(t);return r==="horizontal"?ax(t,"yAxis",n,i):ax(t,"xAxis",e,i)},vFe=(t,e,n)=>{var i=bn(t);return i==="horizontal"?x8(t,"xAxis",e):x8(t,"yAxis",n)},yFe=(t,e,n)=>{var i={},r=t.filter(Cw),a=t.filter(c=>c.stackId==null),s=r.reduce((c,d)=>(c[d.stackId]||(c[d.stackId]=[]),c[d.stackId].push(d),c),i),o=Object.entries(s).map(c=>{var[d,f]=c,p=f.map(_=>_.dataKey),m=MV(e,n,f[0].barSize);return{stackId:d,dataKeys:p,barSize:m}}),l=a.map(c=>{var d=[c.dataKey].filter(p=>p!=null),f=MV(e,n,c.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...o,...l]},bFe=He([gFe,BDe,vFe],yFe),_Fe=(t,e,n,i,r)=>{var a,s,o=Kx(t,e,n,i,r);if(o!=null){var l=bn(t),c=VK(t),{maxBarSize:d}=o,f=mi(d)?c:d,p,m;return l==="horizontal"?(p=Yu(t,"xAxis",e,i),m=Ku(t,"xAxis",e,i)):(p=Yu(t,"yAxis",n,i),m=Ku(t,"yAxis",n,i)),(a=(s=Kp(p,m,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},NZ=(t,e,n,i)=>{var r=bn(t),a,s;return r==="horizontal"?(a=Yu(t,"xAxis",e,i),s=Ku(t,"xAxis",e,i)):(a=Yu(t,"yAxis",n,i),s=Ku(t,"yAxis",n,i)),Kp(a,s)};function SFe(t,e,n,i,r){var a=i.length;if(!(a<1)){var s=na(t,n,0,!0),o,l=[];if(ai(i[0].barSize)){var c=!1,d=n/a,f=i.reduce((x,M)=>x+(M.barSize||0),0);f+=(a-1)*s,f>=n&&(f-=(a-1)*s,s=0),f>=n&&d>0&&(c=!0,d*=.9,f=a*d);var p=(n-f)/2>>0,m={offset:p-s,size:0};o=i.reduce((x,M)=>{var w,E={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:m.offset+m.size+s,size:c?d:(w=M.barSize)!==null&&w!==void 0?w:0}},T=[...x,E];return m=T[T.length-1].position,T},l)}else{var _=na(e,n,0,!0);n-2*_-(a-1)*s<=0&&(s=0);var b=(n-2*_-(a-1)*s)/a;b>1&&(b>>=0);var v=ai(r)?Math.min(b,r):b;o=i.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:_+(b+s)*w+(b-v)/2,size:v}}],l)}return o}}var wFe=(t,e,n,i,r,a,s)=>{var o=mi(s)?e:s,l=SFe(n,i,r!==a?r:a,t,o);return r!==a&&l!=null&&(l=l.map(c=>Ub(Ub({},c),{},{position:Ub(Ub({},c.position),{},{offset:c.position.offset-r/2})}))),l},MFe=He([bFe,VK,zDe,$K,_Fe,NZ,pFe],wFe),EFe=(t,e,n,i)=>Yu(t,"xAxis",e,i),AFe=(t,e,n,i)=>Yu(t,"yAxis",n,i),TFe=(t,e,n,i)=>Ku(t,"xAxis",e,i),CFe=(t,e,n,i)=>Ku(t,"yAxis",n,i),NFe=He([MFe,Kx],(t,e)=>{if(!(t==null||e==null)){var n=t.find(i=>i.stackId===e.stackId&&e.dataKey!=null&&i.dataKeys.includes(e.dataKey));if(n!=null)return n.position}}),RFe=(t,e)=>{var n=Tw(e);if(!(!t||n==null||e==null)){var{stackId:i}=e;if(i!=null){var r=t[i];if(r){var{stackedData:a}=r;if(a)return a.find(s=>s.key===n)}}}},PFe=He([xFe,Kx],RFe),DFe=He([lr,jD,EFe,AFe,TFe,CFe,NFe,bn,Mw,NZ,PFe,Kx,mFe],(t,e,n,i,r,a,s,o,l,c,d,f,p)=>{var{chartData:m,dataStartIndex:_,dataEndIndex:b}=l;if(!(f==null||s==null||e==null||o!=="horizontal"&&o!=="vertical"||n==null||i==null||r==null||a==null||c==null)){var{data:v}=f,x;if(v!=null&&v.length>0?x=v:x=m?.slice(_,b+1),x!=null)return aFe({layout:o,barSettings:f,pos:s,parentViewBox:e,bandSize:c,xAxis:n,yAxis:i,xAxisTicks:r,yAxisTicks:a,stackedData:d,displayedData:x,offset:t,cells:p,dataStartIndex:_})}}),RZ=t=>{var{chartData:e}=t,n=Qn(),i=aa();return A.useEffect(()=>i?()=>{}:(n(R8(e)),()=>{n(R8(void 0))}),[e,n,i]),null},EV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},PZ=Fa({name:"brush",initialState:EV,reducers:{setBrushSettings(t,e){return e.payload==null?EV:e.payload}}}),{setBrushSettings:K8e}=PZ.actions,OFe=PZ.reducer;function kFe(t,e,n){return(e=LFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LFe(t){var e=IFe(t,"string");return typeof e=="symbol"?e:e+""}function IFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class fk{static create(e){return new fk(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(i)switch(i){case"start":return this.scale(e);case"middle":{var r=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+r}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var s=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+s}return this.scale(e)}}isInRange(e){var n=this.range(),i=n[0],r=n[n.length-1];return i<=r?e>=i&&e<=r:e>=r&&e<=i}}kFe(fk,"EPS",1e-4);function UFe(t){return(t%180+180)%180}var jFe=function(e){var{width:n,height:i}=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=UFe(r),s=a*Math.PI/180,o=Math.atan(i/n),l=s>o&&s<Math.PI-o?i/Math.sin(s):n/Math.cos(s);return Math.abs(l)},FFe={dots:[],areas:[],lines:[]},DZ=Fa({name:"referenceElements",initialState:FFe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=xo(t).dots.findIndex(i=>i===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=xo(t).areas.findIndex(i=>i===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=xo(t).lines.findIndex(i=>i===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:Y8e,removeDot:Z8e,addArea:Q8e,removeArea:J8e,addLine:eVe,removeLine:tVe}=DZ.actions,zFe=DZ.reducer,BFe=A.createContext(void 0),HFe=t=>{var{children:e}=t,[n]=A.useState("".concat(W0("recharts"),"-clip")),i=uk();if(i==null)return null;var{x:r,y:a,width:s,height:o}=i;return A.createElement(BFe.Provider,{value:n},A.createElement("defs",null,A.createElement("clipPath",{id:n},A.createElement("rect",{x:r,y:a,height:o,width:s}))),e)};function OZ(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],i=0;i<t.length;i+=e)n.push(t[i]);return n}function VFe(t,e,n){var i={width:t.width+e.width,height:t.height+e.height};return jFe(i,n)}function $Fe(t,e,n){var i=n==="width",{x:r,y:a,width:s,height:o}=t;return e===1?{start:i?r:a,end:i?r+s:a+o}:{start:i?r+s:a+o,end:i?r:a}}function oS(t,e,n,i,r){if(t*e<t*i||t*e>t*r)return!1;var a=n();return t*(e-t*a/2-i)>=0&&t*(e+t*a/2-r)<=0}function GFe(t,e){return OZ(t,e+1)}function WFe(t,e,n,i,r){for(var a=(i||[]).slice(),{start:s,end:o}=e,l=0,c=1,d=s,f=function(){var _=i?.[l];if(_===void 0)return{v:OZ(i,c)};var b=l,v,x=()=>(v===void 0&&(v=n(_,b)),v),M=_.coordinate,w=l===0||oS(t,M,x,d,o);w||(l=0,d=s,c+=1),w&&(d=M+t*(x()/2+r),l+=c)},p;c<=a.length;)if(p=f(),p)return p.v;return[]}function AV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Qr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?AV(Object(n),!0).forEach(function(i){qFe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):AV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function qFe(t,e,n){return(e=XFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XFe(t){var e=KFe(t,"string");return typeof e=="symbol"?e:e+""}function KFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function YFe(t,e,n,i,r){for(var a=(i||[]).slice(),s=a.length,{start:o}=e,{end:l}=e,c=function(p){var m=a[p],_,b=()=>(_===void 0&&(_=n(m,p)),_);if(p===s-1){var v=t*(m.coordinate+t*b()/2-l);a[p]=m=Qr(Qr({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else a[p]=m=Qr(Qr({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var x=oS(t,m.tickCoord,b,o,l);x&&(l=m.tickCoord-t*(b()/2+r),a[p]=Qr(Qr({},m),{},{isShow:!0}))}},d=s-1;d>=0;d--)c(d);return a}function ZFe(t,e,n,i,r,a){var s=(i||[]).slice(),o=s.length,{start:l,end:c}=e;if(a){var d=i[o-1],f=n(d,o-1),p=t*(d.coordinate+t*f/2-c);if(s[o-1]=d=Qr(Qr({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var m=oS(t,d.tickCoord,()=>f,l,c);m&&(c=d.tickCoord-t*(f/2+r),s[o-1]=Qr(Qr({},d),{},{isShow:!0}))}}for(var _=a?o-1:o,b=function(M){var w=s[M],E,T=()=>(E===void 0&&(E=n(w,M)),E);if(M===0){var P=t*(w.coordinate-t*T()/2-l);s[M]=w=Qr(Qr({},w),{},{tickCoord:P<0?w.coordinate-P*t:w.coordinate})}else s[M]=w=Qr(Qr({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var N=oS(t,w.tickCoord,T,l,c);N&&(l=w.tickCoord+t*(T()/2+r),s[M]=Qr(Qr({},w),{},{isShow:!0}))}},v=0;v<_;v++)b(v);return s}function hk(t,e,n){var{tick:i,ticks:r,viewBox:a,minTickGap:s,orientation:o,interval:l,tickFormatter:c,unit:d,angle:f}=t;if(!r||!r.length||!i)return[];if(Et(l)||hm.isSsr){var p;return(p=GFe(r,Et(l)?l:0))!==null&&p!==void 0?p:[]}var m=[],_=o==="top"||o==="bottom"?"width":"height",b=d&&_==="width"?h0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(w,E)=>{var T=typeof c=="function"?c(w.value,E):w.value;return _==="width"?VFe(h0(T,{fontSize:e,letterSpacing:n}),b,f):h0(T,{fontSize:e,letterSpacing:n})[_]},x=r.length>=2?Mr(r[1].coordinate-r[0].coordinate):1,M=$Fe(a,x,_);return l==="equidistantPreserveStart"?WFe(x,M,v,r,s):(l==="preserveStart"||l==="preserveStartEnd"?m=ZFe(x,M,v,r,s,l==="preserveStartEnd"):m=YFe(x,M,v,r,s),m.filter(w=>w.isShow))}var QFe=t=>{var{ticks:e,label:n,labelGapWithTick:i=5,tickSize:r=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>s&&(s=f.width)}});var o=n?n.getBoundingClientRect().width:0,l=r+a,c=s+l+o+(n?i:0);return Math.round(c)}return 0},JFe=["axisLine","width","height","className","hide","ticks","axisType"];function eze(t,e){if(t==null)return{};var n,i,r=tze(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function tze(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function kf(){return kf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},kf.apply(null,arguments)}function TV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function zi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TV(Object(n),!0).forEach(function(i){nze(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function nze(t,e,n){return(e=ize(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ize(t){var e=rze(t,"string");return typeof e=="symbol"?e:e+""}function rze(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var rc={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:$i.axis};function aze(t){var{x:e,y:n,width:i,height:r,orientation:a,mirror:s,axisLine:o,otherSvgProps:l}=t;if(!o)return null;var c=zi(zi(zi({},l),Ua(o)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!s||a==="bottom"&&s);c=zi(zi({},c),{},{x1:e,y1:n+d*r,x2:e+i,y2:n+d*r})}else{var f=+(a==="left"&&!s||a==="right"&&s);c=zi(zi({},c),{},{x1:e+f*i,y1:n,x2:e+f*i,y2:n+r})}return A.createElement("line",kf({},c,{className:Mn("recharts-cartesian-axis-line",Rf(o,"className"))}))}function sze(t,e,n,i,r,a,s,o,l){var c,d,f,p,m,_,b=o?-1:1,v=t.tickSize||s,x=Et(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":c=d=t.coordinate,p=n+ +!o*r,f=p-b*v,_=f-b*l,m=x;break;case"left":f=p=t.coordinate,d=e+ +!o*i,c=d-b*v,m=c-b*l,_=x;break;case"right":f=p=t.coordinate,d=e+ +o*i,c=d+b*v,m=c+b*l,_=x;break;default:c=d=t.coordinate,p=n+ +o*r,f=p+b*v,_=f+b*l,m=x;break}return{line:{x1:c,y1:f,x2:d,y2:p},tick:{x:m,y:_}}}function oze(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function lze(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function cze(t){var{option:e,tickProps:n,value:i}=t,r,a=Mn(n.className,"recharts-cartesian-axis-tick-value");if(A.isValidElement(e))r=A.cloneElement(e,zi(zi({},n),{},{className:a}));else if(typeof e=="function")r=e(zi(zi({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=Mn(s,e?.className)),r=A.createElement(Iw,kf({},n,{className:s}),i)}return r}var uze=A.forwardRef((t,e)=>{var{ticks:n=[],tick:i,tickLine:r,stroke:a,tickFormatter:s,unit:o,padding:l,tickTextProps:c,orientation:d,mirror:f,x:p,y:m,width:_,height:b,tickSize:v,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:E,events:T,axisType:P}=t,N=hk(zi(zi({},E),{},{ticks:n}),M,w),U=oze(d,f),R=lze(d,f),O=Ua(E),z=Nf(i),I={};typeof r=="object"&&(I=r);var G=zi(zi({},O),{},{fill:"none"},I),L=N.map(W=>zi({entry:W},sze(W,p,m,_,b,d,v,f,x))),B=L.map(W=>{var{entry:X,line:Q}=W;return A.createElement(Di,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(X.value,"-").concat(X.coordinate,"-").concat(X.tickCoord)},r&&A.createElement("line",kf({},G,Q,{className:Mn("recharts-cartesian-axis-tick-line",Rf(r,"className"))})))}),q=L.map((W,X)=>{var{entry:Q,tick:ie}=W,H=zi(zi(zi(zi({textAnchor:U,verticalAnchor:R},O),{},{stroke:"none",fill:a},z),ie),{},{index:X,payload:Q,visibleTicksCount:N.length,tickFormatter:s,padding:l},c);return A.createElement(Di,kf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},Ax(T,Q,X)),i&&A.createElement(cze,{option:i,tickProps:H,value:"".concat(typeof s=="function"?s(Q.value,X):Q.value).concat(o||"")}))});return A.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(P,"-ticks")},q.length>0&&A.createElement(za,{zIndex:$i.label},A.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(P,"-tick-labels"),ref:e},q)),B.length>0&&A.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(P,"-tick-lines")},B))}),dze=A.forwardRef((t,e)=>{var{axisLine:n,width:i,height:r,className:a,hide:s,ticks:o,axisType:l}=t,c=eze(t,JFe),[d,f]=A.useState(""),[p,m]=A.useState(""),_=A.useRef(null);A.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return QFe({ticks:_.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var b=A.useCallback(v=>{if(v){var x=v.getElementsByClassName("recharts-cartesian-axis-tick-value");_.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),E=w.fontSize,T=w.letterSpacing;(E!==d||T!==p)&&(f(E),m(T))}}},[d,p]);return s||i!=null&&i<=0||r!=null&&r<=0?null:A.createElement(za,{zIndex:t.zIndex},A.createElement(Di,{className:Mn("recharts-cartesian-axis",a)},A.createElement(aze,{x:t.x,y:t.y,width:i,height:r,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ua(t)}),A.createElement(uze,{ref:b,axisType:l,events:c,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:p,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:o,unit:t.unit,width:t.width,x:t.x,y:t.y}),A.createElement(LIe,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},A.createElement(GIe,{label:t.label,labelRef:t.labelRef}),t.children)))}),pk=A.forwardRef((t,e)=>{var n=Xi(t,rc);return A.createElement(dze,kf({},n,{ref:e}))});pk.displayName="CartesianAxis";var fze=["x1","y1","x2","y2","key"],hze=["offset"],pze=["xAxisId","yAxisId"],mze=["xAxisId","yAxisId"];function CV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function Jr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CV(Object(n),!0).forEach(function(i){gze(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function gze(t,e,n){return(e=xze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xze(t){var e=vze(t,"string");return typeof e=="symbol"?e:e+""}function vze(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ef(){return ef=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},ef.apply(null,arguments)}function lS(t,e){if(t==null)return{};var n,i,r=yze(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function yze(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var bze=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:i,y:r,width:a,height:s,ry:o}=t;return A.createElement("rect",{x:i,y:r,ry:o,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function kZ(t){var{option:e,lineItemProps:n}=t,i;if(A.isValidElement(e))i=A.cloneElement(e,n);else if(typeof e=="function")i=e(n);else{var r,{x1:a,y1:s,x2:o,y2:l,key:c}=n,d=lS(n,fze),f=(r=Ua(d))!==null&&r!==void 0?r:{},{offset:p}=f,m=lS(f,hze);i=A.createElement("line",ef({},m,{x1:a,y1:s,x2:o,y2:l,fill:"none",key:c}))}return i}function _ze(t){var{x:e,width:n,horizontal:i=!0,horizontalPoints:r}=t;if(!i||!r||!r.length)return null;var{xAxisId:a,yAxisId:s}=t,o=lS(t,pze),l=r.map((c,d)=>{var f=Jr(Jr({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(d),index:d});return A.createElement(kZ,{key:"line-".concat(d),option:i,lineItemProps:f})});return A.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function Sze(t){var{y:e,height:n,vertical:i=!0,verticalPoints:r}=t;if(!i||!r||!r.length)return null;var{xAxisId:a,yAxisId:s}=t,o=lS(t,mze),l=r.map((c,d)=>{var f=Jr(Jr({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(d),index:d});return A.createElement(kZ,{option:i,lineItemProps:f,key:"line-".concat(d)})});return A.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function wze(t){var{horizontalFill:e,fillOpacity:n,x:i,y:r,width:a,height:s,horizontalPoints:o,horizontal:l=!0}=t;if(!l||!e||!e.length||o==null)return null;var c=o.map(f=>Math.round(f+r-r)).sort((f,p)=>f-p);r!==c[0]&&c.unshift(0);var d=c.map((f,p)=>{var m=!c[p+1],_=m?r+s-f:c[p+1]-f;if(_<=0)return null;var b=p%e.length;return A.createElement("rect",{key:"react-".concat(p),y:f,x:i,height:_,width:a,stroke:"none",fill:e[b],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return A.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function Mze(t){var{vertical:e=!0,verticalFill:n,fillOpacity:i,x:r,y:a,width:s,height:o,verticalPoints:l}=t;if(!e||!n||!n.length)return null;var c=l.map(f=>Math.round(f+r-r)).sort((f,p)=>f-p);r!==c[0]&&c.unshift(0);var d=c.map((f,p)=>{var m=!c[p+1],_=m?r+s-f:c[p+1]-f;if(_<=0)return null;var b=p%n.length;return A.createElement("rect",{key:"react-".concat(p),x:f,y:a,width:_,height:o,stroke:"none",fill:n[b],fillOpacity:i,className:"recharts-cartesian-grid-bg"})});return A.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var Eze=(t,e)=>{var{xAxis:n,width:i,height:r,offset:a}=t;return gX(hk(Jr(Jr(Jr({},rc),n),{},{ticks:xX(n),viewBox:{x:0,y:0,width:i,height:r}})),a.left,a.left+a.width,e)},Aze=(t,e)=>{var{yAxis:n,width:i,height:r,offset:a}=t;return gX(hk(Jr(Jr(Jr({},rc),n),{},{ticks:xX(n),viewBox:{x:0,y:0,width:i,height:r}})),a.top,a.top+a.height,e)},Tze={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:$i.grid};function NR(t){var e=zD(),n=BD(),i=AX(),r=Jr(Jr({},Xi(t,Tze)),{},{x:Et(t.x)?t.x:i.left,y:Et(t.y)?t.y:i.top,width:Et(t.width)?t.width:i.width,height:Et(t.height)?t.height:i.height}),{xAxisId:a,yAxisId:s,x:o,y:l,width:c,height:d,syncWithTicks:f,horizontalValues:p,verticalValues:m}=r,_=aa(),b=At(R=>v8(R,"xAxis",a,_)),v=At(R=>v8(R,"yAxis",s,_));if(!Yo(c)||!Yo(d)||!Et(o)||!Et(l))return null;var x=r.verticalCoordinatesGenerator||Eze,M=r.horizontalCoordinatesGenerator||Aze,{horizontalPoints:w,verticalPoints:E}=r;if((!w||!w.length)&&typeof M=="function"){var T=p&&p.length,P=M({yAxis:v?Jr(Jr({},v),{},{ticks:T?p:v.ticks}):void 0,width:e??c,height:n??d,offset:i},T?!0:f);O1(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(w=P)}if((!E||!E.length)&&typeof x=="function"){var N=m&&m.length,U=x({xAxis:b?Jr(Jr({},b),{},{ticks:N?m:b.ticks}):void 0,width:e??c,height:n??d,offset:i},N?!0:f);O1(Array.isArray(U),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof U,"]")),Array.isArray(U)&&(E=U)}return A.createElement(za,{zIndex:r.zIndex},A.createElement("g",{className:"recharts-cartesian-grid"},A.createElement(bze,{fill:r.fill,fillOpacity:r.fillOpacity,x:r.x,y:r.y,width:r.width,height:r.height,ry:r.ry}),A.createElement(wze,ef({},r,{horizontalPoints:w})),A.createElement(Mze,ef({},r,{verticalPoints:E})),A.createElement(_ze,ef({},r,{offset:i,horizontalPoints:w,xAxis:b,yAxis:v})),A.createElement(Sze,ef({},r,{offset:i,verticalPoints:E,xAxis:b,yAxis:v}))))}NR.displayName="CartesianGrid";function Cze(t){var e=Nf(t),n=3,i=2;if(e!=null){var{r,strokeWidth:a}=e,s=Number(r),o=Number(a);return(Number.isNaN(s)||s<0)&&(s=n),(Number.isNaN(o)||o<0)&&(o=i),{r:s,strokeWidth:o}}return{r:n,strokeWidth:i}}var LZ=(t,e,n,i)=>Yu(t,"xAxis",e,i),IZ=(t,e,n,i)=>Ku(t,"xAxis",e,i),UZ=(t,e,n,i)=>Yu(t,"yAxis",n,i),jZ=(t,e,n,i)=>Ku(t,"yAxis",n,i),Nze=He([bn,LZ,UZ,IZ,jZ],(t,e,n,i,r)=>yc(t,"xAxis")?Kp(e,i,!1):Kp(n,r,!1)),Rze=(t,e,n,i,r)=>r,FZ=He([Pw,Rze],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),Pze=(t,e,n,i,r)=>{var a,s=FZ(t,e,n,i,r);if(s!=null){var o=bn(t),l=yc(o,"xAxis"),c;if(l?c=ax(t,"yAxis",n,i):c=ax(t,"xAxis",e,i),c!=null){var{stackId:d}=s,f=Tw(s);if(!(d==null||f==null)){var p=(a=c[d])===null||a===void 0?void 0:a.stackedData;return p?.find(m=>m.key===f)}}}},Dze=He([bn,LZ,UZ,IZ,jZ,Pze,Mw,Nze,FZ,HDe],(t,e,n,i,r,a,s,o,l,c)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:p}=s;if(!(l==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||i==null||r==null||i.length===0||r.length===0||o==null)){var{data:m}=l,_;if(m&&m.length>0?_=m:_=d?.slice(f,p+1),_!=null)return Zze({layout:t,xAxis:e,yAxis:n,xAxisTicks:i,yAxisTicks:r,dataStartIndex:f,areaSettings:l,stackedData:a,displayedData:_,chartBaseValue:c,bandSize:o})}}),Oze=["id"],kze=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function pf(){return pf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},pf.apply(null,arguments)}function zZ(t,e){if(t==null)return{};var n,i,r=Lze(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Lze(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function NV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function mp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?NV(Object(n),!0).forEach(function(i){Ize(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):NV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function Ize(t,e,n){return(e=Uze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Uze(t){var e=jze(t,"string");return typeof e=="symbol"?e:e+""}function jze(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function cS(t,e){return t&&t!=="none"?t:e}var Fze=t=>{var{dataKey:e,name:n,stroke:i,fill:r,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:cS(i,r),value:dm(n,e),payload:t}]},zze=A.memo(t=>{var{dataKey:e,data:n,stroke:i,strokeWidth:r,fill:a,name:s,hide:o,unit:l,tooltipType:c}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:i,strokeWidth:r,fill:a,dataKey:e,nameKey:void 0,name:dm(s,e),hide:o,type:c,color:cS(i,a),unit:l}};return A.createElement(lk,{tooltipEntrySettings:d})});function Bze(t){var{clipPathId:e,points:n,props:i}=t,{needClip:r,dot:a,dataKey:s}=i,o=Ua(i);return A.createElement(O4e,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:o,needClip:r,clipPathId:e})}function Hze(t){var{showLabels:e,children:n,points:i}=t,r=i.map(a=>{var s,o,l={x:(s=a.x)!==null&&s!==void 0?s:0,y:(o=a.y)!==null&&o!==void 0?o:0,width:0,lowerWidth:0,upperWidth:0,height:0};return mp(mp({},l),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return A.createElement(cZ,{value:e?r:void 0},n)}function RV(t){var{points:e,baseLine:n,needClip:i,clipPathId:r,props:a}=t,{layout:s,type:o,stroke:l,connectNulls:c,isRange:d}=a,{id:f}=a,p=zZ(a,Oze),m=Ua(p),_=ya(p);return A.createElement(A.Fragment,null,e?.length>1&&A.createElement(Di,{clipPath:i?"url(#clipPath-".concat(r,")"):void 0},A.createElement(Ap,pf({},_,{id:f,points:e,connectNulls:c,type:o,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),l!=="none"&&A.createElement(Ap,pf({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&d&&A.createElement(Ap,pf({},m,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:n}))),A.createElement(Bze,{points:e,props:p,clipPathId:r}))}function Vze(t){var{alpha:e,baseLine:n,points:i,strokeWidth:r}=t,a=i[0].y,s=i[i.length-1].y;if(!ai(a)||!ai(s))return null;var o=e*Math.abs(a-s),l=Math.max(...i.map(c=>c.x||0));return Et(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.x||0),l)),Et(l)?A.createElement("rect",{x:0,y:a<s?a:a-o,width:l+(r?parseInt("".concat(r),10):1),height:Math.floor(o)}):null}function $ze(t){var{alpha:e,baseLine:n,points:i,strokeWidth:r}=t,a=i[0].x,s=i[i.length-1].x;if(!ai(a)||!ai(s))return null;var o=e*Math.abs(a-s),l=Math.max(...i.map(c=>c.y||0));return Et(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(c=>c.y||0),l)),Et(l)?A.createElement("rect",{x:a<s?a:a-o,y:0,width:o,height:Math.floor(l+(r?parseInt("".concat(r),10):1))}):null}function Gze(t){var{alpha:e,layout:n,points:i,baseLine:r,strokeWidth:a}=t;return n==="vertical"?A.createElement(Vze,{alpha:e,points:i,baseLine:r,strokeWidth:a}):A.createElement($ze,{alpha:e,points:i,baseLine:r,strokeWidth:a})}function Wze(t){var{needClip:e,clipPathId:n,props:i,previousPointsRef:r,previousBaselineRef:a}=t,{points:s,baseLine:o,isAnimationActive:l,animationBegin:c,animationDuration:d,animationEasing:f,onAnimationStart:p,onAnimationEnd:m}=i,_=A.useMemo(()=>({points:s,baseLine:o}),[s,o]),b=Ox(_,"recharts-area-"),v=sNe(),[x,M]=A.useState(!1),w=!x,E=A.useCallback(()=>{typeof m=="function"&&m(),M(!1)},[m]),T=A.useCallback(()=>{typeof p=="function"&&p(),M(!0)},[p]);if(v==null)return null;var P=r.current,N=a.current;return A.createElement(Hze,{showLabels:w,points:s},i.children,A.createElement(Dx,{animationId:b,begin:c,duration:d,isActive:l,easing:f,onAnimationEnd:E,onAnimationStart:T,key:b},U=>{if(P){var R=P.length/s.length,O=U===1?s:s.map((I,G)=>{var L=Math.floor(G*R);if(P[L]){var B=P[L];return mp(mp({},I),{},{x:ri(B.x,I.x,U),y:ri(B.y,I.y,U)})}return I}),z;return Et(o)?z=ri(N,o,U):mi(o)||$s(o)?z=ri(N,0,U):z=o.map((I,G)=>{var L=Math.floor(G*R);if(Array.isArray(N)&&N[L]){var B=N[L];return mp(mp({},I),{},{x:ri(B.x,I.x,U),y:ri(B.y,I.y,U)})}return I}),U>0&&(r.current=O,a.current=z),A.createElement(RV,{points:O,baseLine:z,needClip:e,clipPathId:n,props:i})}return U>0&&(r.current=s,a.current=o),A.createElement(Di,null,l&&A.createElement("defs",null,A.createElement("clipPath",{id:"animationClipPath-".concat(n)},A.createElement(Gze,{alpha:U,points:s,baseLine:o,layout:v,strokeWidth:i.strokeWidth}))),A.createElement(Di,{clipPath:"url(#animationClipPath-".concat(n,")")},A.createElement(RV,{points:s,baseLine:o,needClip:e,clipPathId:n,props:i})))}),A.createElement(tk,{label:i.label}))}function qze(t){var{needClip:e,clipPathId:n,props:i}=t,r=A.useRef(null),a=A.useRef();return A.createElement(Wze,{needClip:e,clipPathId:n,props:i,previousPointsRef:r,previousBaselineRef:a})}class Xze extends A.PureComponent{render(){var{hide:e,dot:n,points:i,className:r,top:a,left:s,needClip:o,xAxisId:l,yAxisId:c,width:d,height:f,id:p,baseLine:m,zIndex:_}=this.props;if(e)return null;var b=Mn("recharts-area",r),v=p,{r:x,strokeWidth:M}=Cze(n),w=xZ(n),E=x*2+M,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(v,")"):void 0;return A.createElement(za,{zIndex:_},A.createElement(Di,{className:b},o&&A.createElement("defs",null,A.createElement(AZ,{clipPathId:v,xAxisId:l,yAxisId:c}),!w&&A.createElement("clipPath",{id:"clipPath-dots-".concat(v)},A.createElement("rect",{x:s-E/2,y:a-E/2,width:d+E,height:f+E}))),A.createElement(qze,{needClip:o,clipPathId:v,props:this.props})),A.createElement(gV,{points:i,mainColor:cS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(m)&&A.createElement(gV,{points:m,mainColor:cS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var BZ={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,xAxisId:0,yAxisId:0,zIndex:$i.area};function Kze(t){var e,n=Xi(t,BZ),{activeDot:i,animationBegin:r,animationDuration:a,animationEasing:s,connectNulls:o,dot:l,fill:c,fillOpacity:d,hide:f,isAnimationActive:p,legendType:m,stroke:_,xAxisId:b,yAxisId:v}=n,x=zZ(n,kze),M=fm(),w=$Y(),{needClip:E}=dk(b,v),T=aa(),{points:P,isRange:N,baseLine:U}=(e=At(L=>Dze(L,b,v,T,t.id)))!==null&&e!==void 0?e:{},R=uk();if(M!=="horizontal"&&M!=="vertical"||R==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:O,width:z,x:I,y:G}=R;return!P||!P.length?null:A.createElement(Xze,pf({},x,{activeDot:i,animationBegin:r,animationDuration:a,animationEasing:s,baseLine:U,connectNulls:o,dot:l,fill:c,fillOpacity:d,height:O,hide:f,layout:M,isAnimationActive:p==="auto"?!hm.isSsr:p,isRange:N,legendType:m,needClip:E,points:P,stroke:_,width:z,left:I,top:G,xAxisId:b,yAxisId:v}))}var Yze=(t,e,n,i,r)=>{var a=n??e;if(Et(a))return a;var s=t==="horizontal"?r:i,o=s.scale.domain();if(s.type==="number"){var l=Math.max(o[0],o[1]),c=Math.min(o[0],o[1]);return a==="dataMin"?c:a==="dataMax"||l<0?l:Math.max(Math.min(o[0],o[1]),0)}return a==="dataMin"?o[0]:a==="dataMax"?o[1]:o[0]};function Zze(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:i},stackedData:r,layout:a,chartBaseValue:s,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:d,xAxisTicks:f,yAxisTicks:p,bandSize:m}=t,_=r&&r.length,b=Yze(a,s,n,o,l),v=a==="horizontal",x=!1,M=c.map((E,T)=>{var P;_?P=r[d+T]:(P=Xn(E,i),Array.isArray(P)?x=!0:P=[b,P]);var N=P[1]==null||_&&!e&&Xn(E,i)==null;return v?{x:UH({axis:o,ticks:f,bandSize:m,entry:E,index:T}),y:N?null:l.scale(P[1]),value:P,payload:E}:{x:N?null:o.scale(P[1]),y:UH({axis:l,ticks:p,bandSize:m,entry:E,index:T}),value:P,payload:E}}),w;return _||x?w=M.map(E=>{var T=Array.isArray(E.value)?E.value[0]:null;return v?{x:E.x,y:T!=null&&E.y!=null?l.scale(T):null,payload:E.payload}:{x:T!=null?o.scale(T):null,y:E.y,payload:E.payload}}):w=v?l.scale(b):o.scale(b),{points:M,baseLine:w,isRange:x}}function Qze(t){var e=Xi(t,BZ),n=aa();return A.createElement(ck,{id:e.id,type:"area"},i=>A.createElement(A.Fragment,null,A.createElement(yZ,{legendPayload:Fze(e)}),A.createElement(zze,{dataKey:e.dataKey,data:e.data,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),A.createElement(SZ,{type:"area",id:i,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:vX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),A.createElement(Kze,pf({},e,{id:i}))))}var HZ=A.memo(Qze,zw);HZ.displayName="Area";var Jze=["domain","range"],e5e=["domain","range"];function PV(t,e){if(t==null)return{};var n,i,r=t5e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function t5e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function DV(t,e){return t===e?!0:Array.isArray(t)&&t.length===2&&Array.isArray(e)&&e.length===2?t[0]===e[0]&&t[1]===e[1]:!1}function VZ(t,e){if(t===e)return!0;var{domain:n,range:i}=t,r=PV(t,Jze),{domain:a,range:s}=e,o=PV(e,e5e);return!DV(n,a)||!DV(i,s)?!1:zw(r,o)}var n5e=["dangerouslySetInnerHTML","ticks"],i5e=["id"];function RR(){return RR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},RR.apply(null,arguments)}function OV(t,e){if(t==null)return{};var n,i,r=r5e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function r5e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function a5e(t){var e=Qn(),n=A.useRef(null);return A.useLayoutEffect(()=>{n.current===null?e(j4e(t)):n.current!==t&&e(F4e({prev:n.current,next:t})),n.current=t},[t,e]),A.useLayoutEffect(()=>()=>{n.current&&(e(z4e(n.current)),n.current=null)},[e]),null}var s5e=t=>{var{xAxisId:e,className:n}=t,i=At(jD),r=aa(),a="xAxis",s=At(v=>bm(v,a,e,r)),o=At(v=>SY(v,a,e,r)),l=At(v=>vY(v,e)),c=At(v=>FOe(v,e)),d=At(v=>JK(v,e));if(l==null||c==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:p}=t,m=OV(t,n5e),{id:_}=d,b=OV(d,i5e);return A.createElement(pk,RR({},m,b,{scale:s,x:c.x,y:c.y,width:l.width,height:l.height,className:Mn("recharts-".concat(a," ").concat(a),n),viewBox:i,ticks:o,axisType:a}))},o5e={allowDataOverflow:yr.allowDataOverflow,allowDecimals:yr.allowDecimals,allowDuplicatedCategory:yr.allowDuplicatedCategory,angle:yr.angle,axisLine:rc.axisLine,height:yr.height,hide:!1,includeHidden:yr.includeHidden,interval:yr.interval,minTickGap:yr.minTickGap,mirror:yr.mirror,orientation:yr.orientation,padding:yr.padding,reversed:yr.reversed,scale:yr.scale,tick:yr.tick,tickCount:yr.tickCount,tickLine:rc.tickLine,tickSize:rc.tickSize,type:yr.type,xAxisId:0},l5e=t=>{var e=Xi(t,o5e);return A.createElement(A.Fragment,null,A.createElement(a5e,{allowDataOverflow:e.allowDataOverflow,allowDecimals:e.allowDecimals,allowDuplicatedCategory:e.allowDuplicatedCategory,angle:e.angle,dataKey:e.dataKey,domain:e.domain,height:e.height,hide:e.hide,id:e.xAxisId,includeHidden:e.includeHidden,interval:e.interval,minTickGap:e.minTickGap,mirror:e.mirror,name:e.name,orientation:e.orientation,padding:e.padding,reversed:e.reversed,scale:e.scale,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit}),A.createElement(s5e,e))},PR=A.memo(l5e,VZ);PR.displayName="XAxis";var c5e=["dangerouslySetInnerHTML","ticks"],u5e=["id"];function DR(){return DR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},DR.apply(null,arguments)}function kV(t,e){if(t==null)return{};var n,i,r=d5e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function d5e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function f5e(t){var e=Qn(),n=A.useRef(null);return A.useLayoutEffect(()=>{n.current===null?e(B4e(t)):n.current!==t&&e(H4e({prev:n.current,next:t})),n.current=t},[t,e]),A.useLayoutEffect(()=>()=>{n.current&&(e(V4e(n.current)),n.current=null)},[e]),null}var h5e=t=>{var{yAxisId:e,className:n,width:i,label:r}=t,a=A.useRef(null),s=A.useRef(null),o=At(jD),l=aa(),c=Qn(),d="yAxis",f=At(T=>bm(T,d,e,l)),p=At(T=>yY(T,e)),m=At(T=>BOe(T,e)),_=At(T=>SY(T,d,e,l)),b=At(T=>eY(T,e));if(A.useLayoutEffect(()=>{if(!(i!=="auto"||!p||ek(r)||A.isValidElement(r)||b==null)){var T=a.current;if(T){var P=T.getCalculatedWidth();Math.round(p.width)!==Math.round(P)&&c($4e({id:e,width:P}))}}},[_,p,c,r,e,i,b]),p==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:v,ticks:x}=t,M=kV(t,c5e),{id:w}=b,E=kV(b,u5e);return A.createElement(pk,DR({},M,E,{ref:a,labelRef:s,scale:f,x:m.x,y:m.y,tickTextProps:i==="auto"?{width:void 0}:{width:i},width:p.width,height:p.height,className:Mn("recharts-".concat(d," ").concat(d),n),viewBox:o,ticks:_,axisType:d}))},p5e={allowDataOverflow:br.allowDataOverflow,allowDecimals:br.allowDecimals,allowDuplicatedCategory:br.allowDuplicatedCategory,angle:br.angle,axisLine:rc.axisLine,hide:!1,includeHidden:br.includeHidden,interval:br.interval,minTickGap:br.minTickGap,mirror:br.mirror,orientation:br.orientation,padding:br.padding,reversed:br.reversed,scale:br.scale,tick:br.tick,tickCount:br.tickCount,tickLine:rc.tickLine,tickSize:rc.tickSize,type:br.type,width:br.width,yAxisId:0},m5e=t=>{var e=Xi(t,p5e);return A.createElement(A.Fragment,null,A.createElement(f5e,{interval:e.interval,id:e.yAxisId,scale:e.scale,type:e.type,domain:e.domain,allowDataOverflow:e.allowDataOverflow,dataKey:e.dataKey,allowDuplicatedCategory:e.allowDuplicatedCategory,allowDecimals:e.allowDecimals,tickCount:e.tickCount,padding:e.padding,includeHidden:e.includeHidden,reversed:e.reversed,ticks:e.ticks,width:e.width,orientation:e.orientation,mirror:e.mirror,hide:e.hide,unit:e.unit,name:e.name,angle:e.angle,minTickGap:e.minTickGap,tick:e.tick,tickFormatter:e.tickFormatter}),A.createElement(h5e,e))},OR=A.memo(m5e,VZ);OR.displayName="YAxis";var g5e=(t,e)=>e,mk=He([g5e,bn,ZK,ur,jY,Ec,nLe,lr],cLe),gk=t=>{var e=t.currentTarget.getBoundingClientRect(),n=e.width/t.currentTarget.offsetWidth,i=e.height/t.currentTarget.offsetHeight;return{chartX:Math.round((t.clientX-e.left)/n),chartY:Math.round((t.clientY-e.top)/i)}},$Z=Gs("mouseClick"),GZ=Nx();GZ.startListening({actionCreator:$Z,effect:(t,e)=>{var n=t.payload,i=mk(e.getState(),gk(n));i?.activeIndex!=null&&e.dispatch(tke({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}});var kR=Gs("mouseMove"),WZ=Nx(),jb=null;WZ.startListening({actionCreator:kR,effect:(t,e)=>{var n=t.payload;jb!==null&&cancelAnimationFrame(jb);var i=gk(n);jb=requestAnimationFrame(()=>{var r=e.getState(),a=HO(r,r.tooltip.settings.shared);if(a==="axis"){var s=mk(r,i);s?.activeIndex!=null?e.dispatch(RY({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(NY())}jb=null})}});var LV={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},qZ=Fa({name:"rootProps",initialState:LV,reducers:{updateOptions:(t,e)=>{var n;t.accessibilityLayer=e.payload.accessibilityLayer,t.barCategoryGap=e.payload.barCategoryGap,t.barGap=(n=e.payload.barGap)!==null&&n!==void 0?n:LV.barGap,t.barSize=e.payload.barSize,t.maxBarSize=e.payload.maxBarSize,t.stackOffset=e.payload.stackOffset,t.syncId=e.payload.syncId,t.syncMethod=e.payload.syncMethod,t.className=e.payload.className,t.baseValue=e.payload.baseValue,t.reverseStackOrder=e.payload.reverseStackOrder}}}),x5e=qZ.reducer,{updateOptions:v5e}=qZ.actions,XZ=Fa({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:y5e}=XZ.actions,b5e=XZ.reducer,KZ=Gs("keyDown"),YZ=Gs("focus"),xk=Nx();xk.startListening({actionCreator:KZ,effect:(t,e)=>{var n=e.getState(),i=n.rootProps.accessibilityLayer!==!1;if(i){var{keyboardInteraction:r}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var s=VO(r,Sm(n),Hx(n),Wx(n)),o=s==null?-1:Number(s);if(!(!Number.isFinite(o)||o<0)){var l=Ec(n);if(a==="Enter"){var c=eS(n,"axis","hover",String(r.index));e.dispatch(SR({active:!r.active,activeIndex:r.index,activeDataKey:r.dataKey,activeCoordinate:c}));return}var d=GOe(n),f=d==="left-to-right"?1:-1,p=a==="ArrowRight"?1:-1,m=o+p*f;if(!(l==null||m>=l.length||m<0)){var _=eS(n,"axis","hover",String(m));e.dispatch(SR({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:_}))}}}}}});xk.startListening({actionCreator:YZ,effect:(t,e)=>{var n=e.getState(),i=n.rootProps.accessibilityLayer!==!1;if(i){var{keyboardInteraction:r}=n.tooltip;if(!r.active&&r.index==null){var a="0",s=eS(n,"axis","hover",String(a));e.dispatch(SR({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var As=Gs("externalEvent"),ZZ=Nx(),DC=new Map;ZZ.startListening({actionCreator:As,effect:(t,e)=>{var{handler:n,reactEvent:i}=t.payload;if(n!=null){i.persist();var r=i.type,a=DC.get(r);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:Bke(o),activeDataKey:XO(o),activeIndex:Zu(o),activeLabel:BY(o),activeTooltipIndex:Zu(o),isTooltipActive:Hke(o)};n(l,i)}finally{DC.delete(r)}});DC.set(r,s)}}});var _5e=He([_m],t=>t.tooltipItemPayloads),S5e=He([_5e,$x,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,i)=>{var r=t.find(o=>o.settings.dataKey===i);if(r!=null){var{positions:a}=r;if(a!=null){var s=e(a,n);return s}}}),QZ=Gs("touchMove"),JZ=Nx();JZ.startListening({actionCreator:QZ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var i=e.getState(),r=HO(i,i.tooltip.settings.shared);if(r==="axis"){var a=mk(i,gk({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(RY({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(r==="item"){var s,o=n.touches[0];if(document.elementFromPoint==null)return;var l=document.elementFromPoint(o.clientX,o.clientY);if(!l||!l.getAttribute)return;var c=l.getAttribute(bX),d=(s=l.getAttribute(_X))!==null&&s!==void 0?s:void 0,f=S5e(e.getState(),c,d);e.dispatch(CY({activeDataKey:d,activeIndex:c,activeCoordinate:f}))}}}});var w5e=Bq({brush:OFe,cartesianAxis:G4e,chartData:zLe,errorBars:uje,graphicalItems:ZUe,layout:hCe,legend:_Ne,options:LLe,polarAxis:fUe,polarOptions:b5e,referenceElements:zFe,rootProps:x5e,tooltip:nke,zIndex:wLe}),M5e=function(e){return j2e({reducer:w5e,preloadedState:e,middleware:n=>{var i;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([GZ.middleware,WZ.middleware,xk.middleware,ZZ.middleware,JZ.middleware])},enhancers:n=>{var i=n;return typeof n=="function"&&(i=n()),i.concat(nX({type:"raf"}))},devTools:hm.devToolsEnabled})};function eQ(t){var{preloadedState:e,children:n,reduxStoreName:i}=t,r=aa(),a=A.useRef(null);if(r)return n;a.current==null&&(a.current=M5e(e));var s=ND;return A.createElement(Lje,{context:s,store:a.current},n)}function E5e(t){var{layout:e,margin:n}=t,i=Qn(),r=aa();return A.useEffect(()=>{r||(i(uCe(e)),i(cCe(n)))},[i,r,e,n]),null}var tQ=A.memo(E5e,zw);function nQ(t){var e=Qn();return A.useEffect(()=>{e(v5e(t))},[e,t]),null}function IV(t){var{zIndex:e,isPanorama:n}=t,i=n?"recharts-zindex-panorama-":"recharts-zindex-",r=bZ("".concat(i).concat(e)),a=Qn();return A.useLayoutEffect(()=>(a(_Le({zIndex:e,elementId:r,isPanorama:n})),()=>{a(SLe({zIndex:e,isPanorama:n}))}),[a,e,r,n]),A.createElement("g",{tabIndex:-1,id:r})}function UV(t){var{children:e,isPanorama:n}=t,i=At(dLe);if(!i||i.length===0)return e;var r=i.filter(s=>s<0),a=i.filter(s=>s>0);return A.createElement(A.Fragment,null,r.map(s=>A.createElement(IV,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>A.createElement(IV,{key:s,zIndex:s,isPanorama:n})))}var A5e=["children"];function T5e(t,e){if(t==null)return{};var n,i,r=C5e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function C5e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function uS(){return uS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},uS.apply(null,arguments)}var N5e={width:"100%",height:"100%",display:"block"},R5e=A.forwardRef((t,e)=>{var n=zD(),i=BD(),r=jX();if(!Yo(n)||!Yo(i))return null;var{children:a,otherAttributes:s,title:o,desc:l}=t,c,d;return s!=null&&(typeof s.tabIndex=="number"?c=s.tabIndex:c=r?0:void 0,typeof s.role=="string"?d=s.role:d=r?"application":void 0),A.createElement(yD,uS({},s,{title:o,desc:l,role:d,tabIndex:c,width:n,height:i,style:N5e,ref:e}),a)}),P5e=t=>{var{children:e}=t,n=At(fw);if(!n)return null;var{width:i,height:r,y:a,x:s}=n;return A.createElement(yD,{width:i,height:r,x:s,y:a},e)},jV=A.forwardRef((t,e)=>{var{children:n}=t,i=T5e(t,A5e),r=aa();return r?A.createElement(P5e,null,A.createElement(UV,{isPanorama:!0},n)):A.createElement(R5e,uS({ref:e},i),A.createElement(UV,{isPanorama:!1},n))});function D5e(){var t=Qn(),[e,n]=A.useState(null),i=At(RCe);return A.useEffect(()=>{if(e!=null){var r=e.getBoundingClientRect(),a=r.width/e.offsetWidth;ai(a)&&a!==i&&t(fCe(a))}},[e,t,i]),n}function FV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function O5e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FV(Object(n),!0).forEach(function(i){k5e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function k5e(t,e,n){return(e=L5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L5e(t){var e=I5e(t,"string");return typeof e=="symbol"?e:e+""}function I5e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Lf(){return Lf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Lf.apply(null,arguments)}var U5e=()=>(KLe(),null);function dS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var j5e=A.forwardRef((t,e)=>{var n,i,r=A.useRef(null),[a,s]=A.useState({containerWidth:dS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:dS((i=t.style)===null||i===void 0?void 0:i.height)}),o=A.useCallback((c,d)=>{s(f=>{var p=Math.round(c),m=Math.round(d);return f.containerWidth===p&&f.containerHeight===m?f:{containerWidth:p,containerHeight:m}})},[]),l=A.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=c.getBoundingClientRect();o(d,f);var p=_=>{var{width:b,height:v}=_[0].contentRect;o(b,v)},m=new ResizeObserver(p);m.observe(c),r.current=m}},[e,o]);return A.useEffect(()=>()=>{var c=r.current;c?.disconnect()},[o]),A.createElement(A.Fragment,null,A.createElement(pw,{width:a.containerWidth,height:a.containerHeight}),A.createElement("div",Lf({ref:l},t)))}),F5e=A.forwardRef((t,e)=>{var{width:n,height:i}=t,[r,a]=A.useState({containerWidth:dS(n),containerHeight:dS(i)}),s=A.useCallback((l,c)=>{a(d=>{var f=Math.round(l),p=Math.round(c);return d.containerWidth===f&&d.containerHeight===p?d:{containerWidth:f,containerHeight:p}})},[]),o=A.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:d}=l.getBoundingClientRect();s(c,d)}},[e,s]);return A.createElement(A.Fragment,null,A.createElement(pw,{width:r.containerWidth,height:r.containerHeight}),A.createElement("div",Lf({ref:o},t)))}),z5e=A.forwardRef((t,e)=>{var{width:n,height:i}=t;return A.createElement(A.Fragment,null,A.createElement(pw,{width:n,height:i}),A.createElement("div",Lf({ref:e},t)))}),B5e=A.forwardRef((t,e)=>{var{width:n,height:i}=t;return dc(n)||dc(i)?A.createElement(F5e,Lf({},t,{ref:e})):A.createElement(z5e,Lf({},t,{ref:e}))});function H5e(t){return t===!0?j5e:B5e}var V5e=A.forwardRef((t,e)=>{var{children:n,className:i,height:r,onClick:a,onContextMenu:s,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:d,onMouseMove:f,onMouseUp:p,onTouchEnd:m,onTouchMove:_,onTouchStart:b,style:v,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,E=A.useRef(null),T=Qn(),[P,N]=A.useState(null),[U,R]=A.useState(null),O=D5e(),z=FD(),I=z?.width>0?z.width:x,G=z?.height>0?z.height:r,L=A.useCallback(pe=>{O(pe),typeof e=="function"&&e(pe),N(pe),R(pe),pe!=null&&(E.current=pe)},[O,e,N,R]),B=A.useCallback(pe=>{T($Z(pe)),T(As({handler:a,reactEvent:pe}))},[T,a]),q=A.useCallback(pe=>{T(kR(pe)),T(As({handler:c,reactEvent:pe}))},[T,c]),W=A.useCallback(pe=>{T(NY()),T(As({handler:d,reactEvent:pe}))},[T,d]),X=A.useCallback(pe=>{T(kR(pe)),T(As({handler:f,reactEvent:pe}))},[T,f]),Q=A.useCallback(()=>{T(YZ())},[T]),ie=A.useCallback(pe=>{T(KZ(pe.key))},[T]),H=A.useCallback(pe=>{T(As({handler:s,reactEvent:pe}))},[T,s]),Y=A.useCallback(pe=>{T(As({handler:o,reactEvent:pe}))},[T,o]),se=A.useCallback(pe=>{T(As({handler:l,reactEvent:pe}))},[T,l]),ue=A.useCallback(pe=>{T(As({handler:p,reactEvent:pe}))},[T,p]),xe=A.useCallback(pe=>{T(As({handler:b,reactEvent:pe}))},[T,b]),re=A.useCallback(pe=>{w&&T(QZ(pe)),T(As({handler:_,reactEvent:pe}))},[T,w,_]),ve=A.useCallback(pe=>{T(As({handler:m,reactEvent:pe}))},[T,m]),Pe=H5e(M);return A.createElement(KY.Provider,{value:P},A.createElement(iq.Provider,{value:U},A.createElement(Pe,{width:I??v?.width,height:G??v?.height,className:Mn("recharts-wrapper",i),style:O5e({position:"relative",cursor:"default",width:I,height:G},v),onClick:B,onContextMenu:H,onDoubleClick:Y,onFocus:Q,onKeyDown:ie,onMouseDown:se,onMouseEnter:q,onMouseLeave:W,onMouseMove:X,onMouseUp:ue,onTouchEnd:ve,onTouchMove:re,onTouchStart:xe,ref:L},A.createElement(U5e,null),n)))}),$5e=["width","height","responsive","children","className","style","compact","title","desc"];function G5e(t,e){if(t==null)return{};var n,i,r=W5e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function W5e(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var iQ=A.forwardRef((t,e)=>{var{width:n,height:i,responsive:r,children:a,className:s,style:o,compact:l,title:c,desc:d}=t,f=G5e(t,$5e),p=Ua(f);return l?A.createElement(A.Fragment,null,A.createElement(pw,{width:n,height:i}),A.createElement(jV,{otherAttributes:p,title:c,desc:d},a)):A.createElement(V5e,{className:s,style:o,width:n,height:i,responsive:r??!1,onClick:t.onClick,onMouseLeave:t.onMouseLeave,onMouseEnter:t.onMouseEnter,onMouseMove:t.onMouseMove,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onContextMenu:t.onContextMenu,onDoubleClick:t.onDoubleClick,onTouchStart:t.onTouchStart,onTouchMove:t.onTouchMove,onTouchEnd:t.onTouchEnd},A.createElement(jV,{otherAttributes:p,title:c,desc:d,ref:e},A.createElement(HFe,null,a)))});function LR(){return LR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},LR.apply(null,arguments)}var q5e={top:5,right:5,bottom:5,left:5},X5e={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:q5e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},rQ=A.forwardRef(function(e,n){var i,r=Xi(e.categoricalChartProps,X5e),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:c}=e,d={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return A.createElement(eQ,{preloadedState:{options:d},reduxStoreName:(i=c.id)!==null&&i!==void 0?i:a},A.createElement(RZ,{chartData:c.data}),A.createElement(tQ,{layout:r.layout,margin:r.margin}),A.createElement(nQ,{baseValue:r.baseValue,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),A.createElement(iQ,LR({},r,{ref:n})))}),K5e=["axis","item"],Y5e=A.forwardRef((t,e)=>A.createElement(rQ,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:K5e,tooltipPayloadSearcher:JO,categoricalChartProps:t,ref:e}));function Z5e(t){var e=Qn();return A.useEffect(()=>{e(y5e(t))},[e,t]),null}var Q5e=["layout"];function IR(){return IR=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},IR.apply(null,arguments)}function J5e(t,e){if(t==null)return{};var n,i,r=eBe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function eBe(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}var tBe={top:5,right:5,bottom:5,left:5},aQ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:tBe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},nBe=A.forwardRef(function(e,n){var i,r=Xi(e.categoricalChartProps,aQ),{layout:a}=r,s=J5e(r,Q5e),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:d}=e,f={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:d,eventEmitter:void 0};return A.createElement(eQ,{preloadedState:{options:f},reduxStoreName:(i=r.id)!==null&&i!==void 0?i:o},A.createElement(RZ,{chartData:r.data}),A.createElement(tQ,{layout:a,margin:r.margin}),A.createElement(nQ,{baseValue:void 0,accessibilityLayer:r.accessibilityLayer,barCategoryGap:r.barCategoryGap,maxBarSize:r.maxBarSize,stackOffset:r.stackOffset,barGap:r.barGap,barSize:r.barSize,syncId:r.syncId,syncMethod:r.syncMethod,className:r.className,reverseStackOrder:r.reverseStackOrder}),A.createElement(Z5e,{cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius}),A.createElement(iQ,IR({},s,{ref:n})))});function zV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,i)}return n}function BV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zV(Object(n),!0).forEach(function(i){iBe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function iBe(t,e,n){return(e=rBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rBe(t){var e=aBe(t,"string");return typeof e=="symbol"?e:e+""}function aBe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var sBe=["item"],oBe=BV(BV({},aQ),{},{layout:"centric",startAngle:0,endAngle:360}),lBe=A.forwardRef((t,e)=>{var n=Xi(t,oBe);return A.createElement(nBe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:sBe,tooltipPayloadSearcher:JO,categoricalChartProps:n,ref:e})}),cBe=["axis"],uBe=A.forwardRef((t,e)=>A.createElement(rQ,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:cBe,tooltipPayloadSearcher:JO,categoricalChartProps:t,ref:e}));const Fb=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function dBe(t){const e=new Date;switch(t){case"7d":return new Date(e.getTime()-10080*60*1e3);case"30d":return new Date(e.getTime()-720*60*60*1e3);case"90d":return new Date(e.getTime()-2160*60*60*1e3);case"365d":return new Date(e.getTime()-365*24*60*60*1e3);case"all":return new Date(0)}}function fBe({archives:t,currency:e="$"}){const[n,i]=A.useState("30d"),r=A.useMemo(()=>{const p=dBe(n);return t.filter(m=>new Date(m.completed_at||m.created_at)>=p)},[t,n]),a=A.useMemo(()=>{const p=new Map;return r.forEach(m=>{const b=new Date(m.completed_at||m.created_at).toISOString().split("T")[0],v=p.get(b)||{date:b,filament:0,cost:0,prints:0};v.filament+=m.filament_used_grams||0,v.cost+=m.cost||0,v.prints+=1,p.set(b,v)}),Array.from(p.values()).sort((m,_)=>m.date.localeCompare(_.date)).map(m=>({...m,dateLabel:new Date(m.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[r]),s=A.useMemo(()=>{if(n==="7d"||n==="30d")return a;const p=new Map;return r.forEach(m=>{const _=new Date(m.completed_at||m.created_at),b=new Date(_);b.setDate(_.getDate()-_.getDay());const v=b.toISOString().split("T")[0],x=p.get(v)||{week:v,filament:0,cost:0,prints:0};x.filament+=m.filament_used_grams||0,x.cost+=m.cost||0,x.prints+=1,p.set(v,x)}),Array.from(p.values()).sort((m,_)=>m.week.localeCompare(_.week)).map(m=>({date:m.week,dateLabel:`Week of ${new Date(m.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...m}))},[r,a,n]),o=A.useMemo(()=>{const p=new Map;return r.forEach(m=>{const b=(m.filament_type||"Unknown").split(", ");b.forEach(v=>{const x=(m.filament_used_grams||0)/b.length;p.set(v,(p.get(v)||0)+x)})}),Array.from(p.entries()).map(([m,_])=>({name:m,value:Math.round(_)})).sort((m,_)=>_.value-m.value)},[r]),l=A.useMemo(()=>{const p=new Date,m=[];for(let _=5;_>=0;_--){const b=new Date(p.getFullYear(),p.getMonth()-_,1),v=new Date(p.getFullYear(),p.getMonth()-_+1,0),x=b.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const E=new Date(w.completed_at||w.created_at);return E>=b&&E<=v});m.push({month:x,filament:Math.round(M.reduce((w,E)=>w+(E.filament_used_grams||0),0)),cost:M.reduce((w,E)=>w+(E.cost||0),0),prints:M.length})}return m},[t]),c=n==="7d"||n==="30d"?a:s,d=r.reduce((p,m)=>p+(m.filament_used_grams||0),0),f=r.reduce((p,m)=>p+(m.cost||0),0);return g.jsxs("div",{className:"space-y-6",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),g.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(p=>g.jsx("button",{onClick:()=>i(p),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===p?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:p==="all"?"All":p.replace("d","D")},p))})]}),g.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[g.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[g.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),g.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),g.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),g.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[g.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),g.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),g.jsxs("p",{className:"text-xs text-bambu-gray",children:[r.length," prints"]})]}),g.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[g.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),g.jsxs("p",{className:"text-2xl font-bold text-white",children:[r.length>0?(d/r.length).toFixed(0):0,"g"]}),g.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,r.length>0?(f/r.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?g.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[g.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),g.jsx(J2,{width:"100%",height:250,children:g.jsxs(uBe,{data:c,children:[g.jsx("defs",{children:g.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[g.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),g.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),g.jsx(NR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),g.jsx(PR,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),g.jsx(OR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),g.jsx(xC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:p=>[`${p.toFixed(0)}g`,"Filament"]}),g.jsx(HZ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):g.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),g.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[g.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[g.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsx(J2,{width:160,height:160,children:g.jsxs(lBe,{children:[g.jsx(wZ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((p,m)=>g.jsx(Xx,{fill:Fb[m%Fb.length]},`cell-${m}`))}),g.jsx(xC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:p=>[`${p}g`,"Usage"]})]})}),g.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((p,m)=>{const _=o.reduce((v,x)=>v+x.value,0),b=_>0?(p.value/_*100).toFixed(0):0;return g.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[g.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:Fb[m%Fb.length]}}),g.jsx("span",{className:"text-white truncate flex-1",children:p.name}),g.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[b,"%"]})]},p.name)})})]}):g.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),g.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[g.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),g.jsx(J2,{width:"100%",height:200,children:g.jsxs(Y5e,{data:l,children:[g.jsx(NR,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),g.jsx(PR,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),g.jsx(OR,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),g.jsx(xC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(p,m)=>[m==="filament"?`${p}g`:m==="cost"?`${e}${p.toFixed(2)}`:p,m==="filament"?"Filament":m==="cost"?"Cost":"Prints"]}),g.jsx(UX,{}),g.jsx(CZ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function hBe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return A.useMemo(()=>i=>{e.forEach(r=>r(i))},e)}const Bw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function wm(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function vk(t){return"nodeType"in t}function Ba(t){var e,n;return t?wm(t)?t:vk(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function yk(t){const{Document:e}=Ba(t);return t instanceof e}function Yx(t){return wm(t)?!1:t instanceof Ba(t).HTMLElement}function sQ(t){return t instanceof Ba(t).SVGElement}function Mm(t){return t?wm(t)?t.document:vk(t)?yk(t)?t:Yx(t)||sQ(t)?t.ownerDocument:document:document:document}const Qo=Bw?A.useLayoutEffect:A.useEffect;function bk(t){const e=A.useRef(t);return Qo(()=>{e.current=t}),A.useCallback(function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return e.current==null?void 0:e.current(...i)},[])}function pBe(){const t=A.useRef(null),e=A.useCallback((i,r)=>{t.current=setInterval(i,r)},[]),n=A.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function ox(t,e){e===void 0&&(e=[t]);const n=A.useRef(t);return Qo(()=>{n.current!==t&&(n.current=t)},e),n}function Zx(t,e){const n=A.useRef();return A.useMemo(()=>{const i=t(n.current);return n.current=i,i},[...e])}function fS(t){const e=bk(t),n=A.useRef(null),i=A.useCallback(r=>{r!==n.current&&e?.(r,n.current),n.current=r},[]);return[n,i]}function UR(t){const e=A.useRef();return A.useEffect(()=>{e.current=t},[t]),e.current}let OC={};function Qx(t,e){return A.useMemo(()=>{if(e)return e;const n=OC[t]==null?0:OC[t]+1;return OC[t]=n,t+"-"+n},[t,e])}function oQ(t){return function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return i.reduce((a,s)=>{const o=Object.entries(s);for(const[l,c]of o){const d=a[l];d!=null&&(a[l]=d+t*c)}return a},{...e})}}const Cp=oQ(1),lx=oQ(-1);function mBe(t){return"clientX"in t&&"clientY"in t}function _k(t){if(!t)return!1;const{KeyboardEvent:e}=Ba(t.target);return e&&t instanceof e}function gBe(t){if(!t)return!1;const{TouchEvent:e}=Ba(t.target);return e&&t instanceof e}function jR(t){if(gBe(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return mBe(t)?{x:t.clientX,y:t.clientY}:null}const cx=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[cx.Translate.toString(t),cx.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:i}=t;return e+" "+n+"ms "+i}}}),HV="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function xBe(t){return t.matches(HV)?t:t.querySelector(HV)}const vBe={display:"none"};function yBe(t){let{id:e,value:n}=t;return li.createElement("div",{id:e,style:vBe},n)}function bBe(t){let{id:e,announcement:n,ariaLiveType:i="assertive"}=t;const r={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return li.createElement("div",{id:e,style:r,role:"status","aria-live":i,"aria-atomic":!0},n)}function _Be(){const[t,e]=A.useState("");return{announce:A.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const lQ=A.createContext(null);function SBe(t){const e=A.useContext(lQ);A.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function wBe(){const[t]=A.useState(()=>new Set),e=A.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[A.useCallback(i=>{let{type:r,event:a}=i;t.forEach(s=>{var o;return(o=s[r])==null?void 0:o.call(s,a)})},[t]),e]}const MBe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},EBe={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function ABe(t){let{announcements:e=EBe,container:n,hiddenTextDescribedById:i,screenReaderInstructions:r=MBe}=t;const{announce:a,announcement:s}=_Be(),o=Qx("DndLiveRegion"),[l,c]=A.useState(!1);if(A.useEffect(()=>{c(!0)},[]),SBe(A.useMemo(()=>({onDragStart(f){let{active:p}=f;a(e.onDragStart({active:p}))},onDragMove(f){let{active:p,over:m}=f;e.onDragMove&&a(e.onDragMove({active:p,over:m}))},onDragOver(f){let{active:p,over:m}=f;a(e.onDragOver({active:p,over:m}))},onDragEnd(f){let{active:p,over:m}=f;a(e.onDragEnd({active:p,over:m}))},onDragCancel(f){let{active:p,over:m}=f;a(e.onDragCancel({active:p,over:m}))}}),[a,e])),!l)return null;const d=li.createElement(li.Fragment,null,li.createElement(yBe,{id:i,value:r.draggable}),li.createElement(bBe,{id:o,announcement:s}));return n?$l.createPortal(d,n):d}var tr;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(tr||(tr={}));function hS(){}function VV(t,e){return A.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function TBe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return A.useMemo(()=>[...e].filter(i=>i!=null),[...e])}const bo=Object.freeze({x:0,y:0});function cQ(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function uQ(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return n-i}function CBe(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return i-n}function $V(t){let{left:e,top:n,height:i,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e,y:n+i},{x:e+r,y:n+i}]}function dQ(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function GV(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const NBe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=GV(e,e.left,e.top),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=cQ(GV(l),r);a.push({id:o,data:{droppableContainer:s,value:c}})}}return a.sort(uQ)},RBe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=$V(e),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=$V(l),d=r.reduce((p,m,_)=>p+cQ(c[_],m),0),f=Number((d/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(uQ)};function PBe(t,e){const n=Math.max(e.top,t.top),i=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),s=r-i,o=a-n;if(i<r&&n<a){const l=e.width*e.height,c=t.width*t.height,d=s*o,f=d/(l+c-d);return Number(f.toFixed(4))}return 0}const DBe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=[];for(const a of i){const{id:s}=a,o=n.get(s);if(o){const l=PBe(o,e);l>0&&r.push({id:s,data:{droppableContainer:a,value:l}})}}return r.sort(CBe)};function OBe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function fQ(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:bo}function kBe(t){return function(n){for(var i=arguments.length,r=new Array(i>1?i-1:0),a=1;a<i;a++)r[a-1]=arguments[a];return r.reduce((s,o)=>({...s,top:s.top+t*o.y,bottom:s.bottom+t*o.y,left:s.left+t*o.x,right:s.right+t*o.x}),{...n})}}const LBe=kBe(1);function IBe(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function UBe(t,e,n){const i=IBe(e);if(!i)return t;const{scaleX:r,scaleY:a,x:s,y:o}=i,l=t.left-s-(1-r)*parseFloat(n),c=t.top-o-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?t.width/r:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:c,right:l+d,bottom:c+f,left:l}}const jBe={ignoreTransform:!1};function Em(t,e){e===void 0&&(e=jBe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:d}=Ba(t).getComputedStyle(t);c&&(n=UBe(n,c,d))}const{top:i,left:r,width:a,height:s,bottom:o,right:l}=n;return{top:i,left:r,width:a,height:s,bottom:o,right:l}}function WV(t){return Em(t,{ignoreTransform:!0})}function FBe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function zBe(t,e){return e===void 0&&(e=Ba(t).getComputedStyle(t)),e.position==="fixed"}function BBe(t,e){e===void 0&&(e=Ba(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{const a=e[r];return typeof a=="string"?n.test(a):!1})}function Hw(t,e){const n=[];function i(r){if(e!=null&&n.length>=e||!r)return n;if(yk(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!Yx(r)||sQ(r)||n.includes(r))return n;const a=Ba(t).getComputedStyle(r);return r!==t&&BBe(r,a)&&n.push(r),zBe(r,a)?n:i(r.parentNode)}return t?i(t):n}function hQ(t){const[e]=Hw(t,1);return e??null}function kC(t){return!Bw||!t?null:wm(t)?t:vk(t)?yk(t)||t===Mm(t).scrollingElement?window:Yx(t)?t:null:null}function pQ(t){return wm(t)?t.scrollX:t.scrollLeft}function mQ(t){return wm(t)?t.scrollY:t.scrollTop}function FR(t){return{x:pQ(t),y:mQ(t)}}var Sr;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Sr||(Sr={}));function gQ(t){return!Bw||!t?!1:t===document.scrollingElement}function xQ(t){const e={x:0,y:0},n=gQ(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},i={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},r=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,s=t.scrollTop>=i.y,o=t.scrollLeft>=i.x;return{isTop:r,isLeft:a,isBottom:s,isRight:o,maxScroll:i,minScroll:e}}const HBe={x:.2,y:.2};function VBe(t,e,n,i,r){let{top:a,left:s,right:o,bottom:l}=n;i===void 0&&(i=10),r===void 0&&(r=HBe);const{isTop:c,isBottom:d,isLeft:f,isRight:p}=xQ(t),m={x:0,y:0},_={x:0,y:0},b={height:e.height*r.y,width:e.width*r.x};return!c&&a<=e.top+b.height?(m.y=Sr.Backward,_.y=i*Math.abs((e.top+b.height-a)/b.height)):!d&&l>=e.bottom-b.height&&(m.y=Sr.Forward,_.y=i*Math.abs((e.bottom-b.height-l)/b.height)),!p&&o>=e.right-b.width?(m.x=Sr.Forward,_.x=i*Math.abs((e.right-b.width-o)/b.width)):!f&&s<=e.left+b.width&&(m.x=Sr.Backward,_.x=i*Math.abs((e.left+b.width-s)/b.width)),{direction:m,speed:_}}function $Be(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:s}=window;return{top:0,left:0,right:a,bottom:s,width:a,height:s}}const{top:e,left:n,right:i,bottom:r}=t.getBoundingClientRect();return{top:e,left:n,right:i,bottom:r,width:t.clientWidth,height:t.clientHeight}}function vQ(t){return t.reduce((e,n)=>Cp(e,FR(n)),bo)}function GBe(t){return t.reduce((e,n)=>e+pQ(n),0)}function WBe(t){return t.reduce((e,n)=>e+mQ(n),0)}function qBe(t,e){if(e===void 0&&(e=Em),!t)return;const{top:n,left:i,bottom:r,right:a}=e(t);hQ(t)&&(r<=0||a<=0||n>=window.innerHeight||i>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const XBe=[["x",["left","right"],GBe],["y",["top","bottom"],WBe]];class Sk{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const i=Hw(n),r=vQ(i);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of XBe)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=o(i),d=r[a]-c;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class p0{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var i;return(i=this.target)==null?void 0:i.removeEventListener(...n)})},this.target=e}add(e,n,i){var r;(r=this.target)==null||r.addEventListener(e,n,i),this.listeners.push([e,n,i])}}function KBe(t){const{EventTarget:e}=Ba(t);return t instanceof e?t:Mm(t)}function LC(t,e){const n=Math.abs(t.x),i=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+i**2)>e:"x"in e&&"y"in e?n>e.x&&i>e.y:"x"in e?n>e.x:"y"in e?i>e.y:!1}var Ds;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Ds||(Ds={}));function qV(t){t.preventDefault()}function YBe(t){t.stopPropagation()}var yn;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(yn||(yn={}));const yQ={start:[yn.Space,yn.Enter],cancel:[yn.Esc],end:[yn.Space,yn.Enter,yn.Tab]},ZBe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case yn.Right:return{...n,x:n.x+25};case yn.Left:return{...n,x:n.x-25};case yn.Down:return{...n,y:n.y+25};case yn.Up:return{...n,y:n.y-25}}};class wk{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new p0(Mm(n)),this.windowListeners=new p0(Ba(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ds.Resize,this.handleCancel),this.windowListeners.add(Ds.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ds.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,i=e.node.current;i&&qBe(i),n(bo)}handleKeyDown(e){if(_k(e)){const{active:n,context:i,options:r}=this.props,{keyboardCodes:a=yQ,coordinateGetter:s=ZBe,scrollBehavior:o="smooth"}=r,{code:l}=e;if(a.end.includes(l)){this.handleEnd(e);return}if(a.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=i.current,d=c?{x:c.left,y:c.top}:bo;this.referenceCoordinates||(this.referenceCoordinates=d);const f=s(e,{active:n,context:i.current,currentCoordinates:d});if(f){const p=lx(f,d),m={x:0,y:0},{scrollableAncestors:_}=i.current;for(const b of _){const v=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:E,maxScroll:T,minScroll:P}=xQ(b),N=$Be(b),U={x:Math.min(v===yn.Right?N.right-N.width/2:N.right,Math.max(v===yn.Right?N.left:N.left+N.width/2,f.x)),y:Math.min(v===yn.Down?N.bottom-N.height/2:N.bottom,Math.max(v===yn.Down?N.top:N.top+N.height/2,f.y))},R=v===yn.Right&&!M||v===yn.Left&&!w,O=v===yn.Down&&!E||v===yn.Up&&!x;if(R&&U.x!==f.x){const z=b.scrollLeft+p.x,I=v===yn.Right&&z<=T.x||v===yn.Left&&z>=P.x;if(I&&!p.y){b.scrollTo({left:z,behavior:o});return}I?m.x=b.scrollLeft-z:m.x=v===yn.Right?b.scrollLeft-T.x:b.scrollLeft-P.x,m.x&&b.scrollBy({left:-m.x,behavior:o});break}else if(O&&U.y!==f.y){const z=b.scrollTop+p.y,I=v===yn.Down&&z<=T.y||v===yn.Up&&z>=P.y;if(I&&!p.x){b.scrollTo({top:z,behavior:o});return}I?m.y=b.scrollTop-z:m.y=v===yn.Down?b.scrollTop-T.y:b.scrollTop-P.y,m.y&&b.scrollBy({top:-m.y,behavior:o});break}}this.handleMove(e,Cp(lx(f,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:i}=this.props;e.preventDefault(),i(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}wk.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:i=yQ,onActivation:r}=e,{active:a}=n;const{code:s}=t.nativeEvent;if(i.start.includes(s)){const o=a.activatorNode.current;return o&&t.target!==o?!1:(t.preventDefault(),r?.({event:t.nativeEvent}),!0)}return!1}}];function XV(t){return!!(t&&"distance"in t)}function KV(t){return!!(t&&"delay"in t)}class Mk{constructor(e,n,i){var r;i===void 0&&(i=KBe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:s}=a;this.props=e,this.events=n,this.document=Mm(s),this.documentListeners=new p0(this.document),this.listeners=new p0(i),this.windowListeners=new p0(Ba(s)),this.initialCoordinates=(r=jR(a))!=null?r:bo,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:i}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Ds.Resize,this.handleCancel),this.windowListeners.add(Ds.DragStart,qV),this.windowListeners.add(Ds.VisibilityChange,this.handleCancel),this.windowListeners.add(Ds.ContextMenu,qV),this.documentListeners.add(Ds.Keydown,this.handleKeydown),n){if(i!=null&&i({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(KV(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(XV(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:i,onPending:r}=this.props;r(i,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(Ds.Click,YBe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ds.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:i,initialCoordinates:r,props:a}=this,{onMove:s,options:{activationConstraint:o}}=a;if(!r)return;const l=(n=jR(e))!=null?n:bo,c=lx(r,l);if(!i&&o){if(XV(o)){if(o.tolerance!=null&&LC(c,o.tolerance))return this.handleCancel();if(LC(c,o.distance))return this.handleStart()}if(KV(o)&&LC(c,o.tolerance))return this.handleCancel();this.handlePending(o,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===yn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const QBe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ek extends Mk{constructor(e){const{event:n}=e,i=Mm(n.target);super(e,QBe,i)}}Ek.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;return!n.isPrimary||n.button!==0?!1:(i?.({event:n}),!0)}}];const JBe={move:{name:"mousemove"},end:{name:"mouseup"}};var zR;(function(t){t[t.RightClick=2]="RightClick"})(zR||(zR={}));class eHe extends Mk{constructor(e){super(e,JBe,Mm(e.event.target))}}eHe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;return n.button===zR.RightClick?!1:(i?.({event:n}),!0)}}];const IC={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class tHe extends Mk{constructor(e){super(e,IC)}static setup(){return window.addEventListener(IC.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(IC.move.name,e)};function e(){}}}tHe.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;const{touches:r}=n;return r.length>1?!1:(i?.({event:n}),!0)}}];var m0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(m0||(m0={}));var pS;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(pS||(pS={}));function nHe(t){let{acceleration:e,activator:n=m0.Pointer,canScroll:i,draggingRect:r,enabled:a,interval:s=5,order:o=pS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:d,delta:f,threshold:p}=t;const m=rHe({delta:f,disabled:!a}),[_,b]=pBe(),v=A.useRef({x:0,y:0}),x=A.useRef({x:0,y:0}),M=A.useMemo(()=>{switch(n){case m0.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case m0.DraggableRect:return r}},[n,r,l]),w=A.useRef(null),E=A.useCallback(()=>{const P=w.current;if(!P)return;const N=v.current.x*x.current.x,U=v.current.y*x.current.y;P.scrollBy(N,U)},[]),T=A.useMemo(()=>o===pS.TreeOrder?[...c].reverse():c,[o,c]);A.useEffect(()=>{if(!a||!c.length||!M){b();return}for(const P of T){if(i?.(P)===!1)continue;const N=c.indexOf(P),U=d[N];if(!U)continue;const{direction:R,speed:O}=VBe(P,U,M,e,p);for(const z of["x","y"])m[z][R[z]]||(O[z]=0,R[z]=0);if(O.x>0||O.y>0){b(),w.current=P,_(E,s),v.current=O,x.current=R;return}}v.current={x:0,y:0},x.current={x:0,y:0},b()},[e,E,i,b,a,s,JSON.stringify(M),JSON.stringify(m),_,c,T,d,JSON.stringify(p)])}const iHe={x:{[Sr.Backward]:!1,[Sr.Forward]:!1},y:{[Sr.Backward]:!1,[Sr.Forward]:!1}};function rHe(t){let{delta:e,disabled:n}=t;const i=UR(e);return Zx(r=>{if(n||!i||!r)return iHe;const a={x:Math.sign(e.x-i.x),y:Math.sign(e.y-i.y)};return{x:{[Sr.Backward]:r.x[Sr.Backward]||a.x===-1,[Sr.Forward]:r.x[Sr.Forward]||a.x===1},y:{[Sr.Backward]:r.y[Sr.Backward]||a.y===-1,[Sr.Forward]:r.y[Sr.Forward]||a.y===1}}},[n,e,i])}function aHe(t,e){const n=e!=null?t.get(e):void 0,i=n?n.node.current:null;return Zx(r=>{var a;return e==null?null:(a=i??r)!=null?a:null},[i,e])}function sHe(t,e){return A.useMemo(()=>t.reduce((n,i)=>{const{sensor:r}=i,a=r.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,i)}));return[...n,...a]},[]),[t,e])}var ux;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(ux||(ux={}));var BR;(function(t){t.Optimized="optimized"})(BR||(BR={}));const YV=new Map;function oHe(t,e){let{dragging:n,dependencies:i,config:r}=e;const[a,s]=A.useState(null),{frequency:o,measure:l,strategy:c}=r,d=A.useRef(t),f=v(),p=ox(f),m=A.useCallback(function(x){x===void 0&&(x=[]),!p.current&&s(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[p]),_=A.useRef(null),b=Zx(x=>{if(f&&!n)return YV;if(!x||x===YV||d.current!==t||a!=null){const M=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){M.set(w.id,w.rect.current);continue}const E=w.node.current,T=E?new Sk(l(E),E):null;w.rect.current=T,T&&M.set(w.id,T)}return M}return x},[t,a,n,f,l]);return A.useEffect(()=>{d.current=t},[t]),A.useEffect(()=>{f||m()},[n,f]),A.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),A.useEffect(()=>{f||typeof o!="number"||_.current!==null||(_.current=setTimeout(()=>{m(),_.current=null},o))},[o,f,m,...i]),{droppableRects:b,measureDroppableContainers:m,measuringScheduled:a!=null};function v(){switch(c){case ux.Always:return!1;case ux.BeforeDragging:return n;default:return!n}}}function bQ(t,e){return Zx(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function lHe(t,e){return bQ(t,e)}function cHe(t){let{callback:e,disabled:n}=t;const i=bk(e),r=A.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(i)},[i,n]);return A.useEffect(()=>()=>r?.disconnect(),[r]),r}function Vw(t){let{callback:e,disabled:n}=t;const i=bk(e),r=A.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(i)},[n]);return A.useEffect(()=>()=>r?.disconnect(),[r]),r}function uHe(t){return new Sk(Em(t),t)}function ZV(t,e,n){e===void 0&&(e=uHe);const[i,r]=A.useState(null);function a(){r(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const d=e(t);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const s=cHe({callback(l){if(t)for(const c of l){const{type:d,target:f}=c;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),o=Vw({callback:a});return Qo(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),i}function dHe(t){const e=bQ(t);return fQ(t,e)}const QV=[];function fHe(t){const e=A.useRef(t),n=Zx(i=>t?i&&i!==QV&&t&&e.current&&t.parentNode===e.current.parentNode?i:Hw(t):QV,[t]);return A.useEffect(()=>{e.current=t},[t]),n}function hHe(t){const[e,n]=A.useState(null),i=A.useRef(t),r=A.useCallback(a=>{const s=kC(a.target);s&&n(o=>o?(o.set(s,FR(s)),new Map(o)):null)},[]);return A.useEffect(()=>{const a=i.current;if(t!==a){s(a);const o=t.map(l=>{const c=kC(l);return c?(c.addEventListener("scroll",r,{passive:!0}),[c,FR(c)]):null}).filter(l=>l!=null);n(o.length?new Map(o):null),i.current=t}return()=>{s(t),s(a)};function s(o){o.forEach(l=>{const c=kC(l);c?.removeEventListener("scroll",r)})}},[r,t]),A.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Cp(a,s),bo):vQ(t):bo,[t,e])}function JV(t,e){e===void 0&&(e=[]);const n=A.useRef(null);return A.useEffect(()=>{n.current=null},e),A.useEffect(()=>{const i=t!==bo;i&&!n.current&&(n.current=t),!i&&n.current&&(n.current=null)},[t]),n.current?lx(t,n.current):bo}function pHe(t){A.useEffect(()=>{if(!Bw)return;const e=t.map(n=>{let{sensor:i}=n;return i.setup==null?void 0:i.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function mHe(t,e){return A.useMemo(()=>t.reduce((n,i)=>{let{eventName:r,handler:a}=i;return n[r]=s=>{a(s,e)},n},{}),[t,e])}function _Q(t){return A.useMemo(()=>t?FBe(t):null,[t])}const e$=[];function gHe(t,e){e===void 0&&(e=Em);const[n]=t,i=_Q(n?Ba(n):null),[r,a]=A.useState(e$);function s(){a(()=>t.length?t.map(l=>gQ(l)?i:new Sk(e(l),l)):e$)}const o=Vw({callback:s});return Qo(()=>{o?.disconnect(),s(),t.forEach(l=>o?.observe(l))},[t]),r}function xHe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Yx(e)?e:t}function vHe(t){let{measure:e}=t;const[n,i]=A.useState(null),r=A.useCallback(c=>{for(const{target:d}of c)if(Yx(d)){i(f=>{const p=e(d);return f?{...f,width:p.width,height:p.height}:p});break}},[e]),a=Vw({callback:r}),s=A.useCallback(c=>{const d=xHe(c);a?.disconnect(),d&&a?.observe(d),i(d?e(d):null)},[e,a]),[o,l]=fS(s);return A.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const yHe=[{sensor:Ek,options:{}},{sensor:wk,options:{}}],bHe={current:{}},u_={draggable:{measure:WV},droppable:{measure:WV,strategy:ux.WhileDragging,frequency:BR.Optimized},dragOverlay:{measure:Em}};class g0 extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,i;return(n=(i=this.get(e))==null?void 0:i.node.current)!=null?n:void 0}}const _He={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new g0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:hS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:u_,measureDroppableContainers:hS,windowRect:null,measuringScheduled:!1},SHe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:hS,draggableNodes:new Map,over:null,measureDroppableContainers:hS},$w=A.createContext(SHe),SQ=A.createContext(_He);function wHe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new g0}}}function MHe(t,e){switch(e.type){case tr.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case tr.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case tr.DragEnd:case tr.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case tr.RegisterDroppable:{const{element:n}=e,{id:i}=n,r=new g0(t.droppable.containers);return r.set(i,n),{...t,droppable:{...t.droppable,containers:r}}}case tr.SetDroppableDisabled:{const{id:n,key:i,disabled:r}=e,a=t.droppable.containers.get(n);if(!a||i!==a.key)return t;const s=new g0(t.droppable.containers);return s.set(n,{...a,disabled:r}),{...t,droppable:{...t.droppable,containers:s}}}case tr.UnregisterDroppable:{const{id:n,key:i}=e,r=t.droppable.containers.get(n);if(!r||i!==r.key)return t;const a=new g0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function EHe(t){let{disabled:e}=t;const{active:n,activatorEvent:i,draggableNodes:r}=A.useContext($w),a=UR(i),s=UR(n?.id);return A.useEffect(()=>{if(!e&&!i&&a&&s!=null){if(!_k(a)||document.activeElement===a.target)return;const o=r.get(s);if(!o)return;const{activatorNode:l,node:c}=o;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const d of[l.current,c.current]){if(!d)continue;const f=xBe(d);if(f){f.focus();break}}})}},[i,e,r,s,a]),null}function AHe(t,e){let{transform:n,...i}=e;return t!=null&&t.length?t.reduce((r,a)=>a({transform:r,...i}),n):n}function THe(t){return A.useMemo(()=>({draggable:{...u_.draggable,...t?.draggable},droppable:{...u_.droppable,...t?.droppable},dragOverlay:{...u_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function CHe(t){let{activeNode:e,measure:n,initialRect:i,config:r=!0}=t;const a=A.useRef(!1),{x:s,y:o}=typeof r=="boolean"?{x:r,y:r}:r;Qo(()=>{if(!s&&!o||!e){a.current=!1;return}if(a.current||!i)return;const c=e?.node.current;if(!c||c.isConnected===!1)return;const d=n(c),f=fQ(d,i);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const p=hQ(c);p&&p.scrollBy({top:f.y,left:f.x})}},[e,s,o,i,n])}const wQ=A.createContext({...bo,scaleX:1,scaleY:1});var vu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(vu||(vu={}));const NHe=A.memo(function(e){var n,i,r,a;let{id:s,accessibility:o,autoScroll:l=!0,children:c,sensors:d=yHe,collisionDetection:f=DBe,measuring:p,modifiers:m,..._}=e;const b=A.useReducer(MHe,void 0,wHe),[v,x]=b,[M,w]=wBe(),[E,T]=A.useState(vu.Uninitialized),P=E===vu.Initialized,{draggable:{active:N,nodes:U,translate:R},droppable:{containers:O}}=v,z=N!=null?U.get(N):null,I=A.useRef({initial:null,translated:null}),G=A.useMemo(()=>{var ke;return N!=null?{id:N,data:(ke=z?.data)!=null?ke:bHe,rect:I}:null},[N,z]),L=A.useRef(null),[B,q]=A.useState(null),[W,X]=A.useState(null),Q=ox(_,Object.values(_)),ie=Qx("DndDescribedBy",s),H=A.useMemo(()=>O.getEnabled(),[O]),Y=THe(p),{droppableRects:se,measureDroppableContainers:ue,measuringScheduled:xe}=oHe(H,{dragging:P,dependencies:[R.x,R.y],config:Y.droppable}),re=aHe(U,N),ve=A.useMemo(()=>W?jR(W):null,[W]),Pe=fe(),pe=lHe(re,Y.draggable.measure);CHe({activeNode:N!=null?U.get(N):null,config:Pe.layoutShiftCompensation,initialRect:pe,measure:Y.draggable.measure});const we=ZV(re,Y.draggable.measure,pe),ze=ZV(re?re.parentElement:null),ce=A.useRef({activatorEvent:null,active:null,activeNode:re,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:U,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ft=O.getNodeFor((n=ce.current.over)==null?void 0:n.id),F=vHe({measure:Y.dragOverlay.measure}),$=(i=F.nodeRef.current)!=null?i:re,ae=P?(r=F.rect)!=null?r:we:null,J=!!(F.nodeRef.current&&F.rect),ee=dHe(J?null:we),oe=_Q($?Ba($):null),De=fHe(P?ft??re:null),Ne=gHe(De),te=AHe(m,{transform:{x:R.x-ee.x,y:R.y-ee.y,scaleX:1,scaleY:1},activatorEvent:W,active:G,activeNodeRect:we,containerNodeRect:ze,draggingNodeRect:ae,over:ce.current.over,overlayNodeRect:F.rect,scrollableAncestors:De,scrollableAncestorRects:Ne,windowRect:oe}),j=ve?Cp(ve,R):null,k=hHe(De),K=JV(k),me=JV(k,[we]),ye=Cp(te,K),he=ae?LBe(ae,te):null,Ye=G&&he?f({active:G,collisionRect:he,droppableRects:se,droppableContainers:H,pointerCoordinates:j}):null,Le=dQ(Ye,"id"),[qe,rt]=A.useState(null),Ie=J?te:Cp(te,me),Re=OBe(Ie,(a=qe?.rect)!=null?a:null,we),ht=A.useRef(null),tt=A.useCallback((ke,Me)=>{let{sensor:ge,options:Be}=Me;if(L.current==null)return;const lt=U.get(L.current);if(!lt)return;const bt=ke.nativeEvent,Nt=new ge({active:L.current,activeNode:lt,event:bt,options:Be,context:ce,onAbort(Dt){if(!U.get(Dt))return;const{onDragAbort:Gn}=Q.current,fr={id:Dt};Gn?.(fr),M({type:"onDragAbort",event:fr})},onPending(Dt,Nn,Gn,fr){if(!U.get(Dt))return;const{onDragPending:hr}=Q.current,Cr={id:Dt,constraint:Nn,initialCoordinates:Gn,offset:fr};hr?.(Cr),M({type:"onDragPending",event:Cr})},onStart(Dt){const Nn=L.current;if(Nn==null)return;const Gn=U.get(Nn);if(!Gn)return;const{onDragStart:fr}=Q.current,Ki={activatorEvent:bt,active:{id:Nn,data:Gn.data,rect:I}};$l.unstable_batchedUpdates(()=>{fr?.(Ki),T(vu.Initializing),x({type:tr.DragStart,initialCoordinates:Dt,active:Nn}),M({type:"onDragStart",event:Ki}),q(ht.current),X(bt)})},onMove(Dt){x({type:tr.DragMove,coordinates:Dt})},onEnd:an(tr.DragEnd),onCancel:an(tr.DragCancel)});ht.current=Nt;function an(Dt){return async function(){const{active:Gn,collisions:fr,over:Ki,scrollAdjustedTranslate:hr}=ce.current;let Cr=null;if(Gn&&hr){const{cancelDrop:$r}=Q.current;Cr={activatorEvent:bt,active:Gn,collisions:fr,delta:hr,over:Ki},Dt===tr.DragEnd&&typeof $r=="function"&&await Promise.resolve($r(Cr))&&(Dt=tr.DragCancel)}L.current=null,$l.unstable_batchedUpdates(()=>{x({type:Dt}),T(vu.Uninitialized),rt(null),q(null),X(null),ht.current=null;const $r=Dt===tr.DragEnd?"onDragEnd":"onDragCancel";if(Cr){const Oi=Q.current[$r];Oi?.(Cr),M({type:$r,event:Cr})}})}}},[U]),et=A.useCallback((ke,Me)=>(ge,Be)=>{const lt=ge.nativeEvent,bt=U.get(Be);if(L.current!==null||!bt||lt.dndKit||lt.defaultPrevented)return;const Nt={active:bt};ke(ge,Me.options,Nt)===!0&&(lt.dndKit={capturedBy:Me.sensor},L.current=Be,tt(ge,Me))},[U,tt]),ct=sHe(d,et);pHe(d),Qo(()=>{we&&E===vu.Initializing&&T(vu.Initialized)},[we,E]),A.useEffect(()=>{const{onDragMove:ke}=Q.current,{active:Me,activatorEvent:ge,collisions:Be,over:lt}=ce.current;if(!Me||!ge)return;const bt={active:Me,activatorEvent:ge,collisions:Be,delta:{x:ye.x,y:ye.y},over:lt};$l.unstable_batchedUpdates(()=>{ke?.(bt),M({type:"onDragMove",event:bt})})},[ye.x,ye.y]),A.useEffect(()=>{const{active:ke,activatorEvent:Me,collisions:ge,droppableContainers:Be,scrollAdjustedTranslate:lt}=ce.current;if(!ke||L.current==null||!Me||!lt)return;const{onDragOver:bt}=Q.current,Nt=Be.get(Le),an=Nt&&Nt.rect.current?{id:Nt.id,rect:Nt.rect.current,data:Nt.data,disabled:Nt.disabled}:null,Dt={active:ke,activatorEvent:Me,collisions:ge,delta:{x:lt.x,y:lt.y},over:an};$l.unstable_batchedUpdates(()=>{rt(an),bt?.(Dt),M({type:"onDragOver",event:Dt})})},[Le]),Qo(()=>{ce.current={activatorEvent:W,active:G,activeNode:re,collisionRect:he,collisions:Ye,droppableRects:se,draggableNodes:U,draggingNode:$,draggingNodeRect:ae,droppableContainers:O,over:qe,scrollableAncestors:De,scrollAdjustedTranslate:ye},I.current={initial:ae,translated:he}},[G,re,Ye,he,U,$,ae,se,O,qe,De,ye]),nHe({...Pe,delta:R,draggingRect:he,pointerCoordinates:j,scrollableAncestors:De,scrollableAncestorRects:Ne});const de=A.useMemo(()=>({active:G,activeNode:re,activeNodeRect:we,activatorEvent:W,collisions:Ye,containerNodeRect:ze,dragOverlay:F,draggableNodes:U,droppableContainers:O,droppableRects:se,over:qe,measureDroppableContainers:ue,scrollableAncestors:De,scrollableAncestorRects:Ne,measuringConfiguration:Y,measuringScheduled:xe,windowRect:oe}),[G,re,we,W,Ye,ze,F,U,O,se,qe,ue,De,Ne,Y,xe,oe]),nt=A.useMemo(()=>({activatorEvent:W,activators:ct,active:G,activeNodeRect:we,ariaDescribedById:{draggable:ie},dispatch:x,draggableNodes:U,over:qe,measureDroppableContainers:ue}),[W,ct,G,we,x,ie,U,qe,ue]);return li.createElement(lQ.Provider,{value:w},li.createElement($w.Provider,{value:nt},li.createElement(SQ.Provider,{value:de},li.createElement(wQ.Provider,{value:Re},c)),li.createElement(EHe,{disabled:o?.restoreFocus===!1})),li.createElement(ABe,{...o,hiddenTextDescribedById:ie}));function fe(){const ke=B?.autoScrollEnabled===!1,Me=typeof l=="object"?l.enabled===!1:l===!1,ge=P&&!ke&&!Me;return typeof l=="object"?{...l,enabled:ge}:{enabled:ge}}}),RHe=A.createContext(null),t$="button",PHe="Draggable";function DHe(t){let{id:e,data:n,disabled:i=!1,attributes:r}=t;const a=Qx(PHe),{activators:s,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:d,draggableNodes:f,over:p}=A.useContext($w),{role:m=t$,roleDescription:_="draggable",tabIndex:b=0}=r??{},v=l?.id===e,x=A.useContext(v?wQ:RHe),[M,w]=fS(),[E,T]=fS(),P=mHe(s,e),N=ox(n);Qo(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:E,data:N}),()=>{const R=f.get(e);R&&R.key===a&&f.delete(e)}),[f,e]);const U=A.useMemo(()=>({role:m,tabIndex:b,"aria-disabled":i,"aria-pressed":v&&m===t$?!0:void 0,"aria-roledescription":_,"aria-describedby":d.draggable}),[i,m,b,v,_,d.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:U,isDragging:v,listeners:i?void 0:P,node:M,over:p,setNodeRef:w,setActivatorNodeRef:T,transform:x}}function OHe(){return A.useContext(SQ)}const kHe="Droppable",LHe={timeout:25};function IHe(t){let{data:e,disabled:n=!1,id:i,resizeObserverConfig:r}=t;const a=Qx(kHe),{active:s,dispatch:o,over:l,measureDroppableContainers:c}=A.useContext($w),d=A.useRef({disabled:n}),f=A.useRef(!1),p=A.useRef(null),m=A.useRef(null),{disabled:_,updateMeasurementsFor:b,timeout:v}={...LHe,...r},x=ox(b??i),M=A.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),m.current=null},v)},[v]),w=Vw({callback:M,disabled:_||!s}),E=A.useCallback((U,R)=>{w&&(R&&(w.unobserve(R),f.current=!1),U&&w.observe(U))},[w]),[T,P]=fS(E),N=ox(e);return A.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),A.useEffect(()=>(o({type:tr.RegisterDroppable,element:{id:i,key:a,disabled:n,node:T,rect:p,data:N}}),()=>o({type:tr.UnregisterDroppable,key:a,id:i})),[i]),A.useEffect(()=>{n!==d.current.disabled&&(o({type:tr.SetDroppableDisabled,id:i,key:a,disabled:n}),d.current.disabled=n)},[i,a,n,o]),{active:s,rect:p,isOver:l?.id===i,node:T,over:l,setNodeRef:P}}function Ak(t,e,n){const i=t.slice();return i.splice(n<0?i.length+n:n,0,i.splice(e,1)[0]),i}function UHe(t,e){return t.reduce((n,i,r)=>{const a=e.get(i);return a&&(n[r]=a),n},Array(t.length))}function zb(t){return t!==null&&t>=0}function jHe(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function FHe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const Tk=t=>{let{rects:e,activeIndex:n,overIndex:i,index:r}=t;const a=Ak(e,i,n),s=e[r],o=a[r];return!o||!s?null:{x:o.left-s.left,y:o.top-s.top,scaleX:o.width/s.width,scaleY:o.height/s.height}},MQ="Sortable",EQ=li.createContext({activeIndex:-1,containerId:MQ,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Tk,disabled:{draggable:!1,droppable:!1}});function zHe(t){let{children:e,id:n,items:i,strategy:r=Tk,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:d}=OHe(),f=Qx(MQ,n),p=o.rect!==null,m=A.useMemo(()=>i.map(P=>typeof P=="object"&&"id"in P?P.id:P),[i]),_=s!=null,b=s?m.indexOf(s.id):-1,v=c?m.indexOf(c.id):-1,x=A.useRef(m),M=!jHe(m,x.current),w=v!==-1&&b===-1||M,E=FHe(a);Qo(()=>{M&&_&&d(m)},[M,m,_,d]),A.useEffect(()=>{x.current=m},[m]);const T=A.useMemo(()=>({activeIndex:b,containerId:f,disabled:E,disableTransforms:w,items:m,overIndex:v,useDragOverlay:p,sortedRects:UHe(m,l),strategy:r}),[b,f,E.draggable,E.droppable,w,m,v,l,p,r]);return li.createElement(EQ.Provider,{value:T},e)}const BHe=t=>{let{id:e,items:n,activeIndex:i,overIndex:r}=t;return Ak(n,i,r).indexOf(e)},HHe=t=>{let{containerId:e,isSorting:n,wasDragging:i,index:r,items:a,newIndex:s,previousItems:o,previousContainerId:l,transition:c}=t;return!c||!i||o!==a&&r===s?!1:n?!0:s!==r&&e===l},VHe={duration:200,easing:"ease"},AQ="transform",$He=cx.Transition.toString({property:AQ,duration:0,easing:"linear"}),GHe={roleDescription:"sortable"};function WHe(t){let{disabled:e,index:n,node:i,rect:r}=t;const[a,s]=A.useState(null),o=A.useRef(n);return Qo(()=>{if(!e&&n!==o.current&&i.current){const l=r.current;if(l){const c=Em(i.current,{ignoreTransform:!0}),d={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(d.x||d.y)&&s(d)}}n!==o.current&&(o.current=n)},[e,n,i,r]),A.useEffect(()=>{a&&s(null)},[a]),a}function qHe(t){let{animateLayoutChanges:e=HHe,attributes:n,disabled:i,data:r,getNewIndex:a=BHe,id:s,strategy:o,resizeObserverConfig:l,transition:c=VHe}=t;const{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:_,sortedRects:b,overIndex:v,useDragOverlay:x,strategy:M}=A.useContext(EQ),w=XHe(i,m),E=d.indexOf(s),T=A.useMemo(()=>({sortable:{containerId:f,index:E,items:d},...r}),[f,r,E,d]),P=A.useMemo(()=>d.slice(d.indexOf(s)),[d,s]),{rect:N,node:U,isOver:R,setNodeRef:O}=IHe({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:P,...l}}),{active:z,activatorEvent:I,activeNodeRect:G,attributes:L,setNodeRef:B,listeners:q,isDragging:W,over:X,setActivatorNodeRef:Q,transform:ie}=DHe({id:s,data:T,attributes:{...GHe,...n},disabled:w.draggable}),H=hBe(O,B),Y=!!z,se=Y&&!_&&zb(p)&&zb(v),ue=!x&&W,xe=ue&&se?ie:null,ve=se?xe??(o??M)({rects:b,activeNodeRect:G,activeIndex:p,overIndex:v,index:E}):null,Pe=zb(p)&&zb(v)?a({id:s,items:d,activeIndex:p,overIndex:v}):E,pe=z?.id,we=A.useRef({activeId:pe,items:d,newIndex:Pe,containerId:f}),ze=d!==we.current.items,ce=e({active:z,containerId:f,isDragging:W,isSorting:Y,id:s,index:E,items:d,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:c,wasDragging:we.current.activeId!=null}),ft=WHe({disabled:!ce,index:E,node:U,rect:N});return A.useEffect(()=>{Y&&we.current.newIndex!==Pe&&(we.current.newIndex=Pe),f!==we.current.containerId&&(we.current.containerId=f),d!==we.current.items&&(we.current.items=d)},[Y,Pe,f,d]),A.useEffect(()=>{if(pe===we.current.activeId)return;if(pe!=null&&we.current.activeId==null){we.current.activeId=pe;return}const $=setTimeout(()=>{we.current.activeId=pe},50);return()=>clearTimeout($)},[pe]),{active:z,activeIndex:p,attributes:L,data:T,rect:N,index:E,newIndex:Pe,items:d,isOver:R,isSorting:Y,isDragging:W,listeners:q,node:U,overIndex:v,over:X,setNodeRef:H,setActivatorNodeRef:Q,setDroppableNodeRef:O,setDraggableNodeRef:B,transform:ft??ve,transition:F()};function F(){if(ft||ze&&we.current.newIndex===E)return $He;if(!(ue&&!_k(I)||!c)&&(Y||ce))return cx.Transition.toString({...c,property:AQ})}}function XHe(t,e){var n,i;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(i=t?.droppable)!=null?i:e.droppable}}function mS(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const KHe=[yn.Down,yn.Right,yn.Up,yn.Left],YHe=(t,e)=>{let{context:{active:n,collisionRect:i,droppableRects:r,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(KHe.includes(t.code)){if(t.preventDefault(),!n||!i)return;const l=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const p=r.get(f.id);if(p)switch(t.code){case yn.Down:i.top<p.top&&l.push(f);break;case yn.Up:i.top>p.top&&l.push(f);break;case yn.Left:i.left>p.left&&l.push(f);break;case yn.Right:i.left<p.left&&l.push(f);break}});const c=RBe({collisionRect:i,droppableRects:r,droppableContainers:l});let d=dQ(c,"id");if(d===s?.id&&c.length>1&&(d=c[1].id),d!=null){const f=a.get(n.id),p=a.get(d),m=p?r.get(p.id):null,_=p?.node.current;if(_&&m&&f&&p){const v=Hw(_).some((P,N)=>o[N]!==P),x=TQ(f,p),M=ZHe(f,p),w=v||!x?{x:0,y:0}:{x:M?i.width-m.width:0,y:M?i.height-m.height:0},E={x:m.left,y:m.top};return w.x&&w.y?E:lx(E,w)}}}};function TQ(t,e){return!mS(t)||!mS(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function ZHe(t,e){return!mS(t)||!mS(e)||!TQ(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function QHe({id:t,title:e,children:n,isHidden:i,size:r,onToggleVisibility:a,onToggleSize:s}){const{attributes:o,listeners:l,setNodeRef:c,transform:d,transition:f,isDragging:p}=qHe({id:t}),m={transform:cx.Transform.toString(d),transition:f,opacity:p?.5:1};return i?null:g.jsxs("div",{ref:c,style:{...m,gridColumn:`span ${r}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"ring-2 ring-bambu-green shadow-lg":""}`,children:[g.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("button",{...o,...l,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:g.jsx(nP,{className:"w-4 h-4 text-bambu-gray"})}),g.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("button",{onClick:s,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${r===1?"1/4":r===2?"1/2":"Full"} - Click to cycle`,children:r===4?g.jsx(Hre,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):g.jsx(zre,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),g.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:g.jsx(qie,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),g.jsx("div",{className:"p-4",children:n})]})}function JHe({widgets:t,storageKey:e,columns:n=4}){const i=()=>{const v={};return t.forEach(x=>{v[x.id]=x.defaultSize||4}),v},[r,a]=A.useState(()=>{const v=localStorage.getItem(e);if(v)try{const x=JSON.parse(v);return x.sizes||(x.sizes=i()),x}catch{}return{order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:i()}}),[s,o]=A.useState(!1);A.useEffect(()=>{localStorage.setItem(e,JSON.stringify(r))},[r,e]),A.useEffect(()=>{const x=t.map(M=>M.id).filter(M=>!r.order.includes(M));x.length>0&&a(M=>({...M,order:[...M.order,...x]}))},[t,r.order]);const l=TBe(VV(Ek,{activationConstraint:{distance:8}}),VV(wk,{coordinateGetter:YHe})),c=v=>{const{active:x,over:M}=v;M&&x.id!==M.id&&a(w=>{const E=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:Ak(w.order,E,T)}})},d=v=>{a(x=>({...x,hidden:x.hidden.includes(v)?x.hidden.filter(M=>M!==v):[...x.hidden,v]}))},f=v=>{a(x=>{const M=x.sizes[v]||4,w=M===1?2:M===2?4:1;return{...x,sizes:{...x.sizes,[v]:w}}})},p=()=>{const v={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:i()};a(v)},m=r.order.map(v=>t.find(x=>x.id===v)).filter(Boolean),_=m.filter(v=>!r.hidden.includes(v.id)),b=m.filter(v=>r.hidden.includes(v.id));return g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"flex items-center justify-end gap-2",children:[b.length>0&&g.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>o(!s),children:[g.jsx(F4,{className:"w-4 h-4"}),b.length," Hidden"]}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:p,children:[g.jsx(wS,{className:"w-4 h-4"}),"Reset Layout"]})]}),s&&b.length>0&&g.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[g.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),g.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(v=>g.jsxs("button",{onClick:()=>d(v.id),className:"px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:[g.jsx(F4,{className:"w-3 h-3"}),v.title]},v.id))})]}),g.jsx(NHe,{sensors:l,collisionDetection:NBe,onDragEnd:c,children:g.jsx(zHe,{items:_.map(v=>v.id),strategy:Tk,children:g.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:_.map(v=>g.jsx(QHe,{id:v.id,title:v.title,isHidden:r.hidden.includes(v.id),size:r.sizes[v.id]||2,onToggleVisibility:()=>d(v.id),onToggleSize:()=>f(v.id),children:v.component},v.id))})})}),_.length===0&&g.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[g.jsx("p",{children:"All widgets are hidden."}),g.jsx(ot,{className:"mt-4",onClick:p,children:"Reset Layout"})]})]})}function e6e({stats:t,currency:e}){return g.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[g.jsxs("div",{className:"flex items-start gap-3",children:[g.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:g.jsx(m_,{className:"w-5 h-5"})}),g.jsxs("div",{children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),g.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),g.jsxs("div",{className:"flex items-start gap-3",children:[g.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:g.jsx(fs,{className:"w-5 h-5"})}),g.jsxs("div",{children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),g.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),g.jsxs("div",{className:"flex items-start gap-3",children:[g.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:g.jsx(m_,{className:"w-5 h-5"})}),g.jsxs("div",{children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),g.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),g.jsxs("div",{className:"flex items-start gap-3",children:[g.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:g.jsx(j4,{className:"w-5 h-5"})}),g.jsxs("div",{children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),g.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),g.jsxs("div",{className:"flex items-start gap-3",children:[g.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:g.jsx(W$,{className:"w-5 h-5"})}),g.jsxs("div",{children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),g.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),g.jsxs("div",{className:"flex items-start gap-3",children:[g.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:g.jsx(j4,{className:"w-5 h-5"})}),g.jsxs("div",{children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),g.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function t6e({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return g.jsxs("div",{className:"flex items-center gap-6",children:[g.jsxs("div",{className:"relative w-28 h-28",children:[g.jsxs("svg",{className:"w-full h-full -rotate-90",children:[g.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),g.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),g.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:g.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(td,{className:"w-4 h-4 text-bambu-green"}),g.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),g.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(px,{className:"w-4 h-4 text-red-400"}),g.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),g.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function n6e({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return g.jsx("div",{className:"flex items-center justify-center h-full",children:g.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const r=(Math.min(150,Math.max(50,n))-50)/100*100,s=(l=>l>=95&&l<=105?"#00ae42":l>105?"#3b82f6":"#f97316")(n),o=n-100;return g.jsxs("div",{className:"flex items-center gap-6",children:[g.jsxs("div",{className:"relative w-28 h-28",children:[g.jsxs("svg",{className:"w-full h-full -rotate-90",children:[g.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),g.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r*3.02} 302`})]}),g.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[g.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),g.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),g.jsxs("div",{className:"space-y-2 flex-1",children:[g.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[g.jsx(Nae,{className:"w-3 h-3"}),g.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&g.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>g.jsxs("div",{className:"flex items-center justify-between text-xs",children:[g.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),g.jsxs("span",{className:`font-medium ${c>=95&&c<=105?"text-bambu-green":c>105?"text-blue-400":"text-orange-400"}`,children:[c.toFixed(0),"%"]})]},l))})]})]})}function i6e({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return g.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const e=Object.entries(t.prints_by_filament_type).sort(([,n],[,i])=>i-n);return g.jsx("div",{className:"space-y-3",children:e.map(([n,i])=>{const r=Math.round(i/(t.total_prints||1)*100);return g.jsxs("div",{children:[g.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[g.jsx("span",{className:"text-white",children:n}),g.jsxs("span",{className:"text-bambu-gray",children:[i," prints"]})]}),g.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:g.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${r}%`}})})]},n)})})}function r6e({printDates:t}){return g.jsx(aAe,{printDates:t,months:4})}function a6e({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?g.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):g.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,i])=>g.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[g.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:g.jsx(lc,{className:"w-4 h-4 text-bambu-green"})}),g.jsxs("div",{children:[g.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),g.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," prints"]})]})]},n))})}function s6e({archives:t,currency:e}){return!t||t.length===0?g.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):g.jsx(fBe,{archives:t,currency:e})}function o6e(){const{data:t,isLoading:e}=Bt({queryKey:["archiveStats"],queryFn:Ze.getArchiveStats}),{data:n}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),{data:i}=Bt({queryKey:["archives"],queryFn:()=>Ze.getArchives(void 0,1e3,0)}),{data:r}=Bt({queryKey:["settings"],queryFn:Ze.getSettings}),a=r?.currency||"$",s=new Map(n?.map(c=>[String(c.id),c.name])||[]),o=i?.map(c=>c.created_at)||[];if(e)return g.jsx("div",{className:"p-8",children:g.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:g.jsx(e6e,{stats:t,currency:a}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:g.jsx(t6e,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:g.jsx(n6e,{stats:t,printerMap:s}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:g.jsx(i6e,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:g.jsx(r6e,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:g.jsx(a6e,{stats:t,printerMap:s}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:g.jsx(s6e,{archives:i||[],currency:a}),defaultSize:4}];return g.jsxs("div",{className:"p-8",children:[g.jsxs("div",{className:"mb-6",children:[g.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),g.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),g.jsx(JHe,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function l6e({plug:t,onEdit:e}){const n=ui(),[i,r]=A.useState(!1),[a,s]=A.useState(!1),[o,l]=A.useState(!1),[c,d]=A.useState(!1),{data:f,isLoading:p,refetch:m}=Bt({queryKey:["smart-plug-status",t.id],queryFn:()=>Ze.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:_}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),b=_?.find(P=>P.id===t.printer_id),v=Ut({mutationFn:P=>Ze.controlSmartPlug(t.id,P),onSuccess:()=>{m()}}),x=Ut({mutationFn:P=>Ze.updateSmartPlug(t.id,P),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=Ut({mutationFn:()=>Ze.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",E=f?.reachable??!1,T=v.isPending;return g.jsxs(g.Fragment,{children:[g.jsx(cn,{className:"relative",children:g.jsxs(gn,{className:"p-4",children:[g.jsxs("div",{className:"flex items-start justify-between mb-3",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("div",{className:`p-2 rounded-lg ${E?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:g.jsx(ZC,{className:`w-5 h-5 ${E?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),g.jsxs("div",{children:[g.jsx("h3",{className:"font-medium text-white",children:t.name}),g.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),g.jsx("div",{className:"flex items-center gap-2",children:p?g.jsx(Yt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):E?g.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[g.jsx(iP,{className:"w-4 h-4 text-bambu-green"}),g.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):g.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[g.jsx(ES,{className:"w-4 h-4"}),g.jsx("span",{children:"Offline"})]})})]}),b&&g.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[g.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),g.jsx("span",{className:"text-sm text-white",children:b.name})]}),g.jsxs("div",{className:"flex gap-2 mb-3",children:[g.jsxs(ot,{size:"sm",variant:w?"primary":"secondary",disabled:!E||T,onClick:()=>s(!0),className:"flex-1",children:[T?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(SS,{className:"w-4 h-4"}),"On"]}),g.jsxs(ot,{size:"sm",variant:w?"secondary":"primary",disabled:!E||T,onClick:()=>l(!0),className:"flex-1",children:[T?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(V$,{className:"w-4 h-4"}),"Off"]})]}),g.jsxs("button",{onClick:()=>d(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[g.jsxs("span",{className:"flex items-center gap-2",children:[g.jsx(MS,{className:"w-4 h-4"}),"Automation Settings"]}),g.jsx("span",{children:c?"-":"+"})]}),c&&g.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white",children:"Enabled"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:t.enabled,onChange:P=>x.mutate({enabled:P.target.checked}),className:"sr-only peer"}),g.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white",children:"Auto On"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:P=>x.mutate({auto_on:P.target.checked}),className:"sr-only peer"}),g.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:P=>x.mutate({auto_off:P.target.checked}),className:"sr-only peer"}),g.jsx("div",{className:"w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green"})]})]}),t.auto_off&&g.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[g.jsx(fs,{className:"w-4 h-4"}),"Time"]}),g.jsxs("button",{onClick:()=>x.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[g.jsx(Vb,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?g.jsxs("div",{children:[g.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),g.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:P=>x.mutate({off_delay_minutes:parseInt(P.target.value)||5}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"})]}):g.jsxs("div",{children:[g.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),g.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:P=>x.mutate({off_temp_threshold:parseInt(P.target.value)||70}),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none"}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),g.jsxs("div",{className:"flex gap-2 pt-2",children:[g.jsxs(ot,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[g.jsx(H$,{className:"w-4 h-4"}),"Edit"]}),g.jsx(ot,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:g.jsx(ta,{className:"w-4 h-4"})})]})]})]})}),i&&g.jsx(pa,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{M.mutate(),r(!1)},onCancel:()=>r(!1)}),a&&g.jsx(pa,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),s(!1)},onCancel:()=>s(!1)}),o&&g.jsx(pa,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{v.mutate("off"),l(!1)},onCancel:()=>l(!1)})]})}function c6e({plug:t,onClose:e}){const n=ui(),i=!!t,[r,a]=A.useState(t?.name||""),[s,o]=A.useState(t?.ip_address||""),[l,c]=A.useState(t?.username||""),[d,f]=A.useState(t?.password||""),[p,m]=A.useState(t?.printer_id||null),[_,b]=A.useState(null),[v,x]=A.useState(null),{data:M}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),{data:w}=Bt({queryKey:["smart-plugs"],queryFn:Ze.getSmartPlugs});A.useEffect(()=>{const O=z=>{z.key==="Escape"&&e()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[e]);const E=Ut({mutationFn:()=>Ze.testSmartPlugConnection(s,l||null,d||null),onSuccess:O=>{b(O),x(null),!r&&O.device_name&&a(O.device_name)},onError:O=>{b(null),x(O.message)}}),T=Ut({mutationFn:O=>Ze.createSmartPlug(O),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:O=>{x(O.message)}}),P=Ut({mutationFn:O=>Ze.updateSmartPlug(t.id,O),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:O=>{x(O.message)}}),N=M?.filter(O=>!w?.some(I=>I.printer_id===O.id&&I.id!==t?.id)),U=O=>{if(O.preventDefault(),x(null),!r.trim()){x("Name is required");return}if(!s.trim()){x("IP address is required");return}const z={name:r.trim(),ip_address:s.trim(),username:l.trim()||null,password:d.trim()||null,printer_id:p};i?P.mutate(z):T.mutate(z)},R=T.isPending||P.isPending;return g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:O=>O.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),g.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("form",{onSubmit:U,className:"p-6 space-y-4",children:[v&&g.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx("input",{type:"text",value:s,onChange:O=>{o(O.target.value),b(null)},placeholder:"192.168.1.100",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),g.jsxs(ot,{type:"button",variant:"secondary",onClick:()=>E.mutate(),disabled:!s.trim()||E.isPending,children:[E.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(iP,{className:"w-4 h-4"}),"Test"]})]})]}),_&&g.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${_.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:_.success?g.jsxs(g.Fragment,{children:[g.jsx(td,{className:"w-5 h-5"}),g.jsxs("div",{children:[g.jsx("p",{className:"font-medium",children:"Connected!"}),g.jsxs("p",{className:"text-sm opacity-80",children:[_.device_name&&`Device: ${_.device_name} - `,"State: ",_.state]})]})]}):g.jsxs(g.Fragment,{children:[g.jsx(ES,{className:"w-5 h-5"}),g.jsx("span",{children:"Connection failed"})]})}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),g.jsx("input",{type:"text",value:r,onChange:O=>a(O.target.value),placeholder:"Living Room Plug",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),g.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),g.jsx("input",{type:"text",value:l,onChange:O=>c(O.target.value),placeholder:"admin",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),g.jsx("input",{type:"password",value:d,onChange:O=>f(O.target.value),placeholder:"********",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]}),g.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),g.jsxs("select",{value:p??"",onChange:O=>m(O.target.value?Number(O.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"",children:"No printer (manual control only)"}),N?.map(O=>g.jsx("option",{value:O.id,children:O.name},O.id))]}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),g.jsxs("div",{className:"flex gap-3 pt-2",children:[g.jsx(ot,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),g.jsxs(ot,{type:"submit",disabled:R,className:"flex-1",children:[R?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(mx,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function Ja({checked:t,onChange:e,disabled:n}){const i=r=>{r.preventDefault(),r.stopPropagation(),n||e(!t)};return g.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:i,className:`relative inline-flex w-9 h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?"bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50":t?"bg-bambu-green cursor-pointer":"bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80"}`,children:g.jsx("span",{className:`pointer-events-none absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const u6e={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email"};function d6e({provider:t,onEdit:e}){const n=ui(),[i,r]=A.useState(!1),[a,s]=A.useState(!1),[o,l]=A.useState(null),{data:c}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),d=c?.find(b=>b.id===t.printer_id),f=Ut({mutationFn:b=>Ze.updateNotificationProvider(t.id,b),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=Ut({mutationFn:()=>Ze.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=Ut({mutationFn:()=>Ze.testNotificationProvider(t.id),onSuccess:b=>{l(b),n.invalidateQueries({queryKey:["notification-providers"]})},onError:b=>{l({success:!1,message:b.message})}}),_=b=>b||"";return g.jsxs(g.Fragment,{children:[g.jsx(cn,{className:"relative",children:g.jsxs(gn,{className:"p-4",children:[g.jsxs("div",{className:"flex items-start justify-between mb-3",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:g.jsx(WC,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),g.jsxs("div",{children:[g.jsx("h3",{className:"font-medium text-white",children:t.name}),g.jsx("p",{className:"text-sm text-bambu-gray",children:u6e[t.provider_type]||t.provider_type})]})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&g.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&g.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),d&&g.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[g.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),g.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&g.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:g.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),g.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&g.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&g.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&g.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&g.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&g.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&g.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&g.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Error"}),t.on_filament_low&&g.jsx("span",{className:"px-2 py-0.5 bg-amber-500/20 text-amber-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&g.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&g.jsxs("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded flex items-center gap-1",children:[g.jsx(p_,{className:"w-3 h-3"}),"Quiet"]})]}),g.jsx("div",{className:"mb-3",children:g.jsxs(ot,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:"w-full",children:[m.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx($$,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&g.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${o.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[o.success?g.jsx(td,{className:"w-4 h-4"}):g.jsx(px,{className:"w-4 h-4"}),g.jsx("span",{children:o.message})]}),g.jsxs("button",{onClick:()=>s(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[g.jsxs("span",{className:"flex items-center gap-2",children:[g.jsx(MS,{className:"w-4 h-4"}),"Event Settings"]}),a?g.jsx(k$,{className:"w-4 h-4"}):g.jsx(yS,{className:"w-4 h-4"})]}),a&&g.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white",children:"Enabled"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),g.jsx(Ja,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("p",{className:"text-sm text-white",children:"Print Started"}),g.jsx(Ja,{checked:t.on_print_start,onChange:b=>f.mutate({on_print_start:b})})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),g.jsx(Ja,{checked:t.on_print_complete,onChange:b=>f.mutate({on_print_complete:b})})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),g.jsx(Ja,{checked:t.on_print_failed,onChange:b=>f.mutate({on_print_failed:b})})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),g.jsx(Ja,{checked:t.on_print_stopped,onChange:b=>f.mutate({on_print_stopped:b})})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),g.jsx(Ja,{checked:t.on_print_progress,onChange:b=>f.mutate({on_print_progress:b})})]})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),g.jsx(Ja,{checked:t.on_printer_offline,onChange:b=>f.mutate({on_printer_offline:b})})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),g.jsx(Ja,{checked:t.on_printer_error,onChange:b=>f.mutate({on_printer_error:b})})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),g.jsx(Ja,{checked:t.on_filament_low,onChange:b=>f.mutate({on_filament_low:b})})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),g.jsx(Ja,{checked:t.on_maintenance_due??!1,onChange:b=>f.mutate({on_maintenance_due:b})})]})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(p_,{className:"w-4 h-4 text-purple-400"}),g.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),g.jsx(Ja,{checked:t.quiet_hours_enabled,onChange:b=>f.mutate({quiet_hours_enabled:b})})]}),t.quiet_hours_enabled&&g.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[g.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(fs,{className:"w-4 h-4 text-bambu-gray"}),g.jsxs("span",{className:"text-sm text-white",children:[_(t.quiet_hours_start)||"22:00"," - ",_(t.quiet_hours_end)||"07:00"]})]}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),g.jsxs("div",{className:"flex gap-2 pt-2",children:[g.jsxs(ot,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[g.jsx(H$,{className:"w-4 h-4"}),"Edit"]}),g.jsx(ot,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:g.jsx(ta,{className:"w-4 h-4"})})]})]})]})}),i&&g.jsx(pa,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{p.mutate(),r(!1)},onCancel:()=>r(!1)})]})}const n$=[{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"email",label:"Email",description:"SMTP email notifications"}];function f6e({provider:t,onClose:e}){const n=ui(),i=!!t,[r,a]=A.useState(t?.name||""),[s,o]=A.useState(t?.provider_type||"ntfy"),[l,c]=A.useState(t?.printer_id||null),[d,f]=A.useState(t?.quiet_hours_enabled||!1),[p,m]=A.useState(t?.quiet_hours_start||"22:00"),[_,b]=A.useState(t?.quiet_hours_end||"07:00"),[v,x]=A.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,q])=>[B,String(q)])):{}),[M,w]=A.useState(null),[E,T]=A.useState(null),{data:P}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters});A.useEffect(()=>{const B=q=>{q.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const N=Ut({mutationFn:()=>Ze.testNotificationConfig({provider_type:s,config:v}),onSuccess:B=>{w(B),T(null)},onError:B=>{w({success:!1,message:B.message})}}),U=Ut({mutationFn:B=>Ze.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),R=Ut({mutationFn:B=>Ze.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),O=B=>{if(B.preventDefault(),T(null),!r.trim()){T("Name is required");return}const q=G(s);for(const X of q)if(!v[X.key]?.trim()){T(`${X.label} is required`);return}const W={name:r.trim(),provider_type:s,config:v,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?_:null};i?R.mutate(W):U.mutate(W)},z=U.isPending||R.isPending,I=B=>{switch(B){case"callmebot":return[{key:"phone",label:"Phone Number",placeholder:"+1234567890",type:"text",required:!0},{key:"apikey",label:"API Key",placeholder:"Your CallMeBot API key",type:"text",required:!0}];case"ntfy":return[{key:"server",label:"Server URL",placeholder:"https://ntfy.sh",type:"text",required:!1},{key:"topic",label:"Topic",placeholder:"my-bambutrack",type:"text",required:!0},{key:"auth_token",label:"Auth Token",placeholder:"Optional authentication",type:"password",required:!1}];case"pushover":return[{key:"user_key",label:"User Key",placeholder:"Your Pushover user key",type:"text",required:!0},{key:"app_token",label:"App Token",placeholder:"Your Pushover app token",type:"text",required:!0},{key:"priority",label:"Priority",placeholder:"0 (normal)",type:"number",required:!1}];case"telegram":return[{key:"bot_token",label:"Bot Token",placeholder:"Bot token from @BotFather",type:"password",required:!0},{key:"chat_id",label:"Chat ID",placeholder:"Your chat or group ID",type:"text",required:!0}];case"email":return[{key:"smtp_server",label:"SMTP Server",placeholder:"smtp.gmail.com",type:"text",required:!0},{key:"smtp_port",label:"SMTP Port",placeholder:"587",type:"number",required:!1},{key:"security",label:"Security",type:"select",required:!1,options:[{value:"starttls",label:"STARTTLS (Port 587)"},{value:"ssl",label:"SSL/TLS (Port 465)"},{value:"none",label:"None (Port 25)"}]},{key:"auth_enabled",label:"Authentication",type:"select",required:!1,options:[{value:"true",label:"Enabled"},{value:"false",label:"Disabled"}]},{key:"username",label:"Username",placeholder:"your@email.com",type:"text",required:!1},{key:"password",label:"Password",placeholder:"App password",type:"password",required:!1},{key:"from_email",label:"From Email",placeholder:"your@email.com",type:"text",required:!0},{key:"to_email",label:"To Email",placeholder:"recipient@email.com",type:"text",required:!0}];default:return[]}},G=B=>I(B).filter(q=>q.required),L=I(s);return g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8",onClick:B=>B.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Notification Provider":"Add Notification Provider"}),g.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("form",{onSubmit:O,className:"p-6 space-y-4",children:[E&&g.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),g.jsx("input",{type:"text",value:r,onChange:B=>a(B.target.value),placeholder:"My Notifications",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),g.jsx("select",{value:s,onChange:B=>{o(B.target.value),x({}),w(null)},disabled:i,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:n$.map(B=>g.jsx("option",{value:B.value,children:B.label},B.value))}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n$.find(B=>B.value===s)?.description})]}),g.jsxs("div",{className:"space-y-3",children:[g.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),L.map(B=>g.jsxs("div",{children:[g.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&B.options?g.jsx("select",{value:v[B.key]||B.options[0]?.value||"",onChange:q=>{x({...v,[B.key]:q.target.value}),w(null)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:B.options.map(q=>g.jsx("option",{value:q.value,children:q.label},q.value))}):g.jsx("input",{type:B.type,value:v[B.key]||"",onChange:q=>{x({...v,[B.key]:q.target.value}),w(null)},placeholder:B.placeholder,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]},B.key))]}),g.jsx("div",{className:"flex gap-2",children:g.jsxs(ot,{type:"button",variant:"secondary",onClick:()=>{w(null),N.mutate()},disabled:N.isPending||!v[G(s)[0]?.key],className:"flex-1",children:[N.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx($$,{className:"w-4 h-4"}),"Test Configuration"]})}),M&&g.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${M.success?"bg-bambu-green/20 border border-bambu-green/50 text-bambu-green":"bg-red-500/20 border border-red-500/50 text-red-400"}`,children:M.success?g.jsxs(g.Fragment,{children:[g.jsx(td,{className:"w-5 h-5"}),g.jsx("span",{children:M.message})]}):g.jsxs(g.Fragment,{children:[g.jsx(px,{className:"w-5 h-5"}),g.jsx("span",{children:M.message})]})}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),g.jsxs("select",{value:l??"",onChange:B=>c(B.target.value?Number(B.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"",children:"All printers"}),P?.map(B=>g.jsx("option",{value:B.id,children:B.name},B.id))]}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),g.jsx(Ja,{checked:d,onChange:f})]}),d&&g.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),g.jsx("input",{type:"time",value:p,onChange:B=>m(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),g.jsx("input",{type:"time",value:_,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),g.jsxs("div",{className:"flex gap-3 pt-2",children:[g.jsx(ot,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),g.jsxs(ot,{type:"submit",disabled:z,className:"flex-1",children:[z?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(mx,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}async function h6e(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function p6e(t){const e=await fetch("/api/v1/settings/spoolman",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error("Failed to save Spoolman settings");return e.json()}function m6e(){const t=ui(),[e,n]=A.useState(!1),[i,r]=A.useState(""),[a,s]=A.useState("auto"),[o,l]=A.useState(!1),[c,d]=A.useState(!1),[f,p]=A.useState("all"),{data:m,isLoading:_}=Bt({queryKey:["spoolman-settings"],queryFn:h6e}),{data:b,isLoading:v,refetch:x}=Bt({queryKey:["spoolman-status"],queryFn:Ze.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters});A.useEffect(()=>{m&&(n(m.spoolman_enabled==="true"),r(m.spoolman_url||""),s(m.spoolman_sync_mode||"auto"))},[m]),A.useEffect(()=>{if(m){const I=m.spoolman_enabled==="true"!==e||(m.spoolman_url||"")!==i||(m.spoolman_sync_mode||"auto")!==a;l(I)}},[m,e,i,a]);const w=Ut({mutationFn:()=>p6e({spoolman_enabled:e?"true":"false",spoolman_url:i,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),l(!1),d(!0),setTimeout(()=>d(!1),2e3)}}),E=Ut({mutationFn:Ze.connectSpoolman,onSuccess:()=>{x()}}),T=Ut({mutationFn:Ze.disconnectSpoolman,onSuccess:()=>{x()}}),P=Ut({mutationFn:Ze.syncAllPrintersAms,onSuccess:I=>{I.success}}),N=Ut({mutationFn:I=>Ze.syncPrinterAms(I),onSuccess:I=>{I.success}}),U=()=>{f==="all"?P.mutate():N.mutate(f)},R=P.isPending||N.isPending,O=f==="all"?P.data:N.data,z=f==="all"?P.isSuccess:N.isSuccess;return _?g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(U4,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),g.jsx(gn,{children:g.jsx("div",{className:"flex justify-center py-8",children:g.jsx(Yt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(U4,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),o&&g.jsx(ot,{size:"sm",onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):c?g.jsx(_0,{className:"w-4 h-4"}):"Save"})]})}),g.jsxs(gn,{className:"space-y-4",children:[g.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-white",children:"Enable Spoolman"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:e,onChange:I=>n(I.target.checked),className:"sr-only peer"}),g.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),g.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:i,onChange:I=>r(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none disabled:opacity-50"}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),g.jsxs("select",{value:a,onChange:I=>s(I.target.value),disabled:!e,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50",children:[g.jsx("option",{value:"auto",children:"Automatic"}),g.jsx("option",{value:"manual",children:"Manual Only"})]}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&g.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[g.jsxs("div",{className:"flex items-center justify-between mb-3",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?g.jsx(Yt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):b?.connected?g.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[g.jsx(_0,{className:"w-4 h-4"}),"Connected"]}):g.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[g.jsx(Cn,{className:"w-4 h-4"}),"Disconnected"]})]}),g.jsx("div",{className:"flex gap-2",children:b?.connected?g.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(Tre,{className:"w-4 h-4"}),"Disconnect"]}):g.jsxs(ot,{size:"sm",onClick:()=>E.mutate(),disabled:E.isPending||!i,children:[E.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(Nre,{className:"w-4 h-4"}),"Connect"]})})]}),E.isError&&g.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:E.error.message}),b?.connected&&g.jsxs("div",{className:"space-y-3",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),g.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("div",{className:"relative flex-1",children:[g.jsxs("select",{value:f,onChange:I=>p(I.target.value==="all"?"all":Number(I.target.value)),className:"w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer",children:[g.jsx("option",{value:"all",children:"All Printers"}),M?.map(I=>g.jsx("option",{value:I.id,children:I.name},I.id))]}),g.jsx(yS,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:U,disabled:R,children:[R?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(zu,{className:"w-4 h-4"}),"Sync"]})]})]}),z&&O&&g.jsx("div",{className:`mt-2 p-2 rounded text-sm ${O.success?"bg-green-500/20 border border-green-500/50 text-green-400":"bg-yellow-500/20 border border-yellow-500/50 text-yellow-400"}`,children:O.success?`Synced ${O.synced_count} trays successfully`:`Synced ${O.synced_count} trays with ${O.errors.length} errors`})]})]})]})}function g6e(){const t=ui(),[e,n]=A.useState(null),[i,r]=A.useState(!1),[a,s]=A.useState(!1),[o,l]=A.useState(!1),[c,d]=A.useState(null),[f,p]=A.useState(!1),[m,_]=A.useState(null),[b,v]=A.useState(X$()),x=ie=>{v(ie),lse(ie)},M=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:w,isLoading:E}=Bt({queryKey:["settings"],queryFn:Ze.getSettings}),{data:T,isLoading:P}=Bt({queryKey:["smart-plugs"],queryFn:Ze.getSmartPlugs}),{data:N,isLoading:U}=Bt({queryKey:["notification-providers"],queryFn:Ze.getNotificationProviders}),{data:R}=Bt({queryKey:["ffmpeg-status"],queryFn:Ze.checkFfmpeg}),{data:O}=Bt({queryKey:["version"],queryFn:Ze.getVersion}),{data:z,refetch:I,isRefetching:G}=Bt({queryKey:["updateCheck"],queryFn:Ze.checkForUpdates,staleTime:300*1e3}),{data:L,refetch:B}=Bt({queryKey:["updateStatus"],queryFn:Ze.getUpdateStatus,refetchInterval:ie=>{const H=ie.state.data;return H?.status==="downloading"||H?.status==="installing"?1e3:!1}}),q=Ut({mutationFn:Ze.applyUpdate,onSuccess:()=>{B()}});A.useEffect(()=>{w&&!e&&n(w)},[w,e]),A.useEffect(()=>{if(w&&e){const ie=w.auto_archive!==e.auto_archive||w.save_thumbnails!==e.save_thumbnails||w.capture_finish_photo!==e.capture_finish_photo||w.default_filament_cost!==e.default_filament_cost||w.currency!==e.currency||w.energy_cost_per_kwh!==e.energy_cost_per_kwh||w.energy_tracking_mode!==e.energy_tracking_mode||w.check_updates!==e.check_updates;r(ie)}},[w,e]);const W=Ut({mutationFn:Ze.updateSettings,onSuccess:ie=>{t.setQueryData(["settings"],ie),n(ie),r(!1),s(!0),setTimeout(()=>s(!1),2e3),t.invalidateQueries({queryKey:["archiveStats"]})}}),X=()=>{e&&W.mutate(e)},Q=(ie,H)=>{e&&n({...e,[ie]:H})};return E||!e?g.jsx("div",{className:"p-8 flex justify-center",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):g.jsxs("div",{className:"p-8",children:[g.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),g.jsx("p",{className:"text-bambu-gray",children:"Configure Bambusy"})]}),g.jsxs(ot,{onClick:X,disabled:!i||W.isPending,children:[W.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):a?g.jsx(_0,{className:"w-4 h-4"}):g.jsx(mx,{className:"w-4 h-4"}),a?"Saved!":"Save"]})]}),W.isError&&g.jsxs("div",{className:"mb-6 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:["Failed to save settings: ",W.error.message]}),g.jsxs("div",{className:"flex gap-8",children:[g.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),g.jsxs(gn,{className:"space-y-4",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-white",children:"Auto-archive prints"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:e.auto_archive,onChange:ie=>Q("auto_archive",ie.target.checked),className:"sr-only peer"}),g.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-white",children:"Save thumbnails"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:e.save_thumbnails,onChange:ie=>Q("save_thumbnails",ie.target.checked),className:"sr-only peer"}),g.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-white",children:"Capture finish photo"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:e.capture_finish_photo,onChange:ie=>Q("capture_finish_photo",ie.target.checked),className:"sr-only peer"}),g.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),e.capture_finish_photo&&R&&!R.installed&&g.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[g.jsx(Bu,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),g.jsxs("div",{className:"text-sm",children:[g.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),g.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",g.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",g.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),g.jsxs(gn,{className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),g.jsx("input",{type:"number",step:"0.01",min:"0",value:e.default_filament_cost,onChange:ie=>Q("default_filament_cost",parseFloat(ie.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),g.jsxs("select",{value:e.currency,onChange:ie=>Q("currency",ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"USD",children:"USD ($)"}),g.jsx("option",{value:"EUR",children:"EUR (€)"}),g.jsx("option",{value:"GBP",children:"GBP (£)"}),g.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),g.jsx("option",{value:"JPY",children:"JPY (¥)"}),g.jsx("option",{value:"CNY",children:"CNY (¥)"}),g.jsx("option",{value:"CAD",children:"CAD ($)"}),g.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),g.jsx("input",{type:"number",step:"0.01",min:"0",value:e.energy_cost_per_kwh,onChange:ie=>Q("energy_cost_per_kwh",parseFloat(ie.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),g.jsxs("select",{value:e.energy_tracking_mode||"total",onChange:ie=>Q("energy_tracking_mode",ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"print",children:"Prints Only"}),g.jsx("option",{value:"total",children:"Total Consumption"})]}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interface"})}),g.jsxs(gn,{className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default view on startup"}),g.jsx("select",{value:b,onChange:ie=>x(ie.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:$b.map(ie=>g.jsx("option",{value:ie.to,children:ie.label},ie.id))}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Page to show when opening the app"})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-white",children:"Sidebar order"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:M,children:[g.jsx(wS,{className:"w-4 h-4"}),"Reset"]})]})]})]})]}),g.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[g.jsx(m6e,{}),g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),g.jsxs(gn,{className:"space-y-4",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-white",children:"Check for updates"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),g.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[g.jsx("input",{type:"checkbox",checked:e.check_updates,onChange:ie=>Q("check_updates",ie.target.checked),className:"sr-only peer"}),g.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),g.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[g.jsxs("div",{className:"flex items-center justify-between mb-2",children:[g.jsxs("div",{children:[g.jsx("p",{className:"text-white",children:"Current version"}),g.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",O?.version||"..."]})]}),g.jsxs(ot,{variant:"secondary",size:"sm",onClick:()=>I(),disabled:G,children:[G?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(zu,{className:"w-4 h-4"}),"Check now"]})]}),z?.update_available?g.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[g.jsxs("div",{className:"flex items-start justify-between",children:[g.jsxs("div",{children:[g.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",z.latest_version]}),z.release_name&&z.release_name!==z.latest_version&&g.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:z.release_name}),z.release_notes&&g.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:z.release_notes})]}),z.release_url&&g.jsx("a",{href:z.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:g.jsx(sc,{className:"w-4 h-4"})})]}),L?.status==="downloading"||L?.status==="installing"?g.jsxs("div",{className:"mt-3",children:[g.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[g.jsx(Yt,{className:"w-4 h-4 animate-spin"}),g.jsx("span",{children:L.message})]}),g.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:g.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${L.progress}%`}})})]}):L?.status==="complete"?g.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:L.message}):L?.status==="error"?g.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:L.error||L.message}):g.jsxs(ot,{className:"mt-3",onClick:()=>q.mutate(),disabled:q.isPending,children:[q.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(Fu,{className:"w-4 h-4"}),"Install Update"]})]}):z?.error?g.jsxs("div",{className:"mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400",children:["Failed to check for updates: ",z.error]}):z&&!z.update_available?g.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]})]}),g.jsx("div",{className:"w-80 flex-shrink-0",children:g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ZC,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Smart Plugs"})]}),g.jsxs(ot,{size:"sm",onClick:()=>{d(null),l(!0)},children:[g.jsx(oc,{className:"w-4 h-4"}),"Add"]})]})}),g.jsxs(gn,{children:[g.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Connect Tasmota-based smart plugs to automate power control for your printers."}),P?g.jsx("div",{className:"flex justify-center py-8",children:g.jsx(Yt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):T&&T.length>0?g.jsx("div",{className:"space-y-4",children:T.map(ie=>g.jsx(l6e,{plug:ie,onEdit:H=>{d(H),l(!0)}},ie.id))}):g.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[g.jsx(ZC,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),g.jsx("p",{children:"No smart plugs configured"}),g.jsx("p",{className:"text-sm mt-1",children:"Add a Tasmota plug to get started"})]})]})]})}),g.jsx("div",{className:"w-80 flex-shrink-0",children:g.jsxs(cn,{children:[g.jsx(Fl,{children:g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(WC,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notifications"})]}),g.jsxs(ot,{size:"sm",onClick:()=>{_(null),p(!0)},children:[g.jsx(oc,{className:"w-4 h-4"}),"Add"]})]})}),g.jsxs(gn,{children:[g.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Get notified about print events via WhatsApp, Telegram, Email, and more."}),U?g.jsx("div",{className:"flex justify-center py-8",children:g.jsx(Yt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):N&&N.length>0?g.jsx("div",{className:"space-y-4",children:N.map(ie=>g.jsx(d6e,{provider:ie,onEdit:H=>{_(H),p(!0)}},ie.id))}):g.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[g.jsx(WC,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),g.jsx("p",{children:"No notification providers configured"}),g.jsx("p",{className:"text-sm mt-1",children:"Add a provider to get started"})]})]})]})})]}),o&&g.jsx(c6e,{plug:c,onClose:()=>{l(!1),d(null)}}),f&&g.jsx(f6e,{provider:m,onClose:()=>{p(!1),_(null)}})]})}const CQ=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},x6e=t=>t.startsWith("HH")?"HF":"S",v6e=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},HR=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const i of e)if(t.startsWith(i))return t.slice(i.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function UC({profile:t,onEdit:e}){const n=x6e(t.nozzle_id),i=t.nozzle_diameter,r=t.name||"Unnamed",a=HR(t.name||"");return g.jsxs("button",{onClick:e,className:"w-full text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:CQ(t.k_value)}),g.jsx("span",{className:"text-white text-sm truncate flex-1",title:r,children:r}),g.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[n," ",i]})]}),g.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 truncate",title:`Filament: ${a}`,children:["Filament: ",a||t.filament_id]})]})}function i$({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:i=[],isDualNozzle:r=!1,onClose:a,onSave:s}){const{showToast:o}=_o(),l=ui(),[c,d]=A.useState(t?.name||""),[f,p]=A.useState(t?.k_value?CQ(t.k_value):"0.020"),[m,_]=A.useState(t?.filament_id||""),[b,v]=A.useState(t?.nozzle_id?v6e(t.nozzle_id):"HH00"),[x,M]=A.useState(t?.nozzle_diameter||n),[w,E]=A.useState(t?.extruder_id||0),T=li.useMemo(()=>{const I=new Map;for(const G of i)if(G.filament_id&&!I.has(G.filament_id)){const L=HR(G.name||"");I.set(G.filament_id,{id:G.filament_id,name:L||G.filament_id})}return Array.from(I.values()).sort((G,L)=>G.name.localeCompare(L.name))},[i]),P=Ut({mutationFn:I=>(console.log("[KProfile] Calling API..."),Ze.setKProfile(e,I)),onSuccess:I=>{console.log("[KProfile] Save success:",I),o("K-profile saved"),l.invalidateQueries({queryKey:["kprofiles",e]}),s()},onError:I=>{console.error("[KProfile] Save error:",I),o(I.message,"error")}}),N=Ut({mutationFn:I=>(console.log("[KProfile] Deleting profile..."),Ze.deleteKProfile(e,I)),onSuccess:I=>{console.log("[KProfile] Delete success:",I),o("K-profile deleted"),l.invalidateQueries({queryKey:["kprofiles",e]}),a()},onError:I=>{console.error("[KProfile] Delete error:",I),o(I.message,"error")}}),[U,R]=A.useState(!1),O=()=>{t&&N.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id})},z=I=>{I.preventDefault();const G=parseFloat(f).toFixed(6),L=`${b}-${x}`,B={name:c,k_value:G,filament_id:m,nozzle_id:L,nozzle_diameter:x,extruder_id:w,setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",B),P.mutate(B)};return g.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[g.jsx(cn,{className:"w-full max-w-md",children:g.jsxs(gn,{className:"p-0",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),g.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsxs("form",{onSubmit:z,className:"p-4 space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),g.jsx("input",{type:"text",value:c,onChange:I=>d(I.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,placeholder:"My PLA Profile",required:!0})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),g.jsx("input",{type:"text",inputMode:"decimal",value:f,onChange:I=>{const G=I.target.value;(G===""||/^\d*\.?\d*$/.test(G))&&p(G)},onBlur:I=>{const G=parseFloat(I.target.value);isNaN(G)||p((Math.trunc(G*1e3)/1e3).toFixed(3))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono",placeholder:"0.020",required:!0}),g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG"})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),g.jsxs("select",{value:m,onChange:I=>{const G=I.target.value;if(_(G),!t&&G&&!c){const L=T.find(B=>B.id===G);L&&d(`${b==="HH00"?"HF":"S"} ${L.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,required:!0,children:[g.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&g.jsx("option",{value:t.filament_id,children:HR(t.name||t.filament_id)},t.filament_id),!t&&T.map(I=>g.jsx("option",{value:I.id,children:I.name},I.id))]}),!t&&T.length===0&&g.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),g.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),g.jsxs("select",{value:b,onChange:I=>{const G=I.target.value;if(v(G),!t&&m&&!c){const L=T.find(B=>B.id===m);L&&d(`${G==="HH00"?"HF":"S"} ${L.name}`)}},disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[g.jsx("option",{value:"HH00",children:"High Flow"}),g.jsx("option",{value:"HS00",children:"Standard"})]})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),g.jsxs("select",{value:x,onChange:I=>M(I.target.value),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[g.jsx("option",{value:"0.2",children:"0.2mm"}),g.jsx("option",{value:"0.4",children:"0.4mm"}),g.jsx("option",{value:"0.6",children:"0.6mm"}),g.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),r&&g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Extruder"}),g.jsxs("select",{value:w,onChange:I=>E(parseInt(I.target.value)),disabled:!!t,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${t?"opacity-60 cursor-not-allowed":""}`,children:[g.jsx("option",{value:1,children:"Left"}),g.jsx("option",{value:0,children:"Right"})]})]}),g.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&g.jsx(ot,{type:"button",variant:"secondary",onClick:()=>R(!0),disabled:N.isPending,className:"text-red-500 hover:bg-red-500/10",children:N.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(ta,{className:"w-4 h-4"})}),g.jsx(ot,{type:"button",variant:"secondary",onClick:a,className:"flex-1",children:"Cancel"}),g.jsxs(ot,{type:"submit",disabled:P.isPending,className:"flex-1",children:[P.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(tP,{className:"w-4 h-4"}),"Save"]})]})]})]})}),U&&g.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:g.jsx(cn,{className:"w-full max-w-sm",children:g.jsxs(gn,{className:"p-6",children:[g.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[g.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:g.jsx(ta,{className:"w-5 h-5 text-red-500"})}),g.jsxs("div",{children:[g.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),g.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),g.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",g.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),g.jsxs("div",{className:"flex gap-3",children:[g.jsx(ot,{variant:"secondary",onClick:()=>R(!1),className:"flex-1",children:"Cancel"}),g.jsxs(ot,{onClick:()=>{R(!1),O()},disabled:N.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N.isPending?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(ta,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function y6e(){const[t,e]=A.useState(null),[n,i]=A.useState("0.4"),[r,a]=A.useState(null),[s,o]=A.useState(!1),[l,c]=A.useState(""),[d,f]=A.useState("all"),[p,m]=A.useState("all"),{data:_,isLoading:b}=Bt({queryKey:["printers"],queryFn:Ze.getPrinters}),{data:v,isLoading:x,error:M,refetch:w}=Bt({queryKey:["kprofiles",t,n],queryFn:()=>Ze.getKProfiles(t,n),enabled:!!t,retry:!1}),E=M?.message?.includes("not connected"),T=li.useMemo(()=>v?.profiles?v.profiles.filter(R=>{const O=l.toLowerCase(),z=!O||R.name.toLowerCase().includes(O)||R.filament_id.toLowerCase().includes(O),I=d==="all"||d==="left"&&R.extruder_id===1||d==="right"&&R.extruder_id===0,G=p==="all"||p==="hf"&&R.nozzle_id.startsWith("HH")||p==="s"&&R.nozzle_id.startsWith("HS");return z&&I&&G}):[],[v?.profiles,l,d,p]),P=_?.filter(R=>R.is_active)||[];!t&&P.length>0&&e(P[0].id);const U=_?.find(R=>R.id===t)?.nozzle_count===2;return b?g.jsx("div",{className:"flex justify-center py-12",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!_||_.length===0?g.jsx(cn,{children:g.jsxs(gn,{className:"py-12 text-center",children:[g.jsx(ed,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),g.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),g.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):P.length===0?g.jsx(cn,{children:g.jsxs(gn,{className:"py-12 text-center",children:[g.jsx(lc,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),g.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),g.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[g.jsxs("div",{className:"flex-1 min-w-48",children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),g.jsx("select",{value:t||"",onChange:R=>e(parseInt(R.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:P.map(R=>g.jsx("option",{value:R.id,children:R.name},R.id))})]}),g.jsxs("div",{className:"w-32",children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),g.jsxs("select",{value:n,onChange:R=>i(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"0.2",children:"0.2mm"}),g.jsx("option",{value:"0.4",children:"0.4mm"}),g.jsx("option",{value:"0.6",children:"0.6mm"}),g.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),g.jsxs("div",{className:"flex items-end gap-2",children:[g.jsxs(ot,{variant:"secondary",onClick:()=>w(),disabled:x,children:[g.jsx(zu,{className:`w-4 h-4 ${x?"animate-spin":""}`}),"Refresh"]}),g.jsxs(ot,{onClick:()=>o(!0),children:[g.jsx(oc,{className:"w-4 h-4"}),"Add Profile"]})]})]}),g.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[g.jsxs("div",{className:"flex-1 min-w-48 relative",children:[g.jsx(g_,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),g.jsx("input",{type:"text",value:l,onChange:R=>c(R.target.value),placeholder:"Search by name or filament...",className:"w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"})]}),U&&g.jsx("div",{className:"w-36",children:g.jsxs("select",{value:d,onChange:R=>f(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"all",children:"All Extruders"}),g.jsx("option",{value:"left",children:"Left Only"}),g.jsx("option",{value:"right",children:"Right Only"})]})}),g.jsx("div",{className:"w-32",children:g.jsxs("select",{value:p,onChange:R=>m(R.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"all",children:"All Flow"}),g.jsx("option",{value:"hf",children:"HF Only"}),g.jsx("option",{value:"s",children:"S Only"})]})})]}),x?g.jsx("div",{className:"flex justify-center py-12",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):E?g.jsx(cn,{children:g.jsxs(gn,{className:"py-12 text-center",children:[g.jsx(ES,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),g.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),g.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),g.jsxs(ot,{variant:"secondary",onClick:()=>w(),children:[g.jsx(zu,{className:"w-4 h-4"}),"Retry"]})]})}):T.length>0?U?g.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[g.jsxs("div",{children:[g.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),g.jsx("div",{className:"space-y-1",children:T.filter(R=>R.extruder_id===1).map(R=>g.jsx(UC,{profile:R,onEdit:()=>a(R)},R.slot_id))})]}),g.jsxs("div",{children:[g.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),g.jsx("div",{className:"space-y-1",children:T.filter(R=>R.extruder_id===0).map(R=>g.jsx(UC,{profile:R,onEdit:()=>a(R)},R.slot_id))})]})]}):g.jsx("div",{className:"space-y-1",children:T.map(R=>g.jsx(UC,{profile:R,onEdit:()=>a(R)},R.slot_id))}):l||d!=="all"||p!=="all"?g.jsx(cn,{children:g.jsxs(gn,{className:"py-12 text-center",children:[g.jsx(g_,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),g.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),g.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):g.jsx(cn,{children:g.jsxs(gn,{className:"py-12 text-center",children:[g.jsx(tP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),g.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),g.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",n,"mm nozzle"]}),g.jsxs(ot,{onClick:()=>o(!0),children:[g.jsx(oc,{className:"w-4 h-4"}),"Create First Profile"]})]})}),r&&t&&g.jsx(i$,{profile:r,printerId:t,nozzleDiameter:n,existingProfiles:v?.profiles,isDualNozzle:U,onClose:()=>a(null),onSave:()=>a(null)}),s&&t&&g.jsx(i$,{printerId:t,nozzleDiameter:n,existingProfiles:v?.profiles,isDualNozzle:U,onClose:()=>o(!1),onSave:()=>o(!1)})]})}function b6e({onSuccess:t}){const{showToast:e}=_o(),[n,i]=A.useState("email"),[r,a]=A.useState(""),[s,o]=A.useState(""),[l,c]=A.useState(""),[d,f]=A.useState(""),[p,m]=A.useState("global"),_=Ut({mutationFn:()=>Ze.cloudLogin(r,s,p),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),i("code")):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),b=Ut({mutationFn:()=>Ze.cloudVerify(r,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>{e(w.message,"error")}}),v=Ut({mutationFn:()=>Ze.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>{e(w.message,"error")}}),x=w=>{w.preventDefault(),n==="email"?_.mutate():n==="code"?b.mutate():n==="token"&&v.mutate()},M=_.isPending||b.isPending||v.isPending;return g.jsxs(cn,{className:"max-w-md mx-auto",children:[g.jsx(Fl,{children:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(eP,{className:"w-5 h-5 text-bambu-green"}),g.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"})]})}),g.jsx(gn,{children:g.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),g.jsx("input",{type:"email",value:r,onChange:w=>a(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),g.jsx("input",{type:"password",value:s,onChange:w=>o(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),g.jsxs("select",{value:p,onChange:w=>m(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[g.jsx("option",{value:"global",children:"Global"}),g.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),g.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",r,") for a 6-digit code"]}),g.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&g.jsxs("div",{children:[g.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),g.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),g.jsx("textarea",{value:d,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:3,required:!0})]}),g.jsxs("div",{className:"flex gap-2",children:[n==="code"&&g.jsx(ot,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:"Back"}),g.jsxs(ot,{type:"submit",disabled:M,className:"flex-1",children:[M?g.jsx(Yt,{className:"w-4 h-4 animate-spin"}):g.jsx(H4,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&g.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:g.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[g.jsx(_re,{className:"w-3 h-3"}),"Use access token instead"]})}),n==="token"&&g.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:g.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-1",children:[g.jsx(H4,{className:"w-3 h-3"}),"Login with email instead"]})})]})})]})}function _6e({setting:t,onClick:e}){return g.jsxs("button",{onClick:e,className:"w-full text-left p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[g.jsx("p",{className:"text-white font-medium truncate",children:t.name}),t.updated_time&&g.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Updated: ",new Date(t.updated_time).toLocaleDateString()]})]})}function S6e({setting:t,onClose:e}){const{data:n,isLoading:i}=Bt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>Ze.getCloudSettingDetail(t.setting_id)});return g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:g.jsx(cn,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:g.jsxs(gn,{className:"p-0 flex flex-col h-full",children:[g.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[g.jsxs("div",{children:[g.jsx("h2",{className:"text-xl font-semibold text-white",children:t.name}),g.jsxs("p",{className:"text-sm text-bambu-gray capitalize",children:[t.type," preset"]})]}),g.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:g.jsx(Cn,{className:"w-5 h-5"})})]}),g.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i?g.jsx("div",{className:"flex justify-center py-8",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):n?g.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap overflow-x-auto bg-bambu-dark p-4 rounded-lg",children:JSON.stringify(n,null,2)}):g.jsx("p",{className:"text-bambu-gray text-center py-8",children:"Failed to load preset details"})}),g.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:g.jsx(ot,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})})}function w6e({settings:t}){const[e,n]=A.useState(new Set),[i,r]=A.useState(null),a=l=>[...l].sort((c,d)=>c.name.localeCompare(d.name)),s=l=>{n(c=>{const d=new Set(c);return d.has(l)?d.delete(l):d.add(l),d})},o=[{key:"filament",label:"Filament Presets",icon:L$,items:a(t.filament)},{key:"printer",label:"Printer Presets",icon:lc,items:a(t.printer)},{key:"process",label:"Process Presets",icon:MS,items:a(t.process)}];return g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"space-y-4",children:o.map(({key:l,label:c,icon:d,items:f})=>g.jsxs(cn,{children:[g.jsxs("button",{onClick:()=>s(l),className:"w-full flex items-center justify-between p-4",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx(d,{className:"w-5 h-5 text-bambu-green"}),g.jsx("span",{className:"text-lg font-semibold text-white",children:c}),g.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",f.length,")"]})]}),e.has(l)?g.jsx(yS,{className:"w-5 h-5 text-bambu-gray"}):g.jsx(If,{className:"w-5 h-5 text-bambu-gray"})]}),e.has(l)&&f.length>0&&g.jsx(gn,{className:"pt-0",children:g.jsx("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:f.map(p=>g.jsx(_6e,{setting:p,onClick:()=>r(p)},p.setting_id))})}),e.has(l)&&f.length===0&&g.jsx(gn,{className:"pt-0",children:g.jsx("p",{className:"text-bambu-gray text-sm",children:"No presets found"})})]},l))}),i&&g.jsx(S6e,{setting:i,onClose:()=>r(null)})]})}function M6e(){const t=ui(),{showToast:e}=_o(),[n,i]=A.useState("kprofiles"),{data:r,isLoading:a}=Bt({queryKey:["cloudStatus"],queryFn:Ze.getCloudStatus}),{data:s,isLoading:o,refetch:l}=Bt({queryKey:["cloudSettings"],queryFn:()=>Ze.getCloudSettings(),enabled:!!r?.is_authenticated,retry:!1,staleTime:1e3*60*5}),c=Ut({mutationFn:Ze.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),d=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return a?g.jsx("div",{className:"p-8 flex justify-center",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):g.jsxs("div",{className:"p-8",children:[g.jsxs("div",{className:"mb-6",children:[g.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),g.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),g.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[g.jsxs("button",{onClick:()=>i("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[g.jsx(eP,{className:"w-4 h-4"}),"Cloud Profiles"]}),g.jsxs("button",{onClick:()=>i("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${n==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[g.jsx(tP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[g.jsx("p",{className:"text-bambu-gray",children:r?.is_authenticated?`Connected as ${r.email}`:"Connect to Bambu Cloud to access your slicer presets"}),r?.is_authenticated&&g.jsxs("div",{className:"flex gap-2",children:[g.jsxs(ot,{variant:"secondary",onClick:()=>l(),disabled:o,children:[g.jsx(zu,{className:`w-4 h-4 ${o?"animate-spin":""}`}),"Refresh"]}),g.jsxs(ot,{variant:"secondary",onClick:()=>c.mutate(),disabled:c.isPending,children:[g.jsx(jre,{className:"w-4 h-4"}),"Logout"]})]})]}),r?.is_authenticated?o?g.jsx("div",{className:"flex justify-center py-12",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s?g.jsx(w6e,{settings:s}):g.jsx(cn,{children:g.jsxs(gn,{className:"py-8 text-center",children:[g.jsx("p",{className:"text-bambu-gray",children:"Failed to load profiles"}),g.jsx(ot,{className:"mt-4",onClick:()=>l(),children:"Retry"})]})}):g.jsx(b6e,{onSuccess:d})]}),n==="kprofiles"&&g.jsx(y6e,{})]})}const VR={Droplet:L$,Flame:rre,Ruler:oae,Sparkles:bae,Square:S0,Cable:gie,Wrench:Np};function NQ(t){return t&&VR[t]||Np}function x0(t){return t<1?`${Math.round(t*60)}m`:`${t.toFixed(1)}h`}function E6e(t){const e=Math.floor(t),n=Math.round((t-e)*60);return e===0?`${n} minutes`:n===0?`${e} hours`:`${e}h ${n}m`}function A6e({item:t,onPerform:e,onToggle:n}){const i=NQ(t.maintenance_type_icon),r=Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100)),a=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-yellow-400":"text-bambu-green":"text-bambu-gray",s=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-yellow-500":"bg-bambu-green":"bg-bambu-gray/30",o=()=>t.enabled?t.is_due?`Overdue by ${x0(Math.abs(t.hours_until_due))}`:t.is_warning?`Due in ${x0(t.hours_until_due)}`:`${x0(t.hours_until_due)} left`:"Disabled";return g.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${t.is_due?"bg-red-500/10":t.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[g.jsxs("div",{className:"flex items-center gap-3 min-w-[180px]",children:[g.jsx(i,{className:`w-4 h-4 ${a()}`}),g.jsx("span",{className:`text-sm ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name})]}),g.jsx("div",{className:"flex-1 max-w-[200px]",children:g.jsx("div",{className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:g.jsx("div",{className:`h-full transition-all ${s()}`,style:{width:`${r}%`}})})}),g.jsxs("div",{className:`text-xs min-w-[120px] ${a()}`,children:[t.is_due&&g.jsx(Bu,{className:"w-3 h-3 inline mr-1"}),t.is_warning&&g.jsx(fs,{className:"w-3 h-3 inline mr-1"}),!t.is_due&&!t.is_warning&&t.enabled&&g.jsx(_0,{className:"w-3 h-3 inline mr-1"}),o()]}),g.jsx(Ja,{checked:t.enabled,onChange:l=>n(t.id,l)}),g.jsxs(ot,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"min-w-[70px]",children:[g.jsx(wS,{className:"w-3 h-3"}),"Done"]})]})}function T6e({overview:t,onPerform:e,onToggle:n,onSetHours:i}){const[r,a]=A.useState(!1),[s,o]=A.useState(!1),[l,c]=A.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((m,_)=>m.maintenance_type_id-_.maintenance_type_id),f=[...t.maintenance_items].filter(m=>m.enabled).sort((m,_)=>m.is_due&&!_.is_due?-1:!m.is_due&&_.is_due?1:m.is_warning&&!_.is_warning?-1:!m.is_warning&&_.is_warning?1:m.hours_until_due-_.hours_until_due)[0],p=()=>{const m=parseFloat(l);!isNaN(m)&&m>=0&&(i(t.printer_id,m),o(!1))};return g.jsxs(cn,{children:[g.jsxs("div",{className:"p-4",children:[g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsxs("div",{className:"flex items-center gap-3",children:[g.jsx("h2",{className:"text-lg font-semibold text-white",children:t.printer_name}),t.due_count>0&&g.jsxs("span",{className:"px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1",children:[g.jsx(Bu,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&g.jsxs("span",{className:"px-2.5 py-1 bg-yellow-500/20 text-yellow-400 text-xs font-medium rounded-full flex items-center gap-1",children:[g.jsx(fs,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&g.jsxs("span",{className:"px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1",children:[g.jsx(_0,{className:"w-3 h-3"}),"All good"]})]}),g.jsx("button",{onClick:()=>a(!r),className:"flex items-center gap-1 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded transition-colors",children:r?g.jsxs(g.Fragment,{children:[g.jsx(k$,{className:"w-4 h-4"}),"Hide"]}):g.jsxs(g.Fragment,{children:[g.jsx(yS,{className:"w-4 h-4"}),"Details"]})})]}),g.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[g.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[g.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Total Print Time"}),s?g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("input",{type:"number",value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&p(),m.key==="Escape"&&o(!1)},className:"w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-lg font-semibold",min:"0",step:"1",autoFocus:!0}),g.jsx("span",{className:"text-sm text-bambu-gray",children:"hours"}),g.jsxs("div",{className:"flex gap-1 ml-auto",children:[g.jsx(ot,{size:"sm",onClick:p,children:"Save"}),g.jsx(ot,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"✕"})]})]}):g.jsxs("button",{onClick:()=>{c(Math.round(t.total_print_hours).toString()),o(!0)},className:"flex items-center gap-2 group",title:"Click to edit total print hours",children:[g.jsx("span",{className:"text-xl font-semibold text-white group-hover:text-bambu-green transition-colors",children:E6e(t.total_print_hours)}),g.jsx(B$,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})]})]}),g.jsxs("div",{className:`p-3 rounded-lg ${f?.is_due?"bg-red-500/10":f?.is_warning?"bg-yellow-500/10":"bg-bambu-dark"}`,children:[g.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Next Maintenance"}),f?g.jsxs("div",{children:[g.jsx("div",{className:`text-lg font-semibold ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-white"}`,children:f.maintenance_type_name}),g.jsx("div",{className:`text-sm ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-bambu-gray"}`,children:f.is_due?g.jsxs(g.Fragment,{children:["Overdue by ",x0(Math.abs(f.hours_until_due))]}):g.jsxs(g.Fragment,{children:["Due in ",x0(f.hours_until_due)]})})]}):g.jsx("div",{className:"text-white",children:"No tasks enabled"})]})]})]}),r&&g.jsx(gn,{className:"pt-0 space-y-2 border-t border-bambu-dark-tertiary mt-4",children:g.jsx("div",{className:"pt-4",children:d.map(m=>g.jsx(A6e,{item:m,onPerform:e,onToggle:n},m.id))})})]})}function C6e({onClose:t,types:e,onAddType:n,onDeleteType:i}){const[r,a]=A.useState(""),[s,o]=A.useState("100"),[l,c]=A.useState("Wrench"),d=p=>{p.preventDefault(),r.trim()&&parseFloat(s)>0&&(n({name:r.trim(),default_interval_hours:parseFloat(s),icon:l}),a(""),o("100"))},f=e.filter(p=>!p.is_system);return g.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:g.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 w-full max-w-lg",onClick:p=>p.stopPropagation(),children:[g.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Maintenance Settings"}),f.length>0&&g.jsxs("div",{className:"mb-6",children:[g.jsx("h4",{className:"text-sm text-bambu-gray mb-2",children:"Custom Maintenance Types"}),g.jsx("div",{className:"space-y-2",children:f.map(p=>{const m=NQ(p.icon);return g.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(m,{className:"w-4 h-4 text-bambu-gray"}),g.jsx("span",{className:"text-white text-sm",children:p.name}),g.jsxs("span",{className:"text-bambu-gray text-xs",children:["(",p.default_interval_hours,"h)"]})]}),g.jsx("button",{onClick:()=>{confirm(`Delete "${p.name}"?`)&&i(p.id)},className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400",children:g.jsx(ta,{className:"w-4 h-4"})})]},p.id)})})]}),g.jsxs("form",{onSubmit:d,children:[g.jsx("h4",{className:"text-sm text-bambu-gray mb-2",children:"Add Custom Type"}),g.jsxs("div",{className:"flex gap-2 mb-3",children:[g.jsx("input",{type:"text",value:r,onChange:p=>a(p.target.value),className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",placeholder:"Name (e.g., Replace HEPA Filter)"}),g.jsx("input",{type:"number",value:s,onChange:p=>o(p.target.value),className:"w-20 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",placeholder:"Hours",min:"1"})]}),g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("div",{className:"flex gap-1",children:Object.keys(VR).map(p=>{const m=VR[p];return g.jsx("button",{type:"button",onClick:()=>c(p),className:`p-1.5 rounded ${l===p?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:g.jsx(m,{className:"w-4 h-4"})},p)})}),g.jsxs(ot,{type:"submit",size:"sm",disabled:!r.trim(),children:[g.jsx(oc,{className:"w-4 h-4"}),"Add"]})]})]}),g.jsx("div",{className:"mt-6 pt-4 border-t border-bambu-dark-tertiary flex justify-end",children:g.jsx(ot,{variant:"secondary",onClick:t,children:"Close"})})]})})}function N6e(){const t=ui(),{showToast:e}=_o(),[n,i]=A.useState(!1),{data:r,isLoading:a}=Bt({queryKey:["maintenanceOverview"],queryFn:Ze.getMaintenanceOverview}),{data:s}=Bt({queryKey:["maintenanceTypes"],queryFn:Ze.getMaintenanceTypes}),o=Ut({mutationFn:({id:x,notes:M})=>Ze.performMaintenance(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as done")},onError:x=>{e(x.message,"error")}}),l=Ut({mutationFn:({id:x,data:M})=>Ze.updateMaintenanceItem(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:x=>{e(x.message,"error")}}),c=Ut({mutationFn:Ze.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:x=>{e(x.message,"error")}}),d=Ut({mutationFn:Ze.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:x=>{e(x.message,"error")}}),f=Ut({mutationFn:({printerId:x,hours:M})=>Ze.setPrinterHours(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:x=>{e(x.message,"error")}}),p=x=>{o.mutate({id:x})},m=(x,M)=>{l.mutate({id:x,data:{enabled:M}})},_=(x,M)=>{f.mutate({printerId:x,hours:M})};if(a)return g.jsx("div",{className:"p-8 flex justify-center",children:g.jsx(Yt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const b=r?.reduce((x,M)=>x+M.due_count,0)||0,v=r?.reduce((x,M)=>x+M.warning_count,0)||0;return g.jsxs("div",{className:"p-8",children:[g.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),g.jsxs("p",{className:"text-bambu-gray text-sm",children:[b>0&&g.jsxs("span",{className:"text-red-400",children:[b," tasks overdue"]}),b>0&&v>0&&" · ",v>0&&g.jsxs("span",{className:"text-yellow-400",children:[v," due soon"]}),b===0&&v===0&&"All maintenance up to date"]})]}),g.jsxs(ot,{variant:"secondary",onClick:()=>i(!0),children:[g.jsx(MS,{className:"w-4 h-4"}),"Settings"]})]}),g.jsx("div",{className:"space-y-4",children:r&&r.length>0?[...r].sort((x,M)=>x.printer_name.localeCompare(M.printer_name)).map(x=>g.jsx(T6e,{overview:x,onPerform:p,onToggle:m,onSetHours:_},x.printer_id)):g.jsx(cn,{children:g.jsxs(gn,{className:"text-center py-12",children:[g.jsx(Np,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),g.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),g.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to start tracking maintenance"})]})})}),n&&s&&g.jsx(C6e,{onClose:()=>i(!1),types:s,onAddType:x=>c.mutate(x),onDeleteType:x=>d.mutate(x)})]})}function R6e(){const t=A.useRef(null),e=A.useRef(null),n=ui(),[i,r]=A.useState(!1),a=A.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,d=new WebSocket(c);let f=null;d.onopen=()=>{console.log("[WebSocket] Connected"),r(!0),f=window.setInterval(()=>{d.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"}))},3e4)},d.onmessage=p=>{try{const m=JSON.parse(p.data);s(m)}catch{}},d.onclose=p=>{console.log("[WebSocket] Closed",p.code,p.reason),f&&(clearInterval(f),f=null),r(!1),t.current=null,e.current=window.setTimeout(()=>{a()},3e3)},d.onerror=p=>{console.error("[WebSocket] Error",p),d.close()},t.current=d},[]),s=A.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],c=>({...c,...l.data}));break;case"print_complete":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break;case"archive_created":n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]});break}},[n]);A.useEffect(()=>(a(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[a]);const o=A.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:i,sendMessage:o}}const P6e=new Fne({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function D6e({children:t}){return R6e(),g.jsx(g.Fragment,{children:t})}function O6e(){return g.jsx(nse,{children:g.jsx(fse,{children:g.jsx(zne,{client:P6e,children:g.jsx(D6e,{children:g.jsx(one,{children:g.jsx(jte,{children:g.jsxs(kl,{path:"/",element:g.jsx(cse,{}),children:[g.jsx(kl,{index:!0,element:g.jsx(Cse,{})}),g.jsx(kl,{path:"archives",element:g.jsx(tAe,{})}),g.jsx(kl,{path:"queue",element:g.jsx(rAe,{})}),g.jsx(kl,{path:"stats",element:g.jsx(o6e,{})}),g.jsx(kl,{path:"profiles",element:g.jsx(M6e,{})}),g.jsx(kl,{path:"maintenance",element:g.jsx(N6e,{})}),g.jsx(kl,{path:"settings",element:g.jsx(g6e,{})})]})})})})})})})}$ee.createRoot(document.getElementById("root")).render(g.jsx(A.StrictMode,{children:g.jsx(O6e,{})}));
|