| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601 |
- function ane(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 Ry=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ys(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var EA={exports:{}},Pg={};var V4;function sne(){if(V4)return Pg;V4=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 Pg.Fragment=e,Pg.jsx=n,Pg.jsxs=n,Pg}var G4;function one(){return G4||(G4=1,EA.exports=sne()),EA.exports}var h=one(),AA={exports:{}},Yt={};var W4;function lne(){if(W4)return Yt;W4=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"),u=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),m=Symbol.iterator;function g(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function x(z,V,re){this.props=z,this.context=V,this.refs=v,this.updater=re||y}x.prototype.isReactComponent={},x.prototype.setState=function(z,V){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,V,"setState")},x.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function M(){}M.prototype=x.prototype;function w(z,V,re){this.props=z,this.context=V,this.refs=v,this.updater=re||y}var C=w.prototype=new M;C.constructor=w,_(C,x.prototype),C.isPureReactComponent=!0;var T=Array.isArray;function P(){}var A={H:null,A:null,T:null,S:null},j=Object.prototype.hasOwnProperty;function N(z,V,re){var le=re.ref;return{$$typeof:t,type:z,key:V,ref:le!==void 0?le:null,props:re}}function k(z,V){return N(z.type,V,z.props)}function F(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function I(z){var V={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(re){return V[re]})}var W=/\/+/g;function D(z,V){return typeof z=="object"&&z!==null&&z.key!=null?I(""+z.key):V.toString(36)}function B(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(P,P):(z.status="pending",z.then(function(V){z.status==="pending"&&(z.status="fulfilled",z.value=V)},function(V){z.status==="pending"&&(z.status="rejected",z.reason=V)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function $(z,V,re,le,ge){var ie=typeof z;(ie==="undefined"||ie==="boolean")&&(z=null);var xe=!1;if(z===null)xe=!0;else switch(ie){case"bigint":case"string":case"number":xe=!0;break;case"object":switch(z.$$typeof){case t:case e:xe=!0;break;case u:return xe=z._init,$(xe(z._payload),V,re,le,ge)}}if(xe)return ge=ge(z),xe=le===""?"."+D(z,0):le,T(ge)?(re="",xe!=null&&(re=xe.replace(W,"$&/")+"/"),$(ge,V,re,"",function(we){return we})):ge!=null&&(F(ge)&&(ge=k(ge,re+(ge.key==null||z&&z.key===ge.key?"":(""+ge.key).replace(W,"$&/")+"/")+xe)),V.push(ge)),1;xe=0;var ke=le===""?".":le+":";if(T(z))for(var he=0;he<z.length;he++)le=z[he],ie=ke+D(le,he),xe+=$(le,V,re,ie,ge);else if(he=g(z),typeof he=="function")for(z=he.call(z),he=0;!(le=z.next()).done;)le=le.value,ie=ke+D(le,he++),xe+=$(le,V,re,ie,ge);else if(ie==="object"){if(typeof z.then=="function")return $(B(z),V,re,le,ge);throw V=String(z),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return xe}function K(z,V,re){if(z==null)return z;var le=[],ge=0;return $(z,le,"","",function(ie){return V.call(re,ie,ge++)}),le}function X(z){if(z._status===-1){var V=z._result;V=V(),V.then(function(re){(z._status===0||z._status===-1)&&(z._status=1,z._result=re)},function(re){(z._status===0||z._status===-1)&&(z._status=2,z._result=re)}),z._status===-1&&(z._status=0,z._result=V)}if(z._status===1)return z._result.default;throw z._result}var Y=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},ee={map:K,forEach:function(z,V,re){K(z,function(){V.apply(this,arguments)},re)},count:function(z){var V=0;return K(z,function(){V++}),V},toArray:function(z){return K(z,function(V){return V})||[]},only:function(z){if(!F(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return Yt.Activity=f,Yt.Children=ee,Yt.Component=x,Yt.Fragment=n,Yt.Profiler=r,Yt.PureComponent=w,Yt.StrictMode=i,Yt.Suspense=l,Yt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,Yt.__COMPILER_RUNTIME={__proto__:null,c:function(z){return A.H.useMemoCache(z)}},Yt.cache=function(z){return function(){return z.apply(null,arguments)}},Yt.cacheSignal=function(){return null},Yt.cloneElement=function(z,V,re){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var le=_({},z.props),ge=z.key;if(V!=null)for(ie in V.key!==void 0&&(ge=""+V.key),V)!j.call(V,ie)||ie==="key"||ie==="__self"||ie==="__source"||ie==="ref"&&V.ref===void 0||(le[ie]=V[ie]);var ie=arguments.length-2;if(ie===1)le.children=re;else if(1<ie){for(var xe=Array(ie),ke=0;ke<ie;ke++)xe[ke]=arguments[ke+2];le.children=xe}return N(z.type,ge,le)},Yt.createContext=function(z){return z={$$typeof:s,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:a,_context:z},z},Yt.createElement=function(z,V,re){var le,ge={},ie=null;if(V!=null)for(le in V.key!==void 0&&(ie=""+V.key),V)j.call(V,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(ge[le]=V[le]);var xe=arguments.length-2;if(xe===1)ge.children=re;else if(1<xe){for(var ke=Array(xe),he=0;he<xe;he++)ke[he]=arguments[he+2];ge.children=ke}if(z&&z.defaultProps)for(le in xe=z.defaultProps,xe)ge[le]===void 0&&(ge[le]=xe[le]);return N(z,ie,ge)},Yt.createRef=function(){return{current:null}},Yt.forwardRef=function(z){return{$$typeof:o,render:z}},Yt.isValidElement=F,Yt.lazy=function(z){return{$$typeof:u,_payload:{_status:-1,_result:z},_init:X}},Yt.memo=function(z,V){return{$$typeof:c,type:z,compare:V===void 0?null:V}},Yt.startTransition=function(z){var V=A.T,re={};A.T=re;try{var le=z(),ge=A.S;ge!==null&&ge(re,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(P,Y)}catch(ie){Y(ie)}finally{V!==null&&re.types!==null&&(V.types=re.types),A.T=V}},Yt.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},Yt.use=function(z){return A.H.use(z)},Yt.useActionState=function(z,V,re){return A.H.useActionState(z,V,re)},Yt.useCallback=function(z,V){return A.H.useCallback(z,V)},Yt.useContext=function(z){return A.H.useContext(z)},Yt.useDebugValue=function(){},Yt.useDeferredValue=function(z,V){return A.H.useDeferredValue(z,V)},Yt.useEffect=function(z,V){return A.H.useEffect(z,V)},Yt.useEffectEvent=function(z){return A.H.useEffectEvent(z)},Yt.useId=function(){return A.H.useId()},Yt.useImperativeHandle=function(z,V,re){return A.H.useImperativeHandle(z,V,re)},Yt.useInsertionEffect=function(z,V){return A.H.useInsertionEffect(z,V)},Yt.useLayoutEffect=function(z,V){return A.H.useLayoutEffect(z,V)},Yt.useMemo=function(z,V){return A.H.useMemo(z,V)},Yt.useOptimistic=function(z,V){return A.H.useOptimistic(z,V)},Yt.useReducer=function(z,V,re){return A.H.useReducer(z,V,re)},Yt.useRef=function(z){return A.H.useRef(z)},Yt.useState=function(z){return A.H.useState(z)},Yt.useSyncExternalStore=function(z,V,re){return A.H.useSyncExternalStore(z,V,re)},Yt.useTransition=function(){return A.H.useTransition()},Yt.version="19.2.0",Yt}var q4;function xm(){return q4||(q4=1,AA.exports=lne()),AA.exports}var E=xm();const ui=Ys(E),cne=ane({__proto__:null,default:ui},[E]);var TA={exports:{}},kg={},CA={exports:{}},NA={};var X4;function une(){return X4||(X4=1,(function(t){function e($,K){var X=$.length;$.push(K);e:for(;0<X;){var Y=X-1>>>1,ee=$[Y];if(0<r(ee,K))$[Y]=K,$[X]=ee,X=Y;else break e}}function n($){return $.length===0?null:$[0]}function i($){if($.length===0)return null;var K=$[0],X=$.pop();if(X!==K){$[0]=X;e:for(var Y=0,ee=$.length,z=ee>>>1;Y<z;){var V=2*(Y+1)-1,re=$[V],le=V+1,ge=$[le];if(0>r(re,X))le<ee&&0>r(ge,re)?($[Y]=ge,$[le]=X,Y=le):($[Y]=re,$[V]=X,Y=V);else if(le<ee&&0>r(ge,X))$[Y]=ge,$[le]=X,Y=le;else break e}}return K}function r($,K){var X=$.sortIndex-K.sortIndex;return X!==0?X:$.id-K.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=[],u=1,f=null,m=3,g=!1,y=!1,_=!1,v=!1,x=typeof setTimeout=="function"?setTimeout:null,M=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function C($){for(var K=n(c);K!==null;){if(K.callback===null)i(c);else if(K.startTime<=$)i(c),K.sortIndex=K.expirationTime,e(l,K);else break;K=n(c)}}function T($){if(_=!1,C($),!y)if(n(l)!==null)y=!0,P||(P=!0,I());else{var K=n(c);K!==null&&B(T,K.startTime-$)}}var P=!1,A=-1,j=5,N=-1;function k(){return v?!0:!(t.unstable_now()-N<j)}function F(){if(v=!1,P){var $=t.unstable_now();N=$;var K=!0;try{e:{y=!1,_&&(_=!1,M(A),A=-1),g=!0;var X=m;try{t:{for(C($),f=n(l);f!==null&&!(f.expirationTime>$&&k());){var Y=f.callback;if(typeof Y=="function"){f.callback=null,m=f.priorityLevel;var ee=Y(f.expirationTime<=$);if($=t.unstable_now(),typeof ee=="function"){f.callback=ee,C($),K=!0;break t}f===n(l)&&i(l),C($)}else i(l);f=n(l)}if(f!==null)K=!0;else{var z=n(c);z!==null&&B(T,z.startTime-$),K=!1}}break e}finally{f=null,m=X,g=!1}K=void 0}}finally{K?I():P=!1}}}var I;if(typeof w=="function")I=function(){w(F)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,D=W.port2;W.port1.onmessage=F,I=function(){D.postMessage(null)}}else I=function(){x(F,0)};function B($,K){A=x(function(){$(t.unstable_now())},K)}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($){$.callback=null},t.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<$?Math.floor(1e3/$):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_next=function($){switch(m){case 1:case 2:case 3:var K=3;break;default:K=m}var X=m;m=K;try{return $()}finally{m=X}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function($,K){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var X=m;m=$;try{return K()}finally{m=X}},t.unstable_scheduleCallback=function($,K,X){var Y=t.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?Y+X:Y):X=Y,$){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=X+ee,$={id:u++,callback:K,priorityLevel:$,startTime:X,expirationTime:ee,sortIndex:-1},X>Y?($.sortIndex=X,e(c,$),n(l)===null&&$===n(c)&&(_?(M(A),A=-1):_=!0,B(T,X-Y))):($.sortIndex=ee,e(l,$),y||g||(y=!0,P||(P=!0,I()))),$},t.unstable_shouldYield=k,t.unstable_wrapCallback=function($){var K=m;return function(){var X=m;m=K;try{return $.apply(this,arguments)}finally{m=X}}}})(NA)),NA}var K4;function dne(){return K4||(K4=1,CA.exports=une()),CA.exports}var RA={exports:{}},Xr={};var Y4;function fne(){if(Y4)return Xr;Y4=1;var t=xm();function e(l){var c="https://react.dev/errors/"+l;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)c+="&args[]="+encodeURIComponent(arguments[u])}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,u){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:u}}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 Xr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,Xr.createPortal=function(l,c){var u=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,u)},Xr.flushSync=function(l){var c=s.T,u=i.p;try{if(s.T=null,i.p=2,l)return l()}finally{s.T=c,i.p=u,i.d.f()}},Xr.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))},Xr.prefetchDNS=function(l){typeof l=="string"&&i.d.D(l)},Xr.preinit=function(l,c){if(typeof l=="string"&&c&&typeof c.as=="string"){var u=c.as,f=o(u,c.crossOrigin),m=typeof c.integrity=="string"?c.integrity:void 0,g=typeof c.fetchPriority=="string"?c.fetchPriority:void 0;u==="style"?i.d.S(l,typeof c.precedence=="string"?c.precedence:void 0,{crossOrigin:f,integrity:m,fetchPriority:g}):u==="script"&&i.d.X(l,{crossOrigin:f,integrity:m,fetchPriority:g,nonce:typeof c.nonce=="string"?c.nonce:void 0})}},Xr.preinitModule=function(l,c){if(typeof l=="string")if(typeof c=="object"&&c!==null){if(c.as==null||c.as==="script"){var u=o(c.as,c.crossOrigin);i.d.M(l,{crossOrigin:u,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)},Xr.preload=function(l,c){if(typeof l=="string"&&typeof c=="object"&&c!==null&&typeof c.as=="string"){var u=c.as,f=o(u,c.crossOrigin);i.d.L(l,u,{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})}},Xr.preloadModule=function(l,c){if(typeof l=="string")if(c){var u=o(c.as,c.crossOrigin);i.d.m(l,{as:typeof c.as=="string"&&c.as!=="script"?c.as:void 0,crossOrigin:u,integrity:typeof c.integrity=="string"?c.integrity:void 0})}else i.d.m(l)},Xr.requestFormReset=function(l){i.d.r(l)},Xr.unstable_batchedUpdates=function(l,c){return l(c)},Xr.useFormState=function(l,c,u){return s.H.useFormState(l,c,u)},Xr.useFormStatus=function(){return s.H.useHostTransitionStatus()},Xr.version="19.2.0",Xr}var Z4;function sG(){if(Z4)return RA.exports;Z4=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(),RA.exports=fne(),RA.exports}var Q4;function hne(){if(Q4)return kg;Q4=1;var t=dne(),e=xm(),n=sG();function i(d){var p="https://react.dev/errors/"+d;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var b=2;b<arguments.length;b++)p+="&args[]="+encodeURIComponent(arguments[b])}return"Minified React error #"+d+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(d){return!(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)}function a(d){var p=d,b=d;if(d.alternate)for(;p.return;)p=p.return;else{d=p;do p=d,(p.flags&4098)!==0&&(b=p.return),d=p.return;while(d)}return p.tag===3?b:null}function s(d){if(d.tag===13){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function o(d){if(d.tag===31){var p=d.memoizedState;if(p===null&&(d=d.alternate,d!==null&&(p=d.memoizedState)),p!==null)return p.dehydrated}return null}function l(d){if(a(d)!==d)throw Error(i(188))}function c(d){var p=d.alternate;if(!p){if(p=a(d),p===null)throw Error(i(188));return p!==d?null:d}for(var b=d,S=p;;){var R=b.return;if(R===null)break;var O=R.alternate;if(O===null){if(S=R.return,S!==null){b=S;continue}break}if(R.child===O.child){for(O=R.child;O;){if(O===b)return l(R),d;if(O===S)return l(R),p;O=O.sibling}throw Error(i(188))}if(b.return!==S.return)b=R,S=O;else{for(var G=!1,ae=R.child;ae;){if(ae===b){G=!0,b=R,S=O;break}if(ae===S){G=!0,S=R,b=O;break}ae=ae.sibling}if(!G){for(ae=O.child;ae;){if(ae===b){G=!0,b=O,S=R;break}if(ae===S){G=!0,S=O,b=R;break}ae=ae.sibling}if(!G)throw Error(i(189))}}if(b.alternate!==S)throw Error(i(190))}if(b.tag!==3)throw Error(i(188));return b.stateNode.current===b?d:p}function u(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d;for(d=d.child;d!==null;){if(p=u(d),p!==null)return p;d=d.sibling}return null}var f=Object.assign,m=Symbol.for("react.element"),g=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),_=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"),C=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),k=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function I(d){return d===null||typeof d!="object"?null:(d=F&&d[F]||d["@@iterator"],typeof d=="function"?d:null)}var W=Symbol.for("react.client.reference");function D(d){if(d==null)return null;if(typeof d=="function")return d.$$typeof===W?null:d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case _:return"Fragment";case x:return"Profiler";case v:return"StrictMode";case T:return"Suspense";case P:return"SuspenseList";case N:return"Activity"}if(typeof d=="object")switch(d.$$typeof){case y:return"Portal";case w:return d.displayName||"Context";case M:return(d._context.displayName||"Context")+".Consumer";case C:var p=d.render;return d=d.displayName,d||(d=p.displayName||p.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case A:return p=d.displayName||null,p!==null?p:D(d.type)||"Memo";case j:p=d._payload,d=d._init;try{return D(d(p))}catch{}}return null}var B=Array.isArray,$=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},Y=[],ee=-1;function z(d){return{current:d}}function V(d){0>ee||(d.current=Y[ee],Y[ee]=null,ee--)}function re(d,p){ee++,Y[ee]=d.current,d.current=p}var le=z(null),ge=z(null),ie=z(null),xe=z(null);function ke(d,p){switch(re(ie,p),re(ge,d),re(le,null),p.nodeType){case 9:case 11:d=(d=p.documentElement)&&(d=d.namespaceURI)?h4(d):0;break;default:if(d=p.tagName,p=p.namespaceURI)p=h4(p),d=p4(p,d);else switch(d){case"svg":d=1;break;case"math":d=2;break;default:d=0}}V(le),re(le,d)}function he(){V(le),V(ge),V(ie)}function we(d){d.memoizedState!==null&&re(xe,d);var p=le.current,b=p4(p,d.type);p!==b&&(re(ge,d),re(le,b))}function Ue(d){ge.current===d&&(V(le),V(ge)),xe.current===d&&(V(xe),Tg._currentValue=X)}var ue,lt;function H(d){if(ue===void 0)try{throw Error()}catch(b){var p=b.stack.trim().match(/\n( *(at )?)/);ue=p&&p[1]||"",lt=-1<b.stack.indexOf(`
- at`)?" (<anonymous>)":-1<b.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ue+d+lt}var q=!1;function oe(d,p){if(!d||q)return"";q=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var S={DetermineComponentFrameRoot:function(){try{if(p){var ot=function(){throw Error()};if(Object.defineProperty(ot.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ot,[])}catch(Ze){var Ve=Ze}Reflect.construct(d,[],ot)}else{try{ot.call()}catch(Ze){Ve=Ze}d.call(ot.prototype)}}else{try{throw Error()}catch(Ze){Ve=Ze}(ot=d())&&typeof ot.catch=="function"&&ot.catch(function(){})}}catch(Ze){if(Ze&&Ve&&typeof Ze.stack=="string")return[Ze.stack,Ve.stack]}return[null,null]}};S.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var R=Object.getOwnPropertyDescriptor(S.DetermineComponentFrameRoot,"name");R&&R.configurable&&Object.defineProperty(S.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=S.DetermineComponentFrameRoot(),G=O[0],ae=O[1];if(G&&ae){var _e=G.split(`
- `),ze=ae.split(`
- `);for(R=S=0;S<_e.length&&!_e[S].includes("DetermineComponentFrameRoot");)S++;for(;R<ze.length&&!ze[R].includes("DetermineComponentFrameRoot");)R++;if(S===_e.length||R===ze.length)for(S=_e.length-1,R=ze.length-1;1<=S&&0<=R&&_e[S]!==ze[R];)R--;for(;1<=S&&0<=R;S--,R--)if(_e[S]!==ze[R]){if(S!==1||R!==1)do if(S--,R--,0>R||_e[S]!==ze[R]){var et=`
- `+_e[S].replace(" at new "," at ");return d.displayName&&et.includes("<anonymous>")&&(et=et.replace("<anonymous>",d.displayName)),et}while(1<=S&&0<=R);break}}}finally{q=!1,Error.prepareStackTrace=b}return(b=d?d.displayName||d.name:"")?H(b):""}function Z(d,p){switch(d.tag){case 26:case 27:case 5:return H(d.type);case 16:return H("Lazy");case 13:return d.child!==p&&p!==null?H("Suspense Fallback"):H("Suspense");case 19:return H("SuspenseList");case 0:case 15:return oe(d.type,!1);case 11:return oe(d.type.render,!1);case 1:return oe(d.type,!0);case 31:return H("Activity");default:return""}}function Q(d){try{var p="",b=null;do p+=Z(d,b),b=d,d=d.return;while(d);return p}catch(S){return`
- Error generating stack: `+S.message+`
- `+S.stack}}var se=Object.prototype.hasOwnProperty,Ce=t.unstable_scheduleCallback,Ee=t.unstable_cancelCallback,ne=t.unstable_shouldYield,U=t.unstable_requestPaint,L=t.unstable_now,J=t.unstable_getCurrentPriorityLevel,me=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,pe=t.unstable_NormalPriority,Qe=t.unstable_LowPriority,Le=t.unstable_IdlePriority,Xe=t.log,st=t.unstable_setDisableYieldValue,Ie=null,Pe=null;function pt(d){if(typeof Xe=="function"&&st(d),Pe&&typeof Pe.setStrictMode=="function")try{Pe.setStrictMode(Ie,d)}catch{}}var it=Math.clz32?Math.clz32:de,nt=Math.log,dt=Math.LN2;function de(d){return d>>>=0,d===0?32:31-(nt(d)/dt|0)|0}var rt=256,fe=262144,Oe=4194304;function Me(d){var p=d&42;if(p!==0)return p;switch(d&-d){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 d&261888;case 262144:case 524288:case 1048576:case 2097152:return d&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return d&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return d}}function ve(d,p,b){var S=d.pendingLanes;if(S===0)return 0;var R=0,O=d.suspendedLanes,G=d.pingedLanes;d=d.warmLanes;var ae=S&134217727;return ae!==0?(S=ae&~O,S!==0?R=Me(S):(G&=ae,G!==0?R=Me(G):b||(b=ae&~d,b!==0&&(R=Me(b))))):(ae=S&~O,ae!==0?R=Me(ae):G!==0?R=Me(G):b||(b=S&~d,b!==0&&(R=Me(b)))),R===0?0:p!==0&&p!==R&&(p&O)===0&&(O=R&-R,b=p&-p,O>=b||O===32&&(b&4194048)!==0)?p:R}function Be(d,p){return(d.pendingLanes&~(d.suspendedLanes&~d.pingedLanes)&p)===0}function ct(d,p){switch(d){case 1:case 2:case 4:case 8:case 64:return p+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 p+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 d=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),d}function Rt(d){for(var p=[],b=0;31>b;b++)p.push(d);return p}function ln(d,p){d.pendingLanes|=p,p!==268435456&&(d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0)}function Ot(d,p,b,S,R,O){var G=d.pendingLanes;d.pendingLanes=b,d.suspendedLanes=0,d.pingedLanes=0,d.warmLanes=0,d.expiredLanes&=b,d.entangledLanes&=b,d.errorRecoveryDisabledLanes&=b,d.shellSuspendCounter=0;var ae=d.entanglements,_e=d.expirationTimes,ze=d.hiddenUpdates;for(b=G&~b;0<b;){var et=31-it(b),ot=1<<et;ae[et]=0,_e[et]=-1;var Ve=ze[et];if(Ve!==null)for(ze[et]=null,et=0;et<Ve.length;et++){var Ze=Ve[et];Ze!==null&&(Ze.lane&=-536870913)}b&=~ot}S!==0&&Rn(d,S,0),O!==0&&R===0&&d.tag!==0&&(d.suspendedLanes|=O&~(G&~p))}function Rn(d,p,b){d.pendingLanes|=p,d.suspendedLanes&=~p;var S=31-it(p);d.entangledLanes|=p,d.entanglements[S]=d.entanglements[S]|1073741824|b&261930}function qn(d,p){var b=d.entangledLanes|=p;for(d=d.entanglements;b;){var S=31-it(b),R=1<<S;R&p|d[S]&p&&(d[S]|=p),b&=~R}}function mr(d,p){var b=p&-p;return b=(b&42)!==0?1:Qi(b),(b&(d.suspendedLanes|p))!==0?0:b}function Qi(d){switch(d){case 2:d=1;break;case 8:d=4;break;case 32:d=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:d=128;break;case 268435456:d=134217728;break;default:d=0}return d}function gr(d){return d&=-d,2<d?8<d?(d&134217727)!==0?32:268435456:8:2}function Pr(){var d=K.p;return d!==0?d:(d=window.event,d===void 0?32:j4(d.type))}function qr(d,p){var b=K.p;try{return K.p=d,p()}finally{K.p=b}}var Ii=Math.random().toString(36).slice(2),hi="__reactFiber$"+Ii,Ti="__reactProps$"+Ii,Qs="__reactContainer$"+Ii,Oc="__reactEvents$"+Ii,ce="__reactListeners$"+Ii,je="__reactHandles$"+Ii,qe="__reactResources$"+Ii,Ke="__reactMarker$"+Ii;function We(d){delete d[hi],delete d[Ti],delete d[Oc],delete d[ce],delete d[je]}function _t(d){var p=d[hi];if(p)return p;for(var b=d.parentNode;b;){if(p=b[Qs]||b[hi]){if(b=p.alternate,p.child!==null||b!==null&&b.child!==null)for(d=_4(d);d!==null;){if(b=d[hi])return b;d=_4(d)}return p}d=b,b=d.parentNode}return null}function te(d){if(d=d[hi]||d[Qs]){var p=d.tag;if(p===5||p===6||p===13||p===31||p===26||p===27||p===3)return d}return null}function be(d){var p=d.tag;if(p===5||p===26||p===27||p===6)return d.stateNode;throw Error(i(33))}function Re(d){var p=d[qe];return p||(p=d[qe]={hoistableStyles:new Map,hoistableScripts:new Map}),p}function Ne(d){d[Ke]=!0}var Se=new Set,Je={};function ft(d,p){vt(d,p),vt(d+"Capture",p)}function vt(d,p){for(Je[d]=p,d=0;d<p.length;d++)Se.add(p[d])}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]*$"),Pt={},wt={};function mt(d){return se.call(wt,d)?!0:se.call(Pt,d)?!1:xt.test(d)?wt[d]=!0:(Pt[d]=!0,!1)}function Wt(d,p,b){if(mt(p))if(b===null)d.removeAttribute(p);else{switch(typeof b){case"undefined":case"function":case"symbol":d.removeAttribute(p);return;case"boolean":var S=p.toLowerCase().slice(0,5);if(S!=="data-"&&S!=="aria-"){d.removeAttribute(p);return}}d.setAttribute(p,""+b)}}function It(d,p,b){if(b===null)d.removeAttribute(p);else{switch(typeof b){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(p);return}d.setAttribute(p,""+b)}}function tn(d,p,b,S){if(S===null)d.removeAttribute(b);else{switch(typeof S){case"undefined":case"function":case"symbol":case"boolean":d.removeAttribute(b);return}d.setAttributeNS(p,b,""+S)}}function un(d){switch(typeof d){case"bigint":case"boolean":case"number":case"string":case"undefined":return d;case"object":return d;default:return""}}function mn(d){var p=d.type;return(d=d.nodeName)&&d.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Lt(d,p,b){var S=Object.getOwnPropertyDescriptor(d.constructor.prototype,p);if(!d.hasOwnProperty(p)&&typeof S<"u"&&typeof S.get=="function"&&typeof S.set=="function"){var R=S.get,O=S.set;return Object.defineProperty(d,p,{configurable:!0,get:function(){return R.call(this)},set:function(G){b=""+G,O.call(this,G)}}),Object.defineProperty(d,p,{enumerable:S.enumerable}),{getValue:function(){return b},setValue:function(G){b=""+G},stopTracking:function(){d._valueTracker=null,delete d[p]}}}}function Kt(d){if(!d._valueTracker){var p=mn(d)?"checked":"value";d._valueTracker=Lt(d,p,""+d[p])}}function Zt(d){if(!d)return!1;var p=d._valueTracker;if(!p)return!0;var b=p.getValue(),S="";return d&&(S=mn(d)?d.checked?"true":"false":d.value),d=S,d!==b?(p.setValue(d),!0):!1}function yi(d){if(d=d||(typeof document<"u"?document:void 0),typeof d>"u")return null;try{return d.activeElement||d.body}catch{return d.body}}var Ci=/[\n"\\]/g;function Nn(d){return d.replace(Ci,function(p){return"\\"+p.charCodeAt(0).toString(16)+" "})}function Js(d,p,b,S,R,O,G,ae){d.name="",G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"?d.type=G:d.removeAttribute("type"),p!=null?G==="number"?(p===0&&d.value===""||d.value!=p)&&(d.value=""+un(p)):d.value!==""+un(p)&&(d.value=""+un(p)):G!=="submit"&&G!=="reset"||d.removeAttribute("value"),p!=null?xr(d,G,un(p)):b!=null?xr(d,G,un(b)):S!=null&&d.removeAttribute("value"),R==null&&O!=null&&(d.defaultChecked=!!O),R!=null&&(d.checked=R&&typeof R!="function"&&typeof R!="symbol"),ae!=null&&typeof ae!="function"&&typeof ae!="symbol"&&typeof ae!="boolean"?d.name=""+un(ae):d.removeAttribute("name")}function Pn(d,p,b,S,R,O,G,ae){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(d.type=O),p!=null||b!=null){if(!(O!=="submit"&&O!=="reset"||p!=null)){Kt(d);return}b=b!=null?""+un(b):"",p=p!=null?""+un(p):b,ae||p===d.value||(d.value=p),d.defaultValue=p}S=S??R,S=typeof S!="function"&&typeof S!="symbol"&&!!S,d.checked=ae?d.checked:!!S,d.defaultChecked=!!S,G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"&&(d.name=G),Kt(d)}function xr(d,p,b){p==="number"&&yi(d.ownerDocument)===d||d.defaultValue===""+b||(d.defaultValue=""+b)}function Ji(d,p,b,S){if(d=d.options,p){p={};for(var R=0;R<b.length;R++)p["$"+b[R]]=!0;for(b=0;b<d.length;b++)R=p.hasOwnProperty("$"+d[b].value),d[b].selected!==R&&(d[b].selected=R),R&&S&&(d[b].defaultSelected=!0)}else{for(b=""+un(b),p=null,R=0;R<d.length;R++){if(d[R].value===b){d[R].selected=!0,S&&(d[R].defaultSelected=!0);return}p!==null||d[R].disabled||(p=d[R])}p!==null&&(p.selected=!0)}}function vr(d,p,b){if(p!=null&&(p=""+un(p),p!==d.value&&(d.value=p),b==null)){d.defaultValue!==p&&(d.defaultValue=p);return}d.defaultValue=b!=null?""+un(b):""}function kr(d,p,b,S){if(p==null){if(S!=null){if(b!=null)throw Error(i(92));if(B(S)){if(1<S.length)throw Error(i(93));S=S[0]}b=S}b==null&&(b=""),p=b}b=un(p),d.defaultValue=b,S=d.textContent,S===b&&S!==""&&S!==null&&(d.value=S),Kt(d)}function No(d,p){if(p){var b=d.firstChild;if(b&&b===d.lastChild&&b.nodeType===3){b.nodeValue=p;return}}d.textContent=p}var ul=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 uL(d,p,b){var S=p.indexOf("--")===0;b==null||typeof b=="boolean"||b===""?S?d.setProperty(p,""):p==="float"?d.cssFloat="":d[p]="":S?d.setProperty(p,b):typeof b!="number"||b===0||ul.has(p)?p==="float"?d.cssFloat=b:d[p]=(""+b).trim():d[p]=b+"px"}function dL(d,p,b){if(p!=null&&typeof p!="object")throw Error(i(62));if(d=d.style,b!=null){for(var S in b)!b.hasOwnProperty(S)||p!=null&&p.hasOwnProperty(S)||(S.indexOf("--")===0?d.setProperty(S,""):S==="float"?d.cssFloat="":d[S]="");for(var R in p)S=p[R],p.hasOwnProperty(R)&&b[R]!==S&&uL(d,R,S)}else for(var O in p)p.hasOwnProperty(O)&&uL(d,O,p[O])}function _M(d){if(d.indexOf("-")===-1)return!1;switch(d){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 tee=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"]]),nee=/^[\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 _v(d){return nee.test(""+d)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":d}function dl(){}var SM=null;function wM(d){return d=d.target||d.srcElement||window,d.correspondingUseElement&&(d=d.correspondingUseElement),d.nodeType===3?d.parentNode:d}var qf=null,Xf=null;function fL(d){var p=te(d);if(p&&(d=p.stateNode)){var b=d[Ti]||null;e:switch(d=p.stateNode,p.type){case"input":if(Js(d,b.value,b.defaultValue,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name),p=b.name,b.type==="radio"&&p!=null){for(b=d;b.parentNode;)b=b.parentNode;for(b=b.querySelectorAll('input[name="'+Nn(""+p)+'"][type="radio"]'),p=0;p<b.length;p++){var S=b[p];if(S!==d&&S.form===d.form){var R=S[Ti]||null;if(!R)throw Error(i(90));Js(S,R.value,R.defaultValue,R.defaultValue,R.checked,R.defaultChecked,R.type,R.name)}}for(p=0;p<b.length;p++)S=b[p],S.form===d.form&&Zt(S)}break e;case"textarea":vr(d,b.value,b.defaultValue);break e;case"select":p=b.value,p!=null&&Ji(d,!!b.multiple,p,!1)}}}var MM=!1;function hL(d,p,b){if(MM)return d(p,b);MM=!0;try{var S=d(p);return S}finally{if(MM=!1,(qf!==null||Xf!==null)&&(ly(),qf&&(p=qf,d=Xf,Xf=qf=null,fL(p),d)))for(p=0;p<d.length;p++)fL(d[p])}}function Vm(d,p){var b=d.stateNode;if(b===null)return null;var S=b[Ti]||null;if(S===null)return null;b=S[p];e:switch(p){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)||(d=d.type,S=!(d==="button"||d==="input"||d==="select"||d==="textarea")),d=!S;break e;default:d=!1}if(d)return null;if(b&&typeof b!="function")throw Error(i(231,p,typeof b));return b}var fl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),EM=!1;if(fl)try{var Gm={};Object.defineProperty(Gm,"passive",{get:function(){EM=!0}}),window.addEventListener("test",Gm,Gm),window.removeEventListener("test",Gm,Gm)}catch{EM=!1}var Lc=null,AM=null,Sv=null;function pL(){if(Sv)return Sv;var d,p=AM,b=p.length,S,R="value"in Lc?Lc.value:Lc.textContent,O=R.length;for(d=0;d<b&&p[d]===R[d];d++);var G=b-d;for(S=1;S<=G&&p[b-S]===R[O-S];S++);return Sv=R.slice(d,1<S?1-S:void 0)}function wv(d){var p=d.keyCode;return"charCode"in d?(d=d.charCode,d===0&&p===13&&(d=13)):d=p,d===10&&(d=13),32<=d||d===13?d:0}function Mv(){return!0}function mL(){return!1}function Ma(d){function p(b,S,R,O,G){this._reactName=b,this._targetInst=R,this.type=S,this.nativeEvent=O,this.target=G,this.currentTarget=null;for(var ae in d)d.hasOwnProperty(ae)&&(b=d[ae],this[ae]=b?b(O):O[ae]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Mv:mL,this.isPropagationStopped=mL,this}return f(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var b=this.nativeEvent;b&&(b.preventDefault?b.preventDefault():typeof b.returnValue!="unknown"&&(b.returnValue=!1),this.isDefaultPrevented=Mv)},stopPropagation:function(){var b=this.nativeEvent;b&&(b.stopPropagation?b.stopPropagation():typeof b.cancelBubble!="unknown"&&(b.cancelBubble=!0),this.isPropagationStopped=Mv)},persist:function(){},isPersistent:Mv}),p}var dd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(d){return d.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ev=Ma(dd),Wm=f({},dd,{view:0,detail:0}),iee=Ma(Wm),TM,CM,qm,Av=f({},Wm,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:RM,button:0,buttons:0,relatedTarget:function(d){return d.relatedTarget===void 0?d.fromElement===d.srcElement?d.toElement:d.fromElement:d.relatedTarget},movementX:function(d){return"movementX"in d?d.movementX:(d!==qm&&(qm&&d.type==="mousemove"?(TM=d.screenX-qm.screenX,CM=d.screenY-qm.screenY):CM=TM=0,qm=d),TM)},movementY:function(d){return"movementY"in d?d.movementY:CM}}),gL=Ma(Av),ree=f({},Av,{dataTransfer:0}),aee=Ma(ree),see=f({},Wm,{relatedTarget:0}),NM=Ma(see),oee=f({},dd,{animationName:0,elapsedTime:0,pseudoElement:0}),lee=Ma(oee),cee=f({},dd,{clipboardData:function(d){return"clipboardData"in d?d.clipboardData:window.clipboardData}}),uee=Ma(cee),dee=f({},dd,{data:0}),xL=Ma(dee),fee={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hee={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"},pee={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mee(d){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(d):(d=pee[d])?!!p[d]:!1}function RM(){return mee}var gee=f({},Wm,{key:function(d){if(d.key){var p=fee[d.key]||d.key;if(p!=="Unidentified")return p}return d.type==="keypress"?(d=wv(d),d===13?"Enter":String.fromCharCode(d)):d.type==="keydown"||d.type==="keyup"?hee[d.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:RM,charCode:function(d){return d.type==="keypress"?wv(d):0},keyCode:function(d){return d.type==="keydown"||d.type==="keyup"?d.keyCode:0},which:function(d){return d.type==="keypress"?wv(d):d.type==="keydown"||d.type==="keyup"?d.keyCode:0}}),xee=Ma(gee),vee=f({},Av,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),vL=Ma(vee),yee=f({},Wm,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:RM}),bee=Ma(yee),_ee=f({},dd,{propertyName:0,elapsedTime:0,pseudoElement:0}),See=Ma(_ee),wee=f({},Av,{deltaX:function(d){return"deltaX"in d?d.deltaX:"wheelDeltaX"in d?-d.wheelDeltaX:0},deltaY:function(d){return"deltaY"in d?d.deltaY:"wheelDeltaY"in d?-d.wheelDeltaY:"wheelDelta"in d?-d.wheelDelta:0},deltaZ:0,deltaMode:0}),Mee=Ma(wee),Eee=f({},dd,{newState:0,oldState:0}),Aee=Ma(Eee),Tee=[9,13,27,32],PM=fl&&"CompositionEvent"in window,Xm=null;fl&&"documentMode"in document&&(Xm=document.documentMode);var Cee=fl&&"TextEvent"in window&&!Xm,yL=fl&&(!PM||Xm&&8<Xm&&11>=Xm),bL=" ",_L=!1;function SL(d,p){switch(d){case"keyup":return Tee.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wL(d){return d=d.detail,typeof d=="object"&&"data"in d?d.data:null}var Kf=!1;function Nee(d,p){switch(d){case"compositionend":return wL(p);case"keypress":return p.which!==32?null:(_L=!0,bL);case"textInput":return d=p.data,d===bL&&_L?null:d;default:return null}}function Ree(d,p){if(Kf)return d==="compositionend"||!PM&&SL(d,p)?(d=pL(),Sv=AM=Lc=null,Kf=!1,d):null;switch(d){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return yL&&p.locale!=="ko"?null:p.data;default:return null}}var Pee={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 ML(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p==="input"?!!Pee[d.type]:p==="textarea"}function EL(d,p,b,S){qf?Xf?Xf.push(S):Xf=[S]:qf=S,p=my(p,"onChange"),0<p.length&&(b=new Ev("onChange","change",null,b,S),d.push({event:b,listeners:p}))}var Km=null,Ym=null;function kee(d){o4(d,0)}function Tv(d){var p=be(d);if(Zt(p))return d}function AL(d,p){if(d==="change")return p}var TL=!1;if(fl){var kM;if(fl){var DM="oninput"in document;if(!DM){var CL=document.createElement("div");CL.setAttribute("oninput","return;"),DM=typeof CL.oninput=="function"}kM=DM}else kM=!1;TL=kM&&(!document.documentMode||9<document.documentMode)}function NL(){Km&&(Km.detachEvent("onpropertychange",RL),Ym=Km=null)}function RL(d){if(d.propertyName==="value"&&Tv(Ym)){var p=[];EL(p,Ym,d,wM(d)),hL(kee,p)}}function Dee(d,p,b){d==="focusin"?(NL(),Km=p,Ym=b,Km.attachEvent("onpropertychange",RL)):d==="focusout"&&NL()}function Oee(d){if(d==="selectionchange"||d==="keyup"||d==="keydown")return Tv(Ym)}function Lee(d,p){if(d==="click")return Tv(p)}function Iee(d,p){if(d==="input"||d==="change")return Tv(p)}function jee(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var Wa=typeof Object.is=="function"?Object.is:jee;function Zm(d,p){if(Wa(d,p))return!0;if(typeof d!="object"||d===null||typeof p!="object"||p===null)return!1;var b=Object.keys(d),S=Object.keys(p);if(b.length!==S.length)return!1;for(S=0;S<b.length;S++){var R=b[S];if(!se.call(p,R)||!Wa(d[R],p[R]))return!1}return!0}function PL(d){for(;d&&d.firstChild;)d=d.firstChild;return d}function kL(d,p){var b=PL(d);d=0;for(var S;b;){if(b.nodeType===3){if(S=d+b.textContent.length,d<=p&&S>=p)return{node:b,offset:p-d};d=S}e:{for(;b;){if(b.nextSibling){b=b.nextSibling;break e}b=b.parentNode}b=void 0}b=PL(b)}}function DL(d,p){return d&&p?d===p?!0:d&&d.nodeType===3?!1:p&&p.nodeType===3?DL(d,p.parentNode):"contains"in d?d.contains(p):d.compareDocumentPosition?!!(d.compareDocumentPosition(p)&16):!1:!1}function OL(d){d=d!=null&&d.ownerDocument!=null&&d.ownerDocument.defaultView!=null?d.ownerDocument.defaultView:window;for(var p=yi(d.document);p instanceof d.HTMLIFrameElement;){try{var b=typeof p.contentWindow.location.href=="string"}catch{b=!1}if(b)d=p.contentWindow;else break;p=yi(d.document)}return p}function OM(d){var p=d&&d.nodeName&&d.nodeName.toLowerCase();return p&&(p==="input"&&(d.type==="text"||d.type==="search"||d.type==="tel"||d.type==="url"||d.type==="password")||p==="textarea"||d.contentEditable==="true")}var Uee=fl&&"documentMode"in document&&11>=document.documentMode,Yf=null,LM=null,Qm=null,IM=!1;function LL(d,p,b){var S=b.window===b?b.document:b.nodeType===9?b:b.ownerDocument;IM||Yf==null||Yf!==yi(S)||(S=Yf,"selectionStart"in S&&OM(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}),Qm&&Zm(Qm,S)||(Qm=S,S=my(LM,"onSelect"),0<S.length&&(p=new Ev("onSelect","select",null,p,b),d.push({event:p,listeners:S}),p.target=Yf)))}function fd(d,p){var b={};return b[d.toLowerCase()]=p.toLowerCase(),b["Webkit"+d]="webkit"+p,b["Moz"+d]="moz"+p,b}var Zf={animationend:fd("Animation","AnimationEnd"),animationiteration:fd("Animation","AnimationIteration"),animationstart:fd("Animation","AnimationStart"),transitionrun:fd("Transition","TransitionRun"),transitionstart:fd("Transition","TransitionStart"),transitioncancel:fd("Transition","TransitionCancel"),transitionend:fd("Transition","TransitionEnd")},jM={},IL={};fl&&(IL=document.createElement("div").style,"AnimationEvent"in window||(delete Zf.animationend.animation,delete Zf.animationiteration.animation,delete Zf.animationstart.animation),"TransitionEvent"in window||delete Zf.transitionend.transition);function hd(d){if(jM[d])return jM[d];if(!Zf[d])return d;var p=Zf[d],b;for(b in p)if(p.hasOwnProperty(b)&&b in IL)return jM[d]=p[b];return d}var jL=hd("animationend"),UL=hd("animationiteration"),FL=hd("animationstart"),Fee=hd("transitionrun"),zee=hd("transitionstart"),Bee=hd("transitioncancel"),zL=hd("transitionend"),BL=new Map,UM="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(" ");UM.push("scrollEnd");function eo(d,p){BL.set(d,p),ft(p,[d])}var Cv=typeof reportError=="function"?reportError:function(d){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var p=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof d=="object"&&d!==null&&typeof d.message=="string"?String(d.message):String(d),error:d});if(!window.dispatchEvent(p))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",d);return}console.error(d)},gs=[],Qf=0,FM=0;function Nv(){for(var d=Qf,p=FM=Qf=0;p<d;){var b=gs[p];gs[p++]=null;var S=gs[p];gs[p++]=null;var R=gs[p];gs[p++]=null;var O=gs[p];if(gs[p++]=null,S!==null&&R!==null){var G=S.pending;G===null?R.next=R:(R.next=G.next,G.next=R),S.pending=R}O!==0&&HL(b,R,O)}}function Rv(d,p,b,S){gs[Qf++]=d,gs[Qf++]=p,gs[Qf++]=b,gs[Qf++]=S,FM|=S,d.lanes|=S,d=d.alternate,d!==null&&(d.lanes|=S)}function zM(d,p,b,S){return Rv(d,p,b,S),Pv(d)}function pd(d,p){return Rv(d,null,null,p),Pv(d)}function HL(d,p,b){d.lanes|=b;var S=d.alternate;S!==null&&(S.lanes|=b);for(var R=!1,O=d.return;O!==null;)O.childLanes|=b,S=O.alternate,S!==null&&(S.childLanes|=b),O.tag===22&&(d=O.stateNode,d===null||d._visibility&1||(R=!0)),d=O,O=O.return;return d.tag===3?(O=d.stateNode,R&&p!==null&&(R=31-it(b),d=O.hiddenUpdates,S=d[R],S===null?d[R]=[p]:S.push(p),p.lane=b|536870912),O):null}function Pv(d){if(50<bg)throw bg=0,KE=null,Error(i(185));for(var p=d.return;p!==null;)d=p,p=d.return;return d.tag===3?d.stateNode:null}var Jf={};function Hee(d,p,b,S){this.tag=d,this.key=b,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=p,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 qa(d,p,b,S){return new Hee(d,p,b,S)}function BM(d){return d=d.prototype,!(!d||!d.isReactComponent)}function hl(d,p){var b=d.alternate;return b===null?(b=qa(d.tag,p,d.key,d.mode),b.elementType=d.elementType,b.type=d.type,b.stateNode=d.stateNode,b.alternate=d,d.alternate=b):(b.pendingProps=p,b.type=d.type,b.flags=0,b.subtreeFlags=0,b.deletions=null),b.flags=d.flags&65011712,b.childLanes=d.childLanes,b.lanes=d.lanes,b.child=d.child,b.memoizedProps=d.memoizedProps,b.memoizedState=d.memoizedState,b.updateQueue=d.updateQueue,p=d.dependencies,b.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},b.sibling=d.sibling,b.index=d.index,b.ref=d.ref,b.refCleanup=d.refCleanup,b}function $L(d,p){d.flags&=65011714;var b=d.alternate;return b===null?(d.childLanes=0,d.lanes=p,d.child=null,d.subtreeFlags=0,d.memoizedProps=null,d.memoizedState=null,d.updateQueue=null,d.dependencies=null,d.stateNode=null):(d.childLanes=b.childLanes,d.lanes=b.lanes,d.child=b.child,d.subtreeFlags=0,d.deletions=null,d.memoizedProps=b.memoizedProps,d.memoizedState=b.memoizedState,d.updateQueue=b.updateQueue,d.type=b.type,p=b.dependencies,d.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),d}function kv(d,p,b,S,R,O){var G=0;if(S=d,typeof d=="function")BM(d)&&(G=1);else if(typeof d=="string")G=qte(d,b,le.current)?26:d==="html"||d==="head"||d==="body"?27:5;else e:switch(d){case N:return d=qa(31,b,p,R),d.elementType=N,d.lanes=O,d;case _:return md(b.children,R,O,p);case v:G=8,R|=24;break;case x:return d=qa(12,b,p,R|2),d.elementType=x,d.lanes=O,d;case T:return d=qa(13,b,p,R),d.elementType=T,d.lanes=O,d;case P:return d=qa(19,b,p,R),d.elementType=P,d.lanes=O,d;default:if(typeof d=="object"&&d!==null)switch(d.$$typeof){case w:G=10;break e;case M:G=9;break e;case C:G=11;break e;case A:G=14;break e;case j:G=16,S=null;break e}G=29,b=Error(i(130,d===null?"null":typeof d,"")),S=null}return p=qa(G,b,p,R),p.elementType=d,p.type=S,p.lanes=O,p}function md(d,p,b,S){return d=qa(7,d,S,p),d.lanes=b,d}function HM(d,p,b){return d=qa(6,d,null,p),d.lanes=b,d}function VL(d){var p=qa(18,null,null,0);return p.stateNode=d,p}function $M(d,p,b){return p=qa(4,d.children!==null?d.children:[],d.key,p),p.lanes=b,p.stateNode={containerInfo:d.containerInfo,pendingChildren:null,implementation:d.implementation},p}var GL=new WeakMap;function xs(d,p){if(typeof d=="object"&&d!==null){var b=GL.get(d);return b!==void 0?b:(p={value:d,source:p,stack:Q(p)},GL.set(d,p),p)}return{value:d,source:p,stack:Q(p)}}var eh=[],th=0,Dv=null,Jm=0,vs=[],ys=0,Ic=null,Ro=1,Po="";function pl(d,p){eh[th++]=Jm,eh[th++]=Dv,Dv=d,Jm=p}function WL(d,p,b){vs[ys++]=Ro,vs[ys++]=Po,vs[ys++]=Ic,Ic=d;var S=Ro;d=Po;var R=32-it(S)-1;S&=~(1<<R),b+=1;var O=32-it(p)+R;if(30<O){var G=R-R%5;O=(S&(1<<G)-1).toString(32),S>>=G,R-=G,Ro=1<<32-it(p)+R|b<<R|S,Po=O+d}else Ro=1<<O|b<<R|S,Po=d}function VM(d){d.return!==null&&(pl(d,1),WL(d,1,0))}function GM(d){for(;d===Dv;)Dv=eh[--th],eh[th]=null,Jm=eh[--th],eh[th]=null;for(;d===Ic;)Ic=vs[--ys],vs[ys]=null,Po=vs[--ys],vs[ys]=null,Ro=vs[--ys],vs[ys]=null}function qL(d,p){vs[ys++]=Ro,vs[ys++]=Po,vs[ys++]=Ic,Ro=p.id,Po=p.overflow,Ic=d}var Dr=null,ti=null,yn=!1,jc=null,bs=!1,WM=Error(i(519));function Uc(d){var p=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw eg(xs(p,d)),WM}function XL(d){var p=d.stateNode,b=d.type,S=d.memoizedProps;switch(p[hi]=d,p[Ti]=S,b){case"dialog":hn("cancel",p),hn("close",p);break;case"iframe":case"object":case"embed":hn("load",p);break;case"video":case"audio":for(b=0;b<Sg.length;b++)hn(Sg[b],p);break;case"source":hn("error",p);break;case"img":case"image":case"link":hn("error",p),hn("load",p);break;case"details":hn("toggle",p);break;case"input":hn("invalid",p),Pn(p,S.value,S.defaultValue,S.checked,S.defaultChecked,S.type,S.name,!0);break;case"select":hn("invalid",p);break;case"textarea":hn("invalid",p),kr(p,S.value,S.defaultValue,S.children)}b=S.children,typeof b!="string"&&typeof b!="number"&&typeof b!="bigint"||p.textContent===""+b||S.suppressHydrationWarning===!0||d4(p.textContent,b)?(S.popover!=null&&(hn("beforetoggle",p),hn("toggle",p)),S.onScroll!=null&&hn("scroll",p),S.onScrollEnd!=null&&hn("scrollend",p),S.onClick!=null&&(p.onclick=dl),p=!0):p=!1,p||Uc(d,!0)}function KL(d){for(Dr=d.return;Dr;)switch(Dr.tag){case 5:case 31:case 13:bs=!1;return;case 27:case 3:bs=!0;return;default:Dr=Dr.return}}function nh(d){if(d!==Dr)return!1;if(!yn)return KL(d),yn=!0,!1;var p=d.tag,b;if((b=p!==3&&p!==27)&&((b=p===5)&&(b=d.type,b=!(b!=="form"&&b!=="button")||uA(d.type,d.memoizedProps)),b=!b),b&&ti&&Uc(d),KL(d),p===13){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(i(317));ti=b4(d)}else if(p===31){if(d=d.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(i(317));ti=b4(d)}else p===27?(p=ti,Qc(d.type)?(d=mA,mA=null,ti=d):ti=p):ti=Dr?Ss(d.stateNode.nextSibling):null;return!0}function gd(){ti=Dr=null,yn=!1}function qM(){var d=jc;return d!==null&&(Ca===null?Ca=d:Ca.push.apply(Ca,d),jc=null),d}function eg(d){jc===null?jc=[d]:jc.push(d)}var XM=z(null),xd=null,ml=null;function Fc(d,p,b){re(XM,p._currentValue),p._currentValue=b}function gl(d){d._currentValue=XM.current,V(XM)}function KM(d,p,b){for(;d!==null;){var S=d.alternate;if((d.childLanes&p)!==p?(d.childLanes|=p,S!==null&&(S.childLanes|=p)):S!==null&&(S.childLanes&p)!==p&&(S.childLanes|=p),d===b)break;d=d.return}}function YM(d,p,b,S){var R=d.child;for(R!==null&&(R.return=d);R!==null;){var O=R.dependencies;if(O!==null){var G=R.child;O=O.firstContext;e:for(;O!==null;){var ae=O;O=R;for(var _e=0;_e<p.length;_e++)if(ae.context===p[_e]){O.lanes|=b,ae=O.alternate,ae!==null&&(ae.lanes|=b),KM(O.return,b,d),S||(G=null);break e}O=ae.next}}else if(R.tag===18){if(G=R.return,G===null)throw Error(i(341));G.lanes|=b,O=G.alternate,O!==null&&(O.lanes|=b),KM(G,b,d),G=null}else G=R.child;if(G!==null)G.return=R;else for(G=R;G!==null;){if(G===d){G=null;break}if(R=G.sibling,R!==null){R.return=G.return,G=R;break}G=G.return}R=G}}function ih(d,p,b,S){d=null;for(var R=p,O=!1;R!==null;){if(!O){if((R.flags&524288)!==0)O=!0;else if((R.flags&262144)!==0)break}if(R.tag===10){var G=R.alternate;if(G===null)throw Error(i(387));if(G=G.memoizedProps,G!==null){var ae=R.type;Wa(R.pendingProps.value,G.value)||(d!==null?d.push(ae):d=[ae])}}else if(R===xe.current){if(G=R.alternate,G===null)throw Error(i(387));G.memoizedState.memoizedState!==R.memoizedState.memoizedState&&(d!==null?d.push(Tg):d=[Tg])}R=R.return}d!==null&&YM(p,d,b,S),p.flags|=262144}function Ov(d){for(d=d.firstContext;d!==null;){if(!Wa(d.context._currentValue,d.memoizedValue))return!0;d=d.next}return!1}function vd(d){xd=d,ml=null,d=d.dependencies,d!==null&&(d.firstContext=null)}function Or(d){return YL(xd,d)}function Lv(d,p){return xd===null&&vd(d),YL(d,p)}function YL(d,p){var b=p._currentValue;if(p={context:p,memoizedValue:b,next:null},ml===null){if(d===null)throw Error(i(308));ml=p,d.dependencies={lanes:0,firstContext:p},d.flags|=524288}else ml=ml.next=p;return b}var $ee=typeof AbortController<"u"?AbortController:function(){var d=[],p=this.signal={aborted:!1,addEventListener:function(b,S){d.push(S)}};this.abort=function(){p.aborted=!0,d.forEach(function(b){return b()})}},Vee=t.unstable_scheduleCallback,Gee=t.unstable_NormalPriority,ji={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ZM(){return{controller:new $ee,data:new Map,refCount:0}}function tg(d){d.refCount--,d.refCount===0&&Vee(Gee,function(){d.controller.abort()})}var ng=null,QM=0,rh=0,ah=null;function Wee(d,p){if(ng===null){var b=ng=[];QM=0,rh=tA(),ah={status:"pending",value:void 0,then:function(S){b.push(S)}}}return QM++,p.then(ZL,ZL),p}function ZL(){if(--QM===0&&ng!==null){ah!==null&&(ah.status="fulfilled");var d=ng;ng=null,rh=0,ah=null;for(var p=0;p<d.length;p++)(0,d[p])()}}function qee(d,p){var b=[],S={status:"pending",value:null,reason:null,then:function(R){b.push(R)}};return d.then(function(){S.status="fulfilled",S.value=p;for(var R=0;R<b.length;R++)(0,b[R])(p)},function(R){for(S.status="rejected",S.reason=R,R=0;R<b.length;R++)(0,b[R])(void 0)}),S}var QL=$.S;$.S=function(d,p){Lj=L(),typeof p=="object"&&p!==null&&typeof p.then=="function"&&Wee(d,p),QL!==null&&QL(d,p)};var yd=z(null);function JM(){var d=yd.current;return d!==null?d:Xn.pooledCache}function Iv(d,p){p===null?re(yd,yd.current):re(yd,p.pool)}function JL(){var d=JM();return d===null?null:{parent:ji._currentValue,pool:d}}var sh=Error(i(460)),eE=Error(i(474)),jv=Error(i(542)),Uv={then:function(){}};function eI(d){return d=d.status,d==="fulfilled"||d==="rejected"}function tI(d,p,b){switch(b=d[b],b===void 0?d.push(p):b!==p&&(p.then(dl,dl),p=b),p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,iI(d),d;default:if(typeof p.status=="string")p.then(dl,dl);else{if(d=Xn,d!==null&&100<d.shellSuspendCounter)throw Error(i(482));d=p,d.status="pending",d.then(function(S){if(p.status==="pending"){var R=p;R.status="fulfilled",R.value=S}},function(S){if(p.status==="pending"){var R=p;R.status="rejected",R.reason=S}})}switch(p.status){case"fulfilled":return p.value;case"rejected":throw d=p.reason,iI(d),d}throw _d=p,sh}}function bd(d){try{var p=d._init;return p(d._payload)}catch(b){throw b!==null&&typeof b=="object"&&typeof b.then=="function"?(_d=b,sh):b}}var _d=null;function nI(){if(_d===null)throw Error(i(459));var d=_d;return _d=null,d}function iI(d){if(d===sh||d===jv)throw Error(i(483))}var oh=null,ig=0;function Fv(d){var p=ig;return ig+=1,oh===null&&(oh=[]),tI(oh,d,p)}function rg(d,p){p=p.props.ref,d.ref=p!==void 0?p:null}function zv(d,p){throw p.$$typeof===m?Error(i(525)):(d=Object.prototype.toString.call(p),Error(i(31,d==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":d)))}function rI(d){function p(De,Ae){if(d){var Fe=De.deletions;Fe===null?(De.deletions=[Ae],De.flags|=16):Fe.push(Ae)}}function b(De,Ae){if(!d)return null;for(;Ae!==null;)p(De,Ae),Ae=Ae.sibling;return null}function S(De){for(var Ae=new Map;De!==null;)De.key!==null?Ae.set(De.key,De):Ae.set(De.index,De),De=De.sibling;return Ae}function R(De,Ae){return De=hl(De,Ae),De.index=0,De.sibling=null,De}function O(De,Ae,Fe){return De.index=Fe,d?(Fe=De.alternate,Fe!==null?(Fe=Fe.index,Fe<Ae?(De.flags|=67108866,Ae):Fe):(De.flags|=67108866,Ae)):(De.flags|=1048576,Ae)}function G(De){return d&&De.alternate===null&&(De.flags|=67108866),De}function ae(De,Ae,Fe,at){return Ae===null||Ae.tag!==6?(Ae=HM(Fe,De.mode,at),Ae.return=De,Ae):(Ae=R(Ae,Fe),Ae.return=De,Ae)}function _e(De,Ae,Fe,at){var jt=Fe.type;return jt===_?et(De,Ae,Fe.props.children,at,Fe.key):Ae!==null&&(Ae.elementType===jt||typeof jt=="object"&&jt!==null&&jt.$$typeof===j&&bd(jt)===Ae.type)?(Ae=R(Ae,Fe.props),rg(Ae,Fe),Ae.return=De,Ae):(Ae=kv(Fe.type,Fe.key,Fe.props,null,De.mode,at),rg(Ae,Fe),Ae.return=De,Ae)}function ze(De,Ae,Fe,at){return Ae===null||Ae.tag!==4||Ae.stateNode.containerInfo!==Fe.containerInfo||Ae.stateNode.implementation!==Fe.implementation?(Ae=$M(Fe,De.mode,at),Ae.return=De,Ae):(Ae=R(Ae,Fe.children||[]),Ae.return=De,Ae)}function et(De,Ae,Fe,at,jt){return Ae===null||Ae.tag!==7?(Ae=md(Fe,De.mode,at,jt),Ae.return=De,Ae):(Ae=R(Ae,Fe),Ae.return=De,Ae)}function ot(De,Ae,Fe){if(typeof Ae=="string"&&Ae!==""||typeof Ae=="number"||typeof Ae=="bigint")return Ae=HM(""+Ae,De.mode,Fe),Ae.return=De,Ae;if(typeof Ae=="object"&&Ae!==null){switch(Ae.$$typeof){case g:return Fe=kv(Ae.type,Ae.key,Ae.props,null,De.mode,Fe),rg(Fe,Ae),Fe.return=De,Fe;case y:return Ae=$M(Ae,De.mode,Fe),Ae.return=De,Ae;case j:return Ae=bd(Ae),ot(De,Ae,Fe)}if(B(Ae)||I(Ae))return Ae=md(Ae,De.mode,Fe,null),Ae.return=De,Ae;if(typeof Ae.then=="function")return ot(De,Fv(Ae),Fe);if(Ae.$$typeof===w)return ot(De,Lv(De,Ae),Fe);zv(De,Ae)}return null}function Ve(De,Ae,Fe,at){var jt=Ae!==null?Ae.key:null;if(typeof Fe=="string"&&Fe!==""||typeof Fe=="number"||typeof Fe=="bigint")return jt!==null?null:ae(De,Ae,""+Fe,at);if(typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case g:return Fe.key===jt?_e(De,Ae,Fe,at):null;case y:return Fe.key===jt?ze(De,Ae,Fe,at):null;case j:return Fe=bd(Fe),Ve(De,Ae,Fe,at)}if(B(Fe)||I(Fe))return jt!==null?null:et(De,Ae,Fe,at,null);if(typeof Fe.then=="function")return Ve(De,Ae,Fv(Fe),at);if(Fe.$$typeof===w)return Ve(De,Ae,Lv(De,Fe),at);zv(De,Fe)}return null}function Ze(De,Ae,Fe,at,jt){if(typeof at=="string"&&at!==""||typeof at=="number"||typeof at=="bigint")return De=De.get(Fe)||null,ae(Ae,De,""+at,jt);if(typeof at=="object"&&at!==null){switch(at.$$typeof){case g:return De=De.get(at.key===null?Fe:at.key)||null,_e(Ae,De,at,jt);case y:return De=De.get(at.key===null?Fe:at.key)||null,ze(Ae,De,at,jt);case j:return at=bd(at),Ze(De,Ae,Fe,at,jt)}if(B(at)||I(at))return De=De.get(Fe)||null,et(Ae,De,at,jt,null);if(typeof at.then=="function")return Ze(De,Ae,Fe,Fv(at),jt);if(at.$$typeof===w)return Ze(De,Ae,Fe,Lv(Ae,at),jt);zv(Ae,at)}return null}function Ct(De,Ae,Fe,at){for(var jt=null,wn=null,kt=Ae,en=Ae=0,xn=null;kt!==null&&en<Fe.length;en++){kt.index>en?(xn=kt,kt=null):xn=kt.sibling;var Mn=Ve(De,kt,Fe[en],at);if(Mn===null){kt===null&&(kt=xn);break}d&&kt&&Mn.alternate===null&&p(De,kt),Ae=O(Mn,Ae,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn,kt=xn}if(en===Fe.length)return b(De,kt),yn&&pl(De,en),jt;if(kt===null){for(;en<Fe.length;en++)kt=ot(De,Fe[en],at),kt!==null&&(Ae=O(kt,Ae,en),wn===null?jt=kt:wn.sibling=kt,wn=kt);return yn&&pl(De,en),jt}for(kt=S(kt);en<Fe.length;en++)xn=Ze(kt,De,en,Fe[en],at),xn!==null&&(d&&xn.alternate!==null&&kt.delete(xn.key===null?en:xn.key),Ae=O(xn,Ae,en),wn===null?jt=xn:wn.sibling=xn,wn=xn);return d&&kt.forEach(function(iu){return p(De,iu)}),yn&&pl(De,en),jt}function Bt(De,Ae,Fe,at){if(Fe==null)throw Error(i(151));for(var jt=null,wn=null,kt=Ae,en=Ae=0,xn=null,Mn=Fe.next();kt!==null&&!Mn.done;en++,Mn=Fe.next()){kt.index>en?(xn=kt,kt=null):xn=kt.sibling;var iu=Ve(De,kt,Mn.value,at);if(iu===null){kt===null&&(kt=xn);break}d&&kt&&iu.alternate===null&&p(De,kt),Ae=O(iu,Ae,en),wn===null?jt=iu:wn.sibling=iu,wn=iu,kt=xn}if(Mn.done)return b(De,kt),yn&&pl(De,en),jt;if(kt===null){for(;!Mn.done;en++,Mn=Fe.next())Mn=ot(De,Mn.value,at),Mn!==null&&(Ae=O(Mn,Ae,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn);return yn&&pl(De,en),jt}for(kt=S(kt);!Mn.done;en++,Mn=Fe.next())Mn=Ze(kt,De,en,Mn.value,at),Mn!==null&&(d&&Mn.alternate!==null&&kt.delete(Mn.key===null?en:Mn.key),Ae=O(Mn,Ae,en),wn===null?jt=Mn:wn.sibling=Mn,wn=Mn);return d&&kt.forEach(function(rne){return p(De,rne)}),yn&&pl(De,en),jt}function Fn(De,Ae,Fe,at){if(typeof Fe=="object"&&Fe!==null&&Fe.type===_&&Fe.key===null&&(Fe=Fe.props.children),typeof Fe=="object"&&Fe!==null){switch(Fe.$$typeof){case g:e:{for(var jt=Fe.key;Ae!==null;){if(Ae.key===jt){if(jt=Fe.type,jt===_){if(Ae.tag===7){b(De,Ae.sibling),at=R(Ae,Fe.props.children),at.return=De,De=at;break e}}else if(Ae.elementType===jt||typeof jt=="object"&&jt!==null&&jt.$$typeof===j&&bd(jt)===Ae.type){b(De,Ae.sibling),at=R(Ae,Fe.props),rg(at,Fe),at.return=De,De=at;break e}b(De,Ae);break}else p(De,Ae);Ae=Ae.sibling}Fe.type===_?(at=md(Fe.props.children,De.mode,at,Fe.key),at.return=De,De=at):(at=kv(Fe.type,Fe.key,Fe.props,null,De.mode,at),rg(at,Fe),at.return=De,De=at)}return G(De);case y:e:{for(jt=Fe.key;Ae!==null;){if(Ae.key===jt)if(Ae.tag===4&&Ae.stateNode.containerInfo===Fe.containerInfo&&Ae.stateNode.implementation===Fe.implementation){b(De,Ae.sibling),at=R(Ae,Fe.children||[]),at.return=De,De=at;break e}else{b(De,Ae);break}else p(De,Ae);Ae=Ae.sibling}at=$M(Fe,De.mode,at),at.return=De,De=at}return G(De);case j:return Fe=bd(Fe),Fn(De,Ae,Fe,at)}if(B(Fe))return Ct(De,Ae,Fe,at);if(I(Fe)){if(jt=I(Fe),typeof jt!="function")throw Error(i(150));return Fe=jt.call(Fe),Bt(De,Ae,Fe,at)}if(typeof Fe.then=="function")return Fn(De,Ae,Fv(Fe),at);if(Fe.$$typeof===w)return Fn(De,Ae,Lv(De,Fe),at);zv(De,Fe)}return typeof Fe=="string"&&Fe!==""||typeof Fe=="number"||typeof Fe=="bigint"?(Fe=""+Fe,Ae!==null&&Ae.tag===6?(b(De,Ae.sibling),at=R(Ae,Fe),at.return=De,De=at):(b(De,Ae),at=HM(Fe,De.mode,at),at.return=De,De=at),G(De)):b(De,Ae)}return function(De,Ae,Fe,at){try{ig=0;var jt=Fn(De,Ae,Fe,at);return oh=null,jt}catch(kt){if(kt===sh||kt===jv)throw kt;var wn=qa(29,kt,null,De.mode);return wn.lanes=at,wn.return=De,wn}finally{}}}var Sd=rI(!0),aI=rI(!1),zc=!1;function tE(d){d.updateQueue={baseState:d.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function nE(d,p){d=d.updateQueue,p.updateQueue===d&&(p.updateQueue={baseState:d.baseState,firstBaseUpdate:d.firstBaseUpdate,lastBaseUpdate:d.lastBaseUpdate,shared:d.shared,callbacks:null})}function Bc(d){return{lane:d,tag:0,payload:null,callback:null,next:null}}function Hc(d,p,b){var S=d.updateQueue;if(S===null)return null;if(S=S.shared,(Cn&2)!==0){var R=S.pending;return R===null?p.next=p:(p.next=R.next,R.next=p),S.pending=p,p=Pv(d),HL(d,null,b),p}return Rv(d,S,p,b),Pv(d)}function ag(d,p,b){if(p=p.updateQueue,p!==null&&(p=p.shared,(b&4194048)!==0)){var S=p.lanes;S&=d.pendingLanes,b|=S,p.lanes=b,qn(d,b)}}function iE(d,p){var b=d.updateQueue,S=d.alternate;if(S!==null&&(S=S.updateQueue,b===S)){var R=null,O=null;if(b=b.firstBaseUpdate,b!==null){do{var G={lane:b.lane,tag:b.tag,payload:b.payload,callback:null,next:null};O===null?R=O=G:O=O.next=G,b=b.next}while(b!==null);O===null?R=O=p:O=O.next=p}else R=O=p;b={baseState:S.baseState,firstBaseUpdate:R,lastBaseUpdate:O,shared:S.shared,callbacks:S.callbacks},d.updateQueue=b;return}d=b.lastBaseUpdate,d===null?b.firstBaseUpdate=p:d.next=p,b.lastBaseUpdate=p}var rE=!1;function sg(){if(rE){var d=ah;if(d!==null)throw d}}function og(d,p,b,S){rE=!1;var R=d.updateQueue;zc=!1;var O=R.firstBaseUpdate,G=R.lastBaseUpdate,ae=R.shared.pending;if(ae!==null){R.shared.pending=null;var _e=ae,ze=_e.next;_e.next=null,G===null?O=ze:G.next=ze,G=_e;var et=d.alternate;et!==null&&(et=et.updateQueue,ae=et.lastBaseUpdate,ae!==G&&(ae===null?et.firstBaseUpdate=ze:ae.next=ze,et.lastBaseUpdate=_e))}if(O!==null){var ot=R.baseState;G=0,et=ze=_e=null,ae=O;do{var Ve=ae.lane&-536870913,Ze=Ve!==ae.lane;if(Ze?(gn&Ve)===Ve:(S&Ve)===Ve){Ve!==0&&Ve===rh&&(rE=!0),et!==null&&(et=et.next={lane:0,tag:ae.tag,payload:ae.payload,callback:null,next:null});e:{var Ct=d,Bt=ae;Ve=p;var Fn=b;switch(Bt.tag){case 1:if(Ct=Bt.payload,typeof Ct=="function"){ot=Ct.call(Fn,ot,Ve);break e}ot=Ct;break e;case 3:Ct.flags=Ct.flags&-65537|128;case 0:if(Ct=Bt.payload,Ve=typeof Ct=="function"?Ct.call(Fn,ot,Ve):Ct,Ve==null)break e;ot=f({},ot,Ve);break e;case 2:zc=!0}}Ve=ae.callback,Ve!==null&&(d.flags|=64,Ze&&(d.flags|=8192),Ze=R.callbacks,Ze===null?R.callbacks=[Ve]:Ze.push(Ve))}else Ze={lane:Ve,tag:ae.tag,payload:ae.payload,callback:ae.callback,next:null},et===null?(ze=et=Ze,_e=ot):et=et.next=Ze,G|=Ve;if(ae=ae.next,ae===null){if(ae=R.shared.pending,ae===null)break;Ze=ae,ae=Ze.next,Ze.next=null,R.lastBaseUpdate=Ze,R.shared.pending=null}}while(!0);et===null&&(_e=ot),R.baseState=_e,R.firstBaseUpdate=ze,R.lastBaseUpdate=et,O===null&&(R.shared.lanes=0),qc|=G,d.lanes=G,d.memoizedState=ot}}function sI(d,p){if(typeof d!="function")throw Error(i(191,d));d.call(p)}function oI(d,p){var b=d.callbacks;if(b!==null)for(d.callbacks=null,d=0;d<b.length;d++)sI(b[d],p)}var lh=z(null),Bv=z(0);function lI(d,p){d=El,re(Bv,d),re(lh,p),El=d|p.baseLanes}function aE(){re(Bv,El),re(lh,lh.current)}function sE(){El=Bv.current,V(lh),V(Bv)}var Xa=z(null),_s=null;function $c(d){var p=d.alternate;re(Ni,Ni.current&1),re(Xa,d),_s===null&&(p===null||lh.current!==null||p.memoizedState!==null)&&(_s=d)}function oE(d){re(Ni,Ni.current),re(Xa,d),_s===null&&(_s=d)}function cI(d){d.tag===22?(re(Ni,Ni.current),re(Xa,d),_s===null&&(_s=d)):Vc()}function Vc(){re(Ni,Ni.current),re(Xa,Xa.current)}function Ka(d){V(Xa),_s===d&&(_s=null),V(Ni)}var Ni=z(0);function Hv(d){for(var p=d;p!==null;){if(p.tag===13){var b=p.memoizedState;if(b!==null&&(b=b.dehydrated,b===null||hA(b)||pA(b)))return p}else if(p.tag===19&&(p.memoizedProps.revealOrder==="forwards"||p.memoizedProps.revealOrder==="backwards"||p.memoizedProps.revealOrder==="unstable_legacy-backwards"||p.memoizedProps.revealOrder==="together")){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var xl=0,Jt=null,jn=null,Ui=null,$v=!1,ch=!1,wd=!1,Vv=0,lg=0,uh=null,Xee=0;function bi(){throw Error(i(321))}function lE(d,p){if(p===null)return!1;for(var b=0;b<p.length&&b<d.length;b++)if(!Wa(d[b],p[b]))return!1;return!0}function cE(d,p,b,S,R,O){return xl=O,Jt=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,$.H=d===null||d.memoizedState===null?WI:ME,wd=!1,O=b(S,R),wd=!1,ch&&(O=dI(p,b,S,R)),uI(d),O}function uI(d){$.H=dg;var p=jn!==null&&jn.next!==null;if(xl=0,Ui=jn=Jt=null,$v=!1,lg=0,uh=null,p)throw Error(i(300));d===null||Fi||(d=d.dependencies,d!==null&&Ov(d)&&(Fi=!0))}function dI(d,p,b,S){Jt=d;var R=0;do{if(ch&&(uh=null),lg=0,ch=!1,25<=R)throw Error(i(301));if(R+=1,Ui=jn=null,d.updateQueue!=null){var O=d.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}$.H=qI,O=p(b,S)}while(ch);return O}function Kee(){var d=$.H,p=d.useState()[0];return p=typeof p.then=="function"?cg(p):p,d=d.useState()[0],(jn!==null?jn.memoizedState:null)!==d&&(Jt.flags|=1024),p}function uE(){var d=Vv!==0;return Vv=0,d}function dE(d,p,b){p.updateQueue=d.updateQueue,p.flags&=-2053,d.lanes&=~b}function fE(d){if($v){for(d=d.memoizedState;d!==null;){var p=d.queue;p!==null&&(p.pending=null),d=d.next}$v=!1}xl=0,Ui=jn=Jt=null,ch=!1,lg=Vv=0,uh=null}function la(){var d={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ui===null?Jt.memoizedState=Ui=d:Ui=Ui.next=d,Ui}function Ri(){if(jn===null){var d=Jt.alternate;d=d!==null?d.memoizedState:null}else d=jn.next;var p=Ui===null?Jt.memoizedState:Ui.next;if(p!==null)Ui=p,jn=d;else{if(d===null)throw Jt.alternate===null?Error(i(467)):Error(i(310));jn=d,d={memoizedState:jn.memoizedState,baseState:jn.baseState,baseQueue:jn.baseQueue,queue:jn.queue,next:null},Ui===null?Jt.memoizedState=Ui=d:Ui=Ui.next=d}return Ui}function Gv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function cg(d){var p=lg;return lg+=1,uh===null&&(uh=[]),d=tI(uh,d,p),p=Jt,(Ui===null?p.memoizedState:Ui.next)===null&&(p=p.alternate,$.H=p===null||p.memoizedState===null?WI:ME),d}function Wv(d){if(d!==null&&typeof d=="object"){if(typeof d.then=="function")return cg(d);if(d.$$typeof===w)return Or(d)}throw Error(i(438,String(d)))}function hE(d){var p=null,b=Jt.updateQueue;if(b!==null&&(p=b.memoCache),p==null){var S=Jt.alternate;S!==null&&(S=S.updateQueue,S!==null&&(S=S.memoCache,S!=null&&(p={data:S.data.map(function(R){return R.slice()}),index:0})))}if(p==null&&(p={data:[],index:0}),b===null&&(b=Gv(),Jt.updateQueue=b),b.memoCache=p,b=p.data[p.index],b===void 0)for(b=p.data[p.index]=Array(d),S=0;S<d;S++)b[S]=k;return p.index++,b}function vl(d,p){return typeof p=="function"?p(d):p}function qv(d){var p=Ri();return pE(p,jn,d)}function pE(d,p,b){var S=d.queue;if(S===null)throw Error(i(311));S.lastRenderedReducer=b;var R=d.baseQueue,O=S.pending;if(O!==null){if(R!==null){var G=R.next;R.next=O.next,O.next=G}p.baseQueue=R=O,S.pending=null}if(O=d.baseState,R===null)d.memoizedState=O;else{p=R.next;var ae=G=null,_e=null,ze=p,et=!1;do{var ot=ze.lane&-536870913;if(ot!==ze.lane?(gn&ot)===ot:(xl&ot)===ot){var Ve=ze.revertLane;if(Ve===0)_e!==null&&(_e=_e.next={lane:0,revertLane:0,gesture:null,action:ze.action,hasEagerState:ze.hasEagerState,eagerState:ze.eagerState,next:null}),ot===rh&&(et=!0);else if((xl&Ve)===Ve){ze=ze.next,Ve===rh&&(et=!0);continue}else ot={lane:0,revertLane:ze.revertLane,gesture:null,action:ze.action,hasEagerState:ze.hasEagerState,eagerState:ze.eagerState,next:null},_e===null?(ae=_e=ot,G=O):_e=_e.next=ot,Jt.lanes|=Ve,qc|=Ve;ot=ze.action,wd&&b(O,ot),O=ze.hasEagerState?ze.eagerState:b(O,ot)}else Ve={lane:ot,revertLane:ze.revertLane,gesture:ze.gesture,action:ze.action,hasEagerState:ze.hasEagerState,eagerState:ze.eagerState,next:null},_e===null?(ae=_e=Ve,G=O):_e=_e.next=Ve,Jt.lanes|=ot,qc|=ot;ze=ze.next}while(ze!==null&&ze!==p);if(_e===null?G=O:_e.next=ae,!Wa(O,d.memoizedState)&&(Fi=!0,et&&(b=ah,b!==null)))throw b;d.memoizedState=O,d.baseState=G,d.baseQueue=_e,S.lastRenderedState=O}return R===null&&(S.lanes=0),[d.memoizedState,S.dispatch]}function mE(d){var p=Ri(),b=p.queue;if(b===null)throw Error(i(311));b.lastRenderedReducer=d;var S=b.dispatch,R=b.pending,O=p.memoizedState;if(R!==null){b.pending=null;var G=R=R.next;do O=d(O,G.action),G=G.next;while(G!==R);Wa(O,p.memoizedState)||(Fi=!0),p.memoizedState=O,p.baseQueue===null&&(p.baseState=O),b.lastRenderedState=O}return[O,S]}function fI(d,p,b){var S=Jt,R=Ri(),O=yn;if(O){if(b===void 0)throw Error(i(407));b=b()}else b=p();var G=!Wa((jn||R).memoizedState,b);if(G&&(R.memoizedState=b,Fi=!0),R=R.queue,vE(mI.bind(null,S,R,d),[d]),R.getSnapshot!==p||G||Ui!==null&&Ui.memoizedState.tag&1){if(S.flags|=2048,dh(9,{destroy:void 0},pI.bind(null,S,R,b,p),null),Xn===null)throw Error(i(349));O||(xl&127)!==0||hI(S,p,b)}return b}function hI(d,p,b){d.flags|=16384,d={getSnapshot:p,value:b},p=Jt.updateQueue,p===null?(p=Gv(),Jt.updateQueue=p,p.stores=[d]):(b=p.stores,b===null?p.stores=[d]:b.push(d))}function pI(d,p,b,S){p.value=b,p.getSnapshot=S,gI(p)&&xI(d)}function mI(d,p,b){return b(function(){gI(p)&&xI(d)})}function gI(d){var p=d.getSnapshot;d=d.value;try{var b=p();return!Wa(d,b)}catch{return!0}}function xI(d){var p=pd(d,2);p!==null&&Na(p,d,2)}function gE(d){var p=la();if(typeof d=="function"){var b=d;if(d=b(),wd){pt(!0);try{b()}finally{pt(!1)}}}return p.memoizedState=p.baseState=d,p.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:d},p}function vI(d,p,b,S){return d.baseState=b,pE(d,jn,typeof S=="function"?S:vl)}function Yee(d,p,b,S,R){if(Yv(d))throw Error(i(485));if(d=p.action,d!==null){var O={payload:R,action:d,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(G){O.listeners.push(G)}};$.T!==null?b(!0):O.isTransition=!1,S(O),b=p.pending,b===null?(O.next=p.pending=O,yI(p,O)):(O.next=b.next,p.pending=b.next=O)}}function yI(d,p){var b=p.action,S=p.payload,R=d.state;if(p.isTransition){var O=$.T,G={};$.T=G;try{var ae=b(R,S),_e=$.S;_e!==null&&_e(G,ae),bI(d,p,ae)}catch(ze){xE(d,p,ze)}finally{O!==null&&G.types!==null&&(O.types=G.types),$.T=O}}else try{O=b(R,S),bI(d,p,O)}catch(ze){xE(d,p,ze)}}function bI(d,p,b){b!==null&&typeof b=="object"&&typeof b.then=="function"?b.then(function(S){_I(d,p,S)},function(S){return xE(d,p,S)}):_I(d,p,b)}function _I(d,p,b){p.status="fulfilled",p.value=b,SI(p),d.state=b,p=d.pending,p!==null&&(b=p.next,b===p?d.pending=null:(b=b.next,p.next=b,yI(d,b)))}function xE(d,p,b){var S=d.pending;if(d.pending=null,S!==null){S=S.next;do p.status="rejected",p.reason=b,SI(p),p=p.next;while(p!==S)}d.action=null}function SI(d){d=d.listeners;for(var p=0;p<d.length;p++)(0,d[p])()}function wI(d,p){return p}function MI(d,p){if(yn){var b=Xn.formState;if(b!==null){e:{var S=Jt;if(yn){if(ti){t:{for(var R=ti,O=bs;R.nodeType!==8;){if(!O){R=null;break t}if(R=Ss(R.nextSibling),R===null){R=null;break t}}O=R.data,R=O==="F!"||O==="F"?R:null}if(R){ti=Ss(R.nextSibling),S=R.data==="F!";break e}}Uc(S)}S=!1}S&&(p=b[0])}}return b=la(),b.memoizedState=b.baseState=p,S={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wI,lastRenderedState:p},b.queue=S,b=$I.bind(null,Jt,S),S.dispatch=b,S=gE(!1),O=wE.bind(null,Jt,!1,S.queue),S=la(),R={state:p,dispatch:null,action:d,pending:null},S.queue=R,b=Yee.bind(null,Jt,R,O,b),R.dispatch=b,S.memoizedState=d,[p,b,!1]}function EI(d){var p=Ri();return AI(p,jn,d)}function AI(d,p,b){if(p=pE(d,p,wI)[0],d=qv(vl)[0],typeof p=="object"&&p!==null&&typeof p.then=="function")try{var S=cg(p)}catch(G){throw G===sh?jv:G}else S=p;p=Ri();var R=p.queue,O=R.dispatch;return b!==p.memoizedState&&(Jt.flags|=2048,dh(9,{destroy:void 0},Zee.bind(null,R,b),null)),[S,O,d]}function Zee(d,p){d.action=p}function TI(d){var p=Ri(),b=jn;if(b!==null)return AI(p,b,d);Ri(),p=p.memoizedState,b=Ri();var S=b.queue.dispatch;return b.memoizedState=d,[p,S,!1]}function dh(d,p,b,S){return d={tag:d,create:b,deps:S,inst:p,next:null},p=Jt.updateQueue,p===null&&(p=Gv(),Jt.updateQueue=p),b=p.lastEffect,b===null?p.lastEffect=d.next=d:(S=b.next,b.next=d,d.next=S,p.lastEffect=d),d}function CI(){return Ri().memoizedState}function Xv(d,p,b,S){var R=la();Jt.flags|=d,R.memoizedState=dh(1|p,{destroy:void 0},b,S===void 0?null:S)}function Kv(d,p,b,S){var R=Ri();S=S===void 0?null:S;var O=R.memoizedState.inst;jn!==null&&S!==null&&lE(S,jn.memoizedState.deps)?R.memoizedState=dh(p,O,b,S):(Jt.flags|=d,R.memoizedState=dh(1|p,O,b,S))}function NI(d,p){Xv(8390656,8,d,p)}function vE(d,p){Kv(2048,8,d,p)}function Qee(d){Jt.flags|=4;var p=Jt.updateQueue;if(p===null)p=Gv(),Jt.updateQueue=p,p.events=[d];else{var b=p.events;b===null?p.events=[d]:b.push(d)}}function RI(d){var p=Ri().memoizedState;return Qee({ref:p,nextImpl:d}),function(){if((Cn&2)!==0)throw Error(i(440));return p.impl.apply(void 0,arguments)}}function PI(d,p){return Kv(4,2,d,p)}function kI(d,p){return Kv(4,4,d,p)}function DI(d,p){if(typeof p=="function"){d=d();var b=p(d);return function(){typeof b=="function"?b():p(null)}}if(p!=null)return d=d(),p.current=d,function(){p.current=null}}function OI(d,p,b){b=b!=null?b.concat([d]):null,Kv(4,4,DI.bind(null,p,d),b)}function yE(){}function LI(d,p){var b=Ri();p=p===void 0?null:p;var S=b.memoizedState;return p!==null&&lE(p,S[1])?S[0]:(b.memoizedState=[d,p],d)}function II(d,p){var b=Ri();p=p===void 0?null:p;var S=b.memoizedState;if(p!==null&&lE(p,S[1]))return S[0];if(S=d(),wd){pt(!0);try{d()}finally{pt(!1)}}return b.memoizedState=[S,p],S}function bE(d,p,b){return b===void 0||(xl&1073741824)!==0&&(gn&261930)===0?d.memoizedState=p:(d.memoizedState=b,d=jj(),Jt.lanes|=d,qc|=d,b)}function jI(d,p,b,S){return Wa(b,p)?b:lh.current!==null?(d=bE(d,b,S),Wa(d,p)||(Fi=!0),d):(xl&42)===0||(xl&1073741824)!==0&&(gn&261930)===0?(Fi=!0,d.memoizedState=b):(d=jj(),Jt.lanes|=d,qc|=d,p)}function UI(d,p,b,S,R){var O=K.p;K.p=O!==0&&8>O?O:8;var G=$.T,ae={};$.T=ae,wE(d,!1,p,b);try{var _e=R(),ze=$.S;if(ze!==null&&ze(ae,_e),_e!==null&&typeof _e=="object"&&typeof _e.then=="function"){var et=qee(_e,S);ug(d,p,et,Qa(d))}else ug(d,p,S,Qa(d))}catch(ot){ug(d,p,{then:function(){},status:"rejected",reason:ot},Qa())}finally{K.p=O,G!==null&&ae.types!==null&&(G.types=ae.types),$.T=G}}function Jee(){}function _E(d,p,b,S){if(d.tag!==5)throw Error(i(476));var R=FI(d).queue;UI(d,R,p,X,b===null?Jee:function(){return zI(d),b(S)})}function FI(d){var p=d.memoizedState;if(p!==null)return p;p={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:X},next:null};var b={};return p.next={memoizedState:b,baseState:b,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:b},next:null},d.memoizedState=p,d=d.alternate,d!==null&&(d.memoizedState=p),p}function zI(d){var p=FI(d);p.next===null&&(p=d.alternate.memoizedState),ug(d,p.next.queue,{},Qa())}function SE(){return Or(Tg)}function BI(){return Ri().memoizedState}function HI(){return Ri().memoizedState}function ete(d){for(var p=d.return;p!==null;){switch(p.tag){case 24:case 3:var b=Qa();d=Bc(b);var S=Hc(p,d,b);S!==null&&(Na(S,p,b),ag(S,p,b)),p={cache:ZM()},d.payload=p;return}p=p.return}}function tte(d,p,b){var S=Qa();b={lane:S,revertLane:0,gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},Yv(d)?VI(p,b):(b=zM(d,p,b,S),b!==null&&(Na(b,d,S),GI(b,p,S)))}function $I(d,p,b){var S=Qa();ug(d,p,b,S)}function ug(d,p,b,S){var R={lane:S,revertLane:0,gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null};if(Yv(d))VI(p,R);else{var O=d.alternate;if(d.lanes===0&&(O===null||O.lanes===0)&&(O=p.lastRenderedReducer,O!==null))try{var G=p.lastRenderedState,ae=O(G,b);if(R.hasEagerState=!0,R.eagerState=ae,Wa(ae,G))return Rv(d,p,R,0),Xn===null&&Nv(),!1}catch{}finally{}if(b=zM(d,p,R,S),b!==null)return Na(b,d,S),GI(b,p,S),!0}return!1}function wE(d,p,b,S){if(S={lane:2,revertLane:tA(),gesture:null,action:S,hasEagerState:!1,eagerState:null,next:null},Yv(d)){if(p)throw Error(i(479))}else p=zM(d,b,S,2),p!==null&&Na(p,d,2)}function Yv(d){var p=d.alternate;return d===Jt||p!==null&&p===Jt}function VI(d,p){ch=$v=!0;var b=d.pending;b===null?p.next=p:(p.next=b.next,b.next=p),d.pending=p}function GI(d,p,b){if((b&4194048)!==0){var S=p.lanes;S&=d.pendingLanes,b|=S,p.lanes=b,qn(d,b)}}var dg={readContext:Or,use:Wv,useCallback:bi,useContext:bi,useEffect:bi,useImperativeHandle:bi,useLayoutEffect:bi,useInsertionEffect:bi,useMemo:bi,useReducer:bi,useRef:bi,useState:bi,useDebugValue:bi,useDeferredValue:bi,useTransition:bi,useSyncExternalStore:bi,useId:bi,useHostTransitionStatus:bi,useFormState:bi,useActionState:bi,useOptimistic:bi,useMemoCache:bi,useCacheRefresh:bi};dg.useEffectEvent=bi;var WI={readContext:Or,use:Wv,useCallback:function(d,p){return la().memoizedState=[d,p===void 0?null:p],d},useContext:Or,useEffect:NI,useImperativeHandle:function(d,p,b){b=b!=null?b.concat([d]):null,Xv(4194308,4,DI.bind(null,p,d),b)},useLayoutEffect:function(d,p){return Xv(4194308,4,d,p)},useInsertionEffect:function(d,p){Xv(4,2,d,p)},useMemo:function(d,p){var b=la();p=p===void 0?null:p;var S=d();if(wd){pt(!0);try{d()}finally{pt(!1)}}return b.memoizedState=[S,p],S},useReducer:function(d,p,b){var S=la();if(b!==void 0){var R=b(p);if(wd){pt(!0);try{b(p)}finally{pt(!1)}}}else R=p;return S.memoizedState=S.baseState=R,d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:d,lastRenderedState:R},S.queue=d,d=d.dispatch=tte.bind(null,Jt,d),[S.memoizedState,d]},useRef:function(d){var p=la();return d={current:d},p.memoizedState=d},useState:function(d){d=gE(d);var p=d.queue,b=$I.bind(null,Jt,p);return p.dispatch=b,[d.memoizedState,b]},useDebugValue:yE,useDeferredValue:function(d,p){var b=la();return bE(b,d,p)},useTransition:function(){var d=gE(!1);return d=UI.bind(null,Jt,d.queue,!0,!1),la().memoizedState=d,[!1,d]},useSyncExternalStore:function(d,p,b){var S=Jt,R=la();if(yn){if(b===void 0)throw Error(i(407));b=b()}else{if(b=p(),Xn===null)throw Error(i(349));(gn&127)!==0||hI(S,p,b)}R.memoizedState=b;var O={value:b,getSnapshot:p};return R.queue=O,NI(mI.bind(null,S,O,d),[d]),S.flags|=2048,dh(9,{destroy:void 0},pI.bind(null,S,O,b,p),null),b},useId:function(){var d=la(),p=Xn.identifierPrefix;if(yn){var b=Po,S=Ro;b=(S&~(1<<32-it(S)-1)).toString(32)+b,p="_"+p+"R_"+b,b=Vv++,0<b&&(p+="H"+b.toString(32)),p+="_"}else b=Xee++,p="_"+p+"r_"+b.toString(32)+"_";return d.memoizedState=p},useHostTransitionStatus:SE,useFormState:MI,useActionState:MI,useOptimistic:function(d){var p=la();p.memoizedState=p.baseState=d;var b={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return p.queue=b,p=wE.bind(null,Jt,!0,b),b.dispatch=p,[d,p]},useMemoCache:hE,useCacheRefresh:function(){return la().memoizedState=ete.bind(null,Jt)},useEffectEvent:function(d){var p=la(),b={impl:d};return p.memoizedState=b,function(){if((Cn&2)!==0)throw Error(i(440));return b.impl.apply(void 0,arguments)}}},ME={readContext:Or,use:Wv,useCallback:LI,useContext:Or,useEffect:vE,useImperativeHandle:OI,useInsertionEffect:PI,useLayoutEffect:kI,useMemo:II,useReducer:qv,useRef:CI,useState:function(){return qv(vl)},useDebugValue:yE,useDeferredValue:function(d,p){var b=Ri();return jI(b,jn.memoizedState,d,p)},useTransition:function(){var d=qv(vl)[0],p=Ri().memoizedState;return[typeof d=="boolean"?d:cg(d),p]},useSyncExternalStore:fI,useId:BI,useHostTransitionStatus:SE,useFormState:EI,useActionState:EI,useOptimistic:function(d,p){var b=Ri();return vI(b,jn,d,p)},useMemoCache:hE,useCacheRefresh:HI};ME.useEffectEvent=RI;var qI={readContext:Or,use:Wv,useCallback:LI,useContext:Or,useEffect:vE,useImperativeHandle:OI,useInsertionEffect:PI,useLayoutEffect:kI,useMemo:II,useReducer:mE,useRef:CI,useState:function(){return mE(vl)},useDebugValue:yE,useDeferredValue:function(d,p){var b=Ri();return jn===null?bE(b,d,p):jI(b,jn.memoizedState,d,p)},useTransition:function(){var d=mE(vl)[0],p=Ri().memoizedState;return[typeof d=="boolean"?d:cg(d),p]},useSyncExternalStore:fI,useId:BI,useHostTransitionStatus:SE,useFormState:TI,useActionState:TI,useOptimistic:function(d,p){var b=Ri();return jn!==null?vI(b,jn,d,p):(b.baseState=d,[d,b.queue.dispatch])},useMemoCache:hE,useCacheRefresh:HI};qI.useEffectEvent=RI;function EE(d,p,b,S){p=d.memoizedState,b=b(S,p),b=b==null?p:f({},p,b),d.memoizedState=b,d.lanes===0&&(d.updateQueue.baseState=b)}var AE={enqueueSetState:function(d,p,b){d=d._reactInternals;var S=Qa(),R=Bc(S);R.payload=p,b!=null&&(R.callback=b),p=Hc(d,R,S),p!==null&&(Na(p,d,S),ag(p,d,S))},enqueueReplaceState:function(d,p,b){d=d._reactInternals;var S=Qa(),R=Bc(S);R.tag=1,R.payload=p,b!=null&&(R.callback=b),p=Hc(d,R,S),p!==null&&(Na(p,d,S),ag(p,d,S))},enqueueForceUpdate:function(d,p){d=d._reactInternals;var b=Qa(),S=Bc(b);S.tag=2,p!=null&&(S.callback=p),p=Hc(d,S,b),p!==null&&(Na(p,d,b),ag(p,d,b))}};function XI(d,p,b,S,R,O,G){return d=d.stateNode,typeof d.shouldComponentUpdate=="function"?d.shouldComponentUpdate(S,O,G):p.prototype&&p.prototype.isPureReactComponent?!Zm(b,S)||!Zm(R,O):!0}function KI(d,p,b,S){d=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(b,S),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(b,S),p.state!==d&&AE.enqueueReplaceState(p,p.state,null)}function Md(d,p){var b=p;if("ref"in p){b={};for(var S in p)S!=="ref"&&(b[S]=p[S])}if(d=d.defaultProps){b===p&&(b=f({},b));for(var R in d)b[R]===void 0&&(b[R]=d[R])}return b}function YI(d){Cv(d)}function ZI(d){console.error(d)}function QI(d){Cv(d)}function Zv(d,p){try{var b=d.onUncaughtError;b(p.value,{componentStack:p.stack})}catch(S){setTimeout(function(){throw S})}}function JI(d,p,b){try{var S=d.onCaughtError;S(b.value,{componentStack:b.stack,errorBoundary:p.tag===1?p.stateNode:null})}catch(R){setTimeout(function(){throw R})}}function TE(d,p,b){return b=Bc(b),b.tag=3,b.payload={element:null},b.callback=function(){Zv(d,p)},b}function ej(d){return d=Bc(d),d.tag=3,d}function tj(d,p,b,S){var R=b.type.getDerivedStateFromError;if(typeof R=="function"){var O=S.value;d.payload=function(){return R(O)},d.callback=function(){JI(p,b,S)}}var G=b.stateNode;G!==null&&typeof G.componentDidCatch=="function"&&(d.callback=function(){JI(p,b,S),typeof R!="function"&&(Xc===null?Xc=new Set([this]):Xc.add(this));var ae=S.stack;this.componentDidCatch(S.value,{componentStack:ae!==null?ae:""})})}function nte(d,p,b,S,R){if(b.flags|=32768,S!==null&&typeof S=="object"&&typeof S.then=="function"){if(p=b.alternate,p!==null&&ih(p,b,R,!0),b=Xa.current,b!==null){switch(b.tag){case 31:case 13:return _s===null?cy():b.alternate===null&&_i===0&&(_i=3),b.flags&=-257,b.flags|=65536,b.lanes=R,S===Uv?b.flags|=16384:(p=b.updateQueue,p===null?b.updateQueue=new Set([S]):p.add(S),QE(d,S,R)),!1;case 22:return b.flags|=65536,S===Uv?b.flags|=16384:(p=b.updateQueue,p===null?(p={transitions:null,markerInstances:null,retryQueue:new Set([S])},b.updateQueue=p):(b=p.retryQueue,b===null?p.retryQueue=new Set([S]):b.add(S)),QE(d,S,R)),!1}throw Error(i(435,b.tag))}return QE(d,S,R),cy(),!1}if(yn)return p=Xa.current,p!==null?((p.flags&65536)===0&&(p.flags|=256),p.flags|=65536,p.lanes=R,S!==WM&&(d=Error(i(422),{cause:S}),eg(xs(d,b)))):(S!==WM&&(p=Error(i(423),{cause:S}),eg(xs(p,b))),d=d.current.alternate,d.flags|=65536,R&=-R,d.lanes|=R,S=xs(S,b),R=TE(d.stateNode,S,R),iE(d,R),_i!==4&&(_i=2)),!1;var O=Error(i(520),{cause:S});if(O=xs(O,b),yg===null?yg=[O]:yg.push(O),_i!==4&&(_i=2),p===null)return!0;S=xs(S,b),b=p;do{switch(b.tag){case 3:return b.flags|=65536,d=R&-R,b.lanes|=d,d=TE(b.stateNode,S,d),iE(b,d),!1;case 1:if(p=b.type,O=b.stateNode,(b.flags&128)===0&&(typeof p.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Xc===null||!Xc.has(O))))return b.flags|=65536,R&=-R,b.lanes|=R,R=ej(R),tj(R,d,b,S),iE(b,R),!1}b=b.return}while(b!==null);return!1}var CE=Error(i(461)),Fi=!1;function Lr(d,p,b,S){p.child=d===null?aI(p,null,b,S):Sd(p,d.child,b,S)}function nj(d,p,b,S,R){b=b.render;var O=p.ref;if("ref"in S){var G={};for(var ae in S)ae!=="ref"&&(G[ae]=S[ae])}else G=S;return vd(p),S=cE(d,p,b,G,O,R),ae=uE(),d!==null&&!Fi?(dE(d,p,R),yl(d,p,R)):(yn&&ae&&VM(p),p.flags|=1,Lr(d,p,S,R),p.child)}function ij(d,p,b,S,R){if(d===null){var O=b.type;return typeof O=="function"&&!BM(O)&&O.defaultProps===void 0&&b.compare===null?(p.tag=15,p.type=O,rj(d,p,O,S,R)):(d=kv(b.type,null,S,p,p.mode,R),d.ref=p.ref,d.return=p,p.child=d)}if(O=d.child,!IE(d,R)){var G=O.memoizedProps;if(b=b.compare,b=b!==null?b:Zm,b(G,S)&&d.ref===p.ref)return yl(d,p,R)}return p.flags|=1,d=hl(O,S),d.ref=p.ref,d.return=p,p.child=d}function rj(d,p,b,S,R){if(d!==null){var O=d.memoizedProps;if(Zm(O,S)&&d.ref===p.ref)if(Fi=!1,p.pendingProps=S=O,IE(d,R))(d.flags&131072)!==0&&(Fi=!0);else return p.lanes=d.lanes,yl(d,p,R)}return NE(d,p,b,S,R)}function aj(d,p,b,S){var R=S.children,O=d!==null?d.memoizedState:null;if(d===null&&p.stateNode===null&&(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),S.mode==="hidden"){if((p.flags&128)!==0){if(O=O!==null?O.baseLanes|b:b,d!==null){for(S=p.child=d.child,R=0;S!==null;)R=R|S.lanes|S.childLanes,S=S.sibling;S=R&~O}else S=0,p.child=null;return sj(d,p,O,b,S)}if((b&536870912)!==0)p.memoizedState={baseLanes:0,cachePool:null},d!==null&&Iv(p,O!==null?O.cachePool:null),O!==null?lI(p,O):aE(),cI(p);else return S=p.lanes=536870912,sj(d,p,O!==null?O.baseLanes|b:b,b,S)}else O!==null?(Iv(p,O.cachePool),lI(p,O),Vc(),p.memoizedState=null):(d!==null&&Iv(p,null),aE(),Vc());return Lr(d,p,R,b),p.child}function fg(d,p){return d!==null&&d.tag===22||p.stateNode!==null||(p.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.sibling}function sj(d,p,b,S,R){var O=JM();return O=O===null?null:{parent:ji._currentValue,pool:O},p.memoizedState={baseLanes:b,cachePool:O},d!==null&&Iv(p,null),aE(),cI(p),d!==null&&ih(d,p,S,!0),p.childLanes=R,null}function Qv(d,p){return p=ey({mode:p.mode,children:p.children},d.mode),p.ref=d.ref,d.child=p,p.return=d,p}function oj(d,p,b){return Sd(p,d.child,null,b),d=Qv(p,p.pendingProps),d.flags|=2,Ka(p),p.memoizedState=null,d}function ite(d,p,b){var S=p.pendingProps,R=(p.flags&128)!==0;if(p.flags&=-129,d===null){if(yn){if(S.mode==="hidden")return d=Qv(p,S),p.lanes=536870912,fg(null,d);if(oE(p),(d=ti)?(d=y4(d,bs),d=d!==null&&d.data==="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:Ic!==null?{id:Ro,overflow:Po}:null,retryLane:536870912,hydrationErrors:null},b=VL(d),b.return=p,p.child=b,Dr=p,ti=null)):d=null,d===null)throw Uc(p);return p.lanes=536870912,null}return Qv(p,S)}var O=d.memoizedState;if(O!==null){var G=O.dehydrated;if(oE(p),R)if(p.flags&256)p.flags&=-257,p=oj(d,p,b);else if(p.memoizedState!==null)p.child=d.child,p.flags|=128,p=null;else throw Error(i(558));else if(Fi||ih(d,p,b,!1),R=(b&d.childLanes)!==0,Fi||R){if(S=Xn,S!==null&&(G=mr(S,b),G!==0&&G!==O.retryLane))throw O.retryLane=G,pd(d,G),Na(S,d,G),CE;cy(),p=oj(d,p,b)}else d=O.treeContext,ti=Ss(G.nextSibling),Dr=p,yn=!0,jc=null,bs=!1,d!==null&&qL(p,d),p=Qv(p,S),p.flags|=4096;return p}return d=hl(d.child,{mode:S.mode,children:S.children}),d.ref=p.ref,p.child=d,d.return=p,d}function Jv(d,p){var b=p.ref;if(b===null)d!==null&&d.ref!==null&&(p.flags|=4194816);else{if(typeof b!="function"&&typeof b!="object")throw Error(i(284));(d===null||d.ref!==b)&&(p.flags|=4194816)}}function NE(d,p,b,S,R){return vd(p),b=cE(d,p,b,S,void 0,R),S=uE(),d!==null&&!Fi?(dE(d,p,R),yl(d,p,R)):(yn&&S&&VM(p),p.flags|=1,Lr(d,p,b,R),p.child)}function lj(d,p,b,S,R,O){return vd(p),p.updateQueue=null,b=dI(p,S,b,R),uI(d),S=uE(),d!==null&&!Fi?(dE(d,p,O),yl(d,p,O)):(yn&&S&&VM(p),p.flags|=1,Lr(d,p,b,O),p.child)}function cj(d,p,b,S,R){if(vd(p),p.stateNode===null){var O=Jf,G=b.contextType;typeof G=="object"&&G!==null&&(O=Or(G)),O=new b(S,O),p.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=AE,p.stateNode=O,O._reactInternals=p,O=p.stateNode,O.props=S,O.state=p.memoizedState,O.refs={},tE(p),G=b.contextType,O.context=typeof G=="object"&&G!==null?Or(G):Jf,O.state=p.memoizedState,G=b.getDerivedStateFromProps,typeof G=="function"&&(EE(p,b,G,S),O.state=p.memoizedState),typeof b.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(G=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),G!==O.state&&AE.enqueueReplaceState(O,O.state,null),og(p,S,O,R),sg(),O.state=p.memoizedState),typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!0}else if(d===null){O=p.stateNode;var ae=p.memoizedProps,_e=Md(b,ae);O.props=_e;var ze=O.context,et=b.contextType;G=Jf,typeof et=="object"&&et!==null&&(G=Or(et));var ot=b.getDerivedStateFromProps;et=typeof ot=="function"||typeof O.getSnapshotBeforeUpdate=="function",ae=p.pendingProps!==ae,et||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(ae||ze!==G)&&KI(p,O,S,G),zc=!1;var Ve=p.memoizedState;O.state=Ve,og(p,S,O,R),sg(),ze=p.memoizedState,ae||Ve!==ze||zc?(typeof ot=="function"&&(EE(p,b,ot,S),ze=p.memoizedState),(_e=zc||XI(p,b,_e,S,Ve,ze,G))?(et||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(p.flags|=4194308)):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=S,p.memoizedState=ze),O.props=S,O.state=ze,O.context=G,S=_e):(typeof O.componentDidMount=="function"&&(p.flags|=4194308),S=!1)}else{O=p.stateNode,nE(d,p),G=p.memoizedProps,et=Md(b,G),O.props=et,ot=p.pendingProps,Ve=O.context,ze=b.contextType,_e=Jf,typeof ze=="object"&&ze!==null&&(_e=Or(ze)),ae=b.getDerivedStateFromProps,(ze=typeof ae=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(G!==ot||Ve!==_e)&&KI(p,O,S,_e),zc=!1,Ve=p.memoizedState,O.state=Ve,og(p,S,O,R),sg();var Ze=p.memoizedState;G!==ot||Ve!==Ze||zc||d!==null&&d.dependencies!==null&&Ov(d.dependencies)?(typeof ae=="function"&&(EE(p,b,ae,S),Ze=p.memoizedState),(et=zc||XI(p,b,et,S,Ve,Ze,_e)||d!==null&&d.dependencies!==null&&Ov(d.dependencies))?(ze||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(S,Ze,_e),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(S,Ze,_e)),typeof O.componentDidUpdate=="function"&&(p.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof O.componentDidUpdate!="function"||G===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||G===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=1024),p.memoizedProps=S,p.memoizedState=Ze),O.props=S,O.state=Ze,O.context=_e,S=et):(typeof O.componentDidUpdate!="function"||G===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||G===d.memoizedProps&&Ve===d.memoizedState||(p.flags|=1024),S=!1)}return O=S,Jv(d,p),S=(p.flags&128)!==0,O||S?(O=p.stateNode,b=S&&typeof b.getDerivedStateFromError!="function"?null:O.render(),p.flags|=1,d!==null&&S?(p.child=Sd(p,d.child,null,R),p.child=Sd(p,null,b,R)):Lr(d,p,b,R),p.memoizedState=O.state,d=p.child):d=yl(d,p,R),d}function uj(d,p,b,S){return gd(),p.flags|=256,Lr(d,p,b,S),p.child}var RE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function PE(d){return{baseLanes:d,cachePool:JL()}}function kE(d,p,b){return d=d!==null?d.childLanes&~b:0,p&&(d|=Za),d}function dj(d,p,b){var S=p.pendingProps,R=!1,O=(p.flags&128)!==0,G;if((G=O)||(G=d!==null&&d.memoizedState===null?!1:(Ni.current&2)!==0),G&&(R=!0,p.flags&=-129),G=(p.flags&32)!==0,p.flags&=-33,d===null){if(yn){if(R?$c(p):Vc(),(d=ti)?(d=y4(d,bs),d=d!==null&&d.data!=="&"?d:null,d!==null&&(p.memoizedState={dehydrated:d,treeContext:Ic!==null?{id:Ro,overflow:Po}:null,retryLane:536870912,hydrationErrors:null},b=VL(d),b.return=p,p.child=b,Dr=p,ti=null)):d=null,d===null)throw Uc(p);return pA(d)?p.lanes=32:p.lanes=536870912,null}var ae=S.children;return S=S.fallback,R?(Vc(),R=p.mode,ae=ey({mode:"hidden",children:ae},R),S=md(S,R,b,null),ae.return=p,S.return=p,ae.sibling=S,p.child=ae,S=p.child,S.memoizedState=PE(b),S.childLanes=kE(d,G,b),p.memoizedState=RE,fg(null,S)):($c(p),DE(p,ae))}var _e=d.memoizedState;if(_e!==null&&(ae=_e.dehydrated,ae!==null)){if(O)p.flags&256?($c(p),p.flags&=-257,p=OE(d,p,b)):p.memoizedState!==null?(Vc(),p.child=d.child,p.flags|=128,p=null):(Vc(),ae=S.fallback,R=p.mode,S=ey({mode:"visible",children:S.children},R),ae=md(ae,R,b,null),ae.flags|=2,S.return=p,ae.return=p,S.sibling=ae,p.child=S,Sd(p,d.child,null,b),S=p.child,S.memoizedState=PE(b),S.childLanes=kE(d,G,b),p.memoizedState=RE,p=fg(null,S));else if($c(p),pA(ae)){if(G=ae.nextSibling&&ae.nextSibling.dataset,G)var ze=G.dgst;G=ze,S=Error(i(419)),S.stack="",S.digest=G,eg({value:S,source:null,stack:null}),p=OE(d,p,b)}else if(Fi||ih(d,p,b,!1),G=(b&d.childLanes)!==0,Fi||G){if(G=Xn,G!==null&&(S=mr(G,b),S!==0&&S!==_e.retryLane))throw _e.retryLane=S,pd(d,S),Na(G,d,S),CE;hA(ae)||cy(),p=OE(d,p,b)}else hA(ae)?(p.flags|=192,p.child=d.child,p=null):(d=_e.treeContext,ti=Ss(ae.nextSibling),Dr=p,yn=!0,jc=null,bs=!1,d!==null&&qL(p,d),p=DE(p,S.children),p.flags|=4096);return p}return R?(Vc(),ae=S.fallback,R=p.mode,_e=d.child,ze=_e.sibling,S=hl(_e,{mode:"hidden",children:S.children}),S.subtreeFlags=_e.subtreeFlags&65011712,ze!==null?ae=hl(ze,ae):(ae=md(ae,R,b,null),ae.flags|=2),ae.return=p,S.return=p,S.sibling=ae,p.child=S,fg(null,S),S=p.child,ae=d.child.memoizedState,ae===null?ae=PE(b):(R=ae.cachePool,R!==null?(_e=ji._currentValue,R=R.parent!==_e?{parent:_e,pool:_e}:R):R=JL(),ae={baseLanes:ae.baseLanes|b,cachePool:R}),S.memoizedState=ae,S.childLanes=kE(d,G,b),p.memoizedState=RE,fg(d.child,S)):($c(p),b=d.child,d=b.sibling,b=hl(b,{mode:"visible",children:S.children}),b.return=p,b.sibling=null,d!==null&&(G=p.deletions,G===null?(p.deletions=[d],p.flags|=16):G.push(d)),p.child=b,p.memoizedState=null,b)}function DE(d,p){return p=ey({mode:"visible",children:p},d.mode),p.return=d,d.child=p}function ey(d,p){return d=qa(22,d,null,p),d.lanes=0,d}function OE(d,p,b){return Sd(p,d.child,null,b),d=DE(p,p.pendingProps.children),d.flags|=2,p.memoizedState=null,d}function fj(d,p,b){d.lanes|=p;var S=d.alternate;S!==null&&(S.lanes|=p),KM(d.return,p,b)}function LE(d,p,b,S,R,O){var G=d.memoizedState;G===null?d.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:S,tail:b,tailMode:R,treeForkCount:O}:(G.isBackwards=p,G.rendering=null,G.renderingStartTime=0,G.last=S,G.tail=b,G.tailMode=R,G.treeForkCount=O)}function hj(d,p,b){var S=p.pendingProps,R=S.revealOrder,O=S.tail;S=S.children;var G=Ni.current,ae=(G&2)!==0;if(ae?(G=G&1|2,p.flags|=128):G&=1,re(Ni,G),Lr(d,p,S,b),S=yn?Jm:0,!ae&&d!==null&&(d.flags&128)!==0)e:for(d=p.child;d!==null;){if(d.tag===13)d.memoizedState!==null&&fj(d,b,p);else if(d.tag===19)fj(d,b,p);else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===p)break e;for(;d.sibling===null;){if(d.return===null||d.return===p)break e;d=d.return}d.sibling.return=d.return,d=d.sibling}switch(R){case"forwards":for(b=p.child,R=null;b!==null;)d=b.alternate,d!==null&&Hv(d)===null&&(R=b),b=b.sibling;b=R,b===null?(R=p.child,p.child=null):(R=b.sibling,b.sibling=null),LE(p,!1,R,b,O,S);break;case"backwards":case"unstable_legacy-backwards":for(b=null,R=p.child,p.child=null;R!==null;){if(d=R.alternate,d!==null&&Hv(d)===null){p.child=R;break}d=R.sibling,R.sibling=b,b=R,R=d}LE(p,!0,b,null,O,S);break;case"together":LE(p,!1,null,null,void 0,S);break;default:p.memoizedState=null}return p.child}function yl(d,p,b){if(d!==null&&(p.dependencies=d.dependencies),qc|=p.lanes,(b&p.childLanes)===0)if(d!==null){if(ih(d,p,b,!1),(b&p.childLanes)===0)return null}else return null;if(d!==null&&p.child!==d.child)throw Error(i(153));if(p.child!==null){for(d=p.child,b=hl(d,d.pendingProps),p.child=b,b.return=p;d.sibling!==null;)d=d.sibling,b=b.sibling=hl(d,d.pendingProps),b.return=p;b.sibling=null}return p.child}function IE(d,p){return(d.lanes&p)!==0?!0:(d=d.dependencies,!!(d!==null&&Ov(d)))}function rte(d,p,b){switch(p.tag){case 3:ke(p,p.stateNode.containerInfo),Fc(p,ji,d.memoizedState.cache),gd();break;case 27:case 5:we(p);break;case 4:ke(p,p.stateNode.containerInfo);break;case 10:Fc(p,p.type,p.memoizedProps.value);break;case 31:if(p.memoizedState!==null)return p.flags|=128,oE(p),null;break;case 13:var S=p.memoizedState;if(S!==null)return S.dehydrated!==null?($c(p),p.flags|=128,null):(b&p.child.childLanes)!==0?dj(d,p,b):($c(p),d=yl(d,p,b),d!==null?d.sibling:null);$c(p);break;case 19:var R=(d.flags&128)!==0;if(S=(b&p.childLanes)!==0,S||(ih(d,p,b,!1),S=(b&p.childLanes)!==0),R){if(S)return hj(d,p,b);p.flags|=128}if(R=p.memoizedState,R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),re(Ni,Ni.current),S)break;return null;case 22:return p.lanes=0,aj(d,p,b,p.pendingProps);case 24:Fc(p,ji,d.memoizedState.cache)}return yl(d,p,b)}function pj(d,p,b){if(d!==null)if(d.memoizedProps!==p.pendingProps)Fi=!0;else{if(!IE(d,b)&&(p.flags&128)===0)return Fi=!1,rte(d,p,b);Fi=(d.flags&131072)!==0}else Fi=!1,yn&&(p.flags&1048576)!==0&&WL(p,Jm,p.index);switch(p.lanes=0,p.tag){case 16:e:{var S=p.pendingProps;if(d=bd(p.elementType),p.type=d,typeof d=="function")BM(d)?(S=Md(d,S),p.tag=1,p=cj(null,p,d,S,b)):(p.tag=0,p=NE(null,p,d,S,b));else{if(d!=null){var R=d.$$typeof;if(R===C){p.tag=11,p=nj(null,p,d,S,b);break e}else if(R===A){p.tag=14,p=ij(null,p,d,S,b);break e}}throw p=D(d)||d,Error(i(306,p,""))}}return p;case 0:return NE(d,p,p.type,p.pendingProps,b);case 1:return S=p.type,R=Md(S,p.pendingProps),cj(d,p,S,R,b);case 3:e:{if(ke(p,p.stateNode.containerInfo),d===null)throw Error(i(387));S=p.pendingProps;var O=p.memoizedState;R=O.element,nE(d,p),og(p,S,null,b);var G=p.memoizedState;if(S=G.cache,Fc(p,ji,S),S!==O.cache&&YM(p,[ji],b,!0),sg(),S=G.element,O.isDehydrated)if(O={element:S,isDehydrated:!1,cache:G.cache},p.updateQueue.baseState=O,p.memoizedState=O,p.flags&256){p=uj(d,p,S,b);break e}else if(S!==R){R=xs(Error(i(424)),p),eg(R),p=uj(d,p,S,b);break e}else{switch(d=p.stateNode.containerInfo,d.nodeType){case 9:d=d.body;break;default:d=d.nodeName==="HTML"?d.ownerDocument.body:d}for(ti=Ss(d.firstChild),Dr=p,yn=!0,jc=null,bs=!0,b=aI(p,null,S,b),p.child=b;b;)b.flags=b.flags&-3|4096,b=b.sibling}else{if(gd(),S===R){p=yl(d,p,b);break e}Lr(d,p,S,b)}p=p.child}return p;case 26:return Jv(d,p),d===null?(b=E4(p.type,null,p.pendingProps,null))?p.memoizedState=b:yn||(b=p.type,d=p.pendingProps,S=gy(ie.current).createElement(b),S[hi]=p,S[Ti]=d,Ir(S,b,d),Ne(S),p.stateNode=S):p.memoizedState=E4(p.type,d.memoizedProps,p.pendingProps,d.memoizedState),null;case 27:return we(p),d===null&&yn&&(S=p.stateNode=S4(p.type,p.pendingProps,ie.current),Dr=p,bs=!0,R=ti,Qc(p.type)?(mA=R,ti=Ss(S.firstChild)):ti=R),Lr(d,p,p.pendingProps.children,b),Jv(d,p),d===null&&(p.flags|=4194304),p.child;case 5:return d===null&&yn&&((R=S=ti)&&(S=Ote(S,p.type,p.pendingProps,bs),S!==null?(p.stateNode=S,Dr=p,ti=Ss(S.firstChild),bs=!1,R=!0):R=!1),R||Uc(p)),we(p),R=p.type,O=p.pendingProps,G=d!==null?d.memoizedProps:null,S=O.children,uA(R,O)?S=null:G!==null&&uA(R,G)&&(p.flags|=32),p.memoizedState!==null&&(R=cE(d,p,Kee,null,null,b),Tg._currentValue=R),Jv(d,p),Lr(d,p,S,b),p.child;case 6:return d===null&&yn&&((d=b=ti)&&(b=Lte(b,p.pendingProps,bs),b!==null?(p.stateNode=b,Dr=p,ti=null,d=!0):d=!1),d||Uc(p)),null;case 13:return dj(d,p,b);case 4:return ke(p,p.stateNode.containerInfo),S=p.pendingProps,d===null?p.child=Sd(p,null,S,b):Lr(d,p,S,b),p.child;case 11:return nj(d,p,p.type,p.pendingProps,b);case 7:return Lr(d,p,p.pendingProps,b),p.child;case 8:return Lr(d,p,p.pendingProps.children,b),p.child;case 12:return Lr(d,p,p.pendingProps.children,b),p.child;case 10:return S=p.pendingProps,Fc(p,p.type,S.value),Lr(d,p,S.children,b),p.child;case 9:return R=p.type._context,S=p.pendingProps.children,vd(p),R=Or(R),S=S(R),p.flags|=1,Lr(d,p,S,b),p.child;case 14:return ij(d,p,p.type,p.pendingProps,b);case 15:return rj(d,p,p.type,p.pendingProps,b);case 19:return hj(d,p,b);case 31:return ite(d,p,b);case 22:return aj(d,p,b,p.pendingProps);case 24:return vd(p),S=Or(ji),d===null?(R=JM(),R===null&&(R=Xn,O=ZM(),R.pooledCache=O,O.refCount++,O!==null&&(R.pooledCacheLanes|=b),R=O),p.memoizedState={parent:S,cache:R},tE(p),Fc(p,ji,R)):((d.lanes&b)!==0&&(nE(d,p),og(p,null,null,b),sg()),R=d.memoizedState,O=p.memoizedState,R.parent!==S?(R={parent:S,cache:S},p.memoizedState=R,p.lanes===0&&(p.memoizedState=p.updateQueue.baseState=R),Fc(p,ji,S)):(S=O.cache,Fc(p,ji,S),S!==R.cache&&YM(p,[ji],b,!0))),Lr(d,p,p.pendingProps.children,b),p.child;case 29:throw p.pendingProps}throw Error(i(156,p.tag))}function bl(d){d.flags|=4}function jE(d,p,b,S,R){if((p=(d.mode&32)!==0)&&(p=!1),p){if(d.flags|=16777216,(R&335544128)===R)if(d.stateNode.complete)d.flags|=8192;else if(Bj())d.flags|=8192;else throw _d=Uv,eE}else d.flags&=-16777217}function mj(d,p){if(p.type!=="stylesheet"||(p.state.loading&4)!==0)d.flags&=-16777217;else if(d.flags|=16777216,!R4(p))if(Bj())d.flags|=8192;else throw _d=Uv,eE}function ty(d,p){p!==null&&(d.flags|=4),d.flags&16384&&(p=d.tag!==22?bt():536870912,d.lanes|=p,mh|=p)}function hg(d,p){if(!yn)switch(d.tailMode){case"hidden":p=d.tail;for(var b=null;p!==null;)p.alternate!==null&&(b=p),p=p.sibling;b===null?d.tail=null:b.sibling=null;break;case"collapsed":b=d.tail;for(var S=null;b!==null;)b.alternate!==null&&(S=b),b=b.sibling;S===null?p||d.tail===null?d.tail=null:d.tail.sibling=null:S.sibling=null}}function ni(d){var p=d.alternate!==null&&d.alternate.child===d.child,b=0,S=0;if(p)for(var R=d.child;R!==null;)b|=R.lanes|R.childLanes,S|=R.subtreeFlags&65011712,S|=R.flags&65011712,R.return=d,R=R.sibling;else for(R=d.child;R!==null;)b|=R.lanes|R.childLanes,S|=R.subtreeFlags,S|=R.flags,R.return=d,R=R.sibling;return d.subtreeFlags|=S,d.childLanes=b,p}function ate(d,p,b){var S=p.pendingProps;switch(GM(p),p.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ni(p),null;case 1:return ni(p),null;case 3:return b=p.stateNode,S=null,d!==null&&(S=d.memoizedState.cache),p.memoizedState.cache!==S&&(p.flags|=2048),gl(ji),he(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(d===null||d.child===null)&&(nh(p)?bl(p):d===null||d.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,qM())),ni(p),null;case 26:var R=p.type,O=p.memoizedState;return d===null?(bl(p),O!==null?(ni(p),mj(p,O)):(ni(p),jE(p,R,null,S,b))):O?O!==d.memoizedState?(bl(p),ni(p),mj(p,O)):(ni(p),p.flags&=-16777217):(d=d.memoizedProps,d!==S&&bl(p),ni(p),jE(p,R,d,S,b)),null;case 27:if(Ue(p),b=ie.current,R=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&bl(p);else{if(!S){if(p.stateNode===null)throw Error(i(166));return ni(p),null}d=le.current,nh(p)?XL(p):(d=S4(R,S,b),p.stateNode=d,bl(p))}return ni(p),null;case 5:if(Ue(p),R=p.type,d!==null&&p.stateNode!=null)d.memoizedProps!==S&&bl(p);else{if(!S){if(p.stateNode===null)throw Error(i(166));return ni(p),null}if(O=le.current,nh(p))XL(p);else{var G=gy(ie.current);switch(O){case 1:O=G.createElementNS("http://www.w3.org/2000/svg",R);break;case 2:O=G.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;default:switch(R){case"svg":O=G.createElementNS("http://www.w3.org/2000/svg",R);break;case"math":O=G.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;case"script":O=G.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof S.is=="string"?G.createElement("select",{is:S.is}):G.createElement("select"),S.multiple?O.multiple=!0:S.size&&(O.size=S.size);break;default:O=typeof S.is=="string"?G.createElement(R,{is:S.is}):G.createElement(R)}}O[hi]=p,O[Ti]=S;e:for(G=p.child;G!==null;){if(G.tag===5||G.tag===6)O.appendChild(G.stateNode);else if(G.tag!==4&&G.tag!==27&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===p)break e;for(;G.sibling===null;){if(G.return===null||G.return===p)break e;G=G.return}G.sibling.return=G.return,G=G.sibling}p.stateNode=O;e:switch(Ir(O,R,S),R){case"button":case"input":case"select":case"textarea":S=!!S.autoFocus;break e;case"img":S=!0;break e;default:S=!1}S&&bl(p)}}return ni(p),jE(p,p.type,d===null?null:d.memoizedProps,p.pendingProps,b),null;case 6:if(d&&p.stateNode!=null)d.memoizedProps!==S&&bl(p);else{if(typeof S!="string"&&p.stateNode===null)throw Error(i(166));if(d=ie.current,nh(p)){if(d=p.stateNode,b=p.memoizedProps,S=null,R=Dr,R!==null)switch(R.tag){case 27:case 5:S=R.memoizedProps}d[hi]=p,d=!!(d.nodeValue===b||S!==null&&S.suppressHydrationWarning===!0||d4(d.nodeValue,b)),d||Uc(p,!0)}else d=gy(d).createTextNode(S),d[hi]=p,p.stateNode=d}return ni(p),null;case 31:if(b=p.memoizedState,d===null||d.memoizedState!==null){if(S=nh(p),b!==null){if(d===null){if(!S)throw Error(i(318));if(d=p.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(i(557));d[hi]=p}else gd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;ni(p),d=!1}else b=qM(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=b),d=!0;if(!d)return p.flags&256?(Ka(p),p):(Ka(p),null);if((p.flags&128)!==0)throw Error(i(558))}return ni(p),null;case 13:if(S=p.memoizedState,d===null||d.memoizedState!==null&&d.memoizedState.dehydrated!==null){if(R=nh(p),S!==null&&S.dehydrated!==null){if(d===null){if(!R)throw Error(i(318));if(R=p.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(i(317));R[hi]=p}else gd(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;ni(p),R=!1}else R=qM(),d!==null&&d.memoizedState!==null&&(d.memoizedState.hydrationErrors=R),R=!0;if(!R)return p.flags&256?(Ka(p),p):(Ka(p),null)}return Ka(p),(p.flags&128)!==0?(p.lanes=b,p):(b=S!==null,d=d!==null&&d.memoizedState!==null,b&&(S=p.child,R=null,S.alternate!==null&&S.alternate.memoizedState!==null&&S.alternate.memoizedState.cachePool!==null&&(R=S.alternate.memoizedState.cachePool.pool),O=null,S.memoizedState!==null&&S.memoizedState.cachePool!==null&&(O=S.memoizedState.cachePool.pool),O!==R&&(S.flags|=2048)),b!==d&&b&&(p.child.flags|=8192),ty(p,p.updateQueue),ni(p),null);case 4:return he(),d===null&&aA(p.stateNode.containerInfo),ni(p),null;case 10:return gl(p.type),ni(p),null;case 19:if(V(Ni),S=p.memoizedState,S===null)return ni(p),null;if(R=(p.flags&128)!==0,O=S.rendering,O===null)if(R)hg(S,!1);else{if(_i!==0||d!==null&&(d.flags&128)!==0)for(d=p.child;d!==null;){if(O=Hv(d),O!==null){for(p.flags|=128,hg(S,!1),d=O.updateQueue,p.updateQueue=d,ty(p,d),p.subtreeFlags=0,d=b,b=p.child;b!==null;)$L(b,d),b=b.sibling;return re(Ni,Ni.current&1|2),yn&&pl(p,S.treeForkCount),p.child}d=d.sibling}S.tail!==null&&L()>sy&&(p.flags|=128,R=!0,hg(S,!1),p.lanes=4194304)}else{if(!R)if(d=Hv(O),d!==null){if(p.flags|=128,R=!0,d=d.updateQueue,p.updateQueue=d,ty(p,d),hg(S,!0),S.tail===null&&S.tailMode==="hidden"&&!O.alternate&&!yn)return ni(p),null}else 2*L()-S.renderingStartTime>sy&&b!==536870912&&(p.flags|=128,R=!0,hg(S,!1),p.lanes=4194304);S.isBackwards?(O.sibling=p.child,p.child=O):(d=S.last,d!==null?d.sibling=O:p.child=O,S.last=O)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=L(),d.sibling=null,b=Ni.current,re(Ni,R?b&1|2:b&1),yn&&pl(p,S.treeForkCount),d):(ni(p),null);case 22:case 23:return Ka(p),sE(),S=p.memoizedState!==null,d!==null?d.memoizedState!==null!==S&&(p.flags|=8192):S&&(p.flags|=8192),S?(b&536870912)!==0&&(p.flags&128)===0&&(ni(p),p.subtreeFlags&6&&(p.flags|=8192)):ni(p),b=p.updateQueue,b!==null&&ty(p,b.retryQueue),b=null,d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(b=d.memoizedState.cachePool.pool),S=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(S=p.memoizedState.cachePool.pool),S!==b&&(p.flags|=2048),d!==null&&V(yd),null;case 24:return b=null,d!==null&&(b=d.memoizedState.cache),p.memoizedState.cache!==b&&(p.flags|=2048),gl(ji),ni(p),null;case 25:return null;case 30:return null}throw Error(i(156,p.tag))}function ste(d,p){switch(GM(p),p.tag){case 1:return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 3:return gl(ji),he(),d=p.flags,(d&65536)!==0&&(d&128)===0?(p.flags=d&-65537|128,p):null;case 26:case 27:case 5:return Ue(p),null;case 31:if(p.memoizedState!==null){if(Ka(p),p.alternate===null)throw Error(i(340));gd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 13:if(Ka(p),d=p.memoizedState,d!==null&&d.dehydrated!==null){if(p.alternate===null)throw Error(i(340));gd()}return d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 19:return V(Ni),null;case 4:return he(),null;case 10:return gl(p.type),null;case 22:case 23:return Ka(p),sE(),d!==null&&V(yd),d=p.flags,d&65536?(p.flags=d&-65537|128,p):null;case 24:return gl(ji),null;case 25:return null;default:return null}}function gj(d,p){switch(GM(p),p.tag){case 3:gl(ji),he();break;case 26:case 27:case 5:Ue(p);break;case 4:he();break;case 31:p.memoizedState!==null&&Ka(p);break;case 13:Ka(p);break;case 19:V(Ni);break;case 10:gl(p.type);break;case 22:case 23:Ka(p),sE(),d!==null&&V(yd);break;case 24:gl(ji)}}function pg(d,p){try{var b=p.updateQueue,S=b!==null?b.lastEffect:null;if(S!==null){var R=S.next;b=R;do{if((b.tag&d)===d){S=void 0;var O=b.create,G=b.inst;S=O(),G.destroy=S}b=b.next}while(b!==R)}}catch(ae){Dn(p,p.return,ae)}}function Gc(d,p,b){try{var S=p.updateQueue,R=S!==null?S.lastEffect:null;if(R!==null){var O=R.next;S=O;do{if((S.tag&d)===d){var G=S.inst,ae=G.destroy;if(ae!==void 0){G.destroy=void 0,R=p;var _e=b,ze=ae;try{ze()}catch(et){Dn(R,_e,et)}}}S=S.next}while(S!==O)}}catch(et){Dn(p,p.return,et)}}function xj(d){var p=d.updateQueue;if(p!==null){var b=d.stateNode;try{oI(p,b)}catch(S){Dn(d,d.return,S)}}}function vj(d,p,b){b.props=Md(d.type,d.memoizedProps),b.state=d.memoizedState;try{b.componentWillUnmount()}catch(S){Dn(d,p,S)}}function mg(d,p){try{var b=d.ref;if(b!==null){switch(d.tag){case 26:case 27:case 5:var S=d.stateNode;break;case 30:S=d.stateNode;break;default:S=d.stateNode}typeof b=="function"?d.refCleanup=b(S):b.current=S}}catch(R){Dn(d,p,R)}}function ko(d,p){var b=d.ref,S=d.refCleanup;if(b!==null)if(typeof S=="function")try{S()}catch(R){Dn(d,p,R)}finally{d.refCleanup=null,d=d.alternate,d!=null&&(d.refCleanup=null)}else if(typeof b=="function")try{b(null)}catch(R){Dn(d,p,R)}else b.current=null}function yj(d){var p=d.type,b=d.memoizedProps,S=d.stateNode;try{e:switch(p){case"button":case"input":case"select":case"textarea":b.autoFocus&&S.focus();break e;case"img":b.src?S.src=b.src:b.srcSet&&(S.srcset=b.srcSet)}}catch(R){Dn(d,d.return,R)}}function UE(d,p,b){try{var S=d.stateNode;Cte(S,d.type,b,p),S[Ti]=p}catch(R){Dn(d,d.return,R)}}function bj(d){return d.tag===5||d.tag===3||d.tag===26||d.tag===27&&Qc(d.type)||d.tag===4}function FE(d){e:for(;;){for(;d.sibling===null;){if(d.return===null||bj(d.return))return null;d=d.return}for(d.sibling.return=d.return,d=d.sibling;d.tag!==5&&d.tag!==6&&d.tag!==18;){if(d.tag===27&&Qc(d.type)||d.flags&2||d.child===null||d.tag===4)continue e;d.child.return=d,d=d.child}if(!(d.flags&2))return d.stateNode}}function zE(d,p,b){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?(b.nodeType===9?b.body:b.nodeName==="HTML"?b.ownerDocument.body:b).insertBefore(d,p):(p=b.nodeType===9?b.body:b.nodeName==="HTML"?b.ownerDocument.body:b,p.appendChild(d),b=b._reactRootContainer,b!=null||p.onclick!==null||(p.onclick=dl));else if(S!==4&&(S===27&&Qc(d.type)&&(b=d.stateNode,p=null),d=d.child,d!==null))for(zE(d,p,b),d=d.sibling;d!==null;)zE(d,p,b),d=d.sibling}function ny(d,p,b){var S=d.tag;if(S===5||S===6)d=d.stateNode,p?b.insertBefore(d,p):b.appendChild(d);else if(S!==4&&(S===27&&Qc(d.type)&&(b=d.stateNode),d=d.child,d!==null))for(ny(d,p,b),d=d.sibling;d!==null;)ny(d,p,b),d=d.sibling}function _j(d){var p=d.stateNode,b=d.memoizedProps;try{for(var S=d.type,R=p.attributes;R.length;)p.removeAttributeNode(R[0]);Ir(p,S,b),p[hi]=d,p[Ti]=b}catch(O){Dn(d,d.return,O)}}var _l=!1,zi=!1,BE=!1,Sj=typeof WeakSet=="function"?WeakSet:Set,yr=null;function ote(d,p){if(d=d.containerInfo,lA=wy,d=OL(d),OM(d)){if("selectionStart"in d)var b={start:d.selectionStart,end:d.selectionEnd};else e:{b=(b=d.ownerDocument)&&b.defaultView||window;var S=b.getSelection&&b.getSelection();if(S&&S.rangeCount!==0){b=S.anchorNode;var R=S.anchorOffset,O=S.focusNode;S=S.focusOffset;try{b.nodeType,O.nodeType}catch{b=null;break e}var G=0,ae=-1,_e=-1,ze=0,et=0,ot=d,Ve=null;t:for(;;){for(var Ze;ot!==b||R!==0&&ot.nodeType!==3||(ae=G+R),ot!==O||S!==0&&ot.nodeType!==3||(_e=G+S),ot.nodeType===3&&(G+=ot.nodeValue.length),(Ze=ot.firstChild)!==null;)Ve=ot,ot=Ze;for(;;){if(ot===d)break t;if(Ve===b&&++ze===R&&(ae=G),Ve===O&&++et===S&&(_e=G),(Ze=ot.nextSibling)!==null)break;ot=Ve,Ve=ot.parentNode}ot=Ze}b=ae===-1||_e===-1?null:{start:ae,end:_e}}else b=null}b=b||{start:0,end:0}}else b=null;for(cA={focusedElem:d,selectionRange:b},wy=!1,yr=p;yr!==null;)if(p=yr,d=p.child,(p.subtreeFlags&1028)!==0&&d!==null)d.return=p,yr=d;else for(;yr!==null;){switch(p=yr,O=p.alternate,d=p.flags,p.tag){case 0:if((d&4)!==0&&(d=p.updateQueue,d=d!==null?d.events:null,d!==null))for(b=0;b<d.length;b++)R=d[b],R.ref.impl=R.nextImpl;break;case 11:case 15:break;case 1:if((d&1024)!==0&&O!==null){d=void 0,b=p,R=O.memoizedProps,O=O.memoizedState,S=b.stateNode;try{var Ct=Md(b.type,R);d=S.getSnapshotBeforeUpdate(Ct,O),S.__reactInternalSnapshotBeforeUpdate=d}catch(Bt){Dn(b,b.return,Bt)}}break;case 3:if((d&1024)!==0){if(d=p.stateNode.containerInfo,b=d.nodeType,b===9)fA(d);else if(b===1)switch(d.nodeName){case"HEAD":case"HTML":case"BODY":fA(d);break;default:d.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((d&1024)!==0)throw Error(i(163))}if(d=p.sibling,d!==null){d.return=p.return,yr=d;break}yr=p.return}}function wj(d,p,b){var S=b.flags;switch(b.tag){case 0:case 11:case 15:wl(d,b),S&4&&pg(5,b);break;case 1:if(wl(d,b),S&4)if(d=b.stateNode,p===null)try{d.componentDidMount()}catch(G){Dn(b,b.return,G)}else{var R=Md(b.type,p.memoizedProps);p=p.memoizedState;try{d.componentDidUpdate(R,p,d.__reactInternalSnapshotBeforeUpdate)}catch(G){Dn(b,b.return,G)}}S&64&&xj(b),S&512&&mg(b,b.return);break;case 3:if(wl(d,b),S&64&&(d=b.updateQueue,d!==null)){if(p=null,b.child!==null)switch(b.child.tag){case 27:case 5:p=b.child.stateNode;break;case 1:p=b.child.stateNode}try{oI(d,p)}catch(G){Dn(b,b.return,G)}}break;case 27:p===null&&S&4&&_j(b);case 26:case 5:wl(d,b),p===null&&S&4&&yj(b),S&512&&mg(b,b.return);break;case 12:wl(d,b);break;case 31:wl(d,b),S&4&&Aj(d,b);break;case 13:wl(d,b),S&4&&Tj(d,b),S&64&&(d=b.memoizedState,d!==null&&(d=d.dehydrated,d!==null&&(b=gte.bind(null,b),Ite(d,b))));break;case 22:if(S=b.memoizedState!==null||_l,!S){p=p!==null&&p.memoizedState!==null||zi,R=_l;var O=zi;_l=S,(zi=p)&&!O?Ml(d,b,(b.subtreeFlags&8772)!==0):wl(d,b),_l=R,zi=O}break;case 30:break;default:wl(d,b)}}function Mj(d){var p=d.alternate;p!==null&&(d.alternate=null,Mj(p)),d.child=null,d.deletions=null,d.sibling=null,d.tag===5&&(p=d.stateNode,p!==null&&We(p)),d.stateNode=null,d.return=null,d.dependencies=null,d.memoizedProps=null,d.memoizedState=null,d.pendingProps=null,d.stateNode=null,d.updateQueue=null}var li=null,Ea=!1;function Sl(d,p,b){for(b=b.child;b!==null;)Ej(d,p,b),b=b.sibling}function Ej(d,p,b){if(Pe&&typeof Pe.onCommitFiberUnmount=="function")try{Pe.onCommitFiberUnmount(Ie,b)}catch{}switch(b.tag){case 26:zi||ko(b,p),Sl(d,p,b),b.memoizedState?b.memoizedState.count--:b.stateNode&&(b=b.stateNode,b.parentNode.removeChild(b));break;case 27:zi||ko(b,p);var S=li,R=Ea;Qc(b.type)&&(li=b.stateNode,Ea=!1),Sl(d,p,b),Mg(b.stateNode),li=S,Ea=R;break;case 5:zi||ko(b,p);case 6:if(S=li,R=Ea,li=null,Sl(d,p,b),li=S,Ea=R,li!==null)if(Ea)try{(li.nodeType===9?li.body:li.nodeName==="HTML"?li.ownerDocument.body:li).removeChild(b.stateNode)}catch(O){Dn(b,p,O)}else try{li.removeChild(b.stateNode)}catch(O){Dn(b,p,O)}break;case 18:li!==null&&(Ea?(d=li,x4(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,b.stateNode),wh(d)):x4(li,b.stateNode));break;case 4:S=li,R=Ea,li=b.stateNode.containerInfo,Ea=!0,Sl(d,p,b),li=S,Ea=R;break;case 0:case 11:case 14:case 15:Gc(2,b,p),zi||Gc(4,b,p),Sl(d,p,b);break;case 1:zi||(ko(b,p),S=b.stateNode,typeof S.componentWillUnmount=="function"&&vj(b,p,S)),Sl(d,p,b);break;case 21:Sl(d,p,b);break;case 22:zi=(S=zi)||b.memoizedState!==null,Sl(d,p,b),zi=S;break;default:Sl(d,p,b)}}function Aj(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null))){d=d.dehydrated;try{wh(d)}catch(b){Dn(p,p.return,b)}}}function Tj(d,p){if(p.memoizedState===null&&(d=p.alternate,d!==null&&(d=d.memoizedState,d!==null&&(d=d.dehydrated,d!==null))))try{wh(d)}catch(b){Dn(p,p.return,b)}}function lte(d){switch(d.tag){case 31:case 13:case 19:var p=d.stateNode;return p===null&&(p=d.stateNode=new Sj),p;case 22:return d=d.stateNode,p=d._retryCache,p===null&&(p=d._retryCache=new Sj),p;default:throw Error(i(435,d.tag))}}function iy(d,p){var b=lte(d);p.forEach(function(S){if(!b.has(S)){b.add(S);var R=xte.bind(null,d,S);S.then(R,R)}})}function Aa(d,p){var b=p.deletions;if(b!==null)for(var S=0;S<b.length;S++){var R=b[S],O=d,G=p,ae=G;e:for(;ae!==null;){switch(ae.tag){case 27:if(Qc(ae.type)){li=ae.stateNode,Ea=!1;break e}break;case 5:li=ae.stateNode,Ea=!1;break e;case 3:case 4:li=ae.stateNode.containerInfo,Ea=!0;break e}ae=ae.return}if(li===null)throw Error(i(160));Ej(O,G,R),li=null,Ea=!1,O=R.alternate,O!==null&&(O.return=null),R.return=null}if(p.subtreeFlags&13886)for(p=p.child;p!==null;)Cj(p,d),p=p.sibling}var to=null;function Cj(d,p){var b=d.alternate,S=d.flags;switch(d.tag){case 0:case 11:case 14:case 15:Aa(p,d),Ta(d),S&4&&(Gc(3,d,d.return),pg(3,d),Gc(5,d,d.return));break;case 1:Aa(p,d),Ta(d),S&512&&(zi||b===null||ko(b,b.return)),S&64&&_l&&(d=d.updateQueue,d!==null&&(S=d.callbacks,S!==null&&(b=d.shared.hiddenCallbacks,d.shared.hiddenCallbacks=b===null?S:b.concat(S))));break;case 26:var R=to;if(Aa(p,d),Ta(d),S&512&&(zi||b===null||ko(b,b.return)),S&4){var O=b!==null?b.memoizedState:null;if(S=d.memoizedState,b===null)if(S===null)if(d.stateNode===null){e:{S=d.type,b=d.memoizedProps,R=R.ownerDocument||R;t:switch(S){case"title":O=R.getElementsByTagName("title")[0],(!O||O[Ke]||O[hi]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=R.createElement(S),R.head.insertBefore(O,R.querySelector("head > title"))),Ir(O,S,b),O[hi]=d,Ne(O),S=O;break e;case"link":var G=C4("link","href",R).get(S+(b.href||""));if(G){for(var ae=0;ae<G.length;ae++)if(O=G[ae],O.getAttribute("href")===(b.href==null||b.href===""?null:b.href)&&O.getAttribute("rel")===(b.rel==null?null:b.rel)&&O.getAttribute("title")===(b.title==null?null:b.title)&&O.getAttribute("crossorigin")===(b.crossOrigin==null?null:b.crossOrigin)){G.splice(ae,1);break t}}O=R.createElement(S),Ir(O,S,b),R.head.appendChild(O);break;case"meta":if(G=C4("meta","content",R).get(S+(b.content||""))){for(ae=0;ae<G.length;ae++)if(O=G[ae],O.getAttribute("content")===(b.content==null?null:""+b.content)&&O.getAttribute("name")===(b.name==null?null:b.name)&&O.getAttribute("property")===(b.property==null?null:b.property)&&O.getAttribute("http-equiv")===(b.httpEquiv==null?null:b.httpEquiv)&&O.getAttribute("charset")===(b.charSet==null?null:b.charSet)){G.splice(ae,1);break t}}O=R.createElement(S),Ir(O,S,b),R.head.appendChild(O);break;default:throw Error(i(468,S))}O[hi]=d,Ne(O),S=O}d.stateNode=S}else N4(R,d.type,d.stateNode);else d.stateNode=T4(R,S,d.memoizedProps);else O!==S?(O===null?b.stateNode!==null&&(b=b.stateNode,b.parentNode.removeChild(b)):O.count--,S===null?N4(R,d.type,d.stateNode):T4(R,S,d.memoizedProps)):S===null&&d.stateNode!==null&&UE(d,d.memoizedProps,b.memoizedProps)}break;case 27:Aa(p,d),Ta(d),S&512&&(zi||b===null||ko(b,b.return)),b!==null&&S&4&&UE(d,d.memoizedProps,b.memoizedProps);break;case 5:if(Aa(p,d),Ta(d),S&512&&(zi||b===null||ko(b,b.return)),d.flags&32){R=d.stateNode;try{No(R,"")}catch(Ct){Dn(d,d.return,Ct)}}S&4&&d.stateNode!=null&&(R=d.memoizedProps,UE(d,R,b!==null?b.memoizedProps:R)),S&1024&&(BE=!0);break;case 6:if(Aa(p,d),Ta(d),S&4){if(d.stateNode===null)throw Error(i(162));S=d.memoizedProps,b=d.stateNode;try{b.nodeValue=S}catch(Ct){Dn(d,d.return,Ct)}}break;case 3:if(yy=null,R=to,to=xy(p.containerInfo),Aa(p,d),to=R,Ta(d),S&4&&b!==null&&b.memoizedState.isDehydrated)try{wh(p.containerInfo)}catch(Ct){Dn(d,d.return,Ct)}BE&&(BE=!1,Nj(d));break;case 4:S=to,to=xy(d.stateNode.containerInfo),Aa(p,d),Ta(d),to=S;break;case 12:Aa(p,d),Ta(d);break;case 31:Aa(p,d),Ta(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,iy(d,S)));break;case 13:Aa(p,d),Ta(d),d.child.flags&8192&&d.memoizedState!==null!=(b!==null&&b.memoizedState!==null)&&(ay=L()),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,iy(d,S)));break;case 22:R=d.memoizedState!==null;var _e=b!==null&&b.memoizedState!==null,ze=_l,et=zi;if(_l=ze||R,zi=et||_e,Aa(p,d),zi=et,_l=ze,Ta(d),S&8192)e:for(p=d.stateNode,p._visibility=R?p._visibility&-2:p._visibility|1,R&&(b===null||_e||_l||zi||Ed(d)),b=null,p=d;;){if(p.tag===5||p.tag===26){if(b===null){_e=b=p;try{if(O=_e.stateNode,R)G=O.style,typeof G.setProperty=="function"?G.setProperty("display","none","important"):G.display="none";else{ae=_e.stateNode;var ot=_e.memoizedProps.style,Ve=ot!=null&&ot.hasOwnProperty("display")?ot.display:null;ae.style.display=Ve==null||typeof Ve=="boolean"?"":(""+Ve).trim()}}catch(Ct){Dn(_e,_e.return,Ct)}}}else if(p.tag===6){if(b===null){_e=p;try{_e.stateNode.nodeValue=R?"":_e.memoizedProps}catch(Ct){Dn(_e,_e.return,Ct)}}}else if(p.tag===18){if(b===null){_e=p;try{var Ze=_e.stateNode;R?v4(Ze,!0):v4(_e.stateNode,!1)}catch(Ct){Dn(_e,_e.return,Ct)}}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===d)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===d)break e;for(;p.sibling===null;){if(p.return===null||p.return===d)break e;b===p&&(b=null),p=p.return}b===p&&(b=null),p.sibling.return=p.return,p=p.sibling}S&4&&(S=d.updateQueue,S!==null&&(b=S.retryQueue,b!==null&&(S.retryQueue=null,iy(d,b))));break;case 19:Aa(p,d),Ta(d),S&4&&(S=d.updateQueue,S!==null&&(d.updateQueue=null,iy(d,S)));break;case 30:break;case 21:break;default:Aa(p,d),Ta(d)}}function Ta(d){var p=d.flags;if(p&2){try{for(var b,S=d.return;S!==null;){if(bj(S)){b=S;break}S=S.return}if(b==null)throw Error(i(160));switch(b.tag){case 27:var R=b.stateNode,O=FE(d);ny(d,O,R);break;case 5:var G=b.stateNode;b.flags&32&&(No(G,""),b.flags&=-33);var ae=FE(d);ny(d,ae,G);break;case 3:case 4:var _e=b.stateNode.containerInfo,ze=FE(d);zE(d,ze,_e);break;default:throw Error(i(161))}}catch(et){Dn(d,d.return,et)}d.flags&=-3}p&4096&&(d.flags&=-4097)}function Nj(d){if(d.subtreeFlags&1024)for(d=d.child;d!==null;){var p=d;Nj(p),p.tag===5&&p.flags&1024&&p.stateNode.reset(),d=d.sibling}}function wl(d,p){if(p.subtreeFlags&8772)for(p=p.child;p!==null;)wj(d,p.alternate,p),p=p.sibling}function Ed(d){for(d=d.child;d!==null;){var p=d;switch(p.tag){case 0:case 11:case 14:case 15:Gc(4,p,p.return),Ed(p);break;case 1:ko(p,p.return);var b=p.stateNode;typeof b.componentWillUnmount=="function"&&vj(p,p.return,b),Ed(p);break;case 27:Mg(p.stateNode);case 26:case 5:ko(p,p.return),Ed(p);break;case 22:p.memoizedState===null&&Ed(p);break;case 30:Ed(p);break;default:Ed(p)}d=d.sibling}}function Ml(d,p,b){for(b=b&&(p.subtreeFlags&8772)!==0,p=p.child;p!==null;){var S=p.alternate,R=d,O=p,G=O.flags;switch(O.tag){case 0:case 11:case 15:Ml(R,O,b),pg(4,O);break;case 1:if(Ml(R,O,b),S=O,R=S.stateNode,typeof R.componentDidMount=="function")try{R.componentDidMount()}catch(ze){Dn(S,S.return,ze)}if(S=O,R=S.updateQueue,R!==null){var ae=S.stateNode;try{var _e=R.shared.hiddenCallbacks;if(_e!==null)for(R.shared.hiddenCallbacks=null,R=0;R<_e.length;R++)sI(_e[R],ae)}catch(ze){Dn(S,S.return,ze)}}b&&G&64&&xj(O),mg(O,O.return);break;case 27:_j(O);case 26:case 5:Ml(R,O,b),b&&S===null&&G&4&&yj(O),mg(O,O.return);break;case 12:Ml(R,O,b);break;case 31:Ml(R,O,b),b&&G&4&&Aj(R,O);break;case 13:Ml(R,O,b),b&&G&4&&Tj(R,O);break;case 22:O.memoizedState===null&&Ml(R,O,b),mg(O,O.return);break;case 30:break;default:Ml(R,O,b)}p=p.sibling}}function HE(d,p){var b=null;d!==null&&d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(b=d.memoizedState.cachePool.pool),d=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(d=p.memoizedState.cachePool.pool),d!==b&&(d!=null&&d.refCount++,b!=null&&tg(b))}function $E(d,p){d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&tg(d))}function no(d,p,b,S){if(p.subtreeFlags&10256)for(p=p.child;p!==null;)Rj(d,p,b,S),p=p.sibling}function Rj(d,p,b,S){var R=p.flags;switch(p.tag){case 0:case 11:case 15:no(d,p,b,S),R&2048&&pg(9,p);break;case 1:no(d,p,b,S);break;case 3:no(d,p,b,S),R&2048&&(d=null,p.alternate!==null&&(d=p.alternate.memoizedState.cache),p=p.memoizedState.cache,p!==d&&(p.refCount++,d!=null&&tg(d)));break;case 12:if(R&2048){no(d,p,b,S),d=p.stateNode;try{var O=p.memoizedProps,G=O.id,ae=O.onPostCommit;typeof ae=="function"&&ae(G,p.alternate===null?"mount":"update",d.passiveEffectDuration,-0)}catch(_e){Dn(p,p.return,_e)}}else no(d,p,b,S);break;case 31:no(d,p,b,S);break;case 13:no(d,p,b,S);break;case 23:break;case 22:O=p.stateNode,G=p.alternate,p.memoizedState!==null?O._visibility&2?no(d,p,b,S):gg(d,p):O._visibility&2?no(d,p,b,S):(O._visibility|=2,fh(d,p,b,S,(p.subtreeFlags&10256)!==0||!1)),R&2048&&HE(G,p);break;case 24:no(d,p,b,S),R&2048&&$E(p.alternate,p);break;default:no(d,p,b,S)}}function fh(d,p,b,S,R){for(R=R&&((p.subtreeFlags&10256)!==0||!1),p=p.child;p!==null;){var O=d,G=p,ae=b,_e=S,ze=G.flags;switch(G.tag){case 0:case 11:case 15:fh(O,G,ae,_e,R),pg(8,G);break;case 23:break;case 22:var et=G.stateNode;G.memoizedState!==null?et._visibility&2?fh(O,G,ae,_e,R):gg(O,G):(et._visibility|=2,fh(O,G,ae,_e,R)),R&&ze&2048&&HE(G.alternate,G);break;case 24:fh(O,G,ae,_e,R),R&&ze&2048&&$E(G.alternate,G);break;default:fh(O,G,ae,_e,R)}p=p.sibling}}function gg(d,p){if(p.subtreeFlags&10256)for(p=p.child;p!==null;){var b=d,S=p,R=S.flags;switch(S.tag){case 22:gg(b,S),R&2048&&HE(S.alternate,S);break;case 24:gg(b,S),R&2048&&$E(S.alternate,S);break;default:gg(b,S)}p=p.sibling}}var xg=8192;function hh(d,p,b){if(d.subtreeFlags&xg)for(d=d.child;d!==null;)Pj(d,p,b),d=d.sibling}function Pj(d,p,b){switch(d.tag){case 26:hh(d,p,b),d.flags&xg&&d.memoizedState!==null&&Xte(b,to,d.memoizedState,d.memoizedProps);break;case 5:hh(d,p,b);break;case 3:case 4:var S=to;to=xy(d.stateNode.containerInfo),hh(d,p,b),to=S;break;case 22:d.memoizedState===null&&(S=d.alternate,S!==null&&S.memoizedState!==null?(S=xg,xg=16777216,hh(d,p,b),xg=S):hh(d,p,b));break;default:hh(d,p,b)}}function kj(d){var p=d.alternate;if(p!==null&&(d=p.child,d!==null)){p.child=null;do p=d.sibling,d.sibling=null,d=p;while(d!==null)}}function vg(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var b=0;b<p.length;b++){var S=p[b];yr=S,Oj(S,d)}kj(d)}if(d.subtreeFlags&10256)for(d=d.child;d!==null;)Dj(d),d=d.sibling}function Dj(d){switch(d.tag){case 0:case 11:case 15:vg(d),d.flags&2048&&Gc(9,d,d.return);break;case 3:vg(d);break;case 12:vg(d);break;case 22:var p=d.stateNode;d.memoizedState!==null&&p._visibility&2&&(d.return===null||d.return.tag!==13)?(p._visibility&=-3,ry(d)):vg(d);break;default:vg(d)}}function ry(d){var p=d.deletions;if((d.flags&16)!==0){if(p!==null)for(var b=0;b<p.length;b++){var S=p[b];yr=S,Oj(S,d)}kj(d)}for(d=d.child;d!==null;){switch(p=d,p.tag){case 0:case 11:case 15:Gc(8,p,p.return),ry(p);break;case 22:b=p.stateNode,b._visibility&2&&(b._visibility&=-3,ry(p));break;default:ry(p)}d=d.sibling}}function Oj(d,p){for(;yr!==null;){var b=yr;switch(b.tag){case 0:case 11:case 15:Gc(8,b,p);break;case 23:case 22:if(b.memoizedState!==null&&b.memoizedState.cachePool!==null){var S=b.memoizedState.cachePool.pool;S!=null&&S.refCount++}break;case 24:tg(b.memoizedState.cache)}if(S=b.child,S!==null)S.return=b,yr=S;else e:for(b=d;yr!==null;){S=yr;var R=S.sibling,O=S.return;if(Mj(S),S===b){yr=null;break e}if(R!==null){R.return=O,yr=R;break e}yr=O}}}var cte={getCacheForType:function(d){var p=Or(ji),b=p.data.get(d);return b===void 0&&(b=d(),p.data.set(d,b)),b},cacheSignal:function(){return Or(ji).controller.signal}},ute=typeof WeakMap=="function"?WeakMap:Map,Cn=0,Xn=null,fn=null,gn=0,kn=0,Ya=null,Wc=!1,ph=!1,VE=!1,El=0,_i=0,qc=0,Ad=0,GE=0,Za=0,mh=0,yg=null,Ca=null,WE=!1,ay=0,Lj=0,sy=1/0,oy=null,Xc=null,er=0,Kc=null,gh=null,Al=0,qE=0,XE=null,Ij=null,bg=0,KE=null;function Qa(){return(Cn&2)!==0&&gn!==0?gn&-gn:$.T!==null?tA():Pr()}function jj(){if(Za===0)if((gn&536870912)===0||yn){var d=fe;fe<<=1,(fe&3932160)===0&&(fe=262144),Za=d}else Za=536870912;return d=Xa.current,d!==null&&(d.flags|=32),Za}function Na(d,p,b){(d===Xn&&(kn===2||kn===9)||d.cancelPendingCommit!==null)&&(xh(d,0),Yc(d,gn,Za,!1)),ln(d,b),((Cn&2)===0||d!==Xn)&&(d===Xn&&((Cn&2)===0&&(Ad|=b),_i===4&&Yc(d,gn,Za,!1)),Do(d))}function Uj(d,p,b){if((Cn&6)!==0)throw Error(i(327));var S=!b&&(p&127)===0&&(p&d.expiredLanes)===0||Be(d,p),R=S?hte(d,p):ZE(d,p,!0),O=S;do{if(R===0){ph&&!S&&Yc(d,p,0,!1);break}else{if(b=d.current.alternate,O&&!dte(b)){R=ZE(d,p,!1),O=!1;continue}if(R===2){if(O=p,d.errorRecoveryDisabledLanes&O)var G=0;else G=d.pendingLanes&-536870913,G=G!==0?G:G&536870912?536870912:0;if(G!==0){p=G;e:{var ae=d;R=yg;var _e=ae.current.memoizedState.isDehydrated;if(_e&&(xh(ae,G).flags|=256),G=ZE(ae,G,!1),G!==2){if(VE&&!_e){ae.errorRecoveryDisabledLanes|=O,Ad|=O,R=4;break e}O=Ca,Ca=R,O!==null&&(Ca===null?Ca=O:Ca.push.apply(Ca,O))}R=G}if(O=!1,R!==2)continue}}if(R===1){xh(d,0),Yc(d,p,0,!0);break}e:{switch(S=d,O=R,O){case 0:case 1:throw Error(i(345));case 4:if((p&4194048)!==p)break;case 6:Yc(S,p,Za,!Wc);break e;case 2:Ca=null;break;case 3:case 5:break;default:throw Error(i(329))}if((p&62914560)===p&&(R=ay+300-L(),10<R)){if(Yc(S,p,Za,!Wc),ve(S,0,!0)!==0)break e;Al=p,S.timeoutHandle=m4(Fj.bind(null,S,b,Ca,oy,WE,p,Za,Ad,mh,Wc,O,"Throttled",-0,0),R);break e}Fj(S,b,Ca,oy,WE,p,Za,Ad,mh,Wc,O,null,-0,0)}}break}while(!0);Do(d)}function Fj(d,p,b,S,R,O,G,ae,_e,ze,et,ot,Ve,Ze){if(d.timeoutHandle=-1,ot=p.subtreeFlags,ot&8192||(ot&16785408)===16785408){ot={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:dl},Pj(p,O,ot);var Ct=(O&62914560)===O?ay-L():(O&4194048)===O?Lj-L():0;if(Ct=Kte(ot,Ct),Ct!==null){Al=O,d.cancelPendingCommit=Ct(qj.bind(null,d,p,O,b,S,R,G,ae,_e,et,ot,null,Ve,Ze)),Yc(d,O,G,!ze);return}}qj(d,p,O,b,S,R,G,ae,_e)}function dte(d){for(var p=d;;){var b=p.tag;if((b===0||b===11||b===15)&&p.flags&16384&&(b=p.updateQueue,b!==null&&(b=b.stores,b!==null)))for(var S=0;S<b.length;S++){var R=b[S],O=R.getSnapshot;R=R.value;try{if(!Wa(O(),R))return!1}catch{return!1}}if(b=p.child,p.subtreeFlags&16384&&b!==null)b.return=p,p=b;else{if(p===d)break;for(;p.sibling===null;){if(p.return===null||p.return===d)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function Yc(d,p,b,S){p&=~GE,p&=~Ad,d.suspendedLanes|=p,d.pingedLanes&=~p,S&&(d.warmLanes|=p),S=d.expirationTimes;for(var R=p;0<R;){var O=31-it(R),G=1<<O;S[O]=-1,R&=~G}b!==0&&Rn(d,b,p)}function ly(){return(Cn&6)===0?(_g(0),!1):!0}function YE(){if(fn!==null){if(kn===0)var d=fn.return;else d=fn,ml=xd=null,fE(d),oh=null,ig=0,d=fn;for(;d!==null;)gj(d.alternate,d),d=d.return;fn=null}}function xh(d,p){var b=d.timeoutHandle;b!==-1&&(d.timeoutHandle=-1,Pte(b)),b=d.cancelPendingCommit,b!==null&&(d.cancelPendingCommit=null,b()),Al=0,YE(),Xn=d,fn=b=hl(d.current,null),gn=p,kn=0,Ya=null,Wc=!1,ph=Be(d,p),VE=!1,mh=Za=GE=Ad=qc=_i=0,Ca=yg=null,WE=!1,(p&8)!==0&&(p|=p&32);var S=d.entangledLanes;if(S!==0)for(d=d.entanglements,S&=p;0<S;){var R=31-it(S),O=1<<R;p|=d[R],S&=~O}return El=p,Nv(),b}function zj(d,p){Jt=null,$.H=dg,p===sh||p===jv?(p=nI(),kn=3):p===eE?(p=nI(),kn=4):kn=p===CE?8:p!==null&&typeof p=="object"&&typeof p.then=="function"?6:1,Ya=p,fn===null&&(_i=1,Zv(d,xs(p,d.current)))}function Bj(){var d=Xa.current;return d===null?!0:(gn&4194048)===gn?_s===null:(gn&62914560)===gn||(gn&536870912)!==0?d===_s:!1}function Hj(){var d=$.H;return $.H=dg,d===null?dg:d}function $j(){var d=$.A;return $.A=cte,d}function cy(){_i=4,Wc||(gn&4194048)!==gn&&Xa.current!==null||(ph=!0),(qc&134217727)===0&&(Ad&134217727)===0||Xn===null||Yc(Xn,gn,Za,!1)}function ZE(d,p,b){var S=Cn;Cn|=2;var R=Hj(),O=$j();(Xn!==d||gn!==p)&&(oy=null,xh(d,p)),p=!1;var G=_i;e:do try{if(kn!==0&&fn!==null){var ae=fn,_e=Ya;switch(kn){case 8:YE(),G=6;break e;case 3:case 2:case 9:case 6:Xa.current===null&&(p=!0);var ze=kn;if(kn=0,Ya=null,vh(d,ae,_e,ze),b&&ph){G=0;break e}break;default:ze=kn,kn=0,Ya=null,vh(d,ae,_e,ze)}}fte(),G=_i;break}catch(et){zj(d,et)}while(!0);return p&&d.shellSuspendCounter++,ml=xd=null,Cn=S,$.H=R,$.A=O,fn===null&&(Xn=null,gn=0,Nv()),G}function fte(){for(;fn!==null;)Vj(fn)}function hte(d,p){var b=Cn;Cn|=2;var S=Hj(),R=$j();Xn!==d||gn!==p?(oy=null,sy=L()+500,xh(d,p)):ph=Be(d,p);e:do try{if(kn!==0&&fn!==null){p=fn;var O=Ya;t:switch(kn){case 1:kn=0,Ya=null,vh(d,p,O,1);break;case 2:case 9:if(eI(O)){kn=0,Ya=null,Gj(p);break}p=function(){kn!==2&&kn!==9||Xn!==d||(kn=7),Do(d)},O.then(p,p);break e;case 3:kn=7;break e;case 4:kn=5;break e;case 7:eI(O)?(kn=0,Ya=null,Gj(p)):(kn=0,Ya=null,vh(d,p,O,7));break;case 5:var G=null;switch(fn.tag){case 26:G=fn.memoizedState;case 5:case 27:var ae=fn;if(G?R4(G):ae.stateNode.complete){kn=0,Ya=null;var _e=ae.sibling;if(_e!==null)fn=_e;else{var ze=ae.return;ze!==null?(fn=ze,uy(ze)):fn=null}break t}}kn=0,Ya=null,vh(d,p,O,5);break;case 6:kn=0,Ya=null,vh(d,p,O,6);break;case 8:YE(),_i=6;break e;default:throw Error(i(462))}}pte();break}catch(et){zj(d,et)}while(!0);return ml=xd=null,$.H=S,$.A=R,Cn=b,fn!==null?0:(Xn=null,gn=0,Nv(),_i)}function pte(){for(;fn!==null&&!ne();)Vj(fn)}function Vj(d){var p=pj(d.alternate,d,El);d.memoizedProps=d.pendingProps,p===null?uy(d):fn=p}function Gj(d){var p=d,b=p.alternate;switch(p.tag){case 15:case 0:p=lj(b,p,p.pendingProps,p.type,void 0,gn);break;case 11:p=lj(b,p,p.pendingProps,p.type.render,p.ref,gn);break;case 5:fE(p);default:gj(b,p),p=fn=$L(p,El),p=pj(b,p,El)}d.memoizedProps=d.pendingProps,p===null?uy(d):fn=p}function vh(d,p,b,S){ml=xd=null,fE(p),oh=null,ig=0;var R=p.return;try{if(nte(d,R,p,b,gn)){_i=1,Zv(d,xs(b,d.current)),fn=null;return}}catch(O){if(R!==null)throw fn=R,O;_i=1,Zv(d,xs(b,d.current)),fn=null;return}p.flags&32768?(yn||S===1?d=!0:ph||(gn&536870912)!==0?d=!1:(Wc=d=!0,(S===2||S===9||S===3||S===6)&&(S=Xa.current,S!==null&&S.tag===13&&(S.flags|=16384))),Wj(p,d)):uy(p)}function uy(d){var p=d;do{if((p.flags&32768)!==0){Wj(p,Wc);return}d=p.return;var b=ate(p.alternate,p,El);if(b!==null){fn=b;return}if(p=p.sibling,p!==null){fn=p;return}fn=p=d}while(p!==null);_i===0&&(_i=5)}function Wj(d,p){do{var b=ste(d.alternate,d);if(b!==null){b.flags&=32767,fn=b;return}if(b=d.return,b!==null&&(b.flags|=32768,b.subtreeFlags=0,b.deletions=null),!p&&(d=d.sibling,d!==null)){fn=d;return}fn=d=b}while(d!==null);_i=6,fn=null}function qj(d,p,b,S,R,O,G,ae,_e){d.cancelPendingCommit=null;do dy();while(er!==0);if((Cn&6)!==0)throw Error(i(327));if(p!==null){if(p===d.current)throw Error(i(177));if(O=p.lanes|p.childLanes,O|=FM,Ot(d,b,O,G,ae,_e),d===Xn&&(fn=Xn=null,gn=0),gh=p,Kc=d,Al=b,qE=O,XE=R,Ij=S,(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?(d.callbackNode=null,d.callbackPriority=0,vte(pe,function(){return Qj(),null})):(d.callbackNode=null,d.callbackPriority=0),S=(p.flags&13878)!==0,(p.subtreeFlags&13878)!==0||S){S=$.T,$.T=null,R=K.p,K.p=2,G=Cn,Cn|=4;try{ote(d,p,b)}finally{Cn=G,K.p=R,$.T=S}}er=1,Xj(),Kj(),Yj()}}function Xj(){if(er===1){er=0;var d=Kc,p=gh,b=(p.flags&13878)!==0;if((p.subtreeFlags&13878)!==0||b){b=$.T,$.T=null;var S=K.p;K.p=2;var R=Cn;Cn|=4;try{Cj(p,d);var O=cA,G=OL(d.containerInfo),ae=O.focusedElem,_e=O.selectionRange;if(G!==ae&&ae&&ae.ownerDocument&&DL(ae.ownerDocument.documentElement,ae)){if(_e!==null&&OM(ae)){var ze=_e.start,et=_e.end;if(et===void 0&&(et=ze),"selectionStart"in ae)ae.selectionStart=ze,ae.selectionEnd=Math.min(et,ae.value.length);else{var ot=ae.ownerDocument||document,Ve=ot&&ot.defaultView||window;if(Ve.getSelection){var Ze=Ve.getSelection(),Ct=ae.textContent.length,Bt=Math.min(_e.start,Ct),Fn=_e.end===void 0?Bt:Math.min(_e.end,Ct);!Ze.extend&&Bt>Fn&&(G=Fn,Fn=Bt,Bt=G);var De=kL(ae,Bt),Ae=kL(ae,Fn);if(De&&Ae&&(Ze.rangeCount!==1||Ze.anchorNode!==De.node||Ze.anchorOffset!==De.offset||Ze.focusNode!==Ae.node||Ze.focusOffset!==Ae.offset)){var Fe=ot.createRange();Fe.setStart(De.node,De.offset),Ze.removeAllRanges(),Bt>Fn?(Ze.addRange(Fe),Ze.extend(Ae.node,Ae.offset)):(Fe.setEnd(Ae.node,Ae.offset),Ze.addRange(Fe))}}}}for(ot=[],Ze=ae;Ze=Ze.parentNode;)Ze.nodeType===1&&ot.push({element:Ze,left:Ze.scrollLeft,top:Ze.scrollTop});for(typeof ae.focus=="function"&&ae.focus(),ae=0;ae<ot.length;ae++){var at=ot[ae];at.element.scrollLeft=at.left,at.element.scrollTop=at.top}}wy=!!lA,cA=lA=null}finally{Cn=R,K.p=S,$.T=b}}d.current=p,er=2}}function Kj(){if(er===2){er=0;var d=Kc,p=gh,b=(p.flags&8772)!==0;if((p.subtreeFlags&8772)!==0||b){b=$.T,$.T=null;var S=K.p;K.p=2;var R=Cn;Cn|=4;try{wj(d,p.alternate,p)}finally{Cn=R,K.p=S,$.T=b}}er=3}}function Yj(){if(er===4||er===3){er=0,U();var d=Kc,p=gh,b=Al,S=Ij;(p.subtreeFlags&10256)!==0||(p.flags&10256)!==0?er=5:(er=0,gh=Kc=null,Zj(d,d.pendingLanes));var R=d.pendingLanes;if(R===0&&(Xc=null),gr(b),p=p.stateNode,Pe&&typeof Pe.onCommitFiberRoot=="function")try{Pe.onCommitFiberRoot(Ie,p,void 0,(p.current.flags&128)===128)}catch{}if(S!==null){p=$.T,R=K.p,K.p=2,$.T=null;try{for(var O=d.onRecoverableError,G=0;G<S.length;G++){var ae=S[G];O(ae.value,{componentStack:ae.stack})}}finally{$.T=p,K.p=R}}(Al&3)!==0&&dy(),Do(d),R=d.pendingLanes,(b&261930)!==0&&(R&42)!==0?d===KE?bg++:(bg=0,KE=d):bg=0,_g(0)}}function Zj(d,p){(d.pooledCacheLanes&=p)===0&&(p=d.pooledCache,p!=null&&(d.pooledCache=null,tg(p)))}function dy(){return Xj(),Kj(),Yj(),Qj()}function Qj(){if(er!==5)return!1;var d=Kc,p=qE;qE=0;var b=gr(Al),S=$.T,R=K.p;try{K.p=32>b?32:b,$.T=null,b=XE,XE=null;var O=Kc,G=Al;if(er=0,gh=Kc=null,Al=0,(Cn&6)!==0)throw Error(i(331));var ae=Cn;if(Cn|=4,Dj(O.current),Rj(O,O.current,G,b),Cn=ae,_g(0,!1),Pe&&typeof Pe.onPostCommitFiberRoot=="function")try{Pe.onPostCommitFiberRoot(Ie,O)}catch{}return!0}finally{K.p=R,$.T=S,Zj(d,p)}}function Jj(d,p,b){p=xs(b,p),p=TE(d.stateNode,p,2),d=Hc(d,p,2),d!==null&&(ln(d,2),Do(d))}function Dn(d,p,b){if(d.tag===3)Jj(d,d,b);else for(;p!==null;){if(p.tag===3){Jj(p,d,b);break}else if(p.tag===1){var S=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof S.componentDidCatch=="function"&&(Xc===null||!Xc.has(S))){d=xs(b,d),b=ej(2),S=Hc(p,b,2),S!==null&&(tj(b,S,p,d),ln(S,2),Do(S));break}}p=p.return}}function QE(d,p,b){var S=d.pingCache;if(S===null){S=d.pingCache=new ute;var R=new Set;S.set(p,R)}else R=S.get(p),R===void 0&&(R=new Set,S.set(p,R));R.has(b)||(VE=!0,R.add(b),d=mte.bind(null,d,p,b),p.then(d,d))}function mte(d,p,b){var S=d.pingCache;S!==null&&S.delete(p),d.pingedLanes|=d.suspendedLanes&b,d.warmLanes&=~b,Xn===d&&(gn&b)===b&&(_i===4||_i===3&&(gn&62914560)===gn&&300>L()-ay?(Cn&2)===0&&xh(d,0):GE|=b,mh===gn&&(mh=0)),Do(d)}function e4(d,p){p===0&&(p=bt()),d=pd(d,p),d!==null&&(ln(d,p),Do(d))}function gte(d){var p=d.memoizedState,b=0;p!==null&&(b=p.retryLane),e4(d,b)}function xte(d,p){var b=0;switch(d.tag){case 31:case 13:var S=d.stateNode,R=d.memoizedState;R!==null&&(b=R.retryLane);break;case 19:S=d.stateNode;break;case 22:S=d.stateNode._retryCache;break;default:throw Error(i(314))}S!==null&&S.delete(p),e4(d,b)}function vte(d,p){return Ce(d,p)}var fy=null,yh=null,JE=!1,hy=!1,eA=!1,Zc=0;function Do(d){d!==yh&&d.next===null&&(yh===null?fy=yh=d:yh=yh.next=d),hy=!0,JE||(JE=!0,bte())}function _g(d,p){if(!eA&&hy){eA=!0;do for(var b=!1,S=fy;S!==null;){if(d!==0){var R=S.pendingLanes;if(R===0)var O=0;else{var G=S.suspendedLanes,ae=S.pingedLanes;O=(1<<31-it(42|d)+1)-1,O&=R&~(G&~ae),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(b=!0,r4(S,O))}else O=gn,O=ve(S,S===Xn?O:0,S.cancelPendingCommit!==null||S.timeoutHandle!==-1),(O&3)===0||Be(S,O)||(b=!0,r4(S,O));S=S.next}while(b);eA=!1}}function yte(){t4()}function t4(){hy=JE=!1;var d=0;Zc!==0&&Rte()&&(d=Zc);for(var p=L(),b=null,S=fy;S!==null;){var R=S.next,O=n4(S,p);O===0?(S.next=null,b===null?fy=R:b.next=R,R===null&&(yh=b)):(b=S,(d!==0||(O&3)!==0)&&(hy=!0)),S=R}er!==0&&er!==5||_g(d),Zc!==0&&(Zc=0)}function n4(d,p){for(var b=d.suspendedLanes,S=d.pingedLanes,R=d.expirationTimes,O=d.pendingLanes&-62914561;0<O;){var G=31-it(O),ae=1<<G,_e=R[G];_e===-1?((ae&b)===0||(ae&S)!==0)&&(R[G]=ct(ae,p)):_e<=p&&(d.expiredLanes|=ae),O&=~ae}if(p=Xn,b=gn,b=ve(d,d===p?b:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S=d.callbackNode,b===0||d===p&&(kn===2||kn===9)||d.cancelPendingCommit!==null)return S!==null&&S!==null&&Ee(S),d.callbackNode=null,d.callbackPriority=0;if((b&3)===0||Be(d,b)){if(p=b&-b,p===d.callbackPriority)return p;switch(S!==null&&Ee(S),gr(b)){case 2:case 8:b=ye;break;case 32:b=pe;break;case 268435456:b=Le;break;default:b=pe}return S=i4.bind(null,d),b=Ce(b,S),d.callbackPriority=p,d.callbackNode=b,p}return S!==null&&S!==null&&Ee(S),d.callbackPriority=2,d.callbackNode=null,2}function i4(d,p){if(er!==0&&er!==5)return d.callbackNode=null,d.callbackPriority=0,null;var b=d.callbackNode;if(dy()&&d.callbackNode!==b)return null;var S=gn;return S=ve(d,d===Xn?S:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),S===0?null:(Uj(d,S,p),n4(d,L()),d.callbackNode!=null&&d.callbackNode===b?i4.bind(null,d):null)}function r4(d,p){if(dy())return null;Uj(d,p,!0)}function bte(){kte(function(){(Cn&6)!==0?Ce(me,yte):t4()})}function tA(){if(Zc===0){var d=rh;d===0&&(d=rt,rt<<=1,(rt&261888)===0&&(rt=256)),Zc=d}return Zc}function a4(d){return d==null||typeof d=="symbol"||typeof d=="boolean"?null:typeof d=="function"?d:_v(""+d)}function s4(d,p){var b=p.ownerDocument.createElement("input");return b.name=p.name,b.value=p.value,d.id&&b.setAttribute("form",d.id),p.parentNode.insertBefore(b,p),d=new FormData(d),b.parentNode.removeChild(b),d}function _te(d,p,b,S,R){if(p==="submit"&&b&&b.stateNode===R){var O=a4((R[Ti]||null).action),G=S.submitter;G&&(p=(p=G[Ti]||null)?a4(p.formAction):G.getAttribute("formAction"),p!==null&&(O=p,G=null));var ae=new Ev("action","action",null,S,R);d.push({event:ae,listeners:[{instance:null,listener:function(){if(S.defaultPrevented){if(Zc!==0){var _e=G?s4(R,G):new FormData(R);_E(b,{pending:!0,data:_e,method:R.method,action:O},null,_e)}}else typeof O=="function"&&(ae.preventDefault(),_e=G?s4(R,G):new FormData(R),_E(b,{pending:!0,data:_e,method:R.method,action:O},O,_e))},currentTarget:R}]})}}for(var nA=0;nA<UM.length;nA++){var iA=UM[nA],Ste=iA.toLowerCase(),wte=iA[0].toUpperCase()+iA.slice(1);eo(Ste,"on"+wte)}eo(jL,"onAnimationEnd"),eo(UL,"onAnimationIteration"),eo(FL,"onAnimationStart"),eo("dblclick","onDoubleClick"),eo("focusin","onFocus"),eo("focusout","onBlur"),eo(Fee,"onTransitionRun"),eo(zee,"onTransitionStart"),eo(Bee,"onTransitionCancel"),eo(zL,"onTransitionEnd"),vt("onMouseEnter",["mouseout","mouseover"]),vt("onMouseLeave",["mouseout","mouseover"]),vt("onPointerEnter",["pointerout","pointerover"]),vt("onPointerLeave",["pointerout","pointerover"]),ft("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ft("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ft("onBeforeInput",["compositionend","keypress","textInput","paste"]),ft("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ft("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Sg="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(" "),Mte=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Sg));function o4(d,p){p=(p&4)!==0;for(var b=0;b<d.length;b++){var S=d[b],R=S.event;S=S.listeners;e:{var O=void 0;if(p)for(var G=S.length-1;0<=G;G--){var ae=S[G],_e=ae.instance,ze=ae.currentTarget;if(ae=ae.listener,_e!==O&&R.isPropagationStopped())break e;O=ae,R.currentTarget=ze;try{O(R)}catch(et){Cv(et)}R.currentTarget=null,O=_e}else for(G=0;G<S.length;G++){if(ae=S[G],_e=ae.instance,ze=ae.currentTarget,ae=ae.listener,_e!==O&&R.isPropagationStopped())break e;O=ae,R.currentTarget=ze;try{O(R)}catch(et){Cv(et)}R.currentTarget=null,O=_e}}}}function hn(d,p){var b=p[Oc];b===void 0&&(b=p[Oc]=new Set);var S=d+"__bubble";b.has(S)||(l4(p,d,2,!1),b.add(S))}function rA(d,p,b){var S=0;p&&(S|=4),l4(b,d,S,p)}var py="_reactListening"+Math.random().toString(36).slice(2);function aA(d){if(!d[py]){d[py]=!0,Se.forEach(function(b){b!=="selectionchange"&&(Mte.has(b)||rA(b,!1,d),rA(b,!0,d))});var p=d.nodeType===9?d:d.ownerDocument;p===null||p[py]||(p[py]=!0,rA("selectionchange",!1,p))}}function l4(d,p,b,S){switch(j4(p)){case 2:var R=Qte;break;case 8:R=Jte;break;default:R=bA}b=R.bind(null,p,b,d),R=void 0,!EM||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(R=!0),S?R!==void 0?d.addEventListener(p,b,{capture:!0,passive:R}):d.addEventListener(p,b,!0):R!==void 0?d.addEventListener(p,b,{passive:R}):d.addEventListener(p,b,!1)}function sA(d,p,b,S,R){var O=S;if((p&1)===0&&(p&2)===0&&S!==null)e:for(;;){if(S===null)return;var G=S.tag;if(G===3||G===4){var ae=S.stateNode.containerInfo;if(ae===R)break;if(G===4)for(G=S.return;G!==null;){var _e=G.tag;if((_e===3||_e===4)&&G.stateNode.containerInfo===R)return;G=G.return}for(;ae!==null;){if(G=_t(ae),G===null)return;if(_e=G.tag,_e===5||_e===6||_e===26||_e===27){S=O=G;continue e}ae=ae.parentNode}}S=S.return}hL(function(){var ze=O,et=wM(b),ot=[];e:{var Ve=BL.get(d);if(Ve!==void 0){var Ze=Ev,Ct=d;switch(d){case"keypress":if(wv(b)===0)break e;case"keydown":case"keyup":Ze=xee;break;case"focusin":Ct="focus",Ze=NM;break;case"focusout":Ct="blur",Ze=NM;break;case"beforeblur":case"afterblur":Ze=NM;break;case"click":if(b.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ze=gL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ze=aee;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ze=bee;break;case jL:case UL:case FL:Ze=lee;break;case zL:Ze=See;break;case"scroll":case"scrollend":Ze=iee;break;case"wheel":Ze=Mee;break;case"copy":case"cut":case"paste":Ze=uee;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ze=vL;break;case"toggle":case"beforetoggle":Ze=Aee}var Bt=(p&4)!==0,Fn=!Bt&&(d==="scroll"||d==="scrollend"),De=Bt?Ve!==null?Ve+"Capture":null:Ve;Bt=[];for(var Ae=ze,Fe;Ae!==null;){var at=Ae;if(Fe=at.stateNode,at=at.tag,at!==5&&at!==26&&at!==27||Fe===null||De===null||(at=Vm(Ae,De),at!=null&&Bt.push(wg(Ae,at,Fe))),Fn)break;Ae=Ae.return}0<Bt.length&&(Ve=new Ze(Ve,Ct,null,b,et),ot.push({event:Ve,listeners:Bt}))}}if((p&7)===0){e:{if(Ve=d==="mouseover"||d==="pointerover",Ze=d==="mouseout"||d==="pointerout",Ve&&b!==SM&&(Ct=b.relatedTarget||b.fromElement)&&(_t(Ct)||Ct[Qs]))break e;if((Ze||Ve)&&(Ve=et.window===et?et:(Ve=et.ownerDocument)?Ve.defaultView||Ve.parentWindow:window,Ze?(Ct=b.relatedTarget||b.toElement,Ze=ze,Ct=Ct?_t(Ct):null,Ct!==null&&(Fn=a(Ct),Bt=Ct.tag,Ct!==Fn||Bt!==5&&Bt!==27&&Bt!==6)&&(Ct=null)):(Ze=null,Ct=ze),Ze!==Ct)){if(Bt=gL,at="onMouseLeave",De="onMouseEnter",Ae="mouse",(d==="pointerout"||d==="pointerover")&&(Bt=vL,at="onPointerLeave",De="onPointerEnter",Ae="pointer"),Fn=Ze==null?Ve:be(Ze),Fe=Ct==null?Ve:be(Ct),Ve=new Bt(at,Ae+"leave",Ze,b,et),Ve.target=Fn,Ve.relatedTarget=Fe,at=null,_t(et)===ze&&(Bt=new Bt(De,Ae+"enter",Ct,b,et),Bt.target=Fe,Bt.relatedTarget=Fn,at=Bt),Fn=at,Ze&&Ct)t:{for(Bt=Ete,De=Ze,Ae=Ct,Fe=0,at=De;at;at=Bt(at))Fe++;at=0;for(var jt=Ae;jt;jt=Bt(jt))at++;for(;0<Fe-at;)De=Bt(De),Fe--;for(;0<at-Fe;)Ae=Bt(Ae),at--;for(;Fe--;){if(De===Ae||Ae!==null&&De===Ae.alternate){Bt=De;break t}De=Bt(De),Ae=Bt(Ae)}Bt=null}else Bt=null;Ze!==null&&c4(ot,Ve,Ze,Bt,!1),Ct!==null&&Fn!==null&&c4(ot,Fn,Ct,Bt,!0)}}e:{if(Ve=ze?be(ze):window,Ze=Ve.nodeName&&Ve.nodeName.toLowerCase(),Ze==="select"||Ze==="input"&&Ve.type==="file")var wn=AL;else if(ML(Ve))if(TL)wn=Iee;else{wn=Oee;var kt=Dee}else Ze=Ve.nodeName,!Ze||Ze.toLowerCase()!=="input"||Ve.type!=="checkbox"&&Ve.type!=="radio"?ze&&_M(ze.elementType)&&(wn=AL):wn=Lee;if(wn&&(wn=wn(d,ze))){EL(ot,wn,b,et);break e}kt&&kt(d,Ve,ze),d==="focusout"&&ze&&Ve.type==="number"&&ze.memoizedProps.value!=null&&xr(Ve,"number",Ve.value)}switch(kt=ze?be(ze):window,d){case"focusin":(ML(kt)||kt.contentEditable==="true")&&(Yf=kt,LM=ze,Qm=null);break;case"focusout":Qm=LM=Yf=null;break;case"mousedown":IM=!0;break;case"contextmenu":case"mouseup":case"dragend":IM=!1,LL(ot,b,et);break;case"selectionchange":if(Uee)break;case"keydown":case"keyup":LL(ot,b,et)}var en;if(PM)e:{switch(d){case"compositionstart":var xn="onCompositionStart";break e;case"compositionend":xn="onCompositionEnd";break e;case"compositionupdate":xn="onCompositionUpdate";break e}xn=void 0}else Kf?SL(d,b)&&(xn="onCompositionEnd"):d==="keydown"&&b.keyCode===229&&(xn="onCompositionStart");xn&&(yL&&b.locale!=="ko"&&(Kf||xn!=="onCompositionStart"?xn==="onCompositionEnd"&&Kf&&(en=pL()):(Lc=et,AM="value"in Lc?Lc.value:Lc.textContent,Kf=!0)),kt=my(ze,xn),0<kt.length&&(xn=new xL(xn,d,null,b,et),ot.push({event:xn,listeners:kt}),en?xn.data=en:(en=wL(b),en!==null&&(xn.data=en)))),(en=Cee?Nee(d,b):Ree(d,b))&&(xn=my(ze,"onBeforeInput"),0<xn.length&&(kt=new xL("onBeforeInput","beforeinput",null,b,et),ot.push({event:kt,listeners:xn}),kt.data=en)),_te(ot,d,ze,b,et)}o4(ot,p)})}function wg(d,p,b){return{instance:d,listener:p,currentTarget:b}}function my(d,p){for(var b=p+"Capture",S=[];d!==null;){var R=d,O=R.stateNode;if(R=R.tag,R!==5&&R!==26&&R!==27||O===null||(R=Vm(d,b),R!=null&&S.unshift(wg(d,R,O)),R=Vm(d,p),R!=null&&S.push(wg(d,R,O))),d.tag===3)return S;d=d.return}return[]}function Ete(d){if(d===null)return null;do d=d.return;while(d&&d.tag!==5&&d.tag!==27);return d||null}function c4(d,p,b,S,R){for(var O=p._reactName,G=[];b!==null&&b!==S;){var ae=b,_e=ae.alternate,ze=ae.stateNode;if(ae=ae.tag,_e!==null&&_e===S)break;ae!==5&&ae!==26&&ae!==27||ze===null||(_e=ze,R?(ze=Vm(b,O),ze!=null&&G.unshift(wg(b,ze,_e))):R||(ze=Vm(b,O),ze!=null&&G.push(wg(b,ze,_e)))),b=b.return}G.length!==0&&d.push({event:p,listeners:G})}var Ate=/\r\n?/g,Tte=/\u0000|\uFFFD/g;function u4(d){return(typeof d=="string"?d:""+d).replace(Ate,`
- `).replace(Tte,"")}function d4(d,p){return p=u4(p),u4(d)===p}function Un(d,p,b,S,R,O){switch(b){case"children":typeof S=="string"?p==="body"||p==="textarea"&&S===""||No(d,S):(typeof S=="number"||typeof S=="bigint")&&p!=="body"&&No(d,""+S);break;case"className":It(d,"class",S);break;case"tabIndex":It(d,"tabindex",S);break;case"dir":case"role":case"viewBox":case"width":case"height":It(d,b,S);break;case"style":dL(d,S,O);break;case"data":if(p!=="object"){It(d,"data",S);break}case"src":case"href":if(S===""&&(p!=="a"||b!=="href")){d.removeAttribute(b);break}if(S==null||typeof S=="function"||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(b);break}S=_v(""+S),d.setAttribute(b,S);break;case"action":case"formAction":if(typeof S=="function"){d.setAttribute(b,"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 O=="function"&&(b==="formAction"?(p!=="input"&&Un(d,p,"name",R.name,R,null),Un(d,p,"formEncType",R.formEncType,R,null),Un(d,p,"formMethod",R.formMethod,R,null),Un(d,p,"formTarget",R.formTarget,R,null)):(Un(d,p,"encType",R.encType,R,null),Un(d,p,"method",R.method,R,null),Un(d,p,"target",R.target,R,null)));if(S==null||typeof S=="symbol"||typeof S=="boolean"){d.removeAttribute(b);break}S=_v(""+S),d.setAttribute(b,S);break;case"onClick":S!=null&&(d.onclick=dl);break;case"onScroll":S!=null&&hn("scroll",d);break;case"onScrollEnd":S!=null&&hn("scrollend",d);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(i(61));if(b=S.__html,b!=null){if(R.children!=null)throw Error(i(60));d.innerHTML=b}}break;case"multiple":d.multiple=S&&typeof S!="function"&&typeof S!="symbol";break;case"muted":d.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"){d.removeAttribute("xlink:href");break}b=_v(""+S),d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",b);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"?d.setAttribute(b,""+S):d.removeAttribute(b);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"?d.setAttribute(b,""):d.removeAttribute(b);break;case"capture":case"download":S===!0?d.setAttribute(b,""):S!==!1&&S!=null&&typeof S!="function"&&typeof S!="symbol"?d.setAttribute(b,S):d.removeAttribute(b);break;case"cols":case"rows":case"size":case"span":S!=null&&typeof S!="function"&&typeof S!="symbol"&&!isNaN(S)&&1<=S?d.setAttribute(b,S):d.removeAttribute(b);break;case"rowSpan":case"start":S==null||typeof S=="function"||typeof S=="symbol"||isNaN(S)?d.removeAttribute(b):d.setAttribute(b,S);break;case"popover":hn("beforetoggle",d),hn("toggle",d),Wt(d,"popover",S);break;case"xlinkActuate":tn(d,"http://www.w3.org/1999/xlink","xlink:actuate",S);break;case"xlinkArcrole":tn(d,"http://www.w3.org/1999/xlink","xlink:arcrole",S);break;case"xlinkRole":tn(d,"http://www.w3.org/1999/xlink","xlink:role",S);break;case"xlinkShow":tn(d,"http://www.w3.org/1999/xlink","xlink:show",S);break;case"xlinkTitle":tn(d,"http://www.w3.org/1999/xlink","xlink:title",S);break;case"xlinkType":tn(d,"http://www.w3.org/1999/xlink","xlink:type",S);break;case"xmlBase":tn(d,"http://www.w3.org/XML/1998/namespace","xml:base",S);break;case"xmlLang":tn(d,"http://www.w3.org/XML/1998/namespace","xml:lang",S);break;case"xmlSpace":tn(d,"http://www.w3.org/XML/1998/namespace","xml:space",S);break;case"is":Wt(d,"is",S);break;case"innerText":case"textContent":break;default:(!(2<b.length)||b[0]!=="o"&&b[0]!=="O"||b[1]!=="n"&&b[1]!=="N")&&(b=tee.get(b)||b,Wt(d,b,S))}}function oA(d,p,b,S,R,O){switch(b){case"style":dL(d,S,O);break;case"dangerouslySetInnerHTML":if(S!=null){if(typeof S!="object"||!("__html"in S))throw Error(i(61));if(b=S.__html,b!=null){if(R.children!=null)throw Error(i(60));d.innerHTML=b}}break;case"children":typeof S=="string"?No(d,S):(typeof S=="number"||typeof S=="bigint")&&No(d,""+S);break;case"onScroll":S!=null&&hn("scroll",d);break;case"onScrollEnd":S!=null&&hn("scrollend",d);break;case"onClick":S!=null&&(d.onclick=dl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Je.hasOwnProperty(b))e:{if(b[0]==="o"&&b[1]==="n"&&(R=b.endsWith("Capture"),p=b.slice(2,R?b.length-7:void 0),O=d[Ti]||null,O=O!=null?O[b]:null,typeof O=="function"&&d.removeEventListener(p,O,R),typeof S=="function")){typeof O!="function"&&O!==null&&(b in d?d[b]=null:d.hasAttribute(b)&&d.removeAttribute(b)),d.addEventListener(p,S,R);break e}b in d?d[b]=S:S===!0?d.setAttribute(b,""):Wt(d,b,S)}}}function Ir(d,p,b){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":hn("error",d),hn("load",d);var S=!1,R=!1,O;for(O in b)if(b.hasOwnProperty(O)){var G=b[O];if(G!=null)switch(O){case"src":S=!0;break;case"srcSet":R=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,p));default:Un(d,p,O,G,b,null)}}R&&Un(d,p,"srcSet",b.srcSet,b,null),S&&Un(d,p,"src",b.src,b,null);return;case"input":hn("invalid",d);var ae=O=G=R=null,_e=null,ze=null;for(S in b)if(b.hasOwnProperty(S)){var et=b[S];if(et!=null)switch(S){case"name":R=et;break;case"type":G=et;break;case"checked":_e=et;break;case"defaultChecked":ze=et;break;case"value":O=et;break;case"defaultValue":ae=et;break;case"children":case"dangerouslySetInnerHTML":if(et!=null)throw Error(i(137,p));break;default:Un(d,p,S,et,b,null)}}Pn(d,O,ae,_e,ze,G,R,!1);return;case"select":hn("invalid",d),S=G=O=null;for(R in b)if(b.hasOwnProperty(R)&&(ae=b[R],ae!=null))switch(R){case"value":O=ae;break;case"defaultValue":G=ae;break;case"multiple":S=ae;default:Un(d,p,R,ae,b,null)}p=O,b=G,d.multiple=!!S,p!=null?Ji(d,!!S,p,!1):b!=null&&Ji(d,!!S,b,!0);return;case"textarea":hn("invalid",d),O=R=S=null;for(G in b)if(b.hasOwnProperty(G)&&(ae=b[G],ae!=null))switch(G){case"value":S=ae;break;case"defaultValue":R=ae;break;case"children":O=ae;break;case"dangerouslySetInnerHTML":if(ae!=null)throw Error(i(91));break;default:Un(d,p,G,ae,b,null)}kr(d,S,R,O);return;case"option":for(_e in b)if(b.hasOwnProperty(_e)&&(S=b[_e],S!=null))switch(_e){case"selected":d.selected=S&&typeof S!="function"&&typeof S!="symbol";break;default:Un(d,p,_e,S,b,null)}return;case"dialog":hn("beforetoggle",d),hn("toggle",d),hn("cancel",d),hn("close",d);break;case"iframe":case"object":hn("load",d);break;case"video":case"audio":for(S=0;S<Sg.length;S++)hn(Sg[S],d);break;case"image":hn("error",d),hn("load",d);break;case"details":hn("toggle",d);break;case"embed":case"source":case"link":hn("error",d),hn("load",d);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ze in b)if(b.hasOwnProperty(ze)&&(S=b[ze],S!=null))switch(ze){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,p));default:Un(d,p,ze,S,b,null)}return;default:if(_M(p)){for(et in b)b.hasOwnProperty(et)&&(S=b[et],S!==void 0&&oA(d,p,et,S,b,void 0));return}}for(ae in b)b.hasOwnProperty(ae)&&(S=b[ae],S!=null&&Un(d,p,ae,S,b,null))}function Cte(d,p,b,S){switch(p){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var R=null,O=null,G=null,ae=null,_e=null,ze=null,et=null;for(Ze in b){var ot=b[Ze];if(b.hasOwnProperty(Ze)&&ot!=null)switch(Ze){case"checked":break;case"value":break;case"defaultValue":_e=ot;default:S.hasOwnProperty(Ze)||Un(d,p,Ze,null,S,ot)}}for(var Ve in S){var Ze=S[Ve];if(ot=b[Ve],S.hasOwnProperty(Ve)&&(Ze!=null||ot!=null))switch(Ve){case"type":O=Ze;break;case"name":R=Ze;break;case"checked":ze=Ze;break;case"defaultChecked":et=Ze;break;case"value":G=Ze;break;case"defaultValue":ae=Ze;break;case"children":case"dangerouslySetInnerHTML":if(Ze!=null)throw Error(i(137,p));break;default:Ze!==ot&&Un(d,p,Ve,Ze,S,ot)}}Js(d,G,ae,_e,ze,et,O,R);return;case"select":Ze=G=ae=Ve=null;for(O in b)if(_e=b[O],b.hasOwnProperty(O)&&_e!=null)switch(O){case"value":break;case"multiple":Ze=_e;default:S.hasOwnProperty(O)||Un(d,p,O,null,S,_e)}for(R in S)if(O=S[R],_e=b[R],S.hasOwnProperty(R)&&(O!=null||_e!=null))switch(R){case"value":Ve=O;break;case"defaultValue":ae=O;break;case"multiple":G=O;default:O!==_e&&Un(d,p,R,O,S,_e)}p=ae,b=G,S=Ze,Ve!=null?Ji(d,!!b,Ve,!1):!!S!=!!b&&(p!=null?Ji(d,!!b,p,!0):Ji(d,!!b,b?[]:"",!1));return;case"textarea":Ze=Ve=null;for(ae in b)if(R=b[ae],b.hasOwnProperty(ae)&&R!=null&&!S.hasOwnProperty(ae))switch(ae){case"value":break;case"children":break;default:Un(d,p,ae,null,S,R)}for(G in S)if(R=S[G],O=b[G],S.hasOwnProperty(G)&&(R!=null||O!=null))switch(G){case"value":Ve=R;break;case"defaultValue":Ze=R;break;case"children":break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(i(91));break;default:R!==O&&Un(d,p,G,R,S,O)}vr(d,Ve,Ze);return;case"option":for(var Ct in b)if(Ve=b[Ct],b.hasOwnProperty(Ct)&&Ve!=null&&!S.hasOwnProperty(Ct))switch(Ct){case"selected":d.selected=!1;break;default:Un(d,p,Ct,null,S,Ve)}for(_e in S)if(Ve=S[_e],Ze=b[_e],S.hasOwnProperty(_e)&&Ve!==Ze&&(Ve!=null||Ze!=null))switch(_e){case"selected":d.selected=Ve&&typeof Ve!="function"&&typeof Ve!="symbol";break;default:Un(d,p,_e,Ve,S,Ze)}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 Bt in b)Ve=b[Bt],b.hasOwnProperty(Bt)&&Ve!=null&&!S.hasOwnProperty(Bt)&&Un(d,p,Bt,null,S,Ve);for(ze in S)if(Ve=S[ze],Ze=b[ze],S.hasOwnProperty(ze)&&Ve!==Ze&&(Ve!=null||Ze!=null))switch(ze){case"children":case"dangerouslySetInnerHTML":if(Ve!=null)throw Error(i(137,p));break;default:Un(d,p,ze,Ve,S,Ze)}return;default:if(_M(p)){for(var Fn in b)Ve=b[Fn],b.hasOwnProperty(Fn)&&Ve!==void 0&&!S.hasOwnProperty(Fn)&&oA(d,p,Fn,void 0,S,Ve);for(et in S)Ve=S[et],Ze=b[et],!S.hasOwnProperty(et)||Ve===Ze||Ve===void 0&&Ze===void 0||oA(d,p,et,Ve,S,Ze);return}}for(var De in b)Ve=b[De],b.hasOwnProperty(De)&&Ve!=null&&!S.hasOwnProperty(De)&&Un(d,p,De,null,S,Ve);for(ot in S)Ve=S[ot],Ze=b[ot],!S.hasOwnProperty(ot)||Ve===Ze||Ve==null&&Ze==null||Un(d,p,ot,Ve,S,Ze)}function f4(d){switch(d){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Nte(){if(typeof performance.getEntriesByType=="function"){for(var d=0,p=0,b=performance.getEntriesByType("resource"),S=0;S<b.length;S++){var R=b[S],O=R.transferSize,G=R.initiatorType,ae=R.duration;if(O&&ae&&f4(G)){for(G=0,ae=R.responseEnd,S+=1;S<b.length;S++){var _e=b[S],ze=_e.startTime;if(ze>ae)break;var et=_e.transferSize,ot=_e.initiatorType;et&&f4(ot)&&(_e=_e.responseEnd,G+=et*(_e<ae?1:(ae-ze)/(_e-ze)))}if(--S,p+=8*(O+G)/(R.duration/1e3),d++,10<d)break}}if(0<d)return p/d/1e6}return navigator.connection&&(d=navigator.connection.downlink,typeof d=="number")?d:5}var lA=null,cA=null;function gy(d){return d.nodeType===9?d:d.ownerDocument}function h4(d){switch(d){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function p4(d,p){if(d===0)switch(p){case"svg":return 1;case"math":return 2;default:return 0}return d===1&&p==="foreignObject"?0:d}function uA(d,p){return d==="textarea"||d==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.children=="bigint"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var dA=null;function Rte(){var d=window.event;return d&&d.type==="popstate"?d===dA?!1:(dA=d,!0):(dA=null,!1)}var m4=typeof setTimeout=="function"?setTimeout:void 0,Pte=typeof clearTimeout=="function"?clearTimeout:void 0,g4=typeof Promise=="function"?Promise:void 0,kte=typeof queueMicrotask=="function"?queueMicrotask:typeof g4<"u"?function(d){return g4.resolve(null).then(d).catch(Dte)}:m4;function Dte(d){setTimeout(function(){throw d})}function Qc(d){return d==="head"}function x4(d,p){var b=p,S=0;do{var R=b.nextSibling;if(d.removeChild(b),R&&R.nodeType===8)if(b=R.data,b==="/$"||b==="/&"){if(S===0){d.removeChild(R),wh(p);return}S--}else if(b==="$"||b==="$?"||b==="$~"||b==="$!"||b==="&")S++;else if(b==="html")Mg(d.ownerDocument.documentElement);else if(b==="head"){b=d.ownerDocument.head,Mg(b);for(var O=b.firstChild;O;){var G=O.nextSibling,ae=O.nodeName;O[Ke]||ae==="SCRIPT"||ae==="STYLE"||ae==="LINK"&&O.rel.toLowerCase()==="stylesheet"||b.removeChild(O),O=G}}else b==="body"&&Mg(d.ownerDocument.body);b=R}while(b);wh(p)}function v4(d,p){var b=d;d=0;do{var S=b.nextSibling;if(b.nodeType===1?p?(b._stashedDisplay=b.style.display,b.style.display="none"):(b.style.display=b._stashedDisplay||"",b.getAttribute("style")===""&&b.removeAttribute("style")):b.nodeType===3&&(p?(b._stashedText=b.nodeValue,b.nodeValue=""):b.nodeValue=b._stashedText||""),S&&S.nodeType===8)if(b=S.data,b==="/$"){if(d===0)break;d--}else b!=="$"&&b!=="$?"&&b!=="$~"&&b!=="$!"||d++;b=S}while(b)}function fA(d){var p=d.firstChild;for(p&&p.nodeType===10&&(p=p.nextSibling);p;){var b=p;switch(p=p.nextSibling,b.nodeName){case"HTML":case"HEAD":case"BODY":fA(b),We(b);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(b.rel.toLowerCase()==="stylesheet")continue}d.removeChild(b)}}function Ote(d,p,b,S){for(;d.nodeType===1;){var R=b;if(d.nodeName.toLowerCase()!==p.toLowerCase()){if(!S&&(d.nodeName!=="INPUT"||d.type!=="hidden"))break}else if(S){if(!d[Ke])switch(p){case"meta":if(!d.hasAttribute("itemprop"))break;return d;case"link":if(O=d.getAttribute("rel"),O==="stylesheet"&&d.hasAttribute("data-precedence"))break;if(O!==R.rel||d.getAttribute("href")!==(R.href==null||R.href===""?null:R.href)||d.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin)||d.getAttribute("title")!==(R.title==null?null:R.title))break;return d;case"style":if(d.hasAttribute("data-precedence"))break;return d;case"script":if(O=d.getAttribute("src"),(O!==(R.src==null?null:R.src)||d.getAttribute("type")!==(R.type==null?null:R.type)||d.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin))&&O&&d.hasAttribute("async")&&!d.hasAttribute("itemprop"))break;return d;default:return d}}else if(p==="input"&&d.type==="hidden"){var O=R.name==null?null:""+R.name;if(R.type==="hidden"&&d.getAttribute("name")===O)return d}else return d;if(d=Ss(d.nextSibling),d===null)break}return null}function Lte(d,p,b){if(p==="")return null;for(;d.nodeType!==3;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!b||(d=Ss(d.nextSibling),d===null))return null;return d}function y4(d,p){for(;d.nodeType!==8;)if((d.nodeType!==1||d.nodeName!=="INPUT"||d.type!=="hidden")&&!p||(d=Ss(d.nextSibling),d===null))return null;return d}function hA(d){return d.data==="$?"||d.data==="$~"}function pA(d){return d.data==="$!"||d.data==="$?"&&d.ownerDocument.readyState!=="loading"}function Ite(d,p){var b=d.ownerDocument;if(d.data==="$~")d._reactRetry=p;else if(d.data!=="$?"||b.readyState!=="loading")p();else{var S=function(){p(),b.removeEventListener("DOMContentLoaded",S)};b.addEventListener("DOMContentLoaded",S),d._reactRetry=S}}function Ss(d){for(;d!=null;d=d.nextSibling){var p=d.nodeType;if(p===1||p===3)break;if(p===8){if(p=d.data,p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"||p==="F!"||p==="F")break;if(p==="/$"||p==="/&")return null}}return d}var mA=null;function b4(d){d=d.nextSibling;for(var p=0;d;){if(d.nodeType===8){var b=d.data;if(b==="/$"||b==="/&"){if(p===0)return Ss(d.nextSibling);p--}else b!=="$"&&b!=="$!"&&b!=="$?"&&b!=="$~"&&b!=="&"||p++}d=d.nextSibling}return null}function _4(d){d=d.previousSibling;for(var p=0;d;){if(d.nodeType===8){var b=d.data;if(b==="$"||b==="$!"||b==="$?"||b==="$~"||b==="&"){if(p===0)return d;p--}else b!=="/$"&&b!=="/&"||p++}d=d.previousSibling}return null}function S4(d,p,b){switch(p=gy(b),d){case"html":if(d=p.documentElement,!d)throw Error(i(452));return d;case"head":if(d=p.head,!d)throw Error(i(453));return d;case"body":if(d=p.body,!d)throw Error(i(454));return d;default:throw Error(i(451))}}function Mg(d){for(var p=d.attributes;p.length;)d.removeAttributeNode(p[0]);We(d)}var ws=new Map,w4=new Set;function xy(d){return typeof d.getRootNode=="function"?d.getRootNode():d.nodeType===9?d:d.ownerDocument}var Tl=K.d;K.d={f:jte,r:Ute,D:Fte,C:zte,L:Bte,m:Hte,X:Vte,S:$te,M:Gte};function jte(){var d=Tl.f(),p=ly();return d||p}function Ute(d){var p=te(d);p!==null&&p.tag===5&&p.type==="form"?zI(p):Tl.r(d)}var bh=typeof document>"u"?null:document;function M4(d,p,b){var S=bh;if(S&&typeof p=="string"&&p){var R=Nn(p);R='link[rel="'+d+'"][href="'+R+'"]',typeof b=="string"&&(R+='[crossorigin="'+b+'"]'),w4.has(R)||(w4.add(R),d={rel:d,crossOrigin:b,href:p},S.querySelector(R)===null&&(p=S.createElement("link"),Ir(p,"link",d),Ne(p),S.head.appendChild(p)))}}function Fte(d){Tl.D(d),M4("dns-prefetch",d,null)}function zte(d,p){Tl.C(d,p),M4("preconnect",d,p)}function Bte(d,p,b){Tl.L(d,p,b);var S=bh;if(S&&d&&p){var R='link[rel="preload"][as="'+Nn(p)+'"]';p==="image"&&b&&b.imageSrcSet?(R+='[imagesrcset="'+Nn(b.imageSrcSet)+'"]',typeof b.imageSizes=="string"&&(R+='[imagesizes="'+Nn(b.imageSizes)+'"]')):R+='[href="'+Nn(d)+'"]';var O=R;switch(p){case"style":O=_h(d);break;case"script":O=Sh(d)}ws.has(O)||(d=f({rel:"preload",href:p==="image"&&b&&b.imageSrcSet?void 0:d,as:p},b),ws.set(O,d),S.querySelector(R)!==null||p==="style"&&S.querySelector(Eg(O))||p==="script"&&S.querySelector(Ag(O))||(p=S.createElement("link"),Ir(p,"link",d),Ne(p),S.head.appendChild(p)))}}function Hte(d,p){Tl.m(d,p);var b=bh;if(b&&d){var S=p&&typeof p.as=="string"?p.as:"script",R='link[rel="modulepreload"][as="'+Nn(S)+'"][href="'+Nn(d)+'"]',O=R;switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=Sh(d)}if(!ws.has(O)&&(d=f({rel:"modulepreload",href:d},p),ws.set(O,d),b.querySelector(R)===null)){switch(S){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(b.querySelector(Ag(O)))return}S=b.createElement("link"),Ir(S,"link",d),Ne(S),b.head.appendChild(S)}}}function $te(d,p,b){Tl.S(d,p,b);var S=bh;if(S&&d){var R=Re(S).hoistableStyles,O=_h(d);p=p||"default";var G=R.get(O);if(!G){var ae={loading:0,preload:null};if(G=S.querySelector(Eg(O)))ae.loading=5;else{d=f({rel:"stylesheet",href:d,"data-precedence":p},b),(b=ws.get(O))&&gA(d,b);var _e=G=S.createElement("link");Ne(_e),Ir(_e,"link",d),_e._p=new Promise(function(ze,et){_e.onload=ze,_e.onerror=et}),_e.addEventListener("load",function(){ae.loading|=1}),_e.addEventListener("error",function(){ae.loading|=2}),ae.loading|=4,vy(G,p,S)}G={type:"stylesheet",instance:G,count:1,state:ae},R.set(O,G)}}}function Vte(d,p){Tl.X(d,p);var b=bh;if(b&&d){var S=Re(b).hoistableScripts,R=Sh(d),O=S.get(R);O||(O=b.querySelector(Ag(R)),O||(d=f({src:d,async:!0},p),(p=ws.get(R))&&xA(d,p),O=b.createElement("script"),Ne(O),Ir(O,"link",d),b.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(R,O))}}function Gte(d,p){Tl.M(d,p);var b=bh;if(b&&d){var S=Re(b).hoistableScripts,R=Sh(d),O=S.get(R);O||(O=b.querySelector(Ag(R)),O||(d=f({src:d,async:!0,type:"module"},p),(p=ws.get(R))&&xA(d,p),O=b.createElement("script"),Ne(O),Ir(O,"link",d),b.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},S.set(R,O))}}function E4(d,p,b,S){var R=(R=ie.current)?xy(R):null;if(!R)throw Error(i(446));switch(d){case"meta":case"title":return null;case"style":return typeof b.precedence=="string"&&typeof b.href=="string"?(p=_h(b.href),b=Re(R).hoistableStyles,S=b.get(p),S||(S={type:"style",instance:null,count:0,state:null},b.set(p,S)),S):{type:"void",instance:null,count:0,state:null};case"link":if(b.rel==="stylesheet"&&typeof b.href=="string"&&typeof b.precedence=="string"){d=_h(b.href);var O=Re(R).hoistableStyles,G=O.get(d);if(G||(R=R.ownerDocument||R,G={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(d,G),(O=R.querySelector(Eg(d)))&&!O._p&&(G.instance=O,G.state.loading=5),ws.has(d)||(b={rel:"preload",as:"style",href:b.href,crossOrigin:b.crossOrigin,integrity:b.integrity,media:b.media,hrefLang:b.hrefLang,referrerPolicy:b.referrerPolicy},ws.set(d,b),O||Wte(R,d,b,G.state))),p&&S===null)throw Error(i(528,""));return G}if(p&&S!==null)throw Error(i(529,""));return null;case"script":return p=b.async,b=b.src,typeof b=="string"&&p&&typeof p!="function"&&typeof p!="symbol"?(p=Sh(b),b=Re(R).hoistableScripts,S=b.get(p),S||(S={type:"script",instance:null,count:0,state:null},b.set(p,S)),S):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,d))}}function _h(d){return'href="'+Nn(d)+'"'}function Eg(d){return'link[rel="stylesheet"]['+d+"]"}function A4(d){return f({},d,{"data-precedence":d.precedence,precedence:null})}function Wte(d,p,b,S){d.querySelector('link[rel="preload"][as="style"]['+p+"]")?S.loading=1:(p=d.createElement("link"),S.preload=p,p.addEventListener("load",function(){return S.loading|=1}),p.addEventListener("error",function(){return S.loading|=2}),Ir(p,"link",b),Ne(p),d.head.appendChild(p))}function Sh(d){return'[src="'+Nn(d)+'"]'}function Ag(d){return"script[async]"+d}function T4(d,p,b){if(p.count++,p.instance===null)switch(p.type){case"style":var S=d.querySelector('style[data-href~="'+Nn(b.href)+'"]');if(S)return p.instance=S,Ne(S),S;var R=f({},b,{"data-href":b.href,"data-precedence":b.precedence,href:null,precedence:null});return S=(d.ownerDocument||d).createElement("style"),Ne(S),Ir(S,"style",R),vy(S,b.precedence,d),p.instance=S;case"stylesheet":R=_h(b.href);var O=d.querySelector(Eg(R));if(O)return p.state.loading|=4,p.instance=O,Ne(O),O;S=A4(b),(R=ws.get(R))&&gA(S,R),O=(d.ownerDocument||d).createElement("link"),Ne(O);var G=O;return G._p=new Promise(function(ae,_e){G.onload=ae,G.onerror=_e}),Ir(O,"link",S),p.state.loading|=4,vy(O,b.precedence,d),p.instance=O;case"script":return O=Sh(b.src),(R=d.querySelector(Ag(O)))?(p.instance=R,Ne(R),R):(S=b,(R=ws.get(O))&&(S=f({},b),xA(S,R)),d=d.ownerDocument||d,R=d.createElement("script"),Ne(R),Ir(R,"link",S),d.head.appendChild(R),p.instance=R);case"void":return null;default:throw Error(i(443,p.type))}else p.type==="stylesheet"&&(p.state.loading&4)===0&&(S=p.instance,p.state.loading|=4,vy(S,b.precedence,d));return p.instance}function vy(d,p,b){for(var S=b.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),R=S.length?S[S.length-1]:null,O=R,G=0;G<S.length;G++){var ae=S[G];if(ae.dataset.precedence===p)O=ae;else if(O!==R)break}O?O.parentNode.insertBefore(d,O.nextSibling):(p=b.nodeType===9?b.head:b,p.insertBefore(d,p.firstChild))}function gA(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.title==null&&(d.title=p.title)}function xA(d,p){d.crossOrigin==null&&(d.crossOrigin=p.crossOrigin),d.referrerPolicy==null&&(d.referrerPolicy=p.referrerPolicy),d.integrity==null&&(d.integrity=p.integrity)}var yy=null;function C4(d,p,b){if(yy===null){var S=new Map,R=yy=new Map;R.set(b,S)}else R=yy,S=R.get(b),S||(S=new Map,R.set(b,S));if(S.has(d))return S;for(S.set(d,null),b=b.getElementsByTagName(d),R=0;R<b.length;R++){var O=b[R];if(!(O[Ke]||O[hi]||d==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var G=O.getAttribute(p)||"";G=d+G;var ae=S.get(G);ae?ae.push(O):S.set(G,[O])}}return S}function N4(d,p,b){d=d.ownerDocument||d,d.head.insertBefore(b,p==="title"?d.querySelector("head > title"):null)}function qte(d,p,b){if(b===1||p.itemProp!=null)return!1;switch(d){case"meta":case"title":return!0;case"style":if(typeof p.precedence!="string"||typeof p.href!="string"||p.href==="")break;return!0;case"link":if(typeof p.rel!="string"||typeof p.href!="string"||p.href===""||p.onLoad||p.onError)break;switch(p.rel){case"stylesheet":return d=p.disabled,typeof p.precedence=="string"&&d==null;default:return!0}case"script":if(p.async&&typeof p.async!="function"&&typeof p.async!="symbol"&&!p.onLoad&&!p.onError&&p.src&&typeof p.src=="string")return!0}return!1}function R4(d){return!(d.type==="stylesheet"&&(d.state.loading&3)===0)}function Xte(d,p,b,S){if(b.type==="stylesheet"&&(typeof S.media!="string"||matchMedia(S.media).matches!==!1)&&(b.state.loading&4)===0){if(b.instance===null){var R=_h(S.href),O=p.querySelector(Eg(R));if(O){p=O._p,p!==null&&typeof p=="object"&&typeof p.then=="function"&&(d.count++,d=by.bind(d),p.then(d,d)),b.state.loading|=4,b.instance=O,Ne(O);return}O=p.ownerDocument||p,S=A4(S),(R=ws.get(R))&&gA(S,R),O=O.createElement("link"),Ne(O);var G=O;G._p=new Promise(function(ae,_e){G.onload=ae,G.onerror=_e}),Ir(O,"link",S),b.instance=O}d.stylesheets===null&&(d.stylesheets=new Map),d.stylesheets.set(b,p),(p=b.state.preload)&&(b.state.loading&3)===0&&(d.count++,b=by.bind(d),p.addEventListener("load",b),p.addEventListener("error",b))}}var vA=0;function Kte(d,p){return d.stylesheets&&d.count===0&&Sy(d,d.stylesheets),0<d.count||0<d.imgCount?function(b){var S=setTimeout(function(){if(d.stylesheets&&Sy(d,d.stylesheets),d.unsuspend){var O=d.unsuspend;d.unsuspend=null,O()}},6e4+p);0<d.imgBytes&&vA===0&&(vA=62500*Nte());var R=setTimeout(function(){if(d.waitingForImages=!1,d.count===0&&(d.stylesheets&&Sy(d,d.stylesheets),d.unsuspend)){var O=d.unsuspend;d.unsuspend=null,O()}},(d.imgBytes>vA?50:800)+p);return d.unsuspend=b,function(){d.unsuspend=null,clearTimeout(S),clearTimeout(R)}}:null}function by(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Sy(this,this.stylesheets);else if(this.unsuspend){var d=this.unsuspend;this.unsuspend=null,d()}}}var _y=null;function Sy(d,p){d.stylesheets=null,d.unsuspend!==null&&(d.count++,_y=new Map,p.forEach(Yte,d),_y=null,by.call(d))}function Yte(d,p){if(!(p.state.loading&4)){var b=_y.get(d);if(b)var S=b.get(null);else{b=new Map,_y.set(d,b);for(var R=d.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<R.length;O++){var G=R[O];(G.nodeName==="LINK"||G.getAttribute("media")!=="not all")&&(b.set(G.dataset.precedence,G),S=G)}S&&b.set(null,S)}R=p.instance,G=R.getAttribute("data-precedence"),O=b.get(G)||S,O===S&&b.set(null,R),b.set(G,R),this.count++,S=by.bind(this),R.addEventListener("load",S),R.addEventListener("error",S),O?O.parentNode.insertBefore(R,O.nextSibling):(d=d.nodeType===9?d.head:d,d.insertBefore(R,d.firstChild)),p.state.loading|=4}}var Tg={$$typeof:w,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function Zte(d,p,b,S,R,O,G,ae,_e){this.tag=1,this.containerInfo=d,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=Rt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Rt(0),this.hiddenUpdates=Rt(null),this.identifierPrefix=S,this.onUncaughtError=R,this.onCaughtError=O,this.onRecoverableError=G,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=_e,this.incompleteTransitions=new Map}function P4(d,p,b,S,R,O,G,ae,_e,ze,et,ot){return d=new Zte(d,p,b,G,_e,ze,et,ot,ae),p=1,O===!0&&(p|=24),O=qa(3,null,null,p),d.current=O,O.stateNode=d,p=ZM(),p.refCount++,d.pooledCache=p,p.refCount++,O.memoizedState={element:S,isDehydrated:b,cache:p},tE(O),d}function k4(d){return d?(d=Jf,d):Jf}function D4(d,p,b,S,R,O){R=k4(R),S.context===null?S.context=R:S.pendingContext=R,S=Bc(p),S.payload={element:b},O=O===void 0?null:O,O!==null&&(S.callback=O),b=Hc(d,S,p),b!==null&&(Na(b,d,p),ag(b,d,p))}function O4(d,p){if(d=d.memoizedState,d!==null&&d.dehydrated!==null){var b=d.retryLane;d.retryLane=b!==0&&b<p?b:p}}function yA(d,p){O4(d,p),(d=d.alternate)&&O4(d,p)}function L4(d){if(d.tag===13||d.tag===31){var p=pd(d,67108864);p!==null&&Na(p,d,67108864),yA(d,67108864)}}function I4(d){if(d.tag===13||d.tag===31){var p=Qa();p=Qi(p);var b=pd(d,p);b!==null&&Na(b,d,p),yA(d,p)}}var wy=!0;function Qte(d,p,b,S){var R=$.T;$.T=null;var O=K.p;try{K.p=2,bA(d,p,b,S)}finally{K.p=O,$.T=R}}function Jte(d,p,b,S){var R=$.T;$.T=null;var O=K.p;try{K.p=8,bA(d,p,b,S)}finally{K.p=O,$.T=R}}function bA(d,p,b,S){if(wy){var R=_A(S);if(R===null)sA(d,p,S,My,b),U4(d,S);else if(tne(R,d,p,b,S))S.stopPropagation();else if(U4(d,S),p&4&&-1<ene.indexOf(d)){for(;R!==null;){var O=te(R);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var G=Me(O.pendingLanes);if(G!==0){var ae=O;for(ae.pendingLanes|=2,ae.entangledLanes|=2;G;){var _e=1<<31-it(G);ae.entanglements[1]|=_e,G&=~_e}Do(O),(Cn&6)===0&&(sy=L()+500,_g(0))}}break;case 31:case 13:ae=pd(O,2),ae!==null&&Na(ae,O,2),ly(),yA(O,2)}if(O=_A(S),O===null&&sA(d,p,S,My,b),O===R)break;R=O}R!==null&&S.stopPropagation()}else sA(d,p,S,null,b)}}function _A(d){return d=wM(d),SA(d)}var My=null;function SA(d){if(My=null,d=_t(d),d!==null){var p=a(d);if(p===null)d=null;else{var b=p.tag;if(b===13){if(d=s(p),d!==null)return d;d=null}else if(b===31){if(d=o(p),d!==null)return d;d=null}else if(b===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;d=null}else p!==d&&(d=null)}}return My=d,null}function j4(d){switch(d){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(J()){case me:return 2;case ye:return 8;case pe:case Qe:return 32;case Le:return 268435456;default:return 32}default:return 32}}var wA=!1,Jc=null,eu=null,tu=null,Cg=new Map,Ng=new Map,nu=[],ene="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 U4(d,p){switch(d){case"focusin":case"focusout":Jc=null;break;case"dragenter":case"dragleave":eu=null;break;case"mouseover":case"mouseout":tu=null;break;case"pointerover":case"pointerout":Cg.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ng.delete(p.pointerId)}}function Rg(d,p,b,S,R,O){return d===null||d.nativeEvent!==O?(d={blockedOn:p,domEventName:b,eventSystemFlags:S,nativeEvent:O,targetContainers:[R]},p!==null&&(p=te(p),p!==null&&L4(p)),d):(d.eventSystemFlags|=S,p=d.targetContainers,R!==null&&p.indexOf(R)===-1&&p.push(R),d)}function tne(d,p,b,S,R){switch(p){case"focusin":return Jc=Rg(Jc,d,p,b,S,R),!0;case"dragenter":return eu=Rg(eu,d,p,b,S,R),!0;case"mouseover":return tu=Rg(tu,d,p,b,S,R),!0;case"pointerover":var O=R.pointerId;return Cg.set(O,Rg(Cg.get(O)||null,d,p,b,S,R)),!0;case"gotpointercapture":return O=R.pointerId,Ng.set(O,Rg(Ng.get(O)||null,d,p,b,S,R)),!0}return!1}function F4(d){var p=_t(d.target);if(p!==null){var b=a(p);if(b!==null){if(p=b.tag,p===13){if(p=s(b),p!==null){d.blockedOn=p,qr(d.priority,function(){I4(b)});return}}else if(p===31){if(p=o(b),p!==null){d.blockedOn=p,qr(d.priority,function(){I4(b)});return}}else if(p===3&&b.stateNode.current.memoizedState.isDehydrated){d.blockedOn=b.tag===3?b.stateNode.containerInfo:null;return}}}d.blockedOn=null}function Ey(d){if(d.blockedOn!==null)return!1;for(var p=d.targetContainers;0<p.length;){var b=_A(d.nativeEvent);if(b===null){b=d.nativeEvent;var S=new b.constructor(b.type,b);SM=S,b.target.dispatchEvent(S),SM=null}else return p=te(b),p!==null&&L4(p),d.blockedOn=b,!1;p.shift()}return!0}function z4(d,p,b){Ey(d)&&b.delete(p)}function nne(){wA=!1,Jc!==null&&Ey(Jc)&&(Jc=null),eu!==null&&Ey(eu)&&(eu=null),tu!==null&&Ey(tu)&&(tu=null),Cg.forEach(z4),Ng.forEach(z4)}function Ay(d,p){d.blockedOn===p&&(d.blockedOn=null,wA||(wA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,nne)))}var Ty=null;function B4(d){Ty!==d&&(Ty=d,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Ty===d&&(Ty=null);for(var p=0;p<d.length;p+=3){var b=d[p],S=d[p+1],R=d[p+2];if(typeof S!="function"){if(SA(S||b)===null)continue;break}var O=te(b);O!==null&&(d.splice(p,3),p-=3,_E(O,{pending:!0,data:R,method:b.method,action:S},S,R))}}))}function wh(d){function p(_e){return Ay(_e,d)}Jc!==null&&Ay(Jc,d),eu!==null&&Ay(eu,d),tu!==null&&Ay(tu,d),Cg.forEach(p),Ng.forEach(p);for(var b=0;b<nu.length;b++){var S=nu[b];S.blockedOn===d&&(S.blockedOn=null)}for(;0<nu.length&&(b=nu[0],b.blockedOn===null);)F4(b),b.blockedOn===null&&nu.shift();if(b=(d.ownerDocument||d).$$reactFormReplay,b!=null)for(S=0;S<b.length;S+=3){var R=b[S],O=b[S+1],G=R[Ti]||null;if(typeof O=="function")G||B4(b);else if(G){var ae=null;if(O&&O.hasAttribute("formAction")){if(R=O,G=O[Ti]||null)ae=G.formAction;else if(SA(R)!==null)continue}else ae=G.action;typeof ae=="function"?b[S+1]=ae:(b.splice(S,3),S-=3),B4(b)}}}function H4(){function d(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(G){return R=G})},focusReset:"manual",scroll:"manual"})}function p(){R!==null&&(R(),R=null),S||setTimeout(b,20)}function b(){if(!S&&!navigation.transition){var O=navigation.currentEntry;O&&O.url!=null&&navigation.navigate(O.url,{state:O.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var S=!1,R=null;return navigation.addEventListener("navigate",d),navigation.addEventListener("navigatesuccess",p),navigation.addEventListener("navigateerror",p),setTimeout(b,100),function(){S=!0,navigation.removeEventListener("navigate",d),navigation.removeEventListener("navigatesuccess",p),navigation.removeEventListener("navigateerror",p),R!==null&&(R(),R=null)}}}function MA(d){this._internalRoot=d}Cy.prototype.render=MA.prototype.render=function(d){var p=this._internalRoot;if(p===null)throw Error(i(409));var b=p.current,S=Qa();D4(b,S,d,p,null,null)},Cy.prototype.unmount=MA.prototype.unmount=function(){var d=this._internalRoot;if(d!==null){this._internalRoot=null;var p=d.containerInfo;D4(d.current,2,null,d,null,null),ly(),p[Qs]=null}};function Cy(d){this._internalRoot=d}Cy.prototype.unstable_scheduleHydration=function(d){if(d){var p=Pr();d={blockedOn:null,target:d,priority:p};for(var b=0;b<nu.length&&p!==0&&p<nu[b].priority;b++);nu.splice(b,0,d),b===0&&F4(d)}};var $4=e.version;if($4!=="19.2.0")throw Error(i(527,$4,"19.2.0"));K.findDOMNode=function(d){var p=d._reactInternals;if(p===void 0)throw typeof d.render=="function"?Error(i(188)):(d=Object.keys(d).join(","),Error(i(268,d)));return d=c(p),d=d!==null?u(d):null,d=d===null?null:d.stateNode,d};var ine={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:$,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ny=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ny.isDisabled&&Ny.supportsFiber)try{Ie=Ny.inject(ine),Pe=Ny}catch{}}return kg.createRoot=function(d,p){if(!r(d))throw Error(i(299));var b=!1,S="",R=YI,O=ZI,G=QI;return p!=null&&(p.unstable_strictMode===!0&&(b=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onUncaughtError!==void 0&&(R=p.onUncaughtError),p.onCaughtError!==void 0&&(O=p.onCaughtError),p.onRecoverableError!==void 0&&(G=p.onRecoverableError)),p=P4(d,1,!1,null,null,b,S,null,R,O,G,H4),d[Qs]=p.current,aA(d),new MA(p)},kg.hydrateRoot=function(d,p,b){if(!r(d))throw Error(i(299));var S=!1,R="",O=YI,G=ZI,ae=QI,_e=null;return b!=null&&(b.unstable_strictMode===!0&&(S=!0),b.identifierPrefix!==void 0&&(R=b.identifierPrefix),b.onUncaughtError!==void 0&&(O=b.onUncaughtError),b.onCaughtError!==void 0&&(G=b.onCaughtError),b.onRecoverableError!==void 0&&(ae=b.onRecoverableError),b.formState!==void 0&&(_e=b.formState)),p=P4(d,1,!0,p,b??null,S,R,_e,O,G,ae,H4),p.context=k4(null),b=p.current,S=Qa(),S=Qi(S),R=Bc(S),R.callback=null,Hc(b,R,S),b=S,p.current.lanes=b,ln(p,b),Do(p),d[Qs]=p.current,aA(d),new Cy(p)},kg.version="19.2.0",kg}var J4;function pne(){if(J4)return TA.exports;J4=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(),TA.exports=hne(),TA.exports}var mne=pne();const Vt=t=>typeof t=="string",Dg=()=>{let t,e;const n=new Promise((i,r)=>{t=i,e=r});return n.resolve=t,n.reject=e,n},eU=t=>t==null?"":""+t,gne=(t,e,n)=>{t.forEach(i=>{e[i]&&(n[i]=e[i])})},xne=/###/g,tU=t=>t&&t.indexOf("###")>-1?t.replace(xne,"."):t,nU=t=>!t||Vt(t),xx=(t,e,n)=>{const i=Vt(e)?e.split("."):e;let r=0;for(;r<i.length-1;){if(nU(t))return{};const a=tU(i[r]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++r}return nU(t)?{}:{obj:t,k:tU(i[r])}},iU=(t,e,n)=>{const{obj:i,k:r}=xx(t,e,Object);if(i!==void 0||e.length===1){i[r]=n;return}let a=e[e.length-1],s=e.slice(0,e.length-1),o=xx(t,s,Object);for(;o.obj===void 0&&s.length;)a=`${s[s.length-1]}.${a}`,s=s.slice(0,s.length-1),o=xx(t,s,Object),o?.obj&&typeof o.obj[`${o.k}.${a}`]<"u"&&(o.obj=void 0);o.obj[`${o.k}.${a}`]=n},vne=(t,e,n,i)=>{const{obj:r,k:a}=xx(t,e,Object);r[a]=r[a]||[],r[a].push(n)},I_=(t,e)=>{const{obj:n,k:i}=xx(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,i))return n[i]},yne=(t,e,n)=>{const i=I_(t,n);return i!==void 0?i:I_(e,n)},oG=(t,e,n)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in t?Vt(t[i])||t[i]instanceof String||Vt(e[i])||e[i]instanceof String?n&&(t[i]=e[i]):oG(t[i],e[i],n):t[i]=e[i]);return t},Mh=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var bne={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const _ne=t=>Vt(t)?t.replace(/[&<>"'\/]/g,e=>bne[e]):t;class Sne{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;const i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const wne=[" ",",","?","!",";"],Mne=new Sne(20),Ene=(t,e,n)=>{e=e||"",n=n||"";const i=wne.filter(s=>e.indexOf(s)<0&&n.indexOf(s)<0);if(i.length===0)return!0;const r=Mne.getRegExp(`(${i.map(s=>s==="?"?"\\?":s).join("|")})`);let a=!r.test(t);if(!a){const s=t.indexOf(n);s>0&&!r.test(t.substring(0,s))&&(a=!0)}return a},xN=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const i=e.split(n);let r=t;for(let a=0;a<i.length;){if(!r||typeof r!="object")return;let s,o="";for(let l=a;l<i.length;++l)if(l!==a&&(o+=n),o+=i[l],s=r[o],s!==void 0){if(["string","number","boolean"].indexOf(typeof s)>-1&&l<i.length-1)continue;a+=l-a+1;break}r=s}return r},Bx=t=>t?.replace("_","-"),Ane={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class j_{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||Ane,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,i,r){return r&&!this.debug?null:(Vt(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new j_(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new j_(this.logger,e)}}var Vo=new j_;let GS=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const r=this.observers[i].get(n)||0;this.observers[i].set(n,r+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([r,a])=>{for(let s=0;s<a;s++)r(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,a])=>{for(let s=0;s<a;s++)r.apply(r,[e,...n])})}};class rU extends GS{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,i,r={}){const a=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,s=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let o;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],i&&(Array.isArray(i)?o.push(...i):Vt(i)&&a?o.push(...i.split(a)):o.push(i)));const l=I_(this.data,o);return!l&&!n&&!i&&e.indexOf(".")>-1&&(e=o[0],n=o[1],i=o.slice(2).join(".")),l||!s||!Vt(i)?l:xN(this.data?.[e]?.[n],i,a)}addResource(e,n,i,r,a={silent:!1}){const s=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let o=[e,n];i&&(o=o.concat(s?i.split(s):i)),e.indexOf(".")>-1&&(o=e.split("."),r=n,n=o[1]),this.addNamespaces(n),iU(this.data,o,r),a.silent||this.emit("added",e,n,i,r)}addResources(e,n,i,r={silent:!1}){for(const a in i)(Vt(i[a])||Array.isArray(i[a]))&&this.addResource(e,n,a,i[a],{silent:!0});r.silent||this.emit("added",e,n,i)}addResourceBundle(e,n,i,r,a,s={silent:!1,skipCopy:!1}){let o=[e,n];e.indexOf(".")>-1&&(o=e.split("."),r=i,i=n,n=o[1]),this.addNamespaces(n);let l=I_(this.data,o)||{};s.skipCopy||(i=JSON.parse(JSON.stringify(i))),r?oG(l,i,a):l={...l,...i},iU(this.data,o,l),s.silent||this.emit("added",e,n,i)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(r=>n[r]&&Object.keys(n[r]).length>0)}toJSON(){return this.data}}var lG={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,i,r){return t.forEach(a=>{e=this.processors[a]?.process(e,n,i,r)??e}),e}};const cG=Symbol("i18next/PATH_KEY");function Tne(){const t=[],e=Object.create(null);let n;return e.get=(i,r)=>(n?.revoke?.(),r===cG?t:(t.push(r),n=Proxy.revocable(i,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function vN(t,e){const{[cG]:n}=t(Tne());return n.join(e?.keySeparator??".")}const aU={},PA=t=>!Vt(t)&&typeof t!="boolean"&&typeof t!="number";class U_ extends GS{constructor(e,n={}){super(),gne(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Vo.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const i={...n};if(e==null)return!1;const r=this.resolve(e,i);if(r?.res===void 0)return!1;const a=PA(r.res);return!(i.returnObjects===!1&&a)}extractFromKey(e,n){let i=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const s=i&&e.indexOf(i)>-1,o=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Ene(e,i,r);if(s&&!o){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:Vt(a)?[a]:a};const c=e.split(i);(i!==r||i===r&&this.options.ns.indexOf(c[0])>-1)&&(a=c.shift()),e=c.join(r)}return{key:e,namespaces:Vt(a)?[a]:a}}translate(e,n,i){let r=typeof n=="object"?{...n}:n;if(typeof r!="object"&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),typeof r=="object"&&(r={...r}),r||(r={}),e==null)return"";typeof e=="function"&&(e=vN(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);const a=r.returnDetails!==void 0?r.returnDetails:this.options.returnDetails,s=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,{key:o,namespaces:l}=this.extractFromKey(e[e.length-1],r),c=l[l.length-1];let u=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const f=r.lng||this.language,m=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return m?a?{res:`${c}${u}${o}`,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(r)}:`${c}${u}${o}`:a?{res:o,usedKey:o,exactUsedKey:o,usedLng:f,usedNS:c,usedParams:this.getUsedParamsDetails(r)}:o;const g=this.resolve(e,r);let y=g?.res;const _=g?.usedKey||o,v=g?.exactUsedKey||o,x=["[object Number]","[object Function]","[object RegExp]"],M=r.joinArrays!==void 0?r.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,C=r.count!==void 0&&!Vt(r.count),T=U_.hasDefaultValue(r),P=C?this.pluralResolver.getSuffix(f,r.count,r):"",A=r.ordinal&&C?this.pluralResolver.getSuffix(f,r.count,{ordinal:!1}):"",j=C&&!r.ordinal&&r.count===0,N=j&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${P}`]||r[`defaultValue${A}`]||r.defaultValue;let k=y;w&&!y&&T&&(k=N);const F=PA(k),I=Object.prototype.toString.apply(k);if(w&&k&&F&&x.indexOf(I)<0&&!(Vt(M)&&Array.isArray(k))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const W=this.options.returnedObjectHandler?this.options.returnedObjectHandler(_,k,{...r,ns:l}):`key '${o} (${this.language})' returned an object instead of string.`;return a?(g.res=W,g.usedParams=this.getUsedParamsDetails(r),g):W}if(s){const W=Array.isArray(k),D=W?[]:{},B=W?v:_;for(const $ in k)if(Object.prototype.hasOwnProperty.call(k,$)){const K=`${B}${s}${$}`;T&&!y?D[$]=this.translate(K,{...r,defaultValue:PA(N)?N[$]:void 0,joinArrays:!1,ns:l}):D[$]=this.translate(K,{...r,joinArrays:!1,ns:l}),D[$]===K&&(D[$]=k[$])}y=D}}else if(w&&Vt(M)&&Array.isArray(y))y=y.join(M),y&&(y=this.extendTranslation(y,e,r,i));else{let W=!1,D=!1;!this.isValidLookup(y)&&T&&(W=!0,y=N),this.isValidLookup(y)||(D=!0,y=o);const $=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&D?void 0:y,K=T&&N!==y&&this.options.updateMissing;if(D||W||K){if(this.logger.log(K?"updateKey":"missingKey",f,c,o,K?N:y),s){const z=this.resolve(o,{...r,keySeparator:!1});z&&z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let X=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let z=0;z<Y.length;z++)X.push(Y[z]);else this.options.saveMissingTo==="all"?X=this.languageUtils.toResolveHierarchy(r.lng||this.language):X.push(r.lng||this.language);const ee=(z,V,re)=>{const le=T&&re!==y?re:$;this.options.missingKeyHandler?this.options.missingKeyHandler(z,c,V,le,K,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(z,c,V,le,K,r),this.emit("missingKey",z,c,V,y)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?X.forEach(z=>{const V=this.pluralResolver.getSuffixes(z,r);j&&r[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(re=>{ee([z],o+re,r[`defaultValue${re}`]||N)})}):ee(X,o,N))}y=this.extendTranslation(y,e,r,g,i),D&&y===o&&this.options.appendNamespaceToMissingKey&&(y=`${c}${u}${o}`),(D||W)&&this.options.parseMissingKeyHandler&&(y=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}${u}${o}`:o,W?y:void 0,r))}return a?(g.res=y,g.usedParams=this.getUsedParamsDetails(r),g):y}extendTranslation(e,n,i,r,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const l=Vt(e)&&(i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let c;if(l){const f=e.match(this.interpolator.nestingRegexp);c=f&&f.length}let u=i.replace&&!Vt(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,i.lng||this.language||r.usedLng,i),l){const f=e.match(this.interpolator.nestingRegexp),m=f&&f.length;c<m&&(i.nest=!1)}!i.lng&&r&&r.res&&(i.lng=this.language||r.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),i)),i.interpolation&&this.interpolator.reset()}const s=i.postProcess||this.options.postProcess,o=Vt(s)?[s]:s;return e!=null&&o?.length&&i.applyPostProcessor!==!1&&(e=lG.handle(o,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),e}resolve(e,n={}){let i,r,a,s,o;return Vt(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const c=this.extractFromKey(l,n),u=c.key;r=u;let f=c.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!Vt(n.count),g=m&&!n.ordinal&&n.count===0,y=n.context!==void 0&&(Vt(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(i)||(o=v,!aU[`${_[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(aU[`${_[0]}-${v}`]=!0,this.logger.warn(`key "${r}" for languages "${_.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(x=>{if(this.isValidLookup(i))return;s=x;const M=[u];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(M,u,x,v,n);else{let C;m&&(C=this.pluralResolver.getSuffix(x,n.count,n));const T=`${this.options.pluralSeparator}zero`,P=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(n.ordinal&&C.indexOf(P)===0&&M.push(u+C.replace(P,this.options.pluralSeparator)),M.push(u+C),g&&M.push(u+T)),y){const A=`${u}${this.options.contextSeparator||"_"}${n.context}`;M.push(A),m&&(n.ordinal&&C.indexOf(P)===0&&M.push(A+C.replace(P,this.options.pluralSeparator)),M.push(A+C),g&&M.push(A+T))}}let w;for(;w=M.pop();)this.isValidLookup(i)||(a=w,i=this.getResource(x,v,w,n))}))})}),{res:i,usedKey:r,exactUsedKey:a,usedLng:s,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,i,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,i,r):this.resourceStore.getResource(e,n,i,r)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!Vt(e.replace);let r=i?e.replace:e;if(i&&typeof e.count<"u"&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!i){r={...r};for(const a of n)delete r[a]}return r}static hasDefaultValue(e){const n="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&n===i.substring(0,n.length)&&e[i]!==void 0)return!0;return!1}}class sU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Vo.create("languageUtils")}getScriptPartFromCode(e){if(e=Bx(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Bx(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Vt(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let n;return e.forEach(i=>{if(n)return;const r=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(r))&&(n=r)}),!n&&this.options.supportedLngs&&e.forEach(i=>{if(n)return;const r=this.getScriptPartFromCode(i);if(this.isSupportedCode(r))return n=r;const a=this.getLanguagePartFromCode(i);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(s=>{if(s===a)return s;if(!(s.indexOf("-")<0&&a.indexOf("-")<0)&&(s.indexOf("-")>0&&a.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===a||s.indexOf(a)===0&&a.length>1))return s})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Vt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let i=e[n];return i||(i=e[this.getScriptPartFromCode(n)]),i||(i=e[this.formatLanguageCode(n)]),i||(i=e[this.getLanguagePartFromCode(n)]),i||(i=e.default),i||[]}toResolveHierarchy(e,n){const i=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),r=[],a=s=>{s&&(this.isSupportedCode(s)?r.push(s):this.logger.warn(`rejecting language code not found in supportedLngs: ${s}`))};return Vt(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):Vt(e)&&a(this.formatLanguageCode(e)),i.forEach(s=>{r.indexOf(s)<0&&a(this.formatLanguageCode(s))}),r}}const oU={zero:0,one:1,two:2,few:3,many:4,other:5},lU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Cne{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=Vo.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const i=Bx(e==="dev"?"en":e),r=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:i,type:r});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let s;try{s=new Intl.PluralRules(i,{type:r})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),lU;if(!e.match(/-|_/))return lU;const l=this.languageUtils.getLanguagePartFromCode(e);s=this.getRule(l,n)}return this.pluralRulesCache[a]=s,s}needsPlural(e,n={}){let i=this.getRule(e,n);return i||(i=this.getRule("dev",n)),i?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,i={}){return this.getSuffixes(e,i).map(r=>`${n}${r}`)}getSuffixes(e,n={}){let i=this.getRule(e,n);return i||(i=this.getRule("dev",n)),i?i.resolvedOptions().pluralCategories.sort((r,a)=>oU[r]-oU[a]).map(r=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,n,i={}){const r=this.getRule(e,i);return r?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${r.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,i))}}const cU=(t,e,n,i=".",r=!0)=>{let a=yne(t,e,n);return!a&&r&&Vt(n)&&(a=xN(t,n,i),a===void 0&&(a=xN(e,n,i))),a},kA=t=>t.replace(/\$/g,"$$$$");class Nne{constructor(e={}){this.logger=Vo.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:i,useRawValueToEscape:r,prefix:a,prefixEscaped:s,suffix:o,suffixEscaped:l,formatSeparator:c,unescapeSuffix:u,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:g,nestingSuffix:y,nestingSuffixEscaped:_,nestingOptionsSeparator:v,maxReplaces:x,alwaysFormat:M}=e.interpolation;this.escape=n!==void 0?n:_ne,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=a?Mh(a):s||"{{",this.suffix=o?Mh(o):l||"}}",this.formatSeparator=c||",",this.unescapePrefix=u?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=m?Mh(m):g||Mh("$t("),this.nestingSuffix=y?Mh(y):_||Mh(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=x||1e3,this.alwaysFormat=M!==void 0?M:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,i)=>n?.source===i?(n.lastIndex=0,n):new RegExp(i,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,i,r){let a,s,o;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=g=>{if(g.indexOf(this.formatSeparator)<0){const x=cU(n,l,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(x,void 0,i,{...r,...n,interpolationkey:g}):x}const y=g.split(this.formatSeparator),_=y.shift().trim(),v=y.join(this.formatSeparator).trim();return this.format(cU(n,l,_,this.options.keySeparator,this.options.ignoreJSONStructure),v,i,{...r,...n,interpolationkey:_})};this.resetRegExp();const u=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:g=>kA(g)},{regex:this.regexp,safeValue:g=>this.escapeValue?kA(this.escape(g)):kA(g)}].forEach(g=>{for(o=0;a=g.regex.exec(e);){const y=a[1].trim();if(s=c(y),s===void 0)if(typeof u=="function"){const v=u(e,a,r);s=Vt(v)?v:""}else if(r&&Object.prototype.hasOwnProperty.call(r,y))s="";else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`),s="";else!Vt(s)&&!this.useRawValueToEscape&&(s=eU(s));const _=g.safeValue(s);if(e=e.replace(a[0],_),f?(g.regex.lastIndex+=s.length,g.regex.lastIndex-=a[0].length):g.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,n,i={}){let r,a,s;const o=(l,c)=>{const u=this.nestingOptionsSeparator;if(l.indexOf(u)<0)return l;const f=l.split(new RegExp(`${u}[ ]*{`));let m=`{${f[1]}`;l=f[0],m=this.interpolate(m,s);const g=m.match(/'/g),y=m.match(/"/g);((g?.length??0)%2===0&&!y||y.length%2!==0)&&(m=m.replace(/'/g,'"'));try{s=JSON.parse(m),c&&(s={...c,...s})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${u}${m}`}return s.defaultValue&&s.defaultValue.indexOf(this.prefix)>-1&&delete s.defaultValue,l};for(;r=this.nestingRegexp.exec(e);){let l=[];s={...i},s=s.replace&&!Vt(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;const c=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(c!==-1&&(l=r[1].slice(c).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),r[1]=r[1].slice(0,c)),a=n(o.call(this,r[1].trim(),s),s),a&&r[0]===e&&!Vt(a))return a;Vt(a)||(a=eU(a)),a||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),a=""),l.length&&(a=l.reduce((u,f)=>this.format(u,f,i.lng,{...i,interpolationkey:r[1].trim()}),a.trim())),e=e.replace(r[0],a),this.regexp.lastIndex=0}return e}}const Rne=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const r=i[1].substring(0,i[1].length-1);e==="currency"&&r.indexOf(":")<0?n.currency||(n.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?n.range||(n.range=r.trim()):r.split(";").forEach(s=>{if(s){const[o,...l]=s.split(":"),c=l.join(":").trim().replace(/^'+|'+$/g,""),u=o.trim();n[u]||(n[u]=c),c==="false"&&(n[u]=!1),c==="true"&&(n[u]=!0),isNaN(c)||(n[u]=parseInt(c,10))}})}return{formatName:e,formatOptions:n}},uU=t=>{const e={};return(n,i,r)=>{let a=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(a={...a,[r.interpolationkey]:void 0});const s=i+JSON.stringify(a);let o=e[s];return o||(o=t(Bx(i),r),e[s]=o),o(n)}},Pne=t=>(e,n,i)=>t(Bx(n),i)(e);class kne{constructor(e={}){this.logger=Vo.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const i=n.cacheInBuiltFormats?uU:Pne;this.formats={number:i((r,a)=>{const s=new Intl.NumberFormat(r,{...a});return o=>s.format(o)}),currency:i((r,a)=>{const s=new Intl.NumberFormat(r,{...a,style:"currency"});return o=>s.format(o)}),datetime:i((r,a)=>{const s=new Intl.DateTimeFormat(r,{...a});return o=>s.format(o)}),relativetime:i((r,a)=>{const s=new Intl.RelativeTimeFormat(r,{...a});return o=>s.format(o,a.range||"day")}),list:i((r,a)=>{const s=new Intl.ListFormat(r,{...a});return o=>s.format(o)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=uU(n)}format(e,n,i,r={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(o=>o.indexOf(")")>-1)){const o=a.findIndex(l=>l.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,o)].join(this.formatSeparator)}return a.reduce((o,l)=>{const{formatName:c,formatOptions:u}=Rne(l);if(this.formats[c]){let f=o;try{const m=r?.formatParams?.[r.interpolationkey]||{},g=m.locale||m.lng||r.locale||r.lng||i;f=this.formats[c](o,g,{...u,...r,...m})}catch(m){this.logger.warn(m)}return f}else this.logger.warn(`there was no format function for ${c}`);return o},e)}}const Dne=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class One extends GS{constructor(e,n,i,r={}){super(),this.backend=e,this.store=n,this.services=i,this.languageUtils=i.languageUtils,this.options=r,this.logger=Vo.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(i,r.backend,r)}queueLoad(e,n,i,r){const a={},s={},o={},l={};return e.forEach(c=>{let u=!0;n.forEach(f=>{const m=`${c}|${f}`;!i.reload&&this.store.hasResourceBundle(c,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?s[m]===void 0&&(s[m]=!0):(this.state[m]=1,u=!1,s[m]===void 0&&(s[m]=!0),a[m]===void 0&&(a[m]=!0),l[f]===void 0&&(l[f]=!0)))}),u||(o[c]=!0)}),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}loaded(e,n,i){const r=e.split("|"),a=r[0],s=r[1];n&&this.emit("failedLoading",a,s,n),!n&&i&&this.store.addResourceBundle(a,s,i,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&i&&(this.state[e]=0);const o={};this.queue.forEach(l=>{vne(l.loaded,[a],s),Dne(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(c=>{o[c]||(o[c]={});const u=l.loaded[c];u.length&&u.forEach(f=>{o[c][f]===void 0&&(o[c][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(l=>!l.done)}read(e,n,i,r=0,a=this.retryTimeout,s){if(!e.length)return s(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:i,tried:r,wait:a,callback:s});return}this.readingCalls++;const o=(c,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(c&&u&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,i,r+1,a*2,s)},a);return}s(c,u)},l=this.backend[i].bind(this.backend);if(l.length===2){try{const c=l(e,n);c&&typeof c.then=="function"?c.then(u=>o(null,u)).catch(o):o(null,c)}catch(c){o(c)}return}return l(e,n,o)}prepareLoading(e,n,i={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();Vt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Vt(n)&&(n=[n]);const a=this.queueLoad(e,n,i,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach(s=>{this.loadOne(s)})}load(e,n,i){this.prepareLoading(e,n,{},i)}reload(e,n,i){this.prepareLoading(e,n,{reload:!0},i)}loadOne(e,n=""){const i=e.split("|"),r=i[0],a=i[1];this.read(r,a,"read",void 0,void 0,(s,o)=>{s&&this.logger.warn(`${n}loading namespace ${a} for language ${r} failed`,s),!s&&o&&this.logger.log(`${n}loaded namespace ${a} for language ${r}`,o),this.loaded(e,s,o)})}saveMissing(e,n,i,r,a,s={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${i}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(i==null||i==="")){if(this.backend?.create){const l={...s,isUpdate:a},c=this.backend.create.bind(this.backend);if(c.length<6)try{let u;c.length===5?u=c(e,n,i,r,l):u=c(e,n,i,r),u&&typeof u.then=="function"?u.then(f=>o(null,f)).catch(o):o(null,u)}catch(u){o(u)}else c(e,n,i,r,o,l)}!e||!e[0]||this.store.addResource(e[0],n,i,r)}}}const dU=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),Vt(t[1])&&(e.defaultValue=t[1]),Vt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(i=>{e[i]=n[i]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),fU=t=>(Vt(t.ns)&&(t.ns=[t.ns]),Vt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Vt(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),Py=()=>{},Lne=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class vx extends GS{constructor(e={},n){if(super(),this.options=fU(e),this.services={},this.logger=Vo,this.modules={external:[]},Lne(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,typeof e=="function"&&(n=e,e={}),e.defaultNS==null&&e.ns&&(Vt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const i=dU();this.options={...i,...this.options,...fU(e)},this.options.interpolation={...i.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const r=c=>c?typeof c=="function"?new c:c:null;if(!this.options.isClone){this.modules.logger?Vo.init(r(this.modules.logger),this.options):Vo.init(null,this.options);let c;this.modules.formatter?c=this.modules.formatter:c=kne;const u=new sU(this.options);this.store=new rU(this.options.resources,this.options);const f=this.services;f.logger=Vo,f.resourceStore=this.store,f.languageUtils=u,f.pluralResolver=new Cne(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),c&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=r(c),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Nne(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new One(r(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(g,...y)=>{this.emit(g,...y)}),this.modules.languageDetector&&(f.languageDetector=r(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=r(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new U_(this.services,this.options),this.translator.on("*",(g,...y)=>{this.emit(g,...y)}),this.modules.external.forEach(g=>{g.init&&g.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Py),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const c=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);c.length>0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(c=>{this[c]=(...u)=>this.store[c](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(c=>{this[c]=(...u)=>(this.store[c](...u),this)});const o=Dg(),l=()=>{const c=(u,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(f),n(u,f)};if(this.languages&&!this.isInitialized)return c(null,this.t.bind(this));this.changeLanguage(this.options.lng,c)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),o}loadResources(e,n=Py){let i=n;const r=Vt(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();const a=[],s=o=>{if(!o||o==="cimode")return;this.services.languageUtils.toResolveHierarchy(o).forEach(c=>{c!=="cimode"&&a.indexOf(c)<0&&a.push(c)})};r?s(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(l=>s(l)),this.options.preload?.forEach?.(o=>s(o)),this.services.backendConnector.load(a,this.options.ns,o=>{!o&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(o)})}else i(null)}reloadResources(e,n,i){const r=Dg();return typeof e=="function"&&(i=e,e=void 0),typeof n=="function"&&(i=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),i||(i=Py),this.services.backendConnector.reload(e,n,a=>{r.resolve(),i(a)}),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&lG.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1)){for(let n=0;n<this.languages.length;n++){const i=this.languages[n];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;const i=Dg();this.emit("languageChanging",e);const r=o=>{this.language=o,this.languages=this.services.languageUtils.toResolveHierarchy(o),this.resolvedLanguage=void 0,this.setResolvedLanguage(o)},a=(o,l)=>{l?this.isLanguageChangingTo===e&&(r(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve((...c)=>this.t(...c)),n&&n(o,(...c)=>this.t(...c))},s=o=>{!e&&!o&&this.services.languageDetector&&(o=[]);const l=Vt(o)?o:o&&o[0],c=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(Vt(o)?[o]:o);c&&(this.language||r(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,u=>{a(u,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),i}getFixedT(e,n,i){const r=(a,s,...o)=>{let l;typeof s!="object"?l=this.options.overloadTranslationOptionHandler([a,s].concat(o)):l={...s},l.lng=l.lng||r.lng,l.lngs=l.lngs||r.lngs,l.ns=l.ns||r.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||r.keyPrefix);const c=this.options.keySeparator||".";let u;return l.keyPrefix&&Array.isArray(a)?u=a.map(f=>(typeof f=="function"&&(f=vN(f,{...this.options,...s})),`${l.keyPrefix}${c}${f}`)):(typeof a=="function"&&(a=vN(a,{...this.options,...s})),u=l.keyPrefix?`${l.keyPrefix}${c}${a}`:a),this.t(u,l)};return Vt(e)?r.lng=e:r.lngs=e,r.ns=n,r.keyPrefix=i,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const i=n.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const s=(o,l)=>{const c=this.services.backendConnector.state[`${o}|${l}`];return c===-1||c===0||c===2};if(n.precheck){const o=n.precheck(this,s);if(o!==void 0)return o}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(i,e)&&(!r||s(a,e)))}loadNamespaces(e,n){const i=Dg();return this.options.ns?(Vt(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{i.resolve(),n&&n(r)}),i):(n&&n(),Promise.resolve())}loadLanguages(e,n){const i=Dg();Vt(e)&&(e=[e]);const r=this.options.preload||[],a=e.filter(s=>r.indexOf(s)<0&&this.services.languageUtils.isSupportedCode(s));return a.length?(this.options.preload=r.concat(a),this.loadResources(s=>{i.resolve(),n&&n(s)}),i):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{const r=new Intl.Locale(e);if(r&&r.getTextInfo){const a=r.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],i=this.services?.languageUtils||new sU(dU());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const i=new vx(e,n);return i.createInstance=vx.createInstance,i}cloneInstance(e={},n=Py){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},a=new vx(r);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(o=>{a[o]=this[o]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},i){const o=Object.keys(this.store.data).reduce((l,c)=>(l[c]={...this.store.data[c]},l[c]=Object.keys(l[c]).reduce((u,f)=>(u[f]={...l[c][f]},u),l[c]),l),{});a.store=new rU(o,r),a.services.resourceStore=a.store}return a.translator=new U_(a.services,r),a.translator.on("*",(o,...l)=>{a.emit(o,...l)}),a.init(r,n),a.translator.options=r,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Sa=vx.createInstance();Sa.createInstance;Sa.dir;Sa.init;Sa.loadResources;Sa.reloadResources;Sa.use;Sa.changeLanguage;Sa.getFixedT;Sa.t;Sa.exists;Sa.setDefaultNamespace;Sa.hasLoadedNamespace;Sa.loadNamespaces;Sa.loadLanguages;const Ine=(t,e,n,i)=>{const r=[n,{code:e,...i||{}}];if(t?.services?.logger?.forward)return t.services.logger.forward(r,"warn","react-i18next::",!0);vf(r[0])&&(r[0]=`react-i18next:: ${r[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...r):console?.warn&&console.warn(...r)},hU={},uG=(t,e,n,i)=>{vf(n)&&hU[n]||(vf(n)&&(hU[n]=new Date),Ine(t,e,n,i))},dG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},yN=(t,e,n)=>{t.loadNamespaces(e,dG(t,n))},pU=(t,e,n,i)=>{if(vf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return yN(t,n,i);n.forEach(r=>{t.options.ns.indexOf(r)<0&&t.options.ns.push(r)}),t.loadLanguages(e,dG(t,i))},jne=(t,e,n={})=>!e.languages||!e.languages.length?(uG(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(i,r)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&i.services.backendConnector.backend&&i.isLanguageChangingTo&&!r(i.isLanguageChangingTo,t))return!1}}),vf=t=>typeof t=="string",Une=t=>typeof t=="object"&&t!==null,Fne=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,zne={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},Bne=t=>zne[t],Hne=t=>t.replace(Fne,Bne);let bN={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Hne};const $ne=(t={})=>{bN={...bN,...t}},Vne=()=>bN;let fG;const Gne=t=>{fG=t},Wne=()=>fG,qne={type:"3rdParty",init(t){$ne(t.options.react),Gne(t)}},Xne=E.createContext();class Kne{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var DA={exports:{}},OA={};var mU;function Yne(){if(mU)return OA;mU=1;var t=xm();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var n=typeof Object.is=="function"?Object.is:e,i=t.useState,r=t.useEffect,a=t.useLayoutEffect,s=t.useDebugValue;function o(f,m){var g=m(),y=i({inst:{value:g,getSnapshot:m}}),_=y[0].inst,v=y[1];return a(function(){_.value=g,_.getSnapshot=m,l(_)&&v({inst:_})},[f,g,m]),r(function(){return l(_)&&v({inst:_}),f(function(){l(_)&&v({inst:_})})},[f]),s(g),g}function l(f){var m=f.getSnapshot;f=f.value;try{var g=m();return!n(f,g)}catch{return!0}}function c(f,m){return m()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:o;return OA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,OA}var gU;function hG(){return gU||(gU=1,DA.exports=Yne()),DA.exports}var MP=hG();const Zne=(t,e)=>vf(e)?e:Une(e)&&vf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Qne={t:Zne,ready:!1},Jne=()=>()=>{},EP=(t,e={})=>{const{i18n:n}=e,{i18n:i,defaultNS:r}=E.useContext(Xne)||{},a=n||i||Wne();a&&!a.reportNamespaces&&(a.reportNamespaces=new Kne),a||uG(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=E.useMemo(()=>({...Vne(),...a?.options?.react,...e}),[a,e]),{useSuspense:o,keyPrefix:l}=s,c=r||a?.options?.defaultNS,u=vf(c)?[c]:c||["translation"],f=E.useMemo(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(f);const m=E.useRef(0),g=E.useCallback(N=>{if(!a)return Jne;const{bindI18n:k,bindI18nStore:F}=s,I=()=>{m.current+=1,N()};return k&&a.on(k,I),F&&a.store.on(F,I),()=>{k&&k.split(" ").forEach(W=>a.off(W,I)),F&&F.split(" ").forEach(W=>a.store.off(W,I))}},[a,s]),y=E.useRef(),_=E.useCallback(()=>{if(!a)return Qne;const N=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(B=>jne(B,a,s)),k=e.lng||a.language,F=m.current,I=y.current;if(I&&I.ready===N&&I.lng===k&&I.keyPrefix===l&&I.revision===F)return I;const D={t:a.getFixedT(k,s.nsMode==="fallback"?f:f[0],l),ready:N,lng:k,keyPrefix:l,revision:F};return y.current=D,D},[a,f,l,s,e.lng]),[v,x]=E.useState(0),{t:M,ready:w}=MP.useSyncExternalStore(g,_,_);E.useEffect(()=>{if(a&&!w&&!o){const N=()=>x(k=>k+1);e.lng?pU(a,e.lng,f,N):yN(a,f,N)}},[a,e.lng,f,w,o,v]);const C=a||{},T=E.useRef(null),P=E.useRef(),A=N=>{const k=Object.getOwnPropertyDescriptors(N);k.__original&&delete k.__original;const F=Object.create(Object.getPrototypeOf(N),k);if(!Object.prototype.hasOwnProperty.call(F,"__original"))try{Object.defineProperty(F,"__original",{value:N,writable:!1,enumerable:!1,configurable:!1})}catch{}return F},j=E.useMemo(()=>{const N=C,k=N?.language;let F=N;N&&(T.current&&T.current.__original===N?P.current!==k?(F=A(N),T.current=F,P.current=k):F=T.current:(F=A(N),T.current=F,P.current=k));const I=[M,F,w];return I.t=M,I.i18n=F,I.ready=w,I},[M,C,w,C.resolvedLanguage,C.language,C.languages]);if(a&&o&&!w)throw new Promise(N=>{const k=()=>N();e.lng?pU(a,e.lng,f,k):yN(a,f,k)});return j},{slice:eie,forEach:tie}=[];function nie(t){return tie.call(eie.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function iie(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(n=>n.test(t))}const xU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,rie=function(t,e){const i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},r=encodeURIComponent(e);let a=`${t}=${r}`;if(i.maxAge>0){const s=i.maxAge-0;if(Number.isNaN(s))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(s)}`}if(i.domain){if(!xU.test(i.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${i.domain}`}if(i.path){if(!xU.test(i.path))throw new TypeError("option path is invalid");a+=`; Path=${i.path}`}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${i.expires.toUTCString()}`}if(i.httpOnly&&(a+="; HttpOnly"),i.secure&&(a+="; Secure"),i.sameSite)switch(typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i.partitioned&&(a+="; Partitioned"),a},vU={create(t,e,n,i){let r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(r.expires=new Date,r.expires.setTime(r.expires.getTime()+n*60*1e3)),i&&(r.domain=i),document.cookie=rie(t,e,r)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let i=0;i<n.length;i++){let r=n[i];for(;r.charAt(0)===" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return r.substring(e.length,r.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var aie={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return vU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:i,cookieDomain:r,cookieOptions:a}=e;n&&typeof document<"u"&&vU.create(n,t,i,r,a)}},sie={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:i}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(i=window.location.hash.substring(window.location.hash.indexOf("?")));const a=i.substring(1).split("&");for(let s=0;s<a.length;s++){const o=a[s].indexOf("=");o>0&&a[s].substring(0,o)===e&&(n=a[s].substring(o+1))}}return n}},oie={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,i;if(typeof window<"u"){const{hash:r}=window.location;if(r&&r.length>2){const a=r.substring(1);if(e){const s=a.split("&");for(let o=0;o<s.length;o++){const l=s[o].indexOf("=");l>0&&s[o].substring(0,l)===e&&(i=s[o].substring(l+1))}}if(i)return i;if(!i&&n>-1){const s=r.match(/\/([a-zA-Z-]*)/g);return Array.isArray(s)?s[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return i}};let Eh=null;const yU=()=>{if(Eh!==null)return Eh;try{if(Eh=typeof window<"u"&&window.localStorage!==null,!Eh)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Eh=!1}return Eh};var lie={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&yU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&yU()&&window.localStorage.setItem(n,t)}};let Ah=null;const bU=()=>{if(Ah!==null)return Ah;try{if(Ah=typeof window<"u"&&window.sessionStorage!==null,!Ah)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ah=!1}return Ah};var cie={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&bU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&bU()&&window.sessionStorage.setItem(n,t)}},uie={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:i,language:r}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);i&&e.push(i),r&&e.push(r)}return e.length>0?e:void 0}},die={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const i=e||(typeof document<"u"?document.documentElement:null);return i&&typeof i.getAttribute=="function"&&(n=i.getAttribute("lang")),n}},fie={name:"path",lookup(t){let{lookupFromPathIndex:e}=t;if(typeof window>"u")return;const n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(n)?n[typeof e=="number"?e:0]?.replace("/",""):void 0}},hie={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,i=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(i)return i[n]}};let pG=!1;try{document.cookie,pG=!0}catch{}const mG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];pG||mG.splice(1,1);const pie=()=>({order:mG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class gG{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,n)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=nie(n,this.options||{},pie()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=r=>r.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(aie),this.addDetector(sie),this.addDetector(lie),this.addDetector(cie),this.addDetector(uie),this.addDetector(die),this.addDetector(fie),this.addDetector(hie),this.addDetector(oie)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(i=>{if(this.detectors[i]){let r=this.detectors[i].lookup(this.options);r&&typeof r=="string"&&(r=[r]),r&&(n=n.concat(r))}}),n=n.filter(i=>i!=null&&!iie(i)).map(i=>this.options.convertDetectedLanguage(i)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?n:n.length>0?n[0]:null}cacheUserLanguage(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||n.forEach(i=>{this.detectors[i]&&this.detectors[i].cacheUserLanguage(e,this.options)}))}}gG.type="languageDetector";const mie={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",settings:"Settings",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode"},common:{save:"Save",cancel:"Cancel",delete:"Delete",edit:"Edit",add:"Add",close:"Close",confirm:"Confirm",loading:"Loading...",error:"Error",success:"Success",warning:"Warning",enabled:"Enabled",disabled:"Disabled",yes:"Yes",no:"No",on:"On",off:"Off",all:"All",none:"None",search:"Search",filter:"Filter",sort:"Sort",refresh:"Refresh",download:"Download",upload:"Upload",actions:"Actions",status:"Status",name:"Name",description:"Description",date:"Date",time:"Time",hours:"hours",minutes:"minutes",seconds:"seconds",noPrinters:"No printers configured",noData:"No data available",required:"Required",optional:"Optional"},printers:{title:"Printers",addPrinter:"Add Printer",editPrinter:"Edit Printer",deletePrinter:"Delete Printer",printerName:"Printer Name",serialNumber:"Serial Number",ipAddress:"IP Address",accessCode:"Access Code",model:"Model",nozzleCount:"Nozzle Count",autoArchive:"Auto Archive",status:{idle:"Idle",printing:"Printing",paused:"Paused",offline:"Offline",error:"Error",finished:"Finished",unknown:"Unknown"},temperatures:{nozzle:"Nozzle",bed:"Bed",chamber:"Chamber"},progress:"{{percent}}% complete",timeRemaining:"{{time}} remaining",deleteConfirm:'Are you sure you want to delete "{{name}}"?',maintenanceOk:"Maintenance OK",maintenanceWarning:"{{count}} warning",maintenanceWarning_plural:"{{count}} warnings",maintenanceDue:"{{count}} due",maintenanceDue_plural:"{{count}} due"},archives:{title:"Print Archives",searchPlaceholder:"Search archives...",filterByPrinter:"Filter by printer",filterByStatus:"Filter by status",sortBy:"Sort by",sortNewest:"Newest first",sortOldest:"Oldest first",sortName:"Name",sortDuration:"Duration",noArchives:"No archives found",printTime:"Print Time",filamentUsed:"Filament Used",cost:"Cost",reprint:"Reprint",preview:"Preview",deleteArchive:"Delete Archive",deleteConfirm:"Are you sure you want to delete this archive?",favorite:"Favorite",unfavorite:"Remove from favorites",viewDetails:"View Details",status:{completed:"Completed",failed:"Failed",stopped:"Stopped"}},queue:{title:"Print Queue",addToQueue:"Add to Queue",clearQueue:"Clear Queue",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",remove:"Remove",startNow:"Start Now",status:{pending:"Pending",printing:"Printing",completed:"Completed",failed:"Failed",cancelled:"Cancelled"}},stats:{title:"Statistics",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",totalFilament:"Total Filament Used",totalCost:"Total Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time"},profiles:{title:"Filament Profiles",addProfile:"Add Profile",editProfile:"Edit Profile",deleteProfile:"Delete Profile",material:"Material",brand:"Brand",color:"Color",diameter:"Diameter",density:"Density",costPerKg:"Cost per kg",spoolWeight:"Spool Weight",noProfiles:"No profiles configured",deleteConfirm:"Are you sure you want to delete this profile?"},maintenance:{title:"Maintenance",overview:"Overview",allOk:"All maintenance up to date",dueCount:"{{count}} item due",dueCount_plural:"{{count}} items due",warningCount:"{{count}} warning",warningCount_plural:"{{count}} warnings",totalPrintTime:"Total Print Time",nextMaintenance:"Next Maintenance",nothingDue:"Nothing due",tasks:"Tasks",lastPerformed:"Last performed",interval:"Interval",hoursRemaining:"{{hours}}h remaining",hoursOverdue:"{{hours}}h overdue",markDone:"Mark as Done",performMaintenance:"Perform Maintenance",history:"History",noHistory:"No maintenance history",editPrintHours:"Edit Print Hours",currentHours:"Current Hours",types:{lubricateRails:"Lubricate Linear Rails",cleanNozzle:"Clean Nozzle/Hotend",checkBelts:"Check Belt Tension",cleanBuildPlate:"Clean Build Plate",checkExtruder:"Check Extruder Gears",checkCooling:"Check Cooling Fans",generalInspection:"General Inspection"}},settings:{title:"Settings",general:"General",appearance:"Appearance",notifications:"Notifications",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Language",languageDescription:"Select your preferred language",theme:"Theme",themeLight:"Light",themeDark:"Dark",themeSystem:"System",defaultView:"Default View",defaultViewDescription:"Page to show when opening the app",checkForUpdates:"Check for Updates",autoUpdate:"Auto Update",currentVersion:"Current Version",latestVersion:"Latest Version",upToDate:"You are up to date",updateAvailable:"Update available",notificationLanguage:"Notification Language",notificationLanguageDescription:"Language for push notifications",notificationProviders:"Notification Providers",addProvider:"Add Provider",editProvider:"Edit Provider",providerType:"Provider Type",testNotification:"Test Notification",testSuccess:"Test notification sent successfully",testFailed:"Failed to send test notification",quietHours:"Quiet Hours",quietHoursDescription:"Do not disturb during these hours",quietHoursStart:"Start",quietHoursEnd:"End",events:{title:"Notification Events",printStart:"Print Started",printComplete:"Print Completed",printFailed:"Print Failed",printStopped:"Print Stopped",printProgress:"Progress Milestones",printProgressDescription:"Notify at 25%, 50%, 75%",printerOffline:"Printer Offline",printerError:"Printer Error",filamentLow:"Low Filament",maintenanceDue:"Maintenance Due",maintenanceDueDescription:"Notify when maintenance is needed"},smartPlug:{title:"Smart Plugs",add:"Add Smart Plug",edit:"Edit Smart Plug",name:"Name",ipAddress:"IP Address",linkedPrinter:"Linked Printer",autoOn:"Auto Power On",autoOnDescription:"Turn on when print starts",autoOff:"Auto Power Off",autoOffDescription:"Turn off after print completes",offDelay:"Off Delay",offDelayMinutes:"Minutes after print",offDelayTemp:"When nozzle below temperature",currentState:"Current State",turnOn:"Turn On",turnOff:"Turn Off"},spoolmanEnabled:"Enable Spoolman Integration",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Connected",spoolmanDisconnected:"Disconnected"},notification:{printStarted:{title:"Print Started",body:"{{printer}}: {{filename}} has started printing"},printCompleted:{title:"Print Completed",body:"{{printer}}: {{filename}} completed successfully"},printFailed:{title:"Print Failed",body:"{{printer}}: {{filename}} has failed"},printStopped:{title:"Print Stopped",body:"{{printer}}: {{filename}} was stopped"},printProgress:{title:"Print Progress",body:"{{printer}}: {{filename}} is {{percent}}% complete"},printerOffline:{title:"Printer Offline",body:"{{printer}} is offline"},printerError:{title:"Printer Error",body:"{{printer}}: {{error}}"},filamentLow:{title:"Low Filament",body:"{{printer}}: Filament is running low"},maintenanceDue:{title:"Maintenance Due",body:"{{printer}}: {{items}} need attention"}},errors:{generic:"Something went wrong",networkError:"Network error. Please check your connection.",notFound:"Not found",unauthorized:"Unauthorized",serverError:"Server error",validationError:"Please check your input",printerConnectionFailed:"Failed to connect to printer",saveFailed:"Failed to save changes",deleteFailed:"Failed to delete",loadFailed:"Failed to load data"},confirm:{delete:"Are you sure you want to delete this?",unsavedChanges:"You have unsaved changes. Are you sure you want to leave?",clearQueue:"Are you sure you want to clear the queue?"}},gie={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",settings:"Einstellungen",collapseSidebar:"Seitenleiste einklappen",expandSidebar:"Seitenleiste ausklappen",update:"Update",updateAvailable:"Update verfügbar: v{{version}}",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln"},common:{save:"Speichern",cancel:"Abbrechen",delete:"Löschen",edit:"Bearbeiten",add:"Hinzufügen",close:"Schließen",confirm:"Bestätigen",loading:"Lädt...",error:"Fehler",success:"Erfolg",warning:"Warnung",enabled:"Aktiviert",disabled:"Deaktiviert",yes:"Ja",no:"Nein",on:"An",off:"Aus",all:"Alle",none:"Keine",search:"Suchen",filter:"Filtern",sort:"Sortieren",refresh:"Aktualisieren",download:"Herunterladen",upload:"Hochladen",actions:"Aktionen",status:"Status",name:"Name",description:"Beschreibung",date:"Datum",time:"Zeit",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",required:"Erforderlich",optional:"Optional"},printers:{title:"Drucker",addPrinter:"Drucker hinzufügen",editPrinter:"Drucker bearbeiten",deletePrinter:"Drucker löschen",printerName:"Druckername",serialNumber:"Seriennummer",ipAddress:"IP-Adresse",accessCode:"Zugangscode",model:"Modell",nozzleCount:"Düsenanzahl",autoArchive:"Automatische Archivierung",status:{idle:"Bereit",printing:"Druckt",paused:"Pausiert",offline:"Offline",error:"Fehler",finished:"Fertig",unknown:"Unbekannt"},temperatures:{nozzle:"Düse",bed:"Druckbett",chamber:"Kammer"},progress:"{{percent}}% abgeschlossen",timeRemaining:"Noch {{time}}",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',maintenanceOk:"Wartung OK",maintenanceWarning:"{{count}} Warnung",maintenanceWarning_plural:"{{count}} Warnungen",maintenanceDue:"{{count}} fällig",maintenanceDue_plural:"{{count}} fällig"},archives:{title:"Druckarchiv",searchPlaceholder:"Archiv durchsuchen...",filterByPrinter:"Nach Drucker filtern",filterByStatus:"Nach Status filtern",sortBy:"Sortieren nach",sortNewest:"Neueste zuerst",sortOldest:"Älteste zuerst",sortName:"Name",sortDuration:"Dauer",noArchives:"Keine Archive gefunden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"Erneut drucken",preview:"Vorschau",deleteArchive:"Archiv löschen",deleteConfirm:"Möchten Sie dieses Archiv wirklich löschen?",favorite:"Favorit",unfavorite:"Aus Favoriten entfernen",viewDetails:"Details anzeigen",status:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",stopped:"Gestoppt"}},queue:{title:"Druckwarteschlange",addToQueue:"Zur Warteschlange hinzufügen",clearQueue:"Warteschlange leeren",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",remove:"Entfernen",startNow:"Jetzt starten",status:{pending:"Ausstehend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",cancelled:"Abgebrochen"}},stats:{title:"Statistiken",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",totalFilament:"Gesamtverbrauch Filament",totalCost:"Gesamtkosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt"},profiles:{title:"Filament-Profile",addProfile:"Profil hinzufügen",editProfile:"Profil bearbeiten",deleteProfile:"Profil löschen",material:"Material",brand:"Marke",color:"Farbe",diameter:"Durchmesser",density:"Dichte",costPerKg:"Kosten pro kg",spoolWeight:"Spulengewicht",noProfiles:"Keine Profile konfiguriert",deleteConfirm:"Möchten Sie dieses Profil wirklich löschen?"},maintenance:{title:"Wartung",overview:"Übersicht",allOk:"Alle Wartungen aktuell",dueCount:"{{count}} Aufgabe fällig",dueCount_plural:"{{count}} Aufgaben fällig",warningCount:"{{count}} Warnung",warningCount_plural:"{{count}} Warnungen",totalPrintTime:"Gesamtdruckzeit",nextMaintenance:"Nächste Wartung",nothingDue:"Nichts fällig",tasks:"Aufgaben",lastPerformed:"Zuletzt durchgeführt",interval:"Intervall",hoursRemaining:"{{hours}}h verbleibend",hoursOverdue:"{{hours}}h überfällig",markDone:"Als erledigt markieren",performMaintenance:"Wartung durchführen",history:"Verlauf",noHistory:"Kein Wartungsverlauf",editPrintHours:"Druckstunden bearbeiten",currentHours:"Aktuelle Stunden",types:{lubricateRails:"Linearschienen schmieren",cleanNozzle:"Düse/Hotend reinigen",checkBelts:"Riemenspannung prüfen",cleanBuildPlate:"Druckbett reinigen",checkExtruder:"Extruderzahnräder prüfen",checkCooling:"Kühlungslüfter prüfen",generalInspection:"Allgemeine Inspektion"}},settings:{title:"Einstellungen",general:"Allgemein",appearance:"Erscheinungsbild",notifications:"Benachrichtigungen",smartPlugs:"Smart Plugs",spoolman:"Spoolman",updates:"Updates",language:"Sprache",languageDescription:"Wählen Sie Ihre bevorzugte Sprache",theme:"Design",themeLight:"Hell",themeDark:"Dunkel",themeSystem:"System",defaultView:"Standardansicht",defaultViewDescription:"Seite, die beim Öffnen der App angezeigt wird",checkForUpdates:"Nach Updates suchen",autoUpdate:"Automatische Updates",currentVersion:"Aktuelle Version",latestVersion:"Neueste Version",upToDate:"Sie sind auf dem neuesten Stand",updateAvailable:"Update verfügbar",notificationLanguage:"Benachrichtigungssprache",notificationLanguageDescription:"Sprache für Push-Benachrichtigungen",notificationProviders:"Benachrichtigungsanbieter",addProvider:"Anbieter hinzufügen",editProvider:"Anbieter bearbeiten",providerType:"Anbietertyp",testNotification:"Testbenachrichtigung",testSuccess:"Testbenachrichtigung erfolgreich gesendet",testFailed:"Testbenachrichtigung konnte nicht gesendet werden",quietHours:"Ruhezeiten",quietHoursDescription:"Keine Störungen während dieser Zeiten",quietHoursStart:"Beginn",quietHoursEnd:"Ende",events:{title:"Benachrichtigungsereignisse",printStart:"Druck gestartet",printComplete:"Druck abgeschlossen",printFailed:"Druck fehlgeschlagen",printStopped:"Druck gestoppt",printProgress:"Fortschrittsmeldungen",printProgressDescription:"Bei 25%, 50%, 75% benachrichtigen",printerOffline:"Drucker offline",printerError:"Druckerfehler",filamentLow:"Filament niedrig",maintenanceDue:"Wartung fällig",maintenanceDueDescription:"Benachrichtigen, wenn Wartung erforderlich"},smartPlug:{title:"Smart Plugs",add:"Smart Plug hinzufügen",edit:"Smart Plug bearbeiten",name:"Name",ipAddress:"IP-Adresse",linkedPrinter:"Verknüpfter Drucker",autoOn:"Automatisch einschalten",autoOnDescription:"Einschalten beim Druckstart",autoOff:"Automatisch ausschalten",autoOffDescription:"Ausschalten nach Druckende",offDelay:"Ausschaltverzögerung",offDelayMinutes:"Minuten nach Druck",offDelayTemp:"Wenn Düse unter Temperatur",currentState:"Aktueller Status",turnOn:"Einschalten",turnOff:"Ausschalten"},spoolmanEnabled:"Spoolman-Integration aktivieren",spoolmanUrl:"Spoolman URL",spoolmanConnected:"Verbunden",spoolmanDisconnected:"Nicht verbunden"},notification:{printStarted:{title:"Druck gestartet",body:"{{printer}}: {{filename}} wird gedruckt"},printCompleted:{title:"Druck abgeschlossen",body:"{{printer}}: {{filename}} erfolgreich abgeschlossen"},printFailed:{title:"Druck fehlgeschlagen",body:"{{printer}}: {{filename}} ist fehlgeschlagen"},printStopped:{title:"Druck gestoppt",body:"{{printer}}: {{filename}} wurde gestoppt"},printProgress:{title:"Druckfortschritt",body:"{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen"},printerOffline:{title:"Drucker offline",body:"{{printer}} ist offline"},printerError:{title:"Druckerfehler",body:"{{printer}}: {{error}}"},filamentLow:{title:"Filament niedrig",body:"{{printer}}: Filament geht zur Neige"},maintenanceDue:{title:"Wartung fällig",body:"{{printer}}: {{items}} benötigen Aufmerksamkeit"}},errors:{generic:"Etwas ist schiefgelaufen",networkError:"Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.",notFound:"Nicht gefunden",unauthorized:"Nicht autorisiert",serverError:"Serverfehler",validationError:"Bitte überprüfen Sie Ihre Eingabe",printerConnectionFailed:"Verbindung zum Drucker fehlgeschlagen",saveFailed:"Speichern fehlgeschlagen",deleteFailed:"Löschen fehlgeschlagen",loadFailed:"Laden der Daten fehlgeschlagen"},confirm:{delete:"Möchten Sie dies wirklich löschen?",unsavedChanges:"Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?",clearQueue:"Möchten Sie die Warteschlange wirklich leeren?"}},xie={en:{translation:mie},de:{translation:gie}};Sa.use(gG).use(qne).init({resources:xie,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const _U=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var SU="popstate";function vie(t={}){function e(i,r){let{pathname:a,search:s,hash:o}=i.location;return _N("",{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:Hx(r)}return bie(e,n,null,t)}function mi(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function _o(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function yie(){return Math.random().toString(36).substring(2,10)}function wU(t,e){return{usr:t.state,key:t.key,idx:e}}function _N(t,e,n=null,i){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?vm(e):e,state:n,key:e&&e.key||i||yie()}}function Hx({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 vm(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 bie(t,e,n,i={}){let{window:r=document.defaultView,v5Compat:a=!1}=i,s=r.history,o="POP",l=null,c=u();c==null&&(c=0,s.replaceState({...s.state,idx:c},""));function u(){return(s.state||{idx:null}).idx}function f(){o="POP";let v=u(),x=v==null?null:v-c;c=v,l&&l({action:o,location:_.location,delta:x})}function m(v,x){o="PUSH";let M=_N(_.location,v,x);c=u()+1;let w=wU(M,c),C=_.createHref(M);try{s.pushState(w,"",C)}catch(T){if(T instanceof DOMException&&T.name==="DataCloneError")throw T;r.location.assign(C)}a&&l&&l({action:o,location:_.location,delta:1})}function g(v,x){o="REPLACE";let M=_N(_.location,v,x);c=u();let w=wU(M,c),C=_.createHref(M);s.replaceState(w,"",C),a&&l&&l({action:o,location:_.location,delta:0})}function y(v){return _ie(v)}let _={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(SU,f),l=v,()=>{r.removeEventListener(SU,f),l=null}},createHref(v){return e(r,v)},createURL:y,encodeLocation(v){let x=y(v);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:m,replace:g,go(v){return s.go(v)}};return _}function _ie(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),mi(n,"No window.location.(origin|href) available to create URL");let i=typeof t=="string"?t:Hx(t);return i=i.replace(/ $/,"%20"),!e&&i.startsWith("//")&&(i=n+i),new URL(i,n)}function xG(t,e,n="/"){return Sie(t,e,n,!1)}function Sie(t,e,n,i){let r=typeof e=="string"?vm(e):e,a=fc(r.pathname||"/",n);if(a==null)return null;let s=vG(t);wie(s);let o=null;for(let l=0;o==null&&l<s.length;++l){let c=Oie(a);o=kie(s[l],c,i)}return o}function vG(t,e=[],n=[],i="",r=!1){let a=(s,o,l=r,c)=>{let u={relativePath:c===void 0?s.path||"":c,caseSensitive:s.caseSensitive===!0,childrenIndex:o,route:s};if(u.relativePath.startsWith("/")){if(!u.relativePath.startsWith(i)&&l)return;mi(u.relativePath.startsWith(i),`Absolute route path "${u.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),u.relativePath=u.relativePath.slice(i.length)}let f=rc([i,u.relativePath]),m=n.concat(u);s.children&&s.children.length>0&&(mi(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),vG(s.children,e,m,f,l)),!(s.path==null&&!s.index)&&e.push({path:f,score:Rie(f,s.index),routesMeta:m})};return t.forEach((s,o)=>{if(s.path===""||!s.path?.includes("?"))a(s,o);else for(let l of yG(s.path))a(s,o,!0,l)}),e}function yG(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=yG(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 wie(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:Pie(e.routesMeta.map(i=>i.childrenIndex),n.routesMeta.map(i=>i.childrenIndex)))}var Mie=/^:[\w-]+$/,Eie=3,Aie=2,Tie=1,Cie=10,Nie=-2,MU=t=>t==="*";function Rie(t,e){let n=t.split("/"),i=n.length;return n.some(MU)&&(i+=Nie),e&&(i+=Aie),n.filter(r=>!MU(r)).reduce((r,a)=>r+(Mie.test(a)?Eie:a===""?Tie:Cie),i)}function Pie(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 kie(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,u=a==="/"?e:e.slice(a.length)||"/",f=F_({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},u),m=l.route;if(!f&&c&&n&&!i[i.length-1].route.index&&(f=F_({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},u)),!f)return null;Object.assign(r,f.params),s.push({params:r,pathname:rc([a,f.pathname]),pathnameBase:Fie(rc([a,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(a=rc([a,f.pathnameBase]))}return s}function F_(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,i]=Die(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:u,isOptional:f},m)=>{if(u==="*"){let y=o[m]||"";s=a.slice(0,a.length-y.length).replace(/(.)\/+$/,"$1")}const g=o[m];return f&&!g?c[u]=void 0:c[u]=(g||"").replace(/%2F/g,"/"),c},{}),pathname:a,pathnameBase:s,pattern:t}}function Die(t,e=!1,n=!0){_o(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 Oie(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return _o(!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 fc(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 Lie=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Iie=t=>Lie.test(t);function jie(t,e="/"){let{pathname:n,search:i="",hash:r=""}=typeof t=="string"?vm(t):t,a;if(n)if(Iie(n))a=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),_o(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?a=EU(n.substring(1),"/"):a=EU(n,e)}else a=e;return{pathname:a,search:zie(i),hash:Bie(r)}}function EU(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 LA(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 Uie(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function bG(t){let e=Uie(t);return e.map((n,i)=>i===e.length-1?n.pathname:n.pathnameBase)}function _G(t,e,n,i=!1){let r;typeof t=="string"?r=vm(t):(r={...t},mi(!r.pathname||!r.pathname.includes("?"),LA("?","pathname","search",r)),mi(!r.pathname||!r.pathname.includes("#"),LA("#","pathname","hash",r)),mi(!r.search||!r.search.includes("#"),LA("#","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 m=s.split("/");for(;m[0]==="..";)m.shift(),f-=1;r.pathname=m.join("/")}o=f>=0?e[f]:"/"}let l=jie(r,o),c=s&&s!=="/"&&s.endsWith("/"),u=(a||s===".")&&n.endsWith("/");return!l.pathname.endsWith("/")&&(c||u)&&(l.pathname+="/"),l}var rc=t=>t.join("/").replace(/\/\/+/g,"/"),Fie=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),zie=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Bie=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Hie(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 SG=["POST","PUT","PATCH","DELETE"];new Set(SG);var $ie=["GET",...SG];new Set($ie);var ym=E.createContext(null);ym.displayName="DataRouter";var WS=E.createContext(null);WS.displayName="DataRouterState";E.createContext(!1);var wG=E.createContext({isTransitioning:!1});wG.displayName="ViewTransition";var Vie=E.createContext(new Map);Vie.displayName="Fetchers";var Gie=E.createContext(null);Gie.displayName="Await";var ll=E.createContext(null);ll.displayName="Navigation";var D0=E.createContext(null);D0.displayName="Location";var Ao=E.createContext({outlet:null,matches:[],isDataRoute:!1});Ao.displayName="Route";var AP=E.createContext(null);AP.displayName="RouteError";function Wie(t,{relative:e}={}){mi(O0(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:i}=E.useContext(ll),{hash:r,pathname:a,search:s}=L0(t,{relative:e}),o=a;return n!=="/"&&(o=a==="/"?n:rc([n,a])),i.createHref({pathname:o,search:s,hash:r})}function O0(){return E.useContext(D0)!=null}function rd(){return mi(O0(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(D0).location}var MG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function EG(t){E.useContext(ll).static||E.useLayoutEffect(t)}function TP(){let{isDataRoute:t}=E.useContext(Ao);return t?lre():qie()}function qie(){mi(O0(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(ym),{basename:e,navigator:n}=E.useContext(ll),{matches:i}=E.useContext(Ao),{pathname:r}=rd(),a=JSON.stringify(bG(i)),s=E.useRef(!1);return EG(()=>{s.current=!0}),E.useCallback((l,c={})=>{if(_o(s.current,MG),!s.current)return;if(typeof l=="number"){n.go(l);return}let u=_G(l,JSON.parse(a),r,c.relative==="path");t==null&&e!=="/"&&(u.pathname=u.pathname==="/"?e:rc([e,u.pathname])),(c.replace?n.replace:n.push)(u,c.state,c)},[e,n,a,r,t])}var Xie=E.createContext(null);function Kie(t){let e=E.useContext(Ao).outlet;return E.useMemo(()=>e&&E.createElement(Xie.Provider,{value:t},e),[e,t])}function Yie(){let{matches:t}=E.useContext(Ao),e=t[t.length-1];return e?e.params:{}}function L0(t,{relative:e}={}){let{matches:n}=E.useContext(Ao),{pathname:i}=rd(),r=JSON.stringify(bG(n));return E.useMemo(()=>_G(t,JSON.parse(r),i,e==="path"),[t,r,i,e])}function Zie(t,e){return AG(t,e)}function AG(t,e,n,i,r){mi(O0(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=E.useContext(ll),{matches:s}=E.useContext(Ao),o=s[s.length-1],l=o?o.params:{},c=o?o.pathname:"/",u=o?o.pathnameBase:"/",f=o&&o.route;{let M=f&&f.path||"";TG(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 m=rd(),g;if(e){let M=typeof e=="string"?vm(e):e;mi(u==="/"||M.pathname?.startsWith(u),`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 "${u}" but pathname "${M.pathname}" was given in the \`location\` prop.`),g=M}else g=m;let y=g.pathname||"/",_=y;if(u!=="/"){let M=u.replace(/^\//,"").split("/");_="/"+y.replace(/^\//,"").split("/").slice(M.length).join("/")}let v=xG(t,{pathname:_});_o(f||v!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),_o(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 "${g.pathname}${g.search}${g.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=nre(v&&v.map(M=>Object.assign({},M,{params:Object.assign({},l,M.params),pathname:rc([u,a.encodeLocation?a.encodeLocation(M.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathname]),pathnameBase:M.pathnameBase==="/"?u:rc([u,a.encodeLocation?a.encodeLocation(M.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:M.pathnameBase])})),s,n,i,r);return e&&x?E.createElement(D0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},x):x}function Qie(){let t=ore(),e=Hie(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=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:a},"ErrorBoundary")," or"," ",E.createElement("code",{style:a},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},e),n?E.createElement("pre",{style:r},n):null,s)}var Jie=E.createElement(Qie,null),ere=class extends E.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?E.createElement(Ao.Provider,{value:this.props.routeContext},E.createElement(AP.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function tre({routeContext:t,match:e,children:n}){let i=E.useContext(ym);return i&&i.static&&i.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=e.route.id),E.createElement(Ao.Provider,{value:t},n)}function nre(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 u=a.findIndex(f=>f.route.id&&s?.[f.route.id]!==void 0);mi(u>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,u+1))}let o=!1,l=-1;if(n)for(let u=0;u<a.length;u++){let f=a[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(l=u),f.route.id){let{loaderData:m,errors:g}=n,y=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!g||g[f.route.id]===void 0);if(f.route.lazy||y){o=!0,l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}let c=n&&i?(u,f)=>{i(u,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((u,f,m)=>{let g,y=!1,_=null,v=null;n&&(g=s&&f.route.id?s[f.route.id]:void 0,_=f.route.errorElement||Jie,o&&(l<0&&m===0?(TG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,v=null):l===m&&(y=!0,v=f.route.hydrateFallbackElement||null)));let x=e.concat(a.slice(0,m+1)),M=()=>{let w;return g?w=_:y?w=v:f.route.Component?w=E.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=u,E.createElement(tre,{match:f,routeContext:{outlet:u,matches:x,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?E.createElement(ere,{location:n.location,revalidation:n.revalidation,component:_,error:g,children:M(),routeContext:{outlet:null,matches:x,isDataRoute:!0},onError:c}):M()},null)}function CP(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ire(t){let e=E.useContext(ym);return mi(e,CP(t)),e}function rre(t){let e=E.useContext(WS);return mi(e,CP(t)),e}function are(t){let e=E.useContext(Ao);return mi(e,CP(t)),e}function NP(t){let e=are(t),n=e.matches[e.matches.length-1];return mi(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function sre(){return NP("useRouteId")}function ore(){let t=E.useContext(AP),e=rre("useRouteError"),n=NP("useRouteError");return t!==void 0?t:e.errors?.[n]}function lre(){let{router:t}=ire("useNavigate"),e=NP("useNavigate"),n=E.useRef(!1);return EG(()=>{n.current=!0}),E.useCallback(async(r,a={})=>{_o(n.current,MG),n.current&&(typeof r=="number"?t.navigate(r):await t.navigate(r,{fromRouteId:e,...a}))},[t,e])}var AU={};function TG(t,e,n){!e&&!AU[t]&&(AU[t]=!0,_o(!1,n))}E.memo(cre);function cre({routes:t,future:e,state:n,unstable_onError:i}){return AG(t,void 0,n,i,e)}function ure(t){return Kie(t.context)}function jo(t){mi(!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 dre({basename:t="/",children:e=null,location:n,navigationType:i="POP",navigator:r,static:a=!1}){mi(!O0(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=t.replace(/^\/*/,"/"),o=E.useMemo(()=>({basename:s,navigator:r,static:a,future:{}}),[s,r,a]);typeof n=="string"&&(n=vm(n));let{pathname:l="/",search:c="",hash:u="",state:f=null,key:m="default"}=n,g=E.useMemo(()=>{let y=fc(l,s);return y==null?null:{location:{pathname:y,search:c,hash:u,state:f,key:m},navigationType:i}},[s,l,c,u,f,m,i]);return _o(g!=null,`<Router basename="${s}"> is not able to match the URL "${l}${c}${u}" because it does not start with the basename, so the <Router> won't render anything.`),g==null?null:E.createElement(ll.Provider,{value:o},E.createElement(D0.Provider,{children:e,value:g}))}function fre({children:t,location:e}){return Zie(SN(t),e)}function SN(t,e=[]){let n=[];return E.Children.forEach(t,(i,r)=>{if(!E.isValidElement(i))return;let a=[...e,r];if(i.type===E.Fragment){n.push.apply(n,SN(i.props.children,a));return}mi(i.type===jo,`[${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>`),mi(!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=SN(i.props.children,a)),n.push(s)}),n}var f_="get",h_="application/x-www-form-urlencoded";function qS(t){return t!=null&&typeof t.tagName=="string"}function hre(t){return qS(t)&&t.tagName.toLowerCase()==="button"}function pre(t){return qS(t)&&t.tagName.toLowerCase()==="form"}function mre(t){return qS(t)&&t.tagName.toLowerCase()==="input"}function gre(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function xre(t,e){return t.button===0&&(!e||e==="_self")&&!gre(t)}var ky=null;function vre(){if(ky===null)try{new FormData(document.createElement("form"),0),ky=!1}catch{ky=!0}return ky}var yre=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function IA(t){return t!=null&&!yre.has(t)?(_o(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${h_}"`),null):t}function bre(t,e){let n,i,r,a,s;if(pre(t)){let o=t.getAttribute("action");i=o?fc(o,e):null,n=t.getAttribute("method")||f_,r=IA(t.getAttribute("enctype"))||h_,a=new FormData(t)}else if(hre(t)||mre(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?fc(l,e):null,n=t.getAttribute("formmethod")||o.getAttribute("method")||f_,r=IA(t.getAttribute("formenctype"))||IA(o.getAttribute("enctype"))||h_,a=new FormData(o,t),!vre()){let{name:c,type:u,value:f}=t;if(u==="image"){let m=c?`${c}.`:"";a.append(`${m}x`,"0"),a.append(`${m}y`,"0")}else c&&a.append(c,f)}}else{if(qS(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=f_,i=null,r=h_,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 RP(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function _re(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&&fc(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${n}`,i}async function Sre(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 wre(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 Mre(t,e,n){let i=await Promise.all(t.map(async r=>{let a=e.routes[r.route.id];if(a){let s=await Sre(a,n);return s.links?s.links():[]}return[]}));return Cre(i.flat(1).filter(wre).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function TU(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 u=i.routes[l.route.id];if(!u||!u.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 Ere(t,e,{includeHydrateFallback:n}={}){return Are(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 Are(t){return[...new Set(t)]}function Tre(t){let e={},n=Object.keys(t).sort();for(let i of n)e[i]=t[i];return e}function Cre(t,e){let n=new Set;return new Set(e),t.reduce((i,r)=>{let a=JSON.stringify(Tre(r));return n.has(a)||(n.add(a),i.push({key:a,link:r})),i},[])}function CG(){let t=E.useContext(ym);return RP(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Nre(){let t=E.useContext(WS);return RP(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var PP=E.createContext(void 0);PP.displayName="FrameworkContext";function NG(){let t=E.useContext(PP);return RP(t,"You must render this element inside a <HydratedRouter> element"),t}function Rre(t,e){let n=E.useContext(PP),[i,r]=E.useState(!1),[a,s]=E.useState(!1),{onFocus:o,onBlur:l,onMouseEnter:c,onMouseLeave:u,onTouchStart:f}=e,m=E.useRef(null);E.useEffect(()=>{if(t==="render"&&s(!0),t==="viewport"){let _=x=>{x.forEach(M=>{s(M.isIntersecting)})},v=new IntersectionObserver(_,{threshold:.5});return m.current&&v.observe(m.current),()=>{v.disconnect()}}},[t]),E.useEffect(()=>{if(i){let _=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(_)}}},[i]);let g=()=>{r(!0)},y=()=>{r(!1),s(!1)};return n?t!=="intent"?[a,m,{}]:[a,m,{onFocus:Og(o,g),onBlur:Og(l,y),onMouseEnter:Og(c,g),onMouseLeave:Og(u,y),onTouchStart:Og(f,g)}]:[!1,m,{}]}function Og(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function Pre({page:t,...e}){let{router:n}=CG(),i=E.useMemo(()=>xG(n.routes,t,n.basename),[n.routes,t,n.basename]);return i?E.createElement(Dre,{page:t,matches:i,...e}):null}function kre(t){let{manifest:e,routeModules:n}=NG(),[i,r]=E.useState([]);return E.useEffect(()=>{let a=!1;return Mre(t,e,n).then(s=>{a||r(s)}),()=>{a=!0}},[t,e,n]),i}function Dre({page:t,matches:e,...n}){let i=rd(),{manifest:r,routeModules:a}=NG(),{basename:s}=CG(),{loaderData:o,matches:l}=Nre(),c=E.useMemo(()=>TU(t,e,l,r,i,"data"),[t,e,l,r,i]),u=E.useMemo(()=>TU(t,e,l,r,i,"assets"),[t,e,l,r,i]),f=E.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let y=new Set,_=!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?_=!0:y.add(x.route.id))}),y.size===0)return[];let v=_re(t,s,"data");return _&&y.size>0&&v.searchParams.set("_routes",e.filter(x=>y.has(x.route.id)).map(x=>x.route.id).join(",")),[v.pathname+v.search]},[s,o,i,r,c,e,t,a]),m=E.useMemo(()=>Ere(u,r),[u,r]),g=kre(u);return E.createElement(E.Fragment,null,f.map(y=>E.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),m.map(y=>E.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),g.map(({key:y,link:_})=>E.createElement("link",{key:y,nonce:n.nonce,..._})))}function Ore(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var RG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{RG&&(window.__reactRouterVersion="7.9.6")}catch{}function Lre({basename:t,children:e,window:n}){let i=E.useRef();i.current==null&&(i.current=vie({window:n,v5Compat:!0}));let r=i.current,[a,s]=E.useState({action:r.action,location:r.location}),o=E.useCallback(l=>{E.startTransition(()=>s(l))},[s]);return E.useLayoutEffect(()=>r.listen(o),[r,o]),E.createElement(dre,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:r})}var PG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,XS=E.forwardRef(function({onClick:e,discover:n="render",prefetch:i="none",relative:r,reloadDocument:a,replace:s,state:o,target:l,to:c,preventScrollReset:u,viewTransition:f,...m},g){let{basename:y}=E.useContext(ll),_=typeof c=="string"&&PG.test(c),v,x=!1;if(typeof c=="string"&&_&&(v=c,RG))try{let N=new URL(window.location.href),k=c.startsWith("//")?new URL(N.protocol+c):new URL(c),F=fc(k.pathname,y);k.origin===N.origin&&F!=null?c=F+k.search+k.hash:x=!0}catch{_o(!1,`<Link to="${c}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let M=Wie(c,{relative:r}),[w,C,T]=Rre(i,m),P=Ure(c,{replace:s,state:o,target:l,preventScrollReset:u,relative:r,viewTransition:f});function A(N){e&&e(N),N.defaultPrevented||P(N)}let j=E.createElement("a",{...m,...T,href:v||M,onClick:x||a?e:A,ref:Ore(g,C),target:l,"data-discover":!_&&n==="render"?"true":void 0});return w&&!_?E.createElement(E.Fragment,null,j,E.createElement(Pre,{page:M})):j});XS.displayName="Link";var kG=E.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:i="",end:r=!1,style:a,to:s,viewTransition:o,children:l,...c},u){let f=L0(s,{relative:c.relative}),m=rd(),g=E.useContext(WS),{navigator:y,basename:_}=E.useContext(ll),v=g!=null&&$re(f)&&o===!0,x=y.encodeLocation?y.encodeLocation(f).pathname:f.pathname,M=m.pathname,w=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(M=M.toLowerCase(),w=w?w.toLowerCase():null,x=x.toLowerCase()),w&&_&&(w=fc(w,_)||w);const C=x!=="/"&&x.endsWith("/")?x.length-1:x.length;let T=M===x||!r&&M.startsWith(x)&&M.charAt(C)==="/",P=w!=null&&(w===x||!r&&w.startsWith(x)&&w.charAt(x.length)==="/"),A={isActive:T,isPending:P,isTransitioning:v},j=T?e:void 0,N;typeof i=="function"?N=i(A):N=[i,T?"active":null,P?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let k=typeof a=="function"?a(A):a;return E.createElement(XS,{...c,"aria-current":j,className:N,ref:u,style:k,to:s,viewTransition:o},typeof l=="function"?l(A):l)});kG.displayName="NavLink";var Ire=E.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:i,replace:r,state:a,method:s=f_,action:o,onSubmit:l,relative:c,preventScrollReset:u,viewTransition:f,...m},g)=>{let y=Bre(),_=Hre(o,{relative:c}),v=s.toLowerCase()==="get"?"get":"post",x=typeof o=="string"&&PG.test(o),M=w=>{if(l&&l(w),w.defaultPrevented)return;w.preventDefault();let C=w.nativeEvent.submitter,T=C?.getAttribute("formmethod")||s;y(C||w.currentTarget,{fetcherKey:e,method:T,navigate:n,replace:r,state:a,relative:c,preventScrollReset:u,viewTransition:f})};return E.createElement("form",{ref:g,method:v,action:_,onSubmit:i?l:M,...m,"data-discover":!x&&t==="render"?"true":void 0})});Ire.displayName="Form";function jre(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function DG(t){let e=E.useContext(ym);return mi(e,jre(t)),e}function Ure(t,{target:e,replace:n,state:i,preventScrollReset:r,relative:a,viewTransition:s}={}){let o=TP(),l=rd(),c=L0(t,{relative:a});return E.useCallback(u=>{if(xre(u,e)){u.preventDefault();let f=n!==void 0?n:Hx(l)===Hx(c);o(t,{replace:f,state:i,preventScrollReset:r,relative:a,viewTransition:s})}},[l,o,c,n,i,e,t,r,a,s])}var Fre=0,zre=()=>`__${String(++Fre)}__`;function Bre(){let{router:t}=DG("useSubmit"),{basename:e}=E.useContext(ll),n=sre();return E.useCallback(async(i,r={})=>{let{action:a,method:s,encType:o,formData:l,body:c}=bre(i,e);if(r.navigate===!1){let u=r.fetcherKey||zre();await t.fetch(u,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 Hre(t,{relative:e}={}){let{basename:n}=E.useContext(ll),i=E.useContext(Ao);mi(i,"useFormAction must be used inside a RouteContext");let[r]=i.matches.slice(-1),a={...L0(t||".",{relative:e})},s=rd();if(t==null){a.search=s.search;let o=new URLSearchParams(a.search),l=o.getAll("index");if(l.some(u=>u==="")){o.delete("index"),l.filter(f=>f).forEach(f=>o.append("index",f));let u=o.toString();a.search=u?`?${u}`:""}}return(!t||t===".")&&r.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:rc([n,a.pathname])),Hx(a)}function $re(t,{relative:e}={}){let n=E.useContext(wG);mi(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=DG("useViewTransitionState"),r=L0(t,{relative:e});if(!n.isTransitioning)return!1;let a=fc(n.currentLocation.pathname,i)||n.currentLocation.pathname,s=fc(n.nextLocation.pathname,i)||n.nextLocation.pathname;return F_(r.pathname,s)!=null||F_(r.pathname,a)!=null}var Zl=sG();const Vre=Ys(Zl);var bm=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(){}},Gre={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Wre=class{#e=Gre;#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)}},Kd=new Wre;function qre(t){setTimeout(t,0)}var yf=typeof window>"u"||"Deno"in globalThis;function fa(){}function Xre(t,e){return typeof t=="function"?t(e):t}function wN(t){return typeof t=="number"&&t>=0&&t!==1/0}function OG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ju(t,e){return typeof t=="function"?t(e):t}function ks(t,e){return typeof t=="function"?t(e):t}function CU(t,e){const{type:n="all",exact:i,fetchStatus:r,predicate:a,queryKey:s,stale:o}=t;if(s){if(i){if(e.queryHash!==kP(s,e.options))return!1}else if(!$x(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 NU(t,e){const{exact:n,status:i,predicate:r,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(bf(e.options.mutationKey)!==bf(a))return!1}else if(!$x(e.options.mutationKey,a))return!1}return!(i&&e.state.status!==i||r&&!r(e))}function kP(t,e){return(e?.queryKeyHashFn||bf)(t)}function bf(t){return JSON.stringify(t,(e,n)=>MN(n)?Object.keys(n).sort().reduce((i,r)=>(i[r]=n[r],i),{}):n)}function $x(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>$x(t[n],e[n])):!1}var Kre=Object.prototype.hasOwnProperty;function LG(t,e){if(t===e)return t;const n=RU(t)&&RU(e);if(!n&&!(MN(t)&&MN(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 u=n?c:a[c],f=t[u],m=e[u];if(f===m){o[u]=f,(n?c<r:Kre.call(t,u))&&l++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){o[u]=m;continue}const g=LG(f,m);o[u]=g,g===f&&l++}return r===s&&l===r?t:o}function z_(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 RU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function MN(t){if(!PU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!PU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function PU(t){return Object.prototype.toString.call(t)==="[object Object]"}function Yre(t){return new Promise(e=>{Kd.setTimeout(e,t)})}function EN(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?LG(t,e):e}function Zre(t,e,n=0){const i=[...t,e];return n&&i.length>n?i.slice(1):i}function Qre(t,e,n=0){const i=[e,...t];return n&&i.length>n?i.slice(0,-1):i}var DP=Symbol();function IG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===DP?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function jG(t,e){return typeof t=="function"?t(...e):!!t}var Jre=class extends bm{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!yf&&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"}},OP=new Jre;function AN(){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 eae=qre;function tae(){let t=[],e=0,n=o=>{o()},i=o=>{o()},r=eae;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 rr=tae(),nae=class extends bm{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!yf&&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}},B_=new nae;function iae(t){return Math.min(1e3*2**t,3e4)}function UG(t){return(t??"online")==="online"?B_.isOnline():!0}var TN=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function FG(t){let e=!1,n=0,i;const r=AN(),a=()=>r.status!=="pending",s=_=>{if(!a()){const v=new TN(_);m(v),t.onCancel?.(v)}},o=()=>{e=!0},l=()=>{e=!1},c=()=>OP.isFocused()&&(t.networkMode==="always"||B_.isOnline())&&t.canRun(),u=()=>UG(t.networkMode)&&t.canRun(),f=_=>{a()||(i?.(),r.resolve(_))},m=_=>{a()||(i?.(),r.reject(_))},g=()=>new Promise(_=>{i=v=>{(a()||c())&&_(v)},t.onPause?.()}).then(()=>{i=void 0,a()||t.onContinue?.()}),y=()=>{if(a())return;let _;const v=n===0?t.initialPromise:void 0;try{_=v??t.fn()}catch(x){_=Promise.reject(x)}Promise.resolve(_).then(f).catch(x=>{if(a())return;const M=t.retry??(yf?0:3),w=t.retryDelay??iae,C=typeof w=="function"?w(n,x):w,T=M===!0||typeof M=="number"&&n<M||typeof M=="function"&&M(n,x);if(e||!T){m(x);return}n++,t.onFail?.(n,x),Yre(C).then(()=>c()?void 0:g()).then(()=>{e?m(x):y()})})};return{promise:r,status:()=>r.status,cancel:s,continue:()=>(i?.(),r),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?y():g().then(y),r)}}var zG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),wN(this.gcTime)&&(this.#e=Kd.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(yf?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Kd.clearTimeout(this.#e),this.#e=void 0)}},rae=class extends zG{#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=DU(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=DU(this.options);e.data!==void 0&&(this.setState(kU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=EN(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(fa).catch(fa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>ks(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===DP||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ju(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:!OG(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=IG(this.options,e),c=(()=>{const u={client:this.#r,queryKey:this.queryKey,meta:this.meta};return i(u),u})();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=FG({initialPromise:e?.initialPromise,fn:s.fetchFn,onCancel:o=>{o instanceof TN&&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 TN){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,...BG(n.data,this.options),fetchMeta:t.meta??null};case"success":const i={...n,...kU(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),rr.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function BG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:UG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function kU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function DU(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 aae=class extends bm{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=AN(),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),OU(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return CN(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return CN(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 ks(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&&!z_(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&LU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),i&&(this.#t!==n||ks(this.options.enabled,this.#t)!==ks(e.enabled,this.#t)||ju(this.options.staleTime,this.#t)!==ju(e.staleTime,this.#t))&&this.#g();const r=this.#x();i&&(this.#t!==n||ks(this.options.enabled,this.#t)!==ks(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 oae(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(fa)),e}#g(){this.#b();const t=ju(this.options.staleTime,this.#t);if(yf||this.#r.isStale||!wN(t))return;const n=OG(this.#r.dataUpdatedAt,t)+1;this.#c=Kd.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,!(yf||ks(this.options.enabled,this.#t)===!1||!wN(this.#l)||this.#l===0)&&(this.#u=Kd.setInterval(()=>{(this.options.refetchIntervalInBackground||OP.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#v(this.#x())}#b(){this.#c&&(Kd.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Kd.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 u={...c},f=!1,m;if(e._optimisticResults){const j=this.hasListeners(),N=!j&&OU(t,e),k=j&&LU(t,n,e,i);(N||k)&&(u={...u,...BG(c.data,t.options)}),e._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:g,errorUpdatedAt:y,status:_}=u;m=u.data;let v=!1;if(e.placeholderData!==void 0&&m===void 0&&_==="pending"){let j;r?.isPlaceholderData&&e.placeholderData===s?.placeholderData?(j=r.data,v=!0):j=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,j!==void 0&&(_="success",m=EN(r?.data,j,e),f=!0)}if(e.select&&m!==void 0&&!v)if(r&&m===a?.data&&e.select===this.#m)m=this.#f;else try{this.#m=e.select,m=e.select(m),m=EN(r?.data,m,e),this.#f=m,this.#a=null}catch(j){this.#a=j}this.#a&&(g=this.#a,m=this.#f,y=Date.now(),_="error");const x=u.fetchStatus==="fetching",M=_==="pending",w=_==="error",C=M&&x,T=m!==void 0,A={status:_,fetchStatus:u.fetchStatus,isPending:M,isSuccess:_==="success",isError:w,isInitialLoading:C,isLoading:C,data:m,dataUpdatedAt:u.dataUpdatedAt,error:g,errorUpdatedAt:y,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:x,isRefetching:x&&!M,isLoadingError:w&&!T,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&T,isStale:LP(t,e),refetch:this.refetch,promise:this.#o,isEnabled:ks(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const j=F=>{A.status==="error"?F.reject(A.error):A.data!==void 0&&F.resolve(A.data)},N=()=>{const F=this.#o=A.promise=AN();j(F)},k=this.#o;switch(k.status){case"pending":t.queryHash===n.queryHash&&j(k);break;case"fulfilled":(A.status==="error"||A.data!==k.value)&&N();break;case"rejected":(A.status!=="error"||A.error!==k.reason)&&N();break}}return A}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),z_(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){rr.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function sae(t,e){return ks(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function OU(t,e){return sae(t,e)||t.state.data!==void 0&&CN(t,e,e.refetchOnMount)}function CN(t,e,n){if(ks(e.enabled,t)!==!1&&ju(e.staleTime,t)!=="static"){const i=typeof n=="function"?n(t):n;return i==="always"||i!==!1&&LP(t,e)}return!1}function LU(t,e,n,i){return(t!==e||ks(i.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&LP(t,n)}function LP(t,e){return ks(e.enabled,t)!==!1&&t.isStaleByTime(ju(e.staleTime,t))}function oae(t,e){return!z_(t.getCurrentResult(),e)}function IU(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 u=!1;const f=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(e.signal.aborted?u=!0:e.signal.addEventListener("abort",()=>{u=!0}),e.signal)})},m=IG(e.options,e.fetchOptions),g=async(y,_,v)=>{if(u)return Promise.reject();if(_==null&&y.pages.length)return Promise.resolve(y);const M=(()=>{const P={client:e.client,queryKey:e.queryKey,pageParam:_,direction:v?"backward":"forward",meta:e.options.meta};return f(P),P})(),w=await m(M),{maxPages:C}=e.options,T=v?Qre:Zre;return{pages:T(y.pages,w,C),pageParams:T(y.pageParams,_,C)}};if(r&&a.length){const y=r==="backward",_=y?lae:jU,v={pages:a,pageParams:s},x=_(i,v);o=await g(v,x,y)}else{const y=t??a.length;do{const _=l===0?s[0]??i.initialPageParam:jU(i,o);if(l>0&&_==null)break;o=await g(o,_),l++}while(l<y)}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 jU(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 lae(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var cae=class extends zG{#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||HG(),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=FG({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),rr.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function HG(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var uae=class extends bm{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 cae({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=Dy(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=Dy(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=Dy(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=Dy(t);return typeof e=="string"?this.#t.get(e)?.find(i=>i!==t&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){rr.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=>NU(e,n))}findAll(t={}){return this.getAll().filter(e=>NU(t,e))}notify(t){rr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return rr.batch(()=>Promise.all(t.map(e=>e.continue().catch(fa))))}};function Dy(t){return t.options.scope?.id}var dae=class extends bm{#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),z_(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&bf(n.mutationKey)!==bf(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??HG();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){rr.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)})})}},fae=class extends bm{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const i=e.queryKey,r=e.queryHash??kP(i,e);let a=this.get(r);return a||(a=new rae({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(){rr.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=>CU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>CU(t,n)):e}notify(t){rr.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){rr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){rr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},hae=class{#e;#t;#n;#r;#i;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new fae,this.#t=t.mutationCache||new uae,this.#n=t.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=OP.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=B_.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(ju(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=Xre(e,a);if(s!==void 0)return this.#e.build(this,i).setData(s,{...n,manual:!0})}setQueriesData(t,e,n){return rr.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;rr.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return rr.batch(()=>(n.findAll(t).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},i=rr.batch(()=>this.#e.findAll(t).map(r=>r.cancel(n)));return Promise.all(i).then(fa).catch(fa)}invalidateQueries(t,e={}){return rr.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=rr.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(fa)),r.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(i).then(fa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(ju(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(fa).catch(fa)}fetchInfiniteQuery(t){return t.behavior=IU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(fa).catch(fa)}ensureInfiniteQueryData(t){return t.behavior=IU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return B_.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(bf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(i=>{$x(t,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(t,e){this.#i.set(bf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(i=>{$x(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=kP(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===DP&&(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()}},$G=E.createContext(void 0),In=t=>{const e=E.useContext($G);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},pae=({client:t,children:e})=>(E.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),h.jsx($G.Provider,{value:t,children:e})),VG=E.createContext(!1),mae=()=>E.useContext(VG);VG.Provider;function gae(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var xae=E.createContext(gae()),vae=()=>E.useContext(xae),yae=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},bae=t=>{E.useEffect(()=>{t.clearReset()},[t])},_ae=({result:t,errorResetBoundary:e,throwOnError:n,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||jG(n,[t.error,i])),Sae=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))}},wae=(t,e)=>t.isLoading&&t.isFetching&&!e,Mae=(t,e)=>t?.suspense&&e.isPending,UU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function Eae(t,e,n){const i=mae(),r=vae(),a=In(),s=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(s),s._optimisticResults=i?"isRestoring":"optimistic",Sae(s),yae(s,r),bae(r);const o=!a.getQueryCache().get(s.queryHash),[l]=E.useState(()=>new e(a,s)),c=l.getOptimisticResult(s),u=!i&&t.subscribed!==!1;if(E.useSyncExternalStore(E.useCallback(f=>{const m=u?l.subscribe(rr.batchCalls(f)):fa;return l.updateResult(),m},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),E.useEffect(()=>{l.setOptions(s)},[s,l]),Mae(s,c))throw UU(s,l,r);if(_ae({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&&!yf&&wae(c,i)&&(o?UU(s,l,r):a.getQueryCache().get(s.queryHash)?.promise)?.catch(fa).finally(()=>{l.updateResult()}),s.notifyOnChangeProps?c:l.trackResult(c)}function Dt(t,e){return Eae(t,aae)}function Nt(t,e){const n=In(),[i]=E.useState(()=>new dae(n,t));E.useEffect(()=>{i.setOptions(t)},[i,t]);const r=E.useSyncExternalStore(E.useCallback(s=>i.subscribe(rr.batchCalls(s)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),a=E.useCallback((s,o)=>{i.mutate(s,o).catch(fa)},[i]);if(r.error&&jG(i.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}const Aae=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Tae=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase()),FU=t=>{const e=Tae(t);return e.charAt(0).toUpperCase()+e.slice(1)},GG=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim(),Cae=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var Nae={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 Rae=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:a,iconNode:s,...o},l)=>E.createElement("svg",{ref:l,...Nae,width:e,height:e,stroke:t,strokeWidth:i?Number(n)*24/Number(e):n,className:GG("lucide",r),...!a&&!Cae(o)&&{"aria-hidden":"true"},...o},[...s.map(([c,u])=>E.createElement(c,u)),...Array.isArray(a)?a:[a]]));const tt=(t,e)=>{const n=E.forwardRef(({className:i,...r},a)=>E.createElement(Rae,{ref:a,iconNode:e,className:GG(`lucide-${Aae(FU(t))}`,`lucide-${t}`,i),...r}));return n.displayName=FU(t),n};const Pae=[["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"}]],kae=tt("archive",Pae);const Dae=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Vx=tt("arrow-down",Dae);const Oae=[["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"}]],Lae=tt("arrow-up-down",Oae);const Iae=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],jp=tt("arrow-up",Iae);const jae=[["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"}]],NN=tt("bell",jae);const Uae=[["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"}]],Fae=tt("bold",Uae);const zae=[["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"}]],Gx=tt("box",zae);const Bae=[["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"}]],Hae=tt("cable",Bae);const $ae=[["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"}]],Vae=tt("calendar-days",$ae);const Gae=[["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"}]],Zo=tt("calendar",Gae);const Wae=[["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"}]],H_=tt("camera",Wae);const qae=[["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"}]],Xae=tt("chart-column",qae);const Kae=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Wx=tt("check",Kae);const Yae=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],I0=tt("chevron-down",Yae);const Zae=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],_m=tt("chevron-right",Zae);const Qae=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_f=tt("chevron-left",Qae);const Jae=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],WG=tt("chevron-up",Jae);const ese=[["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"}]],Ec=tt("circle-alert",ese);const tse=[["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"}]],zU=tt("circle-arrow-up",tse);const nse=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],hc=tt("circle-check-big",nse);const ise=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],rse=tt("circle-question-mark",ise);const ase=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],sse=tt("circle-stop",ase);const ose=[["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"}]],j0=tt("circle-x",ose);const lse=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ar=tt("clock",lse);const cse=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],IP=tt("cloud",cse);const use=[["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"}]],dse=tt("code-xml",use);const fse=[["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"}]],Up=tt("copy",fse);const hse=[["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"}]],BU=tt("database",hse);const pse=[["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"}]],HU=tt("dollar-sign",pse);const mse=[["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"}]],pc=tt("download",mse);const gse=[["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"}]],jP=tt("droplet",gse);const xse=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],vse=tt("droplets",xse);const yse=[["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"}]],bse=tt("ellipsis-vertical",yse);const _se=[["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"}]],mc=tt("external-link",_se);const Sse=[["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"}]],wse=tt("eye-off",Sse);const Mse=[["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"}]],$U=tt("eye",Mse);const Ese=[["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"}]],Ase=tt("file-box",Ese);const Tse=[["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"}]],VU=tt("file-code",Tse);const Cse=[["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"}]],Nse=tt("file-exclamation-point",Cse);const Rse=[["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"}]],xp=tt("file-text",Rse);const Pse=[["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"}]],qG=tt("file",Pse);const kse=[["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"}]],Mp=tt("film",kse);const Dse=[["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"}]],Ose=tt("flame",Dse);const Lse=[["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"}]],Ise=tt("folder-open",Lse);const jse=[["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"}]],Use=tt("folder",jse);const Fse=[["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"}]],XG=tt("funnel",Fse);const zse=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],UP=tt("gauge",zse);const Bse=[["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"}]],GU=tt("github",Bse);const Hse=[["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"}]],$_=tt("globe",Hse);const $se=[["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"}]],FP=tt("grip-vertical",$se);const Vse=[["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"}]],KG=tt("hard-drive",Vse);const Gse=[["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"}]],KS=tt("image",Gse);const Wse=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],YG=tt("info",Wse);const qse=[["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"}]],Xse=tt("italic",qse);const Kse=[["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"}]],Yse=tt("key",Kse);const Zse=[["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"}]],RN=tt("keyboard",Zse);const Qse=[["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"}]],Fp=tt("layers",Qse);const Jse=[["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"}]],ZG=tt("layout-grid",Jse);const eoe=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]],toe=tt("layout-list",eoe);const noe=[["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"}]],ioe=tt("link-2-off",noe);const roe=[["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"}]],aoe=tt("link-2",roe);const soe=[["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"}]],QG=tt("link",soe);const ooe=[["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"}]],JG=tt("list-ordered",ooe);const loe=[["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"}]],e9=tt("list",loe);const coe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ht=tt("loader-circle",coe);const uoe=[["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"}]],WU=tt("log-in",uoe);const doe=[["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"}]],foe=tt("log-out",doe);const hoe=[["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"}]],poe=tt("maximize-2",hoe);const moe=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],goe=tt("maximize",moe);const xoe=[["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"}]],voe=tt("minimize-2",xoe);const yoe=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],boe=tt("minimize",yoe);const _oe=[["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"}]],V_=tt("moon",_oe);const Soe=[["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"}]],G_=tt("package",Soe);const woe=[["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"}]],Moe=tt("pause",woe);const Eoe=[["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"}]],zP=tt("pen-line",Eoe);const Aoe=[["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"}]],t9=tt("pen",Aoe);const Toe=[["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"}]],zp=tt("pencil",Toe);const Coe=[["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"}]],YS=tt("play",Coe);const Noe=[["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"}]],PN=tt("plug",Noe);const Roe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],So=tt("plus",Roe);const Poe=[["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"}]],n9=tt("power-off",Poe);const koe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Bf=tt("power",koe);const Doe=[["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"}]],Qo=tt("printer",Doe);const Ooe=[["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"}]],Loe=tt("qr-code",Ooe);const Ioe=[["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"}]],wo=tt("refresh-cw",Ioe);const joe=[["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"}]],ZS=tt("rotate-ccw",joe);const Uoe=[["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"}]],Foe=tt("ruler",Uoe);const zoe=[["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"}]],Sm=tt("save",zoe);const Boe=[["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"}]],Hoe=tt("scan-search",Boe);const $oe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Bp=tt("search",$oe);const Voe=[["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"}]],i9=tt("send",Voe);const Goe=[["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"}]],QS=tt("settings-2",Goe);const Woe=[["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"}]],qoe=tt("settings",Woe);const Xoe=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]],Koe=tt("signal",Xoe);const Yoe=[["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"}]],Zoe=tt("skip-back",Yoe);const Qoe=[["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"}]],r9=tt("skip-forward",Qoe);const Joe=[["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"}]],ele=tt("sparkles",Joe);const tle=[["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"}]],Sf=tt("square-check-big",tle);const nle=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Hp=tt("square",nle);const ile=[["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"}]],qx=tt("star",ile);const rle=[["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"}]],a9=tt("sticky-note",rle);const ale=[["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"}]],qU=tt("sun",ale);const sle=[["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"}]],Xx=tt("tag",sle);const ole=[["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"}]],lle=tt("target",ole);const cle=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ule=tt("terminal",cle);const dle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],fle=tt("text-align-center",dle);const hle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],ple=tt("text-align-end",hle);const mle=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],gle=tt("text-align-start",mle);const xle=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],yx=tt("thermometer",xle);const vle=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],s9=tt("timer",vle);const yle=[["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"}]],Ei=tt("trash-2",yle);const ble=[["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"}]],Jo=tt("triangle-alert",ble);const _le=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Sle=tt("underline",_le);const wle=[["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"}]],o9=tt("unlink",wle);const Mle=[["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"}]],$p=tt("upload",Mle);const Ele=[["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"}]],XU=tt("user",Ele);const Ale=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Tle=tt("video",Ale);const Cle=[["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"}]],BP=tt("wifi-off",Cle);const Nle=[["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"}]],l9=tt("wifi",Nle);const Rle=[["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"}]],Vp=tt("wrench",Rle);const Ple=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Sn=tt("x",Ple);const kle=[["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"}]],Dle=tt("zoom-in",kle);const Ole=[["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"}]],c9=tt("zap",Ole);const Lle=[["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"}]],Ile=tt("zoom-out",Lle),u9=E.createContext(void 0);function jle({children:t}){const[e,n]=E.useState(()=>{const a=localStorage.getItem("theme");return a||(window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark")});E.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 h.jsx(u9.Provider,{value:{theme:e,toggleTheme:i,setTheme:r},children:t})}function d9(){const t=E.useContext(u9);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}function $t({children:t,className:e="",onClick:n,onContextMenu:i}){return h.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary ${e}`,onClick:n,onContextMenu:i,children:t})}function Gl({children:t,className:e=""}){return h.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Qt({children:t,className:e=""}){return h.jsx("div",{className:`p-6 ${e}`,children:t})}function Ule(t,e){return[{category:"Navigation",items:t?t.map((i,r)=>({keys:[String(r+1)],description:`Go to ${e(i.labelKey)}`})):[{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:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles"},{keys:["N"],description:"New profile"},{keys:["Esc"],description:"Exit selection mode"}]},{category:"General",items:[{keys:["?"],description:"Show this help"}]}]}function KU({children:t}){return h.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 Fle({onClose:t,navItems:e}){const{t:n}=EP(),i=Ule(e,n);return E.useEffect(()=>{const r=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t]),h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:h.jsx($t,{className:"w-full max-w-md",onClick:r=>r.stopPropagation(),children:h.jsxs(Qt,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(RN,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),h.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(r=>h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:r.category}),h.jsx("div",{className:"space-y-2",children:r.items.map(a=>h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-white text-sm",children:a.description}),h.jsx("div",{className:"flex gap-1",children:a.keys.map(s=>h.jsx(KU,{children:s},s))})]},a.description))})]},r.category))}),h.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:h.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",h.jsx(KU,{children:"Esc"})," or click outside to close"]})})]})})})}const Pi="/api/v1";async function ut(t,e={}){const n=await fetch(`${Pi}${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 $e={getPrinters:()=>ut("/printers/"),getPrinter:t=>ut(`/printers/${t}`),createPrinter:t=>ut("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>ut(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:t=>ut(`/printers/${t}`,{method:"DELETE"}),getPrinterStatus:t=>ut(`/printers/${t}/status`),connectPrinter:t=>ut(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>ut(`/printers/${t}/disconnect`,{method:"POST"}),enableMQTTLogging:t=>ut(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>ut(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>ut(`/printers/${t}/logging`),clearMQTTLogs:t=>ut(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>ut(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Pi}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>ut(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>ut(`/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)),ut(`/archives/?${i}`)},getArchive:t=>ut(`/archives/${t}`),updateArchive:(t,e)=>ut(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>ut(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>ut(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>ut("/archives/stats"),getArchiveDuplicates:t=>ut(`/archives/${t}/duplicates`),backfillContentHashes:()=>ut("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Pi}/archives/${t}/thumbnail`,getArchiveDownload:t=>`${Pi}/archives/${t}/download`,getArchiveGcode:t=>`${Pi}/archives/${t}/gcode`,getArchiveTimelapse:t=>`${Pi}/archives/${t}/timelapse`,scanArchiveTimelapse:t=>ut(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>ut(`/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(`${Pi}/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)=>`${Pi}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const i=await fetch(`${Pi}/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)=>ut(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Pi}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${Pi}/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(`${Pi}/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=>ut(`/archives/${t}/source`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Pi}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>ut(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>ut(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>ut(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Pi}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Pi}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,reprintArchive:(t,e)=>ut(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST"}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const i=e?`${Pi}/archives/upload?printer_id=${e}`:`${Pi}/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?`${Pi}/archives/upload-bulk?printer_id=${e}`:`${Pi}/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:()=>ut("/settings/"),updateSettings:t=>ut("/settings/",{method:"PUT",body:JSON.stringify(t)}),resetSettings:()=>ut("/settings/reset",{method:"POST"}),checkFfmpeg:()=>ut("/settings/check-ffmpeg"),getCloudStatus:()=>ut("/cloud/status"),cloudLogin:(t,e,n="global")=>ut("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>ut("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>ut("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>ut("/cloud/logout",{method:"POST"}),getCloudSettings:(t="01.09.00.00")=>ut(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>ut(`/cloud/settings/${t}`),createCloudSetting:t=>ut("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>ut(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>ut(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>ut("/cloud/devices"),getSmartPlugs:()=>ut("/smart-plugs/"),getSmartPlug:t=>ut(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>ut(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>ut("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>ut(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>ut(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>ut(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>ut(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>ut("/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),ut(`/queue/?${n}`)},getQueueItem:t=>ut(`/queue/${t}`),addToQueue:t=>ut("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>ut(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>ut(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>ut("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>ut(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>ut(`/queue/${t}/stop`,{method:"POST"}),getKProfiles:(t,e="0.4")=>ut(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>ut(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>ut(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>ut(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>ut(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>ut(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>ut(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>ut(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>ut(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,i,r)=>ut(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(i)}&preset_name=${encodeURIComponent(r)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>ut(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),listFilaments:()=>ut("/filaments/"),getFilament:t=>ut(`/filaments/${t}`),getFilamentsByType:t=>ut(`/filaments/by-type/${t}`),getNotificationProviders:()=>ut("/notifications/"),getNotificationProvider:t=>ut(`/notifications/${t}`),createNotificationProvider:t=>ut("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>ut(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>ut(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>ut(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>ut("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),getSpoolmanStatus:()=>ut("/spoolman/status"),connectSpoolman:()=>ut("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>ut("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>ut(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>ut("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>ut("/spoolman/spools"),getSpoolmanFilaments:()=>ut("/spoolman/filaments"),getVersion:()=>ut("/updates/version"),checkForUpdates:()=>ut("/updates/check"),applyUpdate:()=>ut("/updates/apply",{method:"POST"}),getUpdateStatus:()=>ut("/updates/status"),getMaintenanceTypes:()=>ut("/maintenance/types"),createMaintenanceType:t=>ut("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>ut(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>ut(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>ut("/maintenance/overview"),getPrinterMaintenance:t=>ut(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>ut(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>ut(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>ut(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>ut("/maintenance/summary"),setPrinterHours:(t,e)=>ut(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),getCameraStreamUrl:(t,e=10)=>`${Pi}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Pi}/printers/${t}/camera/snapshot`,testCameraConnection:t=>ut(`/printers/${t}/camera/test`)},p_=[{id:"printers",to:"/",icon:Qo,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:kae,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:Zo,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Xae,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:IP,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Vp,labelKey:"nav.maintenance"},{id:"settings",to:"/settings",icon:qoe,labelKey:"nav.settings"}];function zle(){const t=localStorage.getItem("sidebarOrder");if(t)try{const e=JSON.parse(t),n=new Map(p_.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 p_}return p_}function Ble(t){localStorage.setItem("sidebarOrder",JSON.stringify(t.map(e=>e.id)))}function f9(){return localStorage.getItem("defaultView")||"/"}function Hle(t){localStorage.setItem("defaultView",t)}function $le(){const t=TP(),e=rd(),{theme:n,toggleTheme:i}=d9(),{t:r}=EP(),[a,s]=E.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[o,l]=E.useState(!1),[c,u]=E.useState(zle),[f,m]=E.useState(null),[g,y]=E.useState(null),_=E.useRef(!1),{data:v}=Dt({queryKey:["version"],queryFn:$e.getVersion,staleTime:1/0}),{data:x}=Dt({queryKey:["settings"],queryFn:$e.getSettings,staleTime:300*1e3}),{data:M}=Dt({queryKey:["updateCheck"],queryFn:$e.checkForUpdates,enabled:x?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3});E.useEffect(()=>{if(!_.current&&e.pathname==="/"){const N=f9();N!=="/"&&(_.current=!0,t(N,{replace:!0}))}},[e.pathname,t]),E.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(a))},[a]);const w=(N,k)=>{m(k),N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",String(k))},C=(N,k)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",y(k)},T=()=>{y(null)},P=(N,k)=>{if(N.preventDefault(),f===null||f===k){m(null),y(null);return}const F=[...c],[I]=F.splice(f,1);F.splice(k,0,I),u(F),Ble(F),m(null),y(null)},A=()=>{m(null),y(null)},j=E.useCallback(N=>{const k=N.target;if(!(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){const F=parseInt(N.key);if(F>=1&&F<=c.length){N.preventDefault(),t(c[F-1].to);return}switch(N.key){case"?":N.preventDefault(),l(!0);break;case"Escape":l(!1);break}}},[t,c]);return E.useEffect(()=>(document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)),[j]),h.jsxs("div",{className:"flex min-h-screen",children:[h.jsxs("aside",{className:`${a?"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:[h.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a?"p-4":"p-2"}`,children:h.jsx("img",{src:n==="dark"?"/img/bambusy_logo_dark.png":"/img/bambusy_logo_light.png",alt:"Bambusy",className:a?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),h.jsx("nav",{className:"flex-1 p-2",children:h.jsx("ul",{className:"space-y-2",children:c.map(({id:N,to:k,icon:F,labelKey:I},W)=>h.jsx("li",{draggable:!0,onDragStart:D=>w(D,W),onDragOver:D=>C(D,W),onDragLeave:T,onDrop:D=>P(D,W),onDragEnd:A,className:`relative ${f===W?"opacity-50":""} ${g===W&&f!==W?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:h.jsxs(kG,{to:k,className:({isActive:D})=>`flex items-center ${a?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${D?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:a?void 0:r(I),children:[a&&h.jsx(FP,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),h.jsx(F,{className:"w-5 h-5 flex-shrink-0"}),a&&h.jsx("span",{children:r(I)})]})},N))})}),h.jsx("button",{onClick:()=>s(!a),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(a?"nav.collapseSidebar":"nav.expandSidebar"),children:a?h.jsx(_f,{className:"w-5 h-5"}):h.jsx(_m,{className:"w-5 h-5"})}),h.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a?h.jsxs("div",{className:"flex items-center justify-between px-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",v?.version||"..."]}),M?.update_available&&h.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:r("nav.updateAvailable",{version:M.latest_version}),children:[h.jsx(zU,{className:"w-4 h-4"}),h.jsx("span",{children:r("nav.update")})]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.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:r("nav.viewOnGithub"),children:h.jsx(GU,{className:"w-5 h-5"})}),h.jsx("button",{onClick:()=>l(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:r("nav.keyboardShortcuts"),children:h.jsx(RN,{className:"w-5 h-5"})}),h.jsx("button",{onClick:i,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:r(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?h.jsx(qU,{className:"w-5 h-5"}):h.jsx(V_,{className:"w-5 h-5"})})]})]}):h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[M?.update_available&&h.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:r("nav.updateAvailable",{version:M.latest_version}),children:h.jsx(zU,{className:"w-5 h-5"})}),h.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:r("nav.viewOnGithub"),children:h.jsx(GU,{className:"w-5 h-5"})}),h.jsx("button",{onClick:()=>l(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:r("nav.keyboardShortcuts"),children:h.jsx(RN,{className:"w-5 h-5"})}),h.jsx("button",{onClick:i,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:r(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?h.jsx(qU,{className:"w-5 h-5"}):h.jsx(V_,{className:"w-5 h-5"})})]})})]}),h.jsx("main",{className:`flex-1 bg-bambu-dark overflow-auto ${a?"ml-64":"ml-16"} transition-all duration-300`,children:h.jsx(ure,{})}),o&&h.jsx(Fle,{onClose:()=>l(!1),navItems:c})]})}function Ye({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 h.jsx("button",{className:`${a} ${s[t]} ${o[e]} ${n}`,...r,children:i})}function Ia({title:t,message:e,confirmText:n="Confirm",cancelText:i="Cancel",variant:r="default",onConfirm:a,onCancel:s}){E.useEffect(()=>{const c=u=>{u.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 h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:s,children:h.jsx($t,{className:"w-full max-w-md",onClick:c=>c.stopPropagation(),children:h.jsxs(Qt,{className:"p-6",children:[h.jsxs("div",{className:"flex items-start gap-4",children:[h.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${l.icon}`,children:h.jsx(Jo,{className:"w-6 h-6"})}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),h.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),h.jsxs("div",{className:"flex gap-3 mt-6",children:[h.jsx(Ye,{variant:"secondary",onClick:s,className:"flex-1",children:i}),h.jsx(Ye,{onClick:a,className:`flex-1 ${l.button}`,children:n})]})]})})})}const h9=E.createContext(void 0);function wa(){const t=E.useContext(h9);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Vle={success:h.jsx(hc,{className:"w-5 h-5 text-green-400"}),error:h.jsx(j0,{className:"w-5 h-5 text-red-400"}),warning:h.jsx(Ec,{className:"w-5 h-5 text-yellow-400"}),info:h.jsx(YG,{className:"w-5 h-5 text-blue-400"})},Gle={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 Wle({children:t}){const[e,n]=E.useState([]),i=E.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=E.useCallback(a=>{n(s=>s.filter(o=>o.id!==a))},[]);return h.jsxs(h9.Provider,{value:{showToast:i},children:[t,h.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(a=>h.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${Gle[a.type]}`,children:[Vle[a.type],h.jsx("span",{className:"text-white text-sm",children:a.message}),h.jsx("button",{onClick:()=>r(a.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-4 h-4"})})]},a.id))})]})}function qle(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 YU(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 Xle(t,e){if(e)return Use;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Ase;case"gcode":return xp;case"mp4":case"avi":return Mp;case"png":case"jpg":case"jpeg":return KS;default:return qG}}function Kle({printerId:t,printerName:e,onClose:n}){const{showToast:i}=wa(),r=In(),[a,s]=E.useState("/"),[o,l]=E.useState(null),[c,u]=E.useState(""),[f,m]=E.useState(null);E.useEffect(()=>{const A=j=>{j.key==="Escape"&&n()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n]);const{data:g,isLoading:y,refetch:_}=Dt({queryKey:["printerFiles",t,a],queryFn:()=>$e.getPrinterFiles(t,a)}),{data:v}=Dt({queryKey:["printerStorage",t],queryFn:()=>$e.getPrinterStorage(t),staleTime:3e4}),x=Nt({mutationFn:A=>$e.deletePrinterFile(t,A),onSuccess:(A,j)=>{i(`Deleted: ${j.split("/").pop()}`),r.invalidateQueries({queryKey:["printerFiles",t]}),l(null)},onError:A=>{i(`Delete failed: ${A.message}`,"error")}}),M=A=>{s(A),l(null)},w=()=>{if(a==="/")return;const A=a.split("/").filter(Boolean);A.pop(),s(A.length?"/"+A.join("/"):"/"),l(null)},C=A=>{window.open($e.getPrinterFileDownloadUrl(t,A),"_blank")},T=A=>{m(A)},P=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return h.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[h.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:A=>A.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(KG,{className:"w-5 h-5 text-bambu-green"}),h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[v&&(v.used_bytes!=null||v.free_bytes!=null)&&h.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[v.used_bytes!=null&&h.jsxs("span",{children:["Used: ",YU(v.used_bytes)]}),v.used_bytes!=null&&v.free_bytes!=null&&h.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),v.free_bytes!=null&&h.jsxs("span",{children:["Free: ",YU(v.free_bytes)]})]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]})]}),h.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(A=>h.jsx("button",{onClick:()=>{M(A.path),u("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===A.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:A.label},A.path)),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"relative",children:[h.jsx(Bp,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",placeholder:"Filter files...",value:c,onChange:A=>u(A.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"})]}),h.jsx(Ye,{variant:"secondary",size:"sm",onClick:()=>_(),disabled:y,children:h.jsx(wo,{className:`w-4 h-4 ${y?"animate-spin":""}`})})]}),h.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[h.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:h.jsx(_f,{className:"w-4 h-4"})}),h.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:y?h.jsx("div",{className:"flex items-center justify-center py-12",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):g?.files?.length?h.jsx("div",{className:"space-y-1",children:[...g.files].filter(A=>!c||A.name.toLowerCase().includes(c.toLowerCase())).sort((A,j)=>A.is_directory&&!j.is_directory?-1:!A.is_directory&&j.is_directory?1:A.name.localeCompare(j.name)).map(A=>{const j=Xle(A.name,A.is_directory),N=o===A.path;return h.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${N?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{A.is_directory?M(A.path):l(N?null:A.path)},children:[h.jsx(j,{className:`w-5 h-5 flex-shrink-0 ${A.is_directory?"text-bambu-green":"text-bambu-gray"}`}),h.jsx("span",{className:"flex-1 text-white truncate",children:A.name}),!A.is_directory&&h.jsx("span",{className:"text-sm text-bambu-gray",children:qle(A.size)}),A.is_directory&&h.jsx(_f,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},A.path)})}):h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),h.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[h.jsx("div",{className:"text-sm text-bambu-gray",children:c?`${g?.files?.filter(A=>A.name.toLowerCase().includes(c.toLowerCase())).length||0} of ${g?.files?.length||0} items`:`${g?.files?.length||0} items`}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(Ye,{variant:"secondary",disabled:!o,onClick:()=>o&&C(o),children:[h.jsx(pc,{className:"w-4 h-4"}),"Download"]}),h.jsxs(Ye,{variant:"secondary",disabled:!o||x.isPending,onClick:()=>o&&T(o),className:"text-red-400 hover:text-red-300",children:[x.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Ei,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&h.jsx(Ia,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{x.mutate(f),m(null)},onCancel:()=>m(null)})]})}function Yle({printerId:t,printerName:e,onClose:n}){const i=In(),[r,a]=E.useState(!0),[s,o]=E.useState(new Set),[l,c]=E.useState(""),[u,f]=E.useState("all"),m=E.useRef(null),{data:g,isLoading:y,refetch:_}=Dt({queryKey:["mqtt-logs",t],queryFn:()=>$e.getMQTTLogs(t),refetchInterval:1e3}),v=Nt({mutationFn:()=>$e.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),x=Nt({mutationFn:()=>$e.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),M=Nt({mutationFn:()=>$e.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});E.useEffect(()=>{const N=k=>{k.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]),E.useEffect(()=>{r&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[g?.logs,r]);const w=N=>{o(k=>{const F=new Set(k);return F.has(N)?F.delete(N):F.add(N),F})},C=N=>new Date(N).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),T=(N,k)=>{if(N==null)return"<empty>";const F=typeof N=="string"?JSON.parse(N):N,I=JSON.stringify(F,null,k?2:0);return!k&&I.length>100?I.substring(0,100)+"...":I},P=g?.logging_enabled??!1,A=g?.logs??[],j=E.useMemo(()=>A.filter(N=>{if(u!=="all"&&N.direction!==u)return!1;if(l.trim()){const k=l.toLowerCase(),F=N.topic.toLowerCase().includes(k),W=JSON.stringify(N.payload).toLowerCase().includes(k);return F||W}return!0}),[A,l,u]);return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[P?h.jsxs(Ye,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,children:[h.jsx(Hp,{className:"w-4 h-4"}),"Stop"]}):h.jsxs(Ye,{size:"sm",onClick:()=>v.mutate(),disabled:v.isPending,children:[h.jsx(YS,{className:"w-4 h-4"}),"Start Logging"]}),h.jsxs(Ye,{size:"sm",variant:"secondary",onClick:()=>M.mutate(),disabled:M.isPending||A.length===0,children:[h.jsx(Ei,{className:"w-4 h-4"}),"Clear"]}),h.jsx(Ye,{size:"sm",variant:"secondary",onClick:()=>_(),disabled:y,children:h.jsx(wo,{className:`w-4 h-4 ${y?"animate-spin":""}`})}),h.jsx("div",{className:"flex-1"}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:r,onChange:N=>a(N.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),h.jsxs("span",{className:"text-sm text-bambu-gray",children:[j.length,"/",A.length]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("div",{className:"relative flex-1",children:[h.jsx(Bp,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:l,onChange:N=>c(N.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),l&&h.jsx("button",{onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:h.jsx(Sn,{className:"w-4 h-4"})})]}),h.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[h.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${u==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),h.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${u==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[h.jsx(Vx,{className:"w-3 h-3"}),"In"]}),h.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${u==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[h.jsx(jp,{className:"w-3 h-3"}),"Out"]})]})]})]}),h.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:A.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[h.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!P&&h.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):j.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[h.jsx("p",{className:"mb-2",children:"No messages match your filter"}),h.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):h.jsx("div",{className:"space-y-1",children:j.map((N,k)=>{const F=s.has(k),I=N.direction==="in";return h.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>w(k),children:[h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsx("span",{className:"text-bambu-gray shrink-0",children:C(N.timestamp)}),h.jsx("span",{className:`shrink-0 ${I?"text-blue-400":"text-green-400"}`,title:I?"Incoming":"Outgoing",children:I?h.jsx(Vx,{className:"w-3 h-3"}):h.jsx(jp,{className:"w-3 h-3"})}),h.jsx("span",{className:"text-purple-400 shrink-0",children:N.topic})]}),F?h.jsx("pre",{className:"mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs",children:T(N.payload,!0)}):h.jsx("pre",{className:"mt-1 text-white/80 truncate",children:T(N.payload,!1)})]},k)})})}),h.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[h.jsx("div",{className:"text-sm text-bambu-gray",children:P?h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):h.jsx("span",{children:"Logging stopped"})}),h.jsx(Ye,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const Zle={"0700_5500_0002_0001":"A binding error occurred between AMS and the extruder. Please perform AMS initialization again.","0500_0300_0002_000E":"Some modules are incompatible with the printer firmware version. Please update firmware.","0300_0100_0002_0054":"The heatbed temperature is abnormal. The sensor may be disconnected or damaged.","0500_0100_0005_0005":"Motor driver overheated. Let the printer cool down.","0500_0100_0005_0006":"Motor driver communication error.","0700_0100_0007_0001":"AMS communication error.","0700_0100_0007_0002":"AMS filament runout.","0700_0100_0007_0003":"AMS filament not detected.","0C00_0100_000C_0003":"First layer inspection failed.","0C00_0100_000C_0004":"Nozzle clog detected.","0C00_0100_000C_8000":"Foreign object detected on print bed.","0500_0100_0005_0000":"Motor X axis lost steps.","0500_0100_0005_0001":"Motor Y axis lost steps.","0500_0100_0005_0002":"Motor Z axis lost steps."};function Qle(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Jo};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Jo};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Ec};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:YG}}}function p9(t,e){const n=(t>>24&255).toString(16).padStart(2,"0").toUpperCase(),i=(t>>16&255).toString(16).padStart(2,"0").toUpperCase(),r=(t>>8&255).toString(16).padStart(2,"0").toUpperCase(),a=(t&255).toString(16).padStart(2,"0").toUpperCase(),s=(e>>24&255).toString(16).padStart(2,"0").toUpperCase(),o=(e>>16&255).toString(16).padStart(2,"0").toUpperCase(),l=(e>>8&255).toString(16).padStart(2,"0").toUpperCase(),c=(e&255).toString(16).padStart(2,"0").toUpperCase();return`${n}${i}_${r}${a}_${s}${o}_${l}${c}`}function Jle(t,e,n){const i=p9(t,e);return`https://wiki.bambulab.com/en/${n.toLowerCase().includes("h2")?"h2":"x1"}/troubleshooting/hmscode/${i}`}function ece({printerName:t,errors:e,onClose:n}){return console.log("HMSErrorModal errors:",JSON.stringify(e,null,2)),E.useEffect(()=>{const i=r=>{r.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Jo,{className:"w-5 h-5 text-orange-400"}),h.jsxs("h2",{className:"text-lg font-semibold text-white",children:["HMS Errors - ",t]})]}),h.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(Sn,{className:"w-5 h-5 text-bambu-gray"})})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.length===0?h.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[h.jsx(Ec,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),h.jsx("p",{children:"No HMS errors"})]}):h.jsx("div",{className:"space-y-3",children:e.map((i,r)=>{const{label:a,color:s,bgColor:o,Icon:l}=Qle(i.severity),c=parseInt(i.code.replace("0x",""),16)||0,u=p9(i.attr,c),f=Zle[u]||"Unknown error. Click the link below for details.",m=Jle(i.attr,c,t),g=`HMS_${u.replace(/_/g,"-")}`;return h.jsx("div",{className:`p-4 rounded-lg ${o} border border-white/10`,children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx(l,{className:`w-5 h-5 ${s} flex-shrink-0 mt-0.5`}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("span",{className:`font-mono text-sm ${s}`,children:g}),h.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${o} ${s}`,children:a})]}),h.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:f}),h.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[h.jsx(mc,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${r}`)})})}),h.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:h.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 tce(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 nce({printerId:t}){const{data:e}=Dt({queryKey:["queue",t,"pending"],queryFn:()=>$e.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],i=e?.length||0;return i===0?null:h.jsx(XS,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[h.jsx(Zo,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),h.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),h.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[h.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[h.jsx(ar,{className:"w-3 h-3"}),tce(n?.scheduled_time||null)]}),i>1&&h.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",i-1]}),h.jsx(_m,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function ice({side:t}){const{theme:e}=d9(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return h.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function ZU({className:t}){return h.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:h.jsx("path",{d:"M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z",fill:"#C3C2C1"})})}function rce({className:t}){return h.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("path",{d:"M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z",fill:"#C3C2C1"}),h.jsx("path",{d:"M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z",fill:"#1F8FEB"})]})}function ace({className:t}){return h.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("path",{d:"M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z",fill:"#1F8FEB"}),h.jsx("path",{d:"M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z",fill:"#C3C2C1"})]})}function sce({className:t}){return h.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"}),h.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function oce({className:t}){return h.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),h.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),h.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function lce({className:t}){return h.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[h.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),h.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),h.jsx("path",{d:"M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function cce({humidity:t,goodThreshold:e=40,fairThreshold:n=60}){const i=typeof t=="string"?parseInt(t,10):t,r=typeof e=="number"?e:40,a=typeof n=="number"?n:60;let s,o;isNaN(i)?(s="#C3C2C1",o="Unknown"):i<=r?(s="#22a352",o="Good"):i<=a?(s="#d4a017",o="Fair"):(s="#c62828",o="Bad");let l;return isNaN(i)||i<=r?l=ZU:i<=a?l=rce:l=ace,h.jsxs("div",{className:"flex items-center justify-end gap-1",title:`Humidity: ${i}% - ${o}`,children:[h.jsx(l,{className:"w-3 h-4"}),h.jsxs("span",{className:"text-xs font-medium tabular-nums w-8 text-right",style:{color:s},children:[i,"%"]})]})}function uce({temp:t,goodThreshold:e=28,fairThreshold:n=35}){const i=typeof e=="number"?e:28,r=typeof n=="number"?n:35;let a,s;return t<=i?(a="#22a352",s=sce):t<=r?(a="#d4a017",s=oce):(a="#c62828",s=lce),h.jsxs("span",{className:"flex items-center gap-1",title:"Temperature",children:[h.jsx(s,{className:"w-3 h-4"}),h.jsxs("span",{className:"tabular-nums w-12 text-right",style:{color:a},children:[t,"°C"]})]})}function dce(t,e){const n=typeof t=="string"?parseInt(t,10):t,i=isNaN(n)?0:n,r=e===1,a=i>=128?i-128:i,s=String.fromCharCode(65+a);return r?`HT-${s}`:`AMS-${s}`}function fce(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function hce(t){const e=new Date,n=new Date(e.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const r=new Date(n);r.setHours(0,0,0,0);const a=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),s=Math.floor((r.getTime()-i.getTime())/(1e3*60*60*24));return s===0?a:s===1?`Tomorrow ${a}`:n.toLocaleDateString([],{weekday:"short"})+" "+a}function pce(t){if(!t)return"/img/printers/default.png";const e=t.toLowerCase().replace(/\s+/g,"");return e.includes("x1e")?"/img/printers/x1e.png":e.includes("x1c")||e.includes("x1carbon")||e.includes("x1")?"/img/printers/x1c.png":e.includes("h2d")||e.includes("h2c")||e.includes("h2s")?"/img/printers/h2d.png":e.includes("p2s")||e.includes("p1s")?"/img/printers/p1s.png":e.includes("p1p")?"/img/printers/p1p.png":e.includes("a1mini")?"/img/printers/a1mini.png":e.includes("a1")?"/img/printers/a1.png":"/img/printers/default.png"}function mce(t){return t==null?{label:"",color:"text-bambu-gray",bars:0}:t>=-50?{label:"Excellent",color:"text-bambu-green",bars:4}:t>=-60?{label:"Good",color:"text-bambu-green",bars:3}:t>=-70?{label:"Fair",color:"text-yellow-400",bars:2}:t>=-80?{label:"Weak",color:"text-orange-400",bars:1}:{label:"Very weak",color:"text-red-400",bars:1}}function gce({url:t,printName:e}){const[n,i]=E.useState(!1),[r,a]=E.useState(!1),[s,o]=E.useState(!1);return h.jsxs(h.Fragment,{children:[h.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?h.jsxs(h.Fragment,{children:[h.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>a(!0)}),!n&&h.jsx(Gx,{className:"w-8 h-8 text-bambu-gray"})]}):h.jsx(Gx,{className:"w-8 h-8 text-bambu-gray"})}),s&&t&&h.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>o(!1),children:h.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[h.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&h.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function xce({printers:t}){const e=In(),n=E.useMemo(()=>{let r=0,a=0,s=0,o=0;return t?.forEach(l=>{const c=e.getQueryData(["printerStatus",l.id]);c===void 0?o++:c.connected?c.state==="RUNNING"?r++:a++:s++}),{printing:r,idle:a,offline:s,loading:o,total:t?.length||0}},[t,e]),[,i]=E.useState(0);return E.useEffect(()=>{const r=e.getQueryCache().subscribe(()=>{i(a=>a+1)});return()=>r()},[e]),t?.length?h.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),h.jsxs("span",{className:"text-bambu-gray",children:[h.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),h.jsxs("span",{className:"text-bambu-gray",children:[h.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),h.jsxs("span",{className:"text-bambu-gray",children:[h.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function QU({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:i="expanded",amsThresholds:r}){const a=In(),s=TP(),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,m]=E.useState(!1),[g,y]=E.useState(!1),[_,v]=E.useState(!1),[x,M]=E.useState(!1),[w,C]=E.useState(!1),[T,P]=E.useState(!1),{data:A}=Dt({queryKey:["printerStatus",t.id],queryFn:()=>$e.getPrinterStatus(t.id),refetchInterval:3e4}),[j,N]=E.useState(null);E.useEffect(()=>{A?.wifi_signal!=null&&N(A.wifi_signal)},[A?.wifi_signal]);const k=A?.wifi_signal??j,F=E.useRef({});E.useEffect(()=>{A?.ams_extruder_map&&Object.keys(A.ams_extruder_map).length>0&&(F.current=A.ams_extruder_map)},[A?.ams_extruder_map]);const I=A?.ams_extruder_map&&Object.keys(A.ams_extruder_map).length>0?A.ams_extruder_map:F.current,W=E.useRef([]);E.useEffect(()=>{A?.ams&&A.ams.length>0&&(W.current=A.ams)},[A?.ams]);const D=A?.ams&&A.ams.length>0?A.ams:W.current,{data:B}=Dt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>$e.getSmartPlugByPrinter(t.id)}),{data:$}=Dt({queryKey:["smartPlugStatus",B?.id],queryFn:()=>B?$e.getSmartPlugStatus(B.id):null,enabled:!!B,refetchInterval:1e4}),{data:K}=Dt({queryKey:["queue",t.id,"pending"],queryFn:()=>$e.getQueue(t.id,"pending")}),X=K?.length||0,{data:Y}=Dt({queryKey:["archives",t.id,"last"],queryFn:()=>$e.getArchives(t.id,1,0),enabled:A?.connected&&A?.state!=="RUNNING"}),ee=Y?.[0],z=e&&A&&!A.connected,V=Nt({mutationFn:()=>$e.deletePrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printers"]})}}),re=Nt({mutationFn:()=>$e.connectPrinter(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["printerStatus",t.id]})}}),le=Nt({mutationFn:ie=>B?$e.controlSmartPlug(B.id,ie):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugStatus",B?.id]})}}),ge=Nt({mutationFn:ie=>B?$e.updateSmartPlug(B.id,{auto_off:ie}):Promise.reject("No plug"),onSuccess:()=>{a.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),a.invalidateQueries({queryKey:["smart-plugs"]})}});return z?null:h.jsxs($t,{className:"relative",children:[h.jsxs(Qt,{children:[h.jsxs("div",{className:i==="compact"?"mb-2":"mb-4",children:[h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[h.jsx("img",{src:pce(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${i==="compact"?"w-10 h-10":"w-14 h-14"}`}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:`font-semibold text-white ${i==="compact"?"text-base truncate":"text-lg"}`,children:t.name}),i==="compact"&&h.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${A?.connected?"bg-bambu-green":"bg-red-500"}`,title:A?.connected?"Connected":"Offline"})]}),h.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",i==="expanded"&&A?.nozzles&&A.nozzles[0]?.nozzle_diameter&&h.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:A.nozzles[0].nozzle_type||"Nozzle",children:["• ",A.nozzles[0].nozzle_diameter,"mm"]}),i==="expanded"&&n&&n.total_print_hours>0&&h.jsxs("span",{className:"ml-2 text-bambu-gray",children:[h.jsx(ar,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),h.jsxs("div",{className:"relative flex-shrink-0",children:[h.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>l(!o),children:h.jsx(bse,{className:"w-4 h-4"})}),o&&h.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:[h.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{m(!0),l(!1)},children:[h.jsx(zp,{className:"w-4 h-4"}),"Edit"]}),h.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{re.mutate(),l(!1)},children:[h.jsx(wo,{className:"w-4 h-4"}),"Reconnect"]}),h.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{v(!0),l(!1)},children:[h.jsx(ule,{className:"w-4 h-4"}),"MQTT Debug"]}),h.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:()=>{u(!0),l(!1)},children:[h.jsx(Ei,{className:"w-4 h-4"}),"Delete"]})]})]})]}),i==="expanded"&&h.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[h.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${A?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[A?.connected?h.jsx(QG,{className:"w-3 h-3"}):h.jsx(o9,{className:"w-3 h-3"}),A?.connected?"Connected":"Offline"]}),A?.connected&&k!=null&&h.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${k>=-50||k>=-60?"bg-bambu-green/20 text-bambu-green":k>=-70?"bg-amber-500/20 text-amber-600":k>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${k} dBm - ${mce(k).label}`,children:[h.jsx(Koe,{className:"w-3 h-3"}),k,"dBm"]}),A?.connected&&h.jsxs("button",{onClick:()=>P(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${A.hms_errors&&A.hms_errors.length>0?A.hms_errors.some(ie=>ie.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:[h.jsx(Jo,{className:"w-3 h-3"}),A.hms_errors&&A.hms_errors.length>0?A.hms_errors.length:"OK"]}),n&&h.jsxs("button",{onClick:()=>s("/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:[h.jsx(Vp,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),X>0&&h.jsxs("button",{onClick:()=>s("/queue"),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-purple-500/20 text-purple-400 hover:opacity-80 transition-opacity",title:`${X} print${X>1?"s":""} in queue`,children:[h.jsx(Fp,{className:"w-3 h-3"}),X]})]})]}),c&&h.jsx(Ia,{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:()=>{V.mutate(),u(!1)},onCancel:()=>u(!1)}),A?.connected&&h.jsxs(h.Fragment,{children:[i==="compact"?h.jsx("div",{className:"mt-2",children:A.state==="RUNNING"?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:h.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${A.progress||0}%`}})}),h.jsxs("span",{className:"text-xs text-white",children:[Math.round(A.progress||0),"%"]})]}):h.jsx("p",{className:"text-xs text-bambu-gray capitalize",children:A.state?.toLowerCase()||"Idle"})}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg",children:h.jsxs("div",{className:"flex gap-3",children:[h.jsx(gce,{url:A.state==="RUNNING"?A.cover_url:null,printName:A.state==="RUNNING"&&(A.subtask_name||A.current_print)||void 0}),h.jsx("div",{className:"flex-1 min-w-0",children:A.current_print&&A.state==="RUNNING"?h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Printing"}),h.jsx("p",{className:"text-white text-sm mb-2 truncate",children:A.subtask_name||A.current_print}),h.jsxs("div",{className:"flex items-center justify-between text-sm",children:[h.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:h.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${A.progress||0}%`}})}),h.jsxs("span",{className:"text-white",children:[Math.round(A.progress||0),"%"]})]}),h.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[A.remaining_time!=null&&A.remaining_time>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(ar,{className:"w-3 h-3"}),fce(A.remaining_time*60)]}),h.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",hce(A.remaining_time)]})]}),A.layer_num!=null&&A.total_layers!=null&&A.total_layers>0&&h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx(Fp,{className:"w-3 h-3"}),A.layer_num,"/",A.total_layers]})]})]}):h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),h.jsx("p",{className:"text-white text-sm mb-2 capitalize",children:A.state?.toLowerCase()||"Idle"}),h.jsxs("div",{className:"flex items-center justify-between text-sm",children:[h.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:h.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),h.jsx("span",{className:"text-bambu-gray",children:"—"})]}),ee?h.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:ee.print_name||ee.filename,children:["Last: ",ee.print_name||ee.filename,ee.completed_at&&h.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",new Date(ee.completed_at).toLocaleDateString([],{month:"short",day:"numeric"})]})]}):h.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})}),A.state!=="RUNNING"&&h.jsx(nce,{printerId:t.id})]}),A.temperatures&&i==="expanded"&&h.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[h.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[h.jsx(yx,{className:"w-4 h-4 mx-auto mb-1 text-orange-400"}),A.temperatures.nozzle_2!==void 0?h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Left / Right"}),h.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.nozzle||0),"°C / ",Math.round(A.temperatures.nozzle_2||0),"°C"]})]}):h.jsxs(h.Fragment,{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Nozzle"}),h.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.nozzle||0),"°C"]})]})]}),h.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[h.jsx(yx,{className:"w-4 h-4 mx-auto mb-1 text-blue-400"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Bed"}),h.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.bed||0),"°C"]})]}),A.temperatures.chamber!==void 0&&h.jsxs("div",{className:"text-center p-2 bg-bambu-dark rounded-lg",children:[h.jsx(yx,{className:"w-4 h-4 mx-auto mb-1 text-green-400"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Chamber"}),h.jsxs("p",{className:"text-sm text-white",children:[Math.round(A.temperatures.chamber||0),"°C"]})]})]}),D&&D.length>0&&i==="expanded"&&h.jsxs("div",{className:"mt-3 p-2 bg-bambu-dark rounded-lg",children:[h.jsx("div",{className:"space-y-2",children:D.map(ie=>{const xe=ie.id>=128?ie.id-128:ie.id,ke=I[String(xe)],he=ke!==void 0?ke:xe,we=t.nozzle_count===2||A?.temperatures?.nozzle_2!==void 0,Ue=he===1,ue=he===0;return h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[we&&(Ue||ue)&&h.jsx(ice,{side:Ue?"L":"R"}),h.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:dce(ie.id,ie.tray.length)}),h.jsx("div",{className:"flex gap-1",children:ie.tray.map((lt,H)=>h.jsx("div",{className:`w-5 h-5 rounded-full border border-white/20 ${lt.tray_type?"":"ams-empty-slot"}`,style:{backgroundColor:lt.tray_color?`#${lt.tray_color}`:lt.tray_type?"#333":void 0},title:lt.tray_type?`${lt.tray_sub_brands||lt.tray_type}${lt.remain?` (${lt.remain}%)`:""}`:"Empty slot"},`${ie.id}-${H}`))})]}),(ie.humidity!=null||ie.temp!=null)&&h.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[ie.humidity!=null&&h.jsx("div",{className:"w-14 text-right",children:h.jsx(cce,{humidity:ie.humidity,goodThreshold:r?.humidityGood,fairThreshold:r?.humidityFair})}),ie.temp!=null&&h.jsx(uce,{temp:ie.temp,goodThreshold:r?.tempGood,fairThreshold:r?.tempFair})]})]},ie.id)})}),A.vt_tray&&A.vt_tray.tray_type&&h.jsxs("div",{className:"flex items-center gap-2 pt-2 mt-2 border-t border-bambu-dark-tertiary",children:[h.jsx("span",{className:"text-xs text-bambu-gray w-10",children:"Ext"}),h.jsx("div",{className:"w-5 h-5 rounded-full border border-white/20",style:{backgroundColor:A.vt_tray.tray_color?`#${A.vt_tray.tray_color}`:"#333"},title:A.vt_tray.tray_sub_brands||A.vt_tray.tray_type||"External"})]})]})]}),B&&i==="expanded"&&h.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(c9,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),h.jsx("span",{className:"text-sm text-white truncate",children:B.name}),$&&h.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${$.state==="ON"?"bg-bambu-green/20 text-bambu-green":$.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:$.state||"?"}),$?.energy?.power!=null&&$.state==="ON"&&h.jsxs("span",{className:"text-xs text-yellow-400 font-medium flex-shrink-0",children:[$.energy.power,"W"]})]}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsxs("button",{onClick:()=>M(!0),disabled:le.isPending||$?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${$?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[h.jsx(Bf,{className:"w-3 h-3"}),"On"]}),h.jsxs("button",{onClick:()=>C(!0),disabled:le.isPending||$?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${$?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[h.jsx(n9,{className:"w-3 h-3"}),"Off"]})]}),h.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[h.jsx("span",{className:`text-xs hidden sm:inline ${B.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:B.auto_off_executed?"Auto-off done":"Auto-off"}),h.jsx("button",{onClick:()=>ge.mutate(!B.auto_off),disabled:ge.isPending||B.auto_off_executed,title:B.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 ${B.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":B.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:h.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${B.auto_off||B.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),i==="expanded"&&h.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[h.jsxs("div",{className:"text-xs text-bambu-gray",children:[h.jsx("p",{children:t.ip_address}),h.jsx("p",{className:"truncate",children:t.serial_number})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Ye,{variant:"secondary",size:"sm",onClick:()=>{window.open(`/camera/${t.id}`,`camera-${t.id}`,"width=640,height=400,menubar=no,toolbar=no,location=no,status=no")},disabled:!A?.connected,title:"Open camera in new window",children:h.jsx(Tle,{className:"w-4 h-4"})}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>y(!0),title:"Browse printer files",children:[h.jsx(KG,{className:"w-4 h-4"}),"Files"]})]})]})]}),g&&h.jsx(Kle,{printerId:t.id,printerName:t.name,onClose:()=>y(!1)}),_&&h.jsx(Yle,{printerId:t.id,printerName:t.name,onClose:()=>v(!1)}),x&&B&&h.jsx(Ia,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{le.mutate("on"),M(!1)},onCancel:()=>M(!1)}),w&&B&&h.jsx(Ia,{title:"Power Off Printer",message:A?.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:()=>{le.mutate("off"),C(!1)},onCancel:()=>C(!1)}),T&&h.jsx(ece,{printerName:t.name,errors:A?.hms_errors||[],onClose:()=>P(!1)}),f&&h.jsx(yce,{printer:t,onClose:()=>m(!1)})]})}function vce({onClose:t,onAdd:e}){const[n,i]=E.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0});return E.useEffect(()=>{const r=a=>{a.key==="Escape"&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t]),h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:h.jsx($t,{className:"w-full max-w-md",onClick:r=>r.stopPropagation(),children:h.jsxs(Qt,{children:[h.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),h.jsxs("form",{onSubmit:r=>{r.preventDefault(),e(n)},className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),h.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),h.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),h.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),h.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),h.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:[h.jsx("option",{value:"",children:"Select model..."}),h.jsxs("optgroup",{label:"H2 Series",children:[h.jsx("option",{value:"H2C",children:"H2C"}),h.jsx("option",{value:"H2D",children:"H2D"}),h.jsx("option",{value:"H2S",children:"H2S"})]}),h.jsxs("optgroup",{label:"X1 Series",children:[h.jsx("option",{value:"X1E",children:"X1E"}),h.jsx("option",{value:"X1C",children:"X1 Carbon"}),h.jsx("option",{value:"X1",children:"X1"})]}),h.jsxs("optgroup",{label:"P Series",children:[h.jsx("option",{value:"P2S",children:"P2S"}),h.jsx("option",{value:"P1S",children:"P1S"}),h.jsx("option",{value:"P1P",children:"P1P"})]}),h.jsxs("optgroup",{label:"A1 Series",children:[h.jsx("option",{value:"A1",children:"A1"}),h.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.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"}),h.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),h.jsxs("div",{className:"flex gap-3 pt-4",children:[h.jsx(Ye,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),h.jsx(Ye,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function yce({printer:t,onClose:e}){const n=In(),[i,r]=E.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=Nt({mutationFn:o=>$e.updatePrinter(t.id,o),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});E.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]);const s=o=>{o.preventDefault();const l={name:i.name,ip_address:i.ip_address,model:i.model||void 0,location:i.location||void 0,auto_archive:i.auto_archive};i.access_code&&(l.access_code=i.access_code),a.mutate(l)};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:h.jsx($t,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:h.jsxs(Qt,{children:[h.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),h.jsxs("form",{onSubmit:s,className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),h.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:i.name,onChange:o=>r({...i,name:o.target.value}),placeholder:"My Printer"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),h.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:i.ip_address,onChange:o=>r({...i,ip_address:o.target.value}),placeholder:"192.168.1.100"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),h.jsx("input",{type:"text",disabled:!0,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed",value:t.serial_number}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),h.jsx("input",{type:"password",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:i.access_code,onChange:o=>r({...i,access_code:o.target.value}),placeholder:"Leave empty to keep current"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),h.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:i.model,onChange:o=>r({...i,model:o.target.value}),children:[h.jsx("option",{value:"",children:"Select model..."}),h.jsxs("optgroup",{label:"H2 Series",children:[h.jsx("option",{value:"H2C",children:"H2C"}),h.jsx("option",{value:"H2D",children:"H2D"}),h.jsx("option",{value:"H2S",children:"H2S"})]}),h.jsxs("optgroup",{label:"X1 Series",children:[h.jsx("option",{value:"X1E",children:"X1E"}),h.jsx("option",{value:"X1C",children:"X1 Carbon"}),h.jsx("option",{value:"X1",children:"X1"})]}),h.jsxs("optgroup",{label:"P Series",children:[h.jsx("option",{value:"P2S",children:"P2S"}),h.jsx("option",{value:"P1S",children:"P1S"}),h.jsx("option",{value:"P1P",children:"P1P"})]}),h.jsxs("optgroup",{label:"A1 Series",children:[h.jsx("option",{value:"A1",children:"A1"}),h.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),h.jsx("input",{type:"text",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:i.location,onChange:o=>r({...i,location:o.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:i.auto_archive,onChange:o=>r({...i,auto_archive:o.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),h.jsxs("div",{className:"flex gap-3 pt-4",children:[h.jsx(Ye,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsx(Ye,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function bce(t){const{data:e}=Dt({queryKey:["printerStatus",t],queryFn:()=>$e.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function _ce({printer:t,plug:e,onPowerOn:n,isPowering:i}){const r=bce(t.id),{data:a}=Dt({queryKey:["smartPlugStatus",e.id],queryFn:()=>$e.getSmartPlugStatus(e.id),refetchInterval:1e4});return r?h.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&h.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),h.jsxs("button",{onClick:()=>n(e.id),disabled:i||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[h.jsx(Bf,{className:"w-3 h-3"}),i?"...":"On"]})]}):null}function Sce(){const[t,e]=E.useState(!1),[n,i]=E.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[r,a]=E.useState(!1),[s,o]=E.useState(null),[l,c]=E.useState(()=>localStorage.getItem("printerSortBy")||"name"),[u,f]=E.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,g]=E.useState(()=>localStorage.getItem("printerViewMode")||"expanded"),y=In(),{data:_,isLoading:v}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),{data:x}=Dt({queryKey:["settings"],queryFn:$e.getSettings}),{data:M}=Dt({queryKey:["smart-plugs"],queryFn:$e.getSmartPlugs}),{data:w}=Dt({queryKey:["maintenanceOverview"],queryFn:$e.getMaintenanceOverview,staleTime:60*1e3}),C=w?.reduce((D,B)=>(D[B.printer_id]={due_count:B.due_count,warning_count:B.warning_count,total_print_hours:B.total_print_hours},D),{})||{},T=M?.reduce((D,B)=>(B.printer_id&&(D[B.printer_id]=B),D),{})||{},P=Nt({mutationFn:$e.createPrinter,onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),e(!1)}}),A=Nt({mutationFn:D=>$e.controlSmartPlug(D,"on"),onSuccess:()=>{y.invalidateQueries({queryKey:["smart-plugs"]}),o(null)},onError:()=>{o(null)}}),j=()=>{const D=!n;i(D),localStorage.setItem("hideDisconnectedPrinters",String(D))},N=D=>{c(D),localStorage.setItem("printerSortBy",D)},k=()=>{const D=!u;f(D),localStorage.setItem("printerSortAsc",String(D))},F=()=>{const D=m==="expanded"?"compact":"expanded";g(D),localStorage.setItem("printerViewMode",D)},I=E.useMemo(()=>{if(!_)return[];const D=[..._];switch(l){case"name":D.sort((B,$)=>B.name.localeCompare($.name));break;case"model":D.sort((B,$)=>(B.model||"").localeCompare($.model||""));break;case"location":D.sort((B,$)=>{const K=B.location||"",X=$.location||"";return!K&&X?1:K&&!X?-1:K.localeCompare(X)||B.name.localeCompare($.name)});break;case"status":D.sort((B,$)=>{const K=y.getQueryData(["printerStatus",B.id]),X=y.getQueryData(["printerStatus",$.id]),Y=ee=>ee?.connected?ee.state==="RUNNING"?0:1:2;return Y(K)-Y(X)});break}return u||D.reverse(),D},[_,l,u,y]),W=E.useMemo(()=>{if(l!=="location")return null;const D={};return I.forEach(B=>{const $=B.location||"Ungrouped";D[$]||(D[$]=[]),D[$].push(B)}),D},[l,I]);return h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"flex items-center justify-between mb-6",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),h.jsx(xce,{printers:_})]}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsxs("select",{value:l,onChange:D=>N(D.target.value),className:"text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-2 py-1.5 text-white focus:border-bambu-green focus:outline-none",children:[h.jsx("option",{value:"name",children:"Name"}),h.jsx("option",{value:"status",children:"Status"}),h.jsx("option",{value:"model",children:"Model"}),h.jsx("option",{value:"location",children:"Location"})]}),h.jsx("button",{onClick:k,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:u?"Sort descending":"Sort ascending",children:u?h.jsx(jp,{className:"w-4 h-4 text-bambu-gray"}):h.jsx(Vx,{className:"w-4 h-4 text-bambu-gray"})})]}),h.jsx("button",{onClick:F,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:m==="expanded"?"Switch to compact view":"Switch to expanded view",children:m==="expanded"?h.jsx(toe,{className:"w-5 h-5 text-bambu-gray"}):h.jsx(ZG,{className:"w-5 h-5 text-bambu-gray"})}),h.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),h.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:n,onChange:j,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(T).length>0&&h.jsxs("div",{className:"relative",children:[h.jsxs("button",{onClick:()=>a(!r),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg text-gray-600 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white hover:border-bambu-green transition-colors",children:[h.jsx(Bf,{className:"w-4 h-4"}),"Power On",h.jsx(I0,{className:`w-3 h-3 transition-transform ${r?"rotate-180":""}`})]}),r&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),h.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1",children:[h.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary",children:"Offline printers with smart plugs"}),_?.filter(D=>T[D.id]).map(D=>h.jsx(_ce,{printer:D,plug:T[D.id],onPowerOn:B=>{o(B),A.mutate(B)},isPowering:s===T[D.id]?.id},D.id)),_?.filter(D=>T[D.id]).length===0&&h.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),h.jsxs(Ye,{onClick:()=>e(!0),children:[h.jsx(So,{className:"w-4 h-4"}),"Add Printer"]})]})]}),v?h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):_?.length===0?h.jsx($t,{children:h.jsxs(Qt,{className:"text-center py-12",children:[h.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),h.jsxs(Ye,{onClick:()=>e(!0),children:[h.jsx(So,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):W?h.jsx("div",{className:"space-y-6",children:Object.entries(W).map(([D,B])=>h.jsxs("div",{children:[h.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[h.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),D,h.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",B.length,")"]})]}),h.jsx("div",{className:`grid gap-4 ${m==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:B.map($=>h.jsx(QU,{printer:$,hideIfDisconnected:n,maintenanceInfo:C[$.id],viewMode:m,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},$.id))})]},D))}):h.jsx("div",{className:`grid gap-4 ${m==="compact"?"grid-cols-1 md:grid-cols-2 lg:grid-cols-4":"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"}`,children:I.map(D=>h.jsx(QU,{printer:D,hideIfDisconnected:n,maintenanceInfo:C[D.id],viewMode:m,amsThresholds:x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0},D.id))}),t&&h.jsx(vce,{onClose:()=>e(!1),onAdd:D=>P.mutate(D)})]})}const HP="181",Ep={ROTATE:0,DOLLY:1,PAN:2},vp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},wce=0,JU=1,Mce=2,m9=1,Ece=2,Hl=3,qu=0,ja=1,Ho=2,ac=0,Ap=1,eF=2,tF=3,nF=4,Ace=5,$d=100,Tce=101,Cce=102,Nce=103,Rce=104,Pce=200,kce=201,Dce=202,Oce=203,kN=204,DN=205,Lce=206,Ice=207,jce=208,Uce=209,Fce=210,zce=211,Bce=212,Hce=213,$ce=214,ON=0,LN=1,IN=2,Gp=3,jN=4,UN=5,FN=6,zN=7,$P=0,Vce=1,Gce=2,Uu=0,Wce=1,qce=2,Xce=3,Kce=4,Yce=5,Zce=6,Qce=7,g9=300,Wp=301,qp=302,BN=303,HN=304,JS=306,$N=1e3,Ql=1001,VN=1002,us=1003,Jce=1004,Oy=1005,Bs=1006,jA=1007,Yd=1008,el=1009,x9=1010,v9=1011,Kx=1012,VP=1013,wf=1014,Jl=1015,wm=1016,GP=1017,WP=1018,Yx=1020,y9=35902,b9=35899,_9=1021,S9=1022,go=1023,Zx=1026,Qx=1027,w9=1028,qP=1029,XP=1030,KP=1031,YP=1033,m_=33776,g_=33777,x_=33778,v_=33779,GN=35840,WN=35841,qN=35842,XN=35843,KN=36196,YN=37492,ZN=37496,QN=37808,JN=37809,e3=37810,t3=37811,n3=37812,i3=37813,r3=37814,a3=37815,s3=37816,o3=37817,l3=37818,c3=37819,u3=37820,d3=37821,f3=36492,h3=36494,p3=36495,m3=36283,g3=36284,x3=36285,v3=36286,eue=3200,tue=3201,M9=0,nue=1,Tu="",Ds="srgb",Xp="srgb-linear",W_="linear",Bn="srgb",Th=7680,iF=519,iue=512,rue=513,aue=514,E9=515,sue=516,oue=517,lue=518,cue=519,rF=35044,aF="300 es",Go=2e3,q_=2001;function A9(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function X_(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function uue(){const t=X_("canvas");return t.style.display="block",t}const sF={};function oF(...t){const e="THREE."+t.shift();console.log(e,...t)}function qt(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Di(...t){const e="THREE."+t.shift();console.error(e,...t)}function Jx(...t){const e=t.join(" ");e in sF||(sF[e]=!0,qt(...t))}function due(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 Hf=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 Kr=["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"],y_=Math.PI/180,y3=180/Math.PI;function U0(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Kr[t&255]+Kr[t>>8&255]+Kr[t>>16&255]+Kr[t>>24&255]+"-"+Kr[e&255]+Kr[e>>8&255]+"-"+Kr[e>>16&15|64]+Kr[e>>24&255]+"-"+Kr[n&63|128]+Kr[n>>8&255]+"-"+Kr[n>>16&255]+Kr[n>>24&255]+Kr[i&255]+Kr[i>>8&255]+Kr[i>>16&255]+Kr[i>>24&255]).toLowerCase()}function pn(t,e,n){return Math.max(e,Math.min(n,t))}function fue(t,e){return(t%e+e)%e}function UA(t,e,n){return(1-n)*t+n*e}function Lg(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 Ra(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 hue={DEG2RAD:y_};let sn=class T9{constructor(e=0,n=0){T9.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=pn(this.x,e.x,n.x),this.y=pn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=pn(this.x,e,n),this.y=pn(this.y,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(pn(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(pn(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}},Mf=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],u=i[r+2],f=i[r+3],m=a[s+0],g=a[s+1],y=a[s+2],_=a[s+3];if(o<=0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f;return}if(o>=1){e[n+0]=m,e[n+1]=g,e[n+2]=y,e[n+3]=_;return}if(f!==_||l!==m||c!==g||u!==y){let v=l*m+c*g+u*y+f*_;v<0&&(m=-m,g=-g,y=-y,_=-_,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+m*o,c=c*x+g*o,u=u*x+y*o,f=f*x+_*o}else{l=l*x+m*o,c=c*x+g*o,u=u*x+y*o,f=f*x+_*o;const M=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=M,c*=M,u*=M,f*=M}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f}static multiplyQuaternionsFlat(e,n,i,r,a,s){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],f=a[s],m=a[s+1],g=a[s+2],y=a[s+3];return e[n]=o*y+u*f+l*g-c*m,e[n+1]=l*y+u*m+c*f-o*g,e[n+2]=c*y+u*g+o*m-l*f,e[n+3]=u*y-o*f-l*m-c*g,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),u=o(r/2),f=o(a/2),m=l(i/2),g=l(r/2),y=l(a/2);switch(s){case"XYZ":this._x=m*u*f+c*g*y,this._y=c*g*f-m*u*y,this._z=c*u*y+m*g*f,this._w=c*u*f-m*g*y;break;case"YXZ":this._x=m*u*f+c*g*y,this._y=c*g*f-m*u*y,this._z=c*u*y-m*g*f,this._w=c*u*f+m*g*y;break;case"ZXY":this._x=m*u*f-c*g*y,this._y=c*g*f+m*u*y,this._z=c*u*y+m*g*f,this._w=c*u*f-m*g*y;break;case"ZYX":this._x=m*u*f-c*g*y,this._y=c*g*f+m*u*y,this._z=c*u*y-m*g*f,this._w=c*u*f+m*g*y;break;case"YZX":this._x=m*u*f+c*g*y,this._y=c*g*f+m*u*y,this._z=c*u*y-m*g*f,this._w=c*u*f-m*g*y;break;case"XZY":this._x=m*u*f-c*g*y,this._y=c*g*f-m*u*y,this._z=c*u*y+m*g*f,this._w=c*u*f+m*g*y;break;default:qt("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],u=n[6],f=n[10],m=i+o+f;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(u-l)*g,this._y=(a-c)*g,this._z=(s-r)*g}else if(i>o&&i>f){const g=2*Math.sqrt(1+i-o-f);this._w=(u-l)/g,this._x=.25*g,this._y=(r+s)/g,this._z=(a+c)/g}else if(o>f){const g=2*Math.sqrt(1+o-i-f);this._w=(a-c)/g,this._x=(r+s)/g,this._y=.25*g,this._z=(l+u)/g}else{const g=2*Math.sqrt(1+f-i-o);this._w=(s-r)/g,this._x=(a+c)/g,this._y=(l+u)/g,this._z=.25*g}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(pn(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,u=n._w;return this._x=i*u+s*o+r*c-a*l,this._y=r*u+s*l+a*o-i*c,this._z=a*u+s*c+i*l-r*o,this._w=s*u-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),u=Math.sin(c);l=Math.sin(l*c)/u,n=Math.sin(n*c)/u,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}},Ge=class C9{constructor(e=0,n=0,i=0){C9.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(lF.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(lF.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),u=2*(o*n-a*r),f=2*(a*i-s*n);return this.x=n+l*c+s*f-o*u,this.y=i+l*u+o*c-a*f,this.z=r+l*f+a*u-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=pn(this.x,e.x,n.x),this.y=pn(this.y,e.y,n.y),this.z=pn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=pn(this.x,e,n),this.y=pn(this.y,e,n),this.z=pn(this.z,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(pn(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 FA.copy(this).projectOnVector(e),this.sub(FA)}reflect(e){return this.sub(FA.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(pn(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 FA=new Ge,lF=new Mf;let cn=class N9{constructor(e,n,i,r,a,s,o,l,c){N9.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 u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=n,u[4]=a,u[5]=l,u[6]=i,u[7]=s,u[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],u=i[4],f=i[7],m=i[2],g=i[5],y=i[8],_=r[0],v=r[3],x=r[6],M=r[1],w=r[4],C=r[7],T=r[2],P=r[5],A=r[8];return a[0]=s*_+o*M+l*T,a[3]=s*v+o*w+l*P,a[6]=s*x+o*C+l*A,a[1]=c*_+u*M+f*T,a[4]=c*v+u*w+f*P,a[7]=c*x+u*C+f*A,a[2]=m*_+g*M+y*T,a[5]=m*v+g*w+y*P,a[8]=m*x+g*C+y*A,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],u=e[8];return n*s*u-n*o*c-i*a*u+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],u=e[8],f=u*s-o*c,m=o*l-u*a,g=c*a-s*l,y=n*f+i*m+r*g;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return e[0]=f*_,e[1]=(r*c-u*i)*_,e[2]=(o*i-r*s)*_,e[3]=m*_,e[4]=(u*n-r*l)*_,e[5]=(r*a-o*n)*_,e[6]=g*_,e[7]=(i*l-c*n)*_,e[8]=(s*n-i*a)*_,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(zA.makeScale(e,n)),this}rotate(e){return this.premultiply(zA.makeRotation(-e)),this}translate(e,n){return this.premultiply(zA.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 zA=new cn,cF=new cn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),uF=new cn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pue(){const t={enabled:!0,workingColorSpace:Xp,spaces:{},convert:function(r,a,s){return this.enabled===!1||a===s||!a||!s||(this.spaces[a].transfer===Bn&&(r.r=sc(r.r),r.g=sc(r.g),r.b=sc(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===Bn&&(r.r=Tp(r.r),r.g=Tp(r.g),r.b=Tp(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===Tu?W_: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 Jx("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(r,a)},toWorkingColorSpace:function(r,a){return Jx("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({[Xp]:{primaries:e,whitePoint:i,transfer:W_,toXYZ:cF,fromXYZ:uF,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ds},outputColorSpaceConfig:{drawingBufferColorSpace:Ds}},[Ds]:{primaries:e,whitePoint:i,transfer:Bn,toXYZ:cF,fromXYZ:uF,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ds}}}),t}const En=pue();function sc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Tp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Ch,mue=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{Ch===void 0&&(Ch=X_("canvas")),Ch.width=e.width,Ch.height=e.height;const r=Ch.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=Ch}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=X_("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]=sc(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(sc(n[i]/255)*255):n[i]=sc(n[i]);return{data:n,width:e.width,height:e.height}}else return qt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},gue=0,ZP=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:gue++}),this.uuid=U0(),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(BA(r[s].image)):a.push(BA(r[s]))}else a=BA(r);i.url=a}return n||(e.images[this.uuid]=i),i}};function BA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?mue.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(qt("Texture: Unable to serialize Texture."),{})}let xue=0;const HA=new Ge;let To=class b_ extends Hf{constructor(e=b_.DEFAULT_IMAGE,n=b_.DEFAULT_MAPPING,i=Ql,r=Ql,a=Bs,s=Yd,o=go,l=el,c=b_.DEFAULT_ANISOTROPY,u=Tu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xue++}),this.uuid=U0(),this.name="",this.source=new ZP(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 sn(0,0),this.repeat=new sn(1,1),this.center=new sn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new cn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,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(HA).x}get height(){return this.source.getSize(HA).y}get depth(){return this.source.getSize(HA).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){qt(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){qt(`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!==g9)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case $N:e.x=e.x-Math.floor(e.x);break;case Ql:e.x=e.x<0?0:1;break;case VN: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 $N:e.y=e.y-Math.floor(e.y);break;case Ql:e.y=e.y<0?0:1;break;case VN: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++}};To.DEFAULT_IMAGE=null;To.DEFAULT_MAPPING=g9;To.DEFAULT_ANISOTROPY=1;let Vi=class R9{constructor(e=0,n=0,i=0,r=1){R9.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],u=l[4],f=l[8],m=l[1],g=l[5],y=l[9],_=l[2],v=l[6],x=l[10];if(Math.abs(u-m)<.01&&Math.abs(f-_)<.01&&Math.abs(y-v)<.01){if(Math.abs(u+m)<.1&&Math.abs(f+_)<.1&&Math.abs(y+v)<.1&&Math.abs(c+g+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,C=(g+1)/2,T=(x+1)/2,P=(u+m)/4,A=(f+_)/4,j=(y+v)/4;return w>C&&w>T?w<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(w),r=P/i,a=A/i):C>T?C<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(C),i=P/r,a=j/r):T<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(T),i=A/a,r=j/a),this.set(i,r,a,n),this}let M=Math.sqrt((v-y)*(v-y)+(f-_)*(f-_)+(m-u)*(m-u));return Math.abs(M)<.001&&(M=1),this.x=(v-y)/M,this.y=(f-_)/M,this.z=(m-u)/M,this.w=Math.acos((c+g+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=pn(this.x,e.x,n.x),this.y=pn(this.y,e.y,n.y),this.z=pn(this.z,e.z,n.z),this.w=pn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=pn(this.x,e,n),this.y=pn(this.y,e,n),this.z=pn(this.z,e,n),this.w=pn(this.w,e,n),this}clampLength(e,n){const i=this.length();return this.divideScalar(i||1).multiplyScalar(pn(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}},vue=class extends Hf{constructor(e=1,n=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bs,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 Vi(0,0,e,n),this.scissorTest=!1,this.viewport=new Vi(0,0,e,n);const r={width:e,height:n,depth:i.depth},a=new To(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:Bs,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 ZP(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"})}},Ef=class extends vue{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}},P9=class extends To{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=us,this.minFilter=us,this.wrapR=Ql,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},yue=class extends To{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=us,this.minFilter=us,this.wrapR=Ql,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Af=class{constructor(e=new Ge(1/0,1/0,1/0),n=new Ge(-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(),Ly.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ly.copy(i.boundingBox)),Ly.applyMatrix4(e.matrixWorld),this.union(Ly)}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(Ig),Iy.subVectors(this.max,Ig),Nh.subVectors(e.a,Ig),Rh.subVectors(e.b,Ig),Ph.subVectors(e.c,Ig),ru.subVectors(Rh,Nh),au.subVectors(Ph,Rh),Td.subVectors(Nh,Ph);let n=[0,-ru.z,ru.y,0,-au.z,au.y,0,-Td.z,Td.y,ru.z,0,-ru.x,au.z,0,-au.x,Td.z,0,-Td.x,-ru.y,ru.x,0,-au.y,au.x,0,-Td.y,Td.x,0];return!$A(n,Nh,Rh,Ph,Iy)||(n=[1,0,0,0,1,0,0,0,1],!$A(n,Nh,Rh,Ph,Iy))?!1:(jy.crossVectors(ru,au),n=[jy.x,jy.y,jy.z],$A(n,Nh,Rh,Ph,Iy))}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:(Cl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Cl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Cl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Cl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Cl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Cl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Cl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Cl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Cl),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 Cl=[new Ge,new Ge,new Ge,new Ge,new Ge,new Ge,new Ge,new Ge],io=new Ge,Ly=new Af,Nh=new Ge,Rh=new Ge,Ph=new Ge,ru=new Ge,au=new Ge,Td=new Ge,Ig=new Ge,Iy=new Ge,jy=new Ge,Cd=new Ge;function $A(t,e,n,i,r){for(let a=0,s=t.length-3;a<=s;a+=3){Cd.fromArray(t,a);const o=r.x*Math.abs(Cd.x)+r.y*Math.abs(Cd.y)+r.z*Math.abs(Cd.z),l=e.dot(Cd),c=n.dot(Cd),u=i.dot(Cd);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const bue=new Af,jg=new Ge,VA=new Ge;let ew=class{constructor(e=new Ge,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):bue.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;jg.subVectors(e,this.center);const n=jg.lengthSq();if(n>this.radius*this.radius){const i=Math.sqrt(n),r=(i-this.radius)*.5;this.center.addScaledVector(jg,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):(VA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(jg.copy(e.center).add(VA)),this.expandByPoint(jg.copy(e.center).sub(VA))),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 Nl=new Ge,GA=new Ge,Uy=new Ge,su=new Ge,WA=new Ge,Fy=new Ge,qA=new Ge;let QP=class{constructor(e=new Ge,n=new Ge(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,Nl)),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=Nl.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Nl.copy(this.origin).addScaledVector(this.direction,n),Nl.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){GA.copy(e).add(n).multiplyScalar(.5),Uy.copy(n).sub(e).normalize(),su.copy(this.origin).sub(GA);const a=e.distanceTo(n)*.5,s=-this.direction.dot(Uy),o=su.dot(this.direction),l=-su.dot(Uy),c=su.lengthSq(),u=Math.abs(1-s*s);let f,m,g,y;if(u>0)if(f=s*l-o,m=s*o-l,y=a*u,f>=0)if(m>=-y)if(m<=y){const _=1/u;f*=_,m*=_,g=f*(f+s*m+2*o)+m*(s*f+m+2*l)+c}else m=a,f=Math.max(0,-(s*m+o)),g=-f*f+m*(m+2*l)+c;else m=-a,f=Math.max(0,-(s*m+o)),g=-f*f+m*(m+2*l)+c;else m<=-y?(f=Math.max(0,-(-s*a+o)),m=f>0?-a:Math.min(Math.max(-a,-l),a),g=-f*f+m*(m+2*l)+c):m<=y?(f=0,m=Math.min(Math.max(-a,-l),a),g=m*(m+2*l)+c):(f=Math.max(0,-(s*a+o)),m=f>0?a:Math.min(Math.max(-a,-l),a),g=-f*f+m*(m+2*l)+c);else m=s>0?-a:a,f=Math.max(0,-(s*m+o)),g=-f*f+m*(m+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(GA).addScaledVector(Uy,m),g}intersectSphere(e,n){Nl.subVectors(e.center,this.origin);const i=Nl.dot(this.direction),r=Nl.dot(Nl)-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,u=1/this.direction.y,f=1/this.direction.z,m=this.origin;return c>=0?(i=(e.min.x-m.x)*c,r=(e.max.x-m.x)*c):(i=(e.max.x-m.x)*c,r=(e.min.x-m.x)*c),u>=0?(a=(e.min.y-m.y)*u,s=(e.max.y-m.y)*u):(a=(e.max.y-m.y)*u,s=(e.min.y-m.y)*u),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-m.z)*f,l=(e.max.z-m.z)*f):(o=(e.max.z-m.z)*f,l=(e.min.z-m.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,Nl)!==null}intersectTriangle(e,n,i,r,a){WA.subVectors(n,e),Fy.subVectors(i,e),qA.crossVectors(WA,Fy);let s=this.direction.dot(qA),o;if(s>0){if(r)return null;o=1}else if(s<0)o=-1,s=-s;else return null;su.subVectors(this.origin,e);const l=o*this.direction.dot(Fy.crossVectors(su,Fy));if(l<0)return null;const c=o*this.direction.dot(WA.cross(su));if(c<0||l+c>s)return null;const u=-o*su.dot(qA);return u<0?null:this.at(u/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)}},Xi=class b3{constructor(e,n,i,r,a,s,o,l,c,u,f,m,g,y,_,v){b3.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,u,f,m,g,y,_,v)}set(e,n,i,r,a,s,o,l,c,u,f,m,g,y,_,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]=u,x[10]=f,x[14]=m,x[3]=g,x[7]=y,x[11]=_,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 b3().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/kh.setFromMatrixColumn(e,0).length(),a=1/kh.setFromMatrixColumn(e,1).length(),s=1/kh.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),u=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const m=s*u,g=s*f,y=o*u,_=o*f;n[0]=l*u,n[4]=-l*f,n[8]=c,n[1]=g+y*c,n[5]=m-_*c,n[9]=-o*l,n[2]=_-m*c,n[6]=y+g*c,n[10]=s*l}else if(e.order==="YXZ"){const m=l*u,g=l*f,y=c*u,_=c*f;n[0]=m+_*o,n[4]=y*o-g,n[8]=s*c,n[1]=s*f,n[5]=s*u,n[9]=-o,n[2]=g*o-y,n[6]=_+m*o,n[10]=s*l}else if(e.order==="ZXY"){const m=l*u,g=l*f,y=c*u,_=c*f;n[0]=m-_*o,n[4]=-s*f,n[8]=y+g*o,n[1]=g+y*o,n[5]=s*u,n[9]=_-m*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const m=s*u,g=s*f,y=o*u,_=o*f;n[0]=l*u,n[4]=y*c-g,n[8]=m*c+_,n[1]=l*f,n[5]=_*c+m,n[9]=g*c-y,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const m=s*l,g=s*c,y=o*l,_=o*c;n[0]=l*u,n[4]=_-m*f,n[8]=y*f+g,n[1]=f,n[5]=s*u,n[9]=-o*u,n[2]=-c*u,n[6]=g*f+y,n[10]=m-_*f}else if(e.order==="XZY"){const m=s*l,g=s*c,y=o*l,_=o*c;n[0]=l*u,n[4]=-f,n[8]=c*u,n[1]=m*f+_,n[5]=s*u,n[9]=g*f-y,n[2]=y*f-g,n[6]=o*u,n[10]=_*f+m}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(_ue,e,Sue)}lookAt(e,n,i){const r=this.elements;return Ja.subVectors(e,n),Ja.lengthSq()===0&&(Ja.z=1),Ja.normalize(),ou.crossVectors(i,Ja),ou.lengthSq()===0&&(Math.abs(i.z)===1?Ja.x+=1e-4:Ja.z+=1e-4,Ja.normalize(),ou.crossVectors(i,Ja)),ou.normalize(),zy.crossVectors(Ja,ou),r[0]=ou.x,r[4]=zy.x,r[8]=Ja.x,r[1]=ou.y,r[5]=zy.y,r[9]=Ja.y,r[2]=ou.z,r[6]=zy.z,r[10]=Ja.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],u=i[1],f=i[5],m=i[9],g=i[13],y=i[2],_=i[6],v=i[10],x=i[14],M=i[3],w=i[7],C=i[11],T=i[15],P=r[0],A=r[4],j=r[8],N=r[12],k=r[1],F=r[5],I=r[9],W=r[13],D=r[2],B=r[6],$=r[10],K=r[14],X=r[3],Y=r[7],ee=r[11],z=r[15];return a[0]=s*P+o*k+l*D+c*X,a[4]=s*A+o*F+l*B+c*Y,a[8]=s*j+o*I+l*$+c*ee,a[12]=s*N+o*W+l*K+c*z,a[1]=u*P+f*k+m*D+g*X,a[5]=u*A+f*F+m*B+g*Y,a[9]=u*j+f*I+m*$+g*ee,a[13]=u*N+f*W+m*K+g*z,a[2]=y*P+_*k+v*D+x*X,a[6]=y*A+_*F+v*B+x*Y,a[10]=y*j+_*I+v*$+x*ee,a[14]=y*N+_*W+v*K+x*z,a[3]=M*P+w*k+C*D+T*X,a[7]=M*A+w*F+C*B+T*Y,a[11]=M*j+w*I+C*$+T*ee,a[15]=M*N+w*W+C*K+T*z,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],u=e[2],f=e[6],m=e[10],g=e[14],y=e[3],_=e[7],v=e[11],x=e[15];return y*(+a*l*f-r*c*f-a*o*m+i*c*m+r*o*g-i*l*g)+_*(+n*l*g-n*c*m+a*s*m-r*s*g+r*c*u-a*l*u)+v*(+n*c*f-n*o*g-a*s*f+i*s*g+a*o*u-i*c*u)+x*(-r*o*u-n*l*f+n*o*m+r*s*f-i*s*m+i*l*u)}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],u=e[8],f=e[9],m=e[10],g=e[11],y=e[12],_=e[13],v=e[14],x=e[15],M=f*v*c-_*m*c+_*l*g-o*v*g-f*l*x+o*m*x,w=y*m*c-u*v*c-y*l*g+s*v*g+u*l*x-s*m*x,C=u*_*c-y*f*c+y*o*g-s*_*g-u*o*x+s*f*x,T=y*f*l-u*_*l-y*o*m+s*_*m+u*o*v-s*f*v,P=n*M+i*w+r*C+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 A=1/P;return e[0]=M*A,e[1]=(_*m*a-f*v*a-_*r*g+i*v*g+f*r*x-i*m*x)*A,e[2]=(o*v*a-_*l*a+_*r*c-i*v*c-o*r*x+i*l*x)*A,e[3]=(f*l*a-o*m*a-f*r*c+i*m*c+o*r*g-i*l*g)*A,e[4]=w*A,e[5]=(u*v*a-y*m*a+y*r*g-n*v*g-u*r*x+n*m*x)*A,e[6]=(y*l*a-s*v*a-y*r*c+n*v*c+s*r*x-n*l*x)*A,e[7]=(s*m*a-u*l*a+u*r*c-n*m*c-s*r*g+n*l*g)*A,e[8]=C*A,e[9]=(y*f*a-u*_*a-y*i*g+n*_*g+u*i*x-n*f*x)*A,e[10]=(s*_*a-y*o*a+y*i*c-n*_*c-s*i*x+n*o*x)*A,e[11]=(u*o*a-s*f*a-u*i*c+n*f*c+s*i*g-n*o*g)*A,e[12]=T*A,e[13]=(u*_*r-y*f*r+y*i*m-n*_*m-u*i*v+n*f*v)*A,e[14]=(y*o*r-s*_*r-y*i*l+n*_*l+s*i*v-n*o*v)*A,e[15]=(s*f*r-u*o*r+u*i*l-n*f*l-s*i*m+n*o*m)*A,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,u=a*o;return this.set(c*s+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*s,0,c*l-r*o,u*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,u=s+s,f=o+o,m=a*c,g=a*u,y=a*f,_=s*u,v=s*f,x=o*f,M=l*c,w=l*u,C=l*f,T=i.x,P=i.y,A=i.z;return r[0]=(1-(_+x))*T,r[1]=(g+C)*T,r[2]=(y-w)*T,r[3]=0,r[4]=(g-C)*P,r[5]=(1-(m+x))*P,r[6]=(v+M)*P,r[7]=0,r[8]=(y+w)*A,r[9]=(v-M)*A,r[10]=(1-(m+_))*A,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=kh.set(r[0],r[1],r[2]).length();const s=kh.set(r[4],r[5],r[6]).length(),o=kh.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,u=1/s,f=1/o;return ro.elements[0]*=c,ro.elements[1]*=c,ro.elements[2]*=c,ro.elements[4]*=u,ro.elements[5]*=u,ro.elements[6]*=u,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=Go,l=!1){const c=this.elements,u=2*a/(n-e),f=2*a/(i-r),m=(n+e)/(n-e),g=(i+r)/(i-r);let y,_;if(l)y=a/(s-a),_=s*a/(s-a);else if(o===Go)y=-(s+a)/(s-a),_=-2*s*a/(s-a);else if(o===q_)y=-s/(s-a),_=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=m,c[12]=0,c[1]=0,c[5]=f,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=y,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,i,r,a,s,o=Go,l=!1){const c=this.elements,u=2/(n-e),f=2/(i-r),m=-(n+e)/(n-e),g=-(i+r)/(i-r);let y,_;if(l)y=1/(s-a),_=s/(s-a);else if(o===Go)y=-2/(s-a),_=-(s+a)/(s-a);else if(o===q_)y=-1/(s-a),_=-a/(s-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=m,c[1]=0,c[5]=f,c[9]=0,c[13]=g,c[2]=0,c[6]=0,c[10]=y,c[14]=_,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 kh=new Ge,ro=new Xi,_ue=new Ge(0,0,0),Sue=new Ge(1,1,1),ou=new Ge,zy=new Ge,Ja=new Ge,dF=new Xi,fF=new Mf;let Xu=class k9{constructor(e=0,n=0,i=0,r=k9.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],u=r[9],f=r[2],m=r[6],g=r[10];switch(n){case"XYZ":this._y=Math.asin(pn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,g),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(m,c),this._z=0);break;case"YXZ":this._x=Math.asin(-pn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(pn(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-pn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(pn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-pn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(m,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-u,g),this._y=0);break;default:qt("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,i){return dF.makeRotationFromQuaternion(e),this.setFromRotationMatrix(dF,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return fF.setFromEuler(this),this.setFromQuaternion(fF,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}};Xu.DEFAULT_ORDER="XYZ";let D9=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}},wue=0;const hF=new Ge,Dh=new Mf,Rl=new Xi,By=new Ge,Ug=new Ge,Mue=new Ge,Eue=new Mf,pF=new Ge(1,0,0),mF=new Ge(0,1,0),gF=new Ge(0,0,1),xF={type:"added"},Aue={type:"removed"},Oh={type:"childadded",child:null},XA={type:"childremoved",child:null};let ps=class __ extends Hf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:wue++}),this.uuid=U0(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=__.DEFAULT_UP.clone();const e=new Ge,n=new Xu,i=new Mf,r=new Ge(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 Xi},normalMatrix:{value:new cn}}),this.matrix=new Xi,this.matrixWorld=new Xi,this.matrixAutoUpdate=__.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=__.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new D9,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 Dh.setFromAxisAngle(e,n),this.quaternion.multiply(Dh),this}rotateOnWorldAxis(e,n){return Dh.setFromAxisAngle(e,n),this.quaternion.premultiply(Dh),this}rotateX(e){return this.rotateOnAxis(pF,e)}rotateY(e){return this.rotateOnAxis(mF,e)}rotateZ(e){return this.rotateOnAxis(gF,e)}translateOnAxis(e,n){return hF.copy(e).applyQuaternion(this.quaternion),this.position.add(hF.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(pF,e)}translateY(e){return this.translateOnAxis(mF,e)}translateZ(e){return this.translateOnAxis(gF,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Rl.copy(this.matrixWorld).invert())}lookAt(e,n,i){e.isVector3?By.copy(e):By.set(e,n,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Ug.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Rl.lookAt(Ug,By,this.up):Rl.lookAt(By,Ug,this.up),this.quaternion.setFromRotationMatrix(Rl),r&&(Rl.extractRotation(r.matrixWorld),Dh.setFromRotationMatrix(Rl),this.quaternion.premultiply(Dh.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Di("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(xF),Oh.child=e,this.dispatchEvent(Oh),Oh.child=null):Di("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(Aue),XA.child=e,this.dispatchEvent(XA),XA.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),Rl.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Rl.multiply(e.parent.matrixWorld)),e.applyMatrix4(Rl),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(xF),Oh.child=e,this.dispatchEvent(Oh),Oh.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(Ug,e,Mue),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ug,Eue,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,u=l.length;c<u;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),u=s(e.images),f=s(e.shapes),m=s(e.skeletons),g=s(e.animations),y=s(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),f.length>0&&(i.shapes=f),m.length>0&&(i.skeletons=m),g.length>0&&(i.animations=g),y.length>0&&(i.nodes=y)}return i.object=r,i;function s(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}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}};ps.DEFAULT_UP=new Ge(0,1,0);ps.DEFAULT_MATRIX_AUTO_UPDATE=!0;ps.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ao=new Ge,Pl=new Ge,KA=new Ge,kl=new Ge,Lh=new Ge,Ih=new Ge,vF=new Ge,YA=new Ge,ZA=new Ge,QA=new Ge,JA=new Vi,eT=new Vi,tT=new Vi;let Fg=class dp{constructor(e=new Ge,n=new Ge,i=new Ge){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),Pl.subVectors(i,n),KA.subVectors(e,n);const s=ao.dot(ao),o=ao.dot(Pl),l=ao.dot(KA),c=Pl.dot(Pl),u=Pl.dot(KA),f=s*c-o*o;if(f===0)return a.set(0,0,0),null;const m=1/f,g=(c*l-o*u)*m,y=(s*u-o*l)*m;return a.set(1-g-y,y,g)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,kl)===null?!1:kl.x>=0&&kl.y>=0&&kl.x+kl.y<=1}static getInterpolation(e,n,i,r,a,s,o,l){return this.getBarycoord(e,n,i,r,kl)===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,kl.x),l.addScaledVector(s,kl.y),l.addScaledVector(o,kl.z),l)}static getInterpolatedAttribute(e,n,i,r,a,s){return JA.setScalar(0),eT.setScalar(0),tT.setScalar(0),JA.fromBufferAttribute(e,n),eT.fromBufferAttribute(e,i),tT.fromBufferAttribute(e,r),s.setScalar(0),s.addScaledVector(JA,a.x),s.addScaledVector(eT,a.y),s.addScaledVector(tT,a.z),s}static isFrontFacing(e,n,i,r){return ao.subVectors(i,n),Pl.subVectors(e,n),ao.cross(Pl).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),Pl.subVectors(this.a,this.b),ao.cross(Pl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return dp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return dp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,i,r,a){return dp.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}containsPoint(e){return dp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dp.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;Lh.subVectors(r,i),Ih.subVectors(a,i),YA.subVectors(e,i);const l=Lh.dot(YA),c=Ih.dot(YA);if(l<=0&&c<=0)return n.copy(i);ZA.subVectors(e,r);const u=Lh.dot(ZA),f=Ih.dot(ZA);if(u>=0&&f<=u)return n.copy(r);const m=l*f-u*c;if(m<=0&&l>=0&&u<=0)return s=l/(l-u),n.copy(i).addScaledVector(Lh,s);QA.subVectors(e,a);const g=Lh.dot(QA),y=Ih.dot(QA);if(y>=0&&g<=y)return n.copy(a);const _=g*c-l*y;if(_<=0&&c>=0&&y<=0)return o=c/(c-y),n.copy(i).addScaledVector(Ih,o);const v=u*y-g*f;if(v<=0&&f-u>=0&&g-y>=0)return vF.subVectors(a,r),o=(f-u)/(f-u+(g-y)),n.copy(r).addScaledVector(vF,o);const x=1/(v+_+m);return s=_*x,o=m*x,n.copy(i).addScaledVector(Lh,s).addScaledVector(Ih,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const O9={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},lu={h:0,s:0,l:0},Hy={h:0,s:0,l:0};function nT(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 vn=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=Ds){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,En.colorSpaceToWorking(this,n),this}setRGB(e,n,i,r=En.workingColorSpace){return this.r=e,this.g=n,this.b=i,En.colorSpaceToWorking(this,r),this}setHSL(e,n,i,r=En.workingColorSpace){if(e=fue(e,1),n=pn(n,0,1),i=pn(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=nT(s,a,e+1/3),this.g=nT(s,a,e),this.b=nT(s,a,e-1/3)}return En.colorSpaceToWorking(this,r),this}setStyle(e,n=Ds){function i(a){a!==void 0&&parseFloat(a)<1&&qt("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:qt("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);qt("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Ds){const i=O9[e.toLowerCase()];return i!==void 0?this.setHex(i,n):qt("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=sc(e.r),this.g=sc(e.g),this.b=sc(e.b),this}copyLinearToSRGB(e){return this.r=Tp(e.r),this.g=Tp(e.g),this.b=Tp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ds){return En.workingToColorSpace(Yr.copy(this),e),Math.round(pn(Yr.r*255,0,255))*65536+Math.round(pn(Yr.g*255,0,255))*256+Math.round(pn(Yr.b*255,0,255))}getHexString(e=Ds){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=En.workingColorSpace){En.workingToColorSpace(Yr.copy(this),n);const i=Yr.r,r=Yr.g,a=Yr.b,s=Math.max(i,r,a),o=Math.min(i,r,a);let l,c;const u=(o+s)/2;if(o===s)l=0,c=0;else{const f=s-o;switch(c=u<=.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=u,e}getRGB(e,n=En.workingColorSpace){return En.workingToColorSpace(Yr.copy(this),n),e.r=Yr.r,e.g=Yr.g,e.b=Yr.b,e}getStyle(e=Ds){En.workingToColorSpace(Yr.copy(this),e);const n=Yr.r,i=Yr.g,r=Yr.b;return e!==Ds?`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(lu),this.setHSL(lu.h+e,lu.s+n,lu.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(lu),e.getHSL(Hy);const i=UA(lu.h,Hy.h,n),r=UA(lu.s,Hy.s,n),a=UA(lu.l,Hy.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 Yr=new vn;vn.NAMES=O9;let Tue=0,Mm=class extends Hf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Tue++}),this.uuid=U0(),this.name="",this.type="Material",this.blending=Ap,this.side=qu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=kN,this.blendDst=DN,this.blendEquation=$d,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new vn(0,0,0),this.blendAlpha=0,this.depthFunc=Gp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=iF,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Th,this.stencilZFail=Th,this.stencilZPass=Th,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){qt(`Material: parameter '${n}' has value of undefined.`);continue}const r=this[n];if(r===void 0){qt(`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!==Ap&&(i.blending=this.blending),this.side!==qu&&(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!==kN&&(i.blendSrc=this.blendSrc),this.blendDst!==DN&&(i.blendDst=this.blendDst),this.blendEquation!==$d&&(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!==Gp&&(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!==iF&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Th&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Th&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Th&&(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++}},JP=class extends Mm{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vn(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 Xu,this.combine=$P,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 Bi=new Ge,$y=new sn;let Cue=0,$s=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:Cue++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=i,this.usage=rF,this.updateRanges=[],this.gpuType=Jl,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++)$y.fromBufferAttribute(this,n),$y.applyMatrix3(e),this.setXY(n,$y.x,$y.y);else if(this.itemSize===3)for(let n=0,i=this.count;n<i;n++)Bi.fromBufferAttribute(this,n),Bi.applyMatrix3(e),this.setXYZ(n,Bi.x,Bi.y,Bi.z);return this}applyMatrix4(e){for(let n=0,i=this.count;n<i;n++)Bi.fromBufferAttribute(this,n),Bi.applyMatrix4(e),this.setXYZ(n,Bi.x,Bi.y,Bi.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)Bi.fromBufferAttribute(this,n),Bi.applyNormalMatrix(e),this.setXYZ(n,Bi.x,Bi.y,Bi.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)Bi.fromBufferAttribute(this,n),Bi.transformDirection(e),this.setXYZ(n,Bi.x,Bi.y,Bi.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=Lg(i,this.array)),i}setComponent(e,n,i){return this.normalized&&(i=Ra(i,this.array)),this.array[e*this.itemSize+n]=i,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Lg(n,this.array)),n}setX(e,n){return this.normalized&&(n=Ra(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Lg(n,this.array)),n}setY(e,n){return this.normalized&&(n=Ra(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=Lg(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Ra(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=Lg(n,this.array)),n}setW(e,n){return this.normalized&&(n=Ra(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,i){return e*=this.itemSize,this.normalized&&(n=Ra(n,this.array),i=Ra(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=Ra(n,this.array),i=Ra(i,this.array),r=Ra(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=Ra(n,this.array),i=Ra(i,this.array),r=Ra(r,this.array),a=Ra(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!==rF&&(e.usage=this.usage),e}},L9=class extends $s{constructor(e,n,i){super(new Uint16Array(e),n,i)}},I9=class extends $s{constructor(e,n,i){super(new Uint32Array(e),n,i)}},yo=class extends $s{constructor(e,n,i){super(new Float32Array(e),n,i)}},Nue=0;const Ms=new Xi,iT=new ps,jh=new Ge,es=new Af,zg=new Af,br=new Ge;let cl=class j9 extends Hf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Nue++}),this.uuid=U0(),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(A9(e)?I9:L9)(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 cn().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 Ms.makeRotationFromQuaternion(e),this.applyMatrix4(Ms),this}rotateX(e){return Ms.makeRotationX(e),this.applyMatrix4(Ms),this}rotateY(e){return Ms.makeRotationY(e),this.applyMatrix4(Ms),this}rotateZ(e){return Ms.makeRotationZ(e),this.applyMatrix4(Ms),this}translate(e,n,i){return Ms.makeTranslation(e,n,i),this.applyMatrix4(Ms),this}scale(e,n,i){return Ms.makeScale(e,n,i),this.applyMatrix4(Ms),this}lookAt(e){return iT.lookAt(e),iT.updateMatrix(),this.applyMatrix4(iT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(jh).negate(),this.translate(jh.x,jh.y,jh.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 yo(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&&qt("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 Af);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Di("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Ge(-1/0,-1/0,-1/0),new Ge(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];es.setFromBufferAttribute(a),this.morphTargetsRelative?(br.addVectors(this.boundingBox.min,es.min),this.boundingBox.expandByPoint(br),br.addVectors(this.boundingBox.max,es.max),this.boundingBox.expandByPoint(br)):(this.boundingBox.expandByPoint(es.min),this.boundingBox.expandByPoint(es.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Di('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 ew);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Di("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Ge,1/0);return}if(e){const i=this.boundingSphere.center;if(es.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];zg.setFromBufferAttribute(o),this.morphTargetsRelative?(br.addVectors(es.min,zg.min),es.expandByPoint(br),br.addVectors(es.max,zg.max),es.expandByPoint(br)):(es.expandByPoint(zg.min),es.expandByPoint(zg.max))}es.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)br.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(br));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)br.fromBufferAttribute(o,c),l&&(jh.fromBufferAttribute(e,c),br.add(jh)),r=Math.max(r,i.distanceToSquared(br))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Di('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){Di("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 $s(new Float32Array(4*i.count),4));const s=this.getAttribute("tangent"),o=[],l=[];for(let j=0;j<i.count;j++)o[j]=new Ge,l[j]=new Ge;const c=new Ge,u=new Ge,f=new Ge,m=new sn,g=new sn,y=new sn,_=new Ge,v=new Ge;function x(j,N,k){c.fromBufferAttribute(i,j),u.fromBufferAttribute(i,N),f.fromBufferAttribute(i,k),m.fromBufferAttribute(a,j),g.fromBufferAttribute(a,N),y.fromBufferAttribute(a,k),u.sub(c),f.sub(c),g.sub(m),y.sub(m);const F=1/(g.x*y.y-y.x*g.y);isFinite(F)&&(_.copy(u).multiplyScalar(y.y).addScaledVector(f,-g.y).multiplyScalar(F),v.copy(f).multiplyScalar(g.x).addScaledVector(u,-y.x).multiplyScalar(F),o[j].add(_),o[N].add(_),o[k].add(_),l[j].add(v),l[N].add(v),l[k].add(v))}let M=this.groups;M.length===0&&(M=[{start:0,count:e.count}]);for(let j=0,N=M.length;j<N;++j){const k=M[j],F=k.start,I=k.count;for(let W=F,D=F+I;W<D;W+=3)x(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const w=new Ge,C=new Ge,T=new Ge,P=new Ge;function A(j){T.fromBufferAttribute(r,j),P.copy(T);const N=o[j];w.copy(N),w.sub(T.multiplyScalar(T.dot(N))).normalize(),C.crossVectors(P,N);const F=C.dot(l[j])<0?-1:1;s.setXYZW(j,w.x,w.y,w.z,F)}for(let j=0,N=M.length;j<N;++j){const k=M[j],F=k.start,I=k.count;for(let W=F,D=F+I;W<D;W+=3)A(e.getX(W+0)),A(e.getX(W+1)),A(e.getX(W+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 $s(new Float32Array(n.count*3),3),this.setAttribute("normal",i);else for(let m=0,g=i.count;m<g;m++)i.setXYZ(m,0,0,0);const r=new Ge,a=new Ge,s=new Ge,o=new Ge,l=new Ge,c=new Ge,u=new Ge,f=new Ge;if(e)for(let m=0,g=e.count;m<g;m+=3){const y=e.getX(m+0),_=e.getX(m+1),v=e.getX(m+2);r.fromBufferAttribute(n,y),a.fromBufferAttribute(n,_),s.fromBufferAttribute(n,v),u.subVectors(s,a),f.subVectors(r,a),u.cross(f),o.fromBufferAttribute(i,y),l.fromBufferAttribute(i,_),c.fromBufferAttribute(i,v),o.add(u),l.add(u),c.add(u),i.setXYZ(y,o.x,o.y,o.z),i.setXYZ(_,l.x,l.y,l.z),i.setXYZ(v,c.x,c.y,c.z)}else for(let m=0,g=n.count;m<g;m+=3)r.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),s.fromBufferAttribute(n,m+2),u.subVectors(s,a),f.subVectors(r,a),u.cross(f),i.setXYZ(m+0,u.x,u.y,u.z),i.setXYZ(m+1,u.x,u.y,u.z),i.setXYZ(m+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,i=e.count;n<i;n++)br.fromBufferAttribute(e,n),br.normalize(),e.setXYZ(n,br.x,br.y,br.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,f=o.normalized,m=new c.constructor(l.length*u);let g=0,y=0;for(let _=0,v=l.length;_<v;_++){o.isInterleavedBufferAttribute?g=l[_]*o.data.stride+o.offset:g=l[_]*u;for(let x=0;x<u;x++)m[y++]=c[g++]}return new $s(m,u,f)}if(this.index===null)return qt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new j9,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 u=0,f=c.length;u<f;u++){const m=c[u],g=e(m,i);l.push(g)}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],u=[];for(let f=0,m=c.length;f<m;f++){const g=c[f];u.push(g.toJSON(e.data))}u.length>0&&(r[l]=u,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 u=r[c];this.setAttribute(c,u.clone(n))}const a=e.morphAttributes;for(const c in a){const u=[],f=a[c];for(let m=0,g=f.length;m<g;m++)u.push(f[m].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,u=s.length;c<u;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 yF=new Xi,Nd=new QP,Vy=new ew,bF=new Ge,Gy=new Ge,Wy=new Ge,qy=new Ge,rT=new Ge,Xy=new Ge,_F=new Ge,Ky=new Ge;let tl=class extends ps{constructor(e=new cl,n=new JP){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){Xy.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const u=o[l],f=a[l];u!==0&&(rT.fromBufferAttribute(f,e),s?Xy.addScaledVector(rT,u):Xy.addScaledVector(rT.sub(n),u))}n.add(Xy)}return n}raycast(e,n){const i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Vy.copy(i.boundingSphere),Vy.applyMatrix4(a),Nd.copy(e.ray).recast(e.near),!(Vy.containsPoint(Nd.origin)===!1&&(Nd.intersectSphere(Vy,bF)===null||Nd.origin.distanceToSquared(bF)>(e.far-e.near)**2))&&(yF.copy(a).invert(),Nd.copy(e.ray).applyMatrix4(yF),!(i.boundingBox!==null&&Nd.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,n,Nd)))}_computeIntersections(e,n,i){let r;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,u=a.attributes.uv1,f=a.attributes.normal,m=a.groups,g=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,_=m.length;y<_;y++){const v=m[y],x=s[v.materialIndex],M=Math.max(v.start,g.start),w=Math.min(o.count,Math.min(v.start+v.count,g.start+g.count));for(let C=M,T=w;C<T;C+=3){const P=o.getX(C),A=o.getX(C+1),j=o.getX(C+2);r=Yy(this,x,e,i,c,u,f,P,A,j),r&&(r.faceIndex=Math.floor(C/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const y=Math.max(0,g.start),_=Math.min(o.count,g.start+g.count);for(let v=y,x=_;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),C=o.getX(v+2);r=Yy(this,s,e,i,c,u,f,M,w,C),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}else if(l!==void 0)if(Array.isArray(s))for(let y=0,_=m.length;y<_;y++){const v=m[y],x=s[v.materialIndex],M=Math.max(v.start,g.start),w=Math.min(l.count,Math.min(v.start+v.count,g.start+g.count));for(let C=M,T=w;C<T;C+=3){const P=C,A=C+1,j=C+2;r=Yy(this,x,e,i,c,u,f,P,A,j),r&&(r.faceIndex=Math.floor(C/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const y=Math.max(0,g.start),_=Math.min(l.count,g.start+g.count);for(let v=y,x=_;v<x;v+=3){const M=v,w=v+1,C=v+2;r=Yy(this,s,e,i,c,u,f,M,w,C),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}}};function Rue(t,e,n,i,r,a,s,o){let l;if(e.side===ja?l=i.intersectTriangle(s,a,r,!0,o):l=i.intersectTriangle(r,a,s,e.side===qu,o),l===null)return null;Ky.copy(o),Ky.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(Ky);return c<n.near||c>n.far?null:{distance:c,point:Ky.clone(),object:t}}function Yy(t,e,n,i,r,a,s,o,l,c){t.getVertexPosition(o,Gy),t.getVertexPosition(l,Wy),t.getVertexPosition(c,qy);const u=Rue(t,e,n,i,Gy,Wy,qy,_F);if(u){const f=new Ge;Fg.getBarycoord(_F,Gy,Wy,qy,f),r&&(u.uv=Fg.getInterpolatedAttribute(r,o,l,c,f,new sn)),a&&(u.uv1=Fg.getInterpolatedAttribute(a,o,l,c,f,new sn)),s&&(u.normal=Fg.getInterpolatedAttribute(s,o,l,c,f,new Ge),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const m={a:o,b:l,c,normal:new Ge,materialIndex:0};Fg.getNormal(Gy,Wy,qy,m.normal),u.face=m,u.barycoord=f}return u}let ek=class U9 extends cl{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=[],u=[],f=[];let m=0,g=0;y("z","y","x",-1,-1,i,n,e,s,a,0),y("z","y","x",1,-1,i,n,-e,s,a,1),y("x","z","y",1,1,e,i,n,r,s,2),y("x","z","y",1,-1,e,i,-n,r,s,3),y("x","y","z",1,-1,e,n,i,r,a,4),y("x","y","z",-1,-1,e,n,-i,r,a,5),this.setIndex(l),this.setAttribute("position",new yo(c,3)),this.setAttribute("normal",new yo(u,3)),this.setAttribute("uv",new yo(f,2));function y(_,v,x,M,w,C,T,P,A,j,N){const k=C/A,F=T/j,I=C/2,W=T/2,D=P/2,B=A+1,$=j+1;let K=0,X=0;const Y=new Ge;for(let ee=0;ee<$;ee++){const z=ee*F-W;for(let V=0;V<B;V++){const re=V*k-I;Y[_]=re*M,Y[v]=z*w,Y[x]=D,c.push(Y.x,Y.y,Y.z),Y[_]=0,Y[v]=0,Y[x]=P>0?1:-1,u.push(Y.x,Y.y,Y.z),f.push(V/A),f.push(1-ee/j),K+=1}}for(let ee=0;ee<j;ee++)for(let z=0;z<A;z++){const V=m+z+B*ee,re=m+z+B*(ee+1),le=m+(z+1)+B*(ee+1),ge=m+(z+1)+B*ee;l.push(V,re,ge),l.push(re,le,ge),X+=6}o.addGroup(g,X,N),g+=X,m+=K}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new U9(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?(qt("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 ua(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 Pue(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function F9(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:En.workingColorSpace}const kue={clone:Kp,merge:ua};var Due=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Oue=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let gc=class extends Mm{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Due,this.fragmentShader=Oue,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=Pue(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}},z9=class extends ps{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xi,this.projectionMatrix=new Xi,this.projectionMatrixInverse=new Xi,this.coordinateSystem=Go,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 cu=new Ge,SF=new sn,wF=new sn;let Is=class extends z9{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=y3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(y_*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return y3*2*Math.atan(Math.tan(y_*.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){cu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(cu.x,cu.y).multiplyScalar(-e/cu.z),cu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(cu.x,cu.y).multiplyScalar(-e/cu.z)}getViewSize(e,n){return this.getViewBounds(e,SF,wF),n.subVectors(wF,SF)}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(y_*.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 Uh=-90,Fh=1;let Lue=class extends ps{constructor(e,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Is(Uh,Fh,e,n);r.layers=this.layers,this.add(r);const a=new Is(Uh,Fh,e,n);a.layers=this.layers,this.add(a);const s=new Is(Uh,Fh,e,n);s.layers=this.layers,this.add(s);const o=new Is(Uh,Fh,e,n);o.layers=this.layers,this.add(o);const l=new Is(Uh,Fh,e,n);l.layers=this.layers,this.add(l);const c=new Is(Uh,Fh,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===Go)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===q_)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,u]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;const _=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=_,e.setRenderTarget(i,5,r),e.render(n,u),e.setRenderTarget(f,m,g),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}},B9=class extends To{constructor(e=[],n=Wp,i,r,a,s,o,l,c,u){super(e,n,i,r,a,s,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Iue=class extends Ef{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 B9(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 ek(5,5,5),a=new gc({name:"CubemapFromEquirect",uniforms:Kp(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:ja,blending:ac});a.uniforms.tEquirect.value=n;const s=new tl(r,a),o=n.minFilter;return n.minFilter===Yd&&(n.minFilter=Bs),new Lue(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)}},ox=class extends ps{constructor(){super(),this.isGroup=!0,this.type="Group"}};const jue={type:"move"};let aT=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ox,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 ox,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Ge,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Ge),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ox,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Ge,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Ge),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 _ of e.hand.values()){const v=n.getJointPose(_,i),x=this._getHandJoint(c,_);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 u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],m=u.position.distanceTo(f.position),g=.02,y=.005;c.inputState.pinching&&m>g+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&m<=g-y&&(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(jue)))}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 ox;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}},Uue=class extends ps{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 Xu,this.environmentIntensity=1,this.environmentRotation=new Xu,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}},Fue=class extends To{constructor(e=null,n=1,i=1,r,a,s,o,l,c=us,u=us,f,m){super(null,s,o,l,c,u,r,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const sT=new Ge,zue=new Ge,Bue=new cn;let yu=class{constructor(e=new Ge(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=sT.subVectors(i,n).cross(zue.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(sT),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||Bue.getNormalMatrix(e),r=this.coplanarPoint(sT).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 Rd=new ew,Hue=new sn(.5,.5),Zy=new Ge;let tk=class{constructor(e=new yu,n=new yu,i=new yu,r=new yu,a=new yu,s=new yu){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=Go,i=!1){const r=this.planes,a=e.elements,s=a[0],o=a[1],l=a[2],c=a[3],u=a[4],f=a[5],m=a[6],g=a[7],y=a[8],_=a[9],v=a[10],x=a[11],M=a[12],w=a[13],C=a[14],T=a[15];if(r[0].setComponents(c-s,g-u,x-y,T-M).normalize(),r[1].setComponents(c+s,g+u,x+y,T+M).normalize(),r[2].setComponents(c+o,g+f,x+_,T+w).normalize(),r[3].setComponents(c-o,g-f,x-_,T-w).normalize(),i)r[4].setComponents(l,m,v,C).normalize(),r[5].setComponents(c-l,g-m,x-v,T-C).normalize();else if(r[4].setComponents(c-l,g-m,x-v,T-C).normalize(),n===Go)r[5].setComponents(c+l,g+m,x+v,T+C).normalize();else if(n===q_)r[5].setComponents(l,m,v,C).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(),Rd.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Rd.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Rd)}intersectsSprite(e){Rd.center.set(0,0,0);const n=Hue.distanceTo(e.center);return Rd.radius=.7071067811865476+n,Rd.applyMatrix4(e.matrixWorld),this.intersectsSphere(Rd)}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(Zy.x=r.normal.x>0?e.max.x:e.min.x,Zy.y=r.normal.y>0?e.max.y:e.min.y,Zy.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Zy)<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)}},H9=class extends Mm{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new vn(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 K_=new Ge,Y_=new Ge,MF=new Xi,Bg=new QP,Qy=new ew,oT=new Ge,EF=new Ge;let $ue=class extends ps{constructor(e=new cl,n=new H9){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++)K_.fromBufferAttribute(n,r-1),Y_.fromBufferAttribute(n,r),i[r]=i[r-1],i[r]+=K_.distanceTo(Y_);e.setAttribute("lineDistance",new yo(i,1))}else qt("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(),Qy.copy(i.boundingSphere),Qy.applyMatrix4(r),Qy.radius+=a,e.ray.intersectsSphere(Qy)===!1)return;MF.copy(r).invert(),Bg.copy(e.ray).applyMatrix4(MF);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=i.index,m=i.attributes.position;if(u!==null){const g=Math.max(0,s.start),y=Math.min(u.count,s.start+s.count);for(let _=g,v=y-1;_<v;_+=c){const x=u.getX(_),M=u.getX(_+1),w=Jy(this,e,Bg,l,x,M,_);w&&n.push(w)}if(this.isLineLoop){const _=u.getX(y-1),v=u.getX(g),x=Jy(this,e,Bg,l,_,v,y-1);x&&n.push(x)}}else{const g=Math.max(0,s.start),y=Math.min(m.count,s.start+s.count);for(let _=g,v=y-1;_<v;_+=c){const x=Jy(this,e,Bg,l,_,_+1,_);x&&n.push(x)}if(this.isLineLoop){const _=Jy(this,e,Bg,l,y-1,g,y-1);_&&n.push(_)}}}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 Jy(t,e,n,i,r,a,s){const o=t.geometry.attributes.position;if(K_.fromBufferAttribute(o,r),Y_.fromBufferAttribute(o,a),n.distanceSqToSegment(K_,Y_,oT,EF)>i)return;oT.applyMatrix4(t.matrixWorld);const c=e.ray.origin.distanceTo(oT);if(!(c<e.near||c>e.far))return{distance:c,point:EF.clone().applyMatrix4(t.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:t}}const AF=new Ge,TF=new Ge;let Vue=class extends $ue{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)AF.fromBufferAttribute(n,r),TF.fromBufferAttribute(n,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+AF.distanceTo(TF);e.setAttribute("lineDistance",new yo(i,1))}else qt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},$9=class extends To{constructor(e,n,i=wf,r,a,s,o=us,l=us,c,u=Zx,f=1){if(u!==Zx&&u!==Qx)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const m={width:e,height:n,depth:f};super(m,r,a,s,o,l,u,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ZP(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 V9 extends To{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let nk=class G9 extends cl{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,u=l+1,f=e/o,m=n/l,g=[],y=[],_=[],v=[];for(let x=0;x<u;x++){const M=x*m-s;for(let w=0;w<c;w++){const C=w*f-a;y.push(C,-M,0),_.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,C=M+c*(x+1),T=M+1+c*(x+1),P=M+1+c*x;g.push(w,C,P),g.push(C,T,P)}this.setIndex(g),this.setAttribute("position",new yo(y,3)),this.setAttribute("normal",new yo(_,3)),this.setAttribute("uv",new yo(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new G9(e.width,e.height,e.widthSegments,e.heightSegments)}};class Gue extends Mm{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new vn(16777215),this.specular=new vn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=M9,this.normalScale=new sn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xu,this.combine=$P,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 Wue=class extends Mm{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=eue,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}},que=class extends Mm{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}},W9=class extends ps{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new vn(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 lT=new Xi,CF=new Ge,NF=new Ge;let Xue=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new sn(512,512),this.mapType=el,this.map=null,this.mapPass=null,this.matrix=new Xi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new tk,this._frameExtents=new sn(1,1),this._viewportCount=1,this._viewports=[new Vi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,i=this.matrix;CF.setFromMatrixPosition(e.matrixWorld),n.position.copy(CF),NF.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(NF),n.updateMatrixWorld(),lT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lT,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(lT)}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}},q9=class extends z9{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,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=u*this.view.offsetY,l=o-u*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 Kue extends Xue{constructor(){super(new q9(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class RF extends W9{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ps.DEFAULT_UP),this.updateMatrix(),this.target=new ps,this.shadow=new Kue}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Yue=class extends W9{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},Zue=class extends Is{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},PF=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=pn(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(pn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Que extends Vue{constructor(e=10,n=10,i=4473924,r=8947848){i=new vn(i),r=new vn(r);const a=n/2,s=e/n,o=e/2,l=[],c=[];for(let m=0,g=0,y=-o;m<=n;m++,y+=s){l.push(-o,0,y,o,0,y),l.push(y,0,-o,y,0,o);const _=m===a?i:r;_.toArray(c,g),g+=3,_.toArray(c,g),g+=3,_.toArray(c,g),g+=3,_.toArray(c,g),g+=3}const u=new cl;u.setAttribute("position",new yo(l,3)),u.setAttribute("color",new yo(c,3));const f=new H9({vertexColors:!0,toneMapped:!1});super(u,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Jue extends Hf{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){qt("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function kF(t,e,n,i){const r=ede(i);switch(n){case _9:return t*e;case w9:return t*e/r.components*r.byteLength;case qP:return t*e/r.components*r.byteLength;case XP:return t*e*2/r.components*r.byteLength;case KP:return t*e*2/r.components*r.byteLength;case S9:return t*e*3/r.components*r.byteLength;case go:return t*e*4/r.components*r.byteLength;case YP:return t*e*4/r.components*r.byteLength;case m_:case g_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case x_:case v_:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case WN:case XN:return Math.max(t,16)*Math.max(e,8)/4;case GN:case qN:return Math.max(t,8)*Math.max(e,8)/2;case KN:case YN:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case ZN:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case QN:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case JN:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case e3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case t3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case n3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case i3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case r3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case a3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case s3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case o3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case l3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case c3:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case u3:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case d3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case f3:case h3:case p3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case m3:case g3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case x3:case v3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function ede(t){switch(t){case el:case x9:return{byteLength:1,components:1};case Kx:case v9:case wm:return{byteLength:2,components:1};case GP:case WP:return{byteLength:2,components:4};case wf:case VP:case Jl:return{byteLength:4,components:1};case y9:case b9:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:HP}}));typeof window<"u"&&(window.__THREE__?qt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=HP);function X9(){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 tde(t){const e=new WeakMap;function n(o,l){const c=o.array,u=o.usage,f=c.byteLength,m=t.createBuffer();t.bindBuffer(l,m),t.bufferData(l,c,u),o.onUploadCallback();let g;if(c instanceof Float32Array)g=t.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)g=t.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?g=t.HALF_FLOAT:g=t.UNSIGNED_SHORT;else if(c instanceof Int16Array)g=t.SHORT;else if(c instanceof Uint32Array)g=t.UNSIGNED_INT;else if(c instanceof Int32Array)g=t.INT;else if(c instanceof Int8Array)g=t.BYTE;else if(c instanceof Uint8Array)g=t.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)g=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:m,type:g,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:f}}function i(o,l,c){const u=l.array,f=l.updateRanges;if(t.bindBuffer(c,o),f.length===0)t.bufferSubData(c,0,u);else{f.sort((g,y)=>g.start-y.start);let m=0;for(let g=1;g<f.length;g++){const y=f[m],_=f[g];_.start<=y.start+y.count+1?y.count=Math.max(y.count,_.start+_.count-y.start):(++m,f[m]=_)}f.length=m+1;for(let g=0,y=f.length;g<y;g++){const _=f[g];t.bufferSubData(c,_.start*u.BYTES_PER_ELEMENT,u,_.start,_.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 u=e.get(o);(!u||u.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 nde=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,ide=`#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`,rde=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,ade=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,sde=`#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`,ode=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,lde=`#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`,cde=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,ude=`#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`,dde=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,fde=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,hde=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,pde=`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`,mde=`#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`,gde=`#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`,xde=`#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`,vde=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,yde=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,bde=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,_de=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,Sde=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,wde=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,Mde=`#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`,Ede=`#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`,Ade=`#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`,Tde=`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`,Cde=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,Nde=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,Rde=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,Pde=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,kde="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dde=`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 );
- }`,Ode=`#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`,Lde=`#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`,Ide=`#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`,jde=`#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`,Ude=`#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`,Fde=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,zde=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,Bde=`#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`,Hde=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,$de=`#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
- }`,Vde=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,Gde=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,Wde=`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`,qde=`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`,Xde=`#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`,Kde=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,Yde=`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`,Zde=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,Qde=`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`,Jde=`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`,efe=`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 );
- }`,tfe=`
- 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`,nfe=`#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`,ife=`#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`,rfe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,afe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,sfe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,ofe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,lfe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,cfe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,ufe=`#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`,dfe=`#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`,ffe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,hfe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,pfe=`#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`,mfe=`#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`,gfe=`#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`,xfe=`#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`,vfe=`#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`,yfe=`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;`,bfe=`#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`,_fe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,Sfe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,wfe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,Mfe=`#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`,Efe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,Afe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,Tfe=`#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`,Cfe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,Nfe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Rfe=`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 );
- }`,Pfe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,kfe=`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;`,Dfe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,Ofe=`#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`,Lfe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Ife=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,jfe=`#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`,Ufe=`#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`,Ffe=`#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`,zfe=`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;
- }`,Bfe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,Hfe=`#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`,$fe=`#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`,Vfe=`#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`,Gfe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,Wfe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,qfe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,Xfe=`#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; }`,Kfe=`#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`,Yfe=`#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`,Zfe=`#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`,Qfe=`#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`,Jfe=`#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`,ehe=`#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 the=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,nhe=`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>
- }`,ihe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,rhe=`#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>
- }`,ahe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,she=`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>
- }`,ohe=`#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;
- }`,lhe=`#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
- }`,che=`#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;
- }`,uhe=`#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 );
- }`,dhe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,fhe=`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>
- }`,hhe=`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>
- }`,phe=`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>
- }`,mhe=`#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>
- }`,ghe=`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>
- }`,xhe=`#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>
- }`,vhe=`#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>
- }`,yhe=`#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;
- }`,bhe=`#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>
- }`,_he=`#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
- }`,She=`#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
- }`,whe=`#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>
- }`,Mhe=`#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>
- }`,Ehe=`#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
- }`,Ahe=`#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>
- }`,The=`#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>
- }`,Che=`#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>
- }`,Nhe=`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>
- }`,Rhe=`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>
- }`,Phe=`#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>
- }`,khe=`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>
- }`,Dhe=`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>
- }`,Ohe=`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>
- }`,rn={alphahash_fragment:nde,alphahash_pars_fragment:ide,alphamap_fragment:rde,alphamap_pars_fragment:ade,alphatest_fragment:sde,alphatest_pars_fragment:ode,aomap_fragment:lde,aomap_pars_fragment:cde,batching_pars_vertex:ude,batching_vertex:dde,begin_vertex:fde,beginnormal_vertex:hde,bsdfs:pde,iridescence_fragment:mde,bumpmap_pars_fragment:gde,clipping_planes_fragment:xde,clipping_planes_pars_fragment:vde,clipping_planes_pars_vertex:yde,clipping_planes_vertex:bde,color_fragment:_de,color_pars_fragment:Sde,color_pars_vertex:wde,color_vertex:Mde,common:Ede,cube_uv_reflection_fragment:Ade,defaultnormal_vertex:Tde,displacementmap_pars_vertex:Cde,displacementmap_vertex:Nde,emissivemap_fragment:Rde,emissivemap_pars_fragment:Pde,colorspace_fragment:kde,colorspace_pars_fragment:Dde,envmap_fragment:Ode,envmap_common_pars_fragment:Lde,envmap_pars_fragment:Ide,envmap_pars_vertex:jde,envmap_physical_pars_fragment:Xde,envmap_vertex:Ude,fog_vertex:Fde,fog_pars_vertex:zde,fog_fragment:Bde,fog_pars_fragment:Hde,gradientmap_pars_fragment:$de,lightmap_pars_fragment:Vde,lights_lambert_fragment:Gde,lights_lambert_pars_fragment:Wde,lights_pars_begin:qde,lights_toon_fragment:Kde,lights_toon_pars_fragment:Yde,lights_phong_fragment:Zde,lights_phong_pars_fragment:Qde,lights_physical_fragment:Jde,lights_physical_pars_fragment:efe,lights_fragment_begin:tfe,lights_fragment_maps:nfe,lights_fragment_end:ife,logdepthbuf_fragment:rfe,logdepthbuf_pars_fragment:afe,logdepthbuf_pars_vertex:sfe,logdepthbuf_vertex:ofe,map_fragment:lfe,map_pars_fragment:cfe,map_particle_fragment:ufe,map_particle_pars_fragment:dfe,metalnessmap_fragment:ffe,metalnessmap_pars_fragment:hfe,morphinstance_vertex:pfe,morphcolor_vertex:mfe,morphnormal_vertex:gfe,morphtarget_pars_vertex:xfe,morphtarget_vertex:vfe,normal_fragment_begin:yfe,normal_fragment_maps:bfe,normal_pars_fragment:_fe,normal_pars_vertex:Sfe,normal_vertex:wfe,normalmap_pars_fragment:Mfe,clearcoat_normal_fragment_begin:Efe,clearcoat_normal_fragment_maps:Afe,clearcoat_pars_fragment:Tfe,iridescence_pars_fragment:Cfe,opaque_fragment:Nfe,packing:Rfe,premultiplied_alpha_fragment:Pfe,project_vertex:kfe,dithering_fragment:Dfe,dithering_pars_fragment:Ofe,roughnessmap_fragment:Lfe,roughnessmap_pars_fragment:Ife,shadowmap_pars_fragment:jfe,shadowmap_pars_vertex:Ufe,shadowmap_vertex:Ffe,shadowmask_pars_fragment:zfe,skinbase_vertex:Bfe,skinning_pars_vertex:Hfe,skinning_vertex:$fe,skinnormal_vertex:Vfe,specularmap_fragment:Gfe,specularmap_pars_fragment:Wfe,tonemapping_fragment:qfe,tonemapping_pars_fragment:Xfe,transmission_fragment:Kfe,transmission_pars_fragment:Yfe,uv_pars_fragment:Zfe,uv_pars_vertex:Qfe,uv_vertex:Jfe,worldpos_vertex:ehe,background_vert:the,background_frag:nhe,backgroundCube_vert:ihe,backgroundCube_frag:rhe,cube_vert:ahe,cube_frag:she,depth_vert:ohe,depth_frag:lhe,distanceRGBA_vert:che,distanceRGBA_frag:uhe,equirect_vert:dhe,equirect_frag:fhe,linedashed_vert:hhe,linedashed_frag:phe,meshbasic_vert:mhe,meshbasic_frag:ghe,meshlambert_vert:xhe,meshlambert_frag:vhe,meshmatcap_vert:yhe,meshmatcap_frag:bhe,meshnormal_vert:_he,meshnormal_frag:She,meshphong_vert:whe,meshphong_frag:Mhe,meshphysical_vert:Ehe,meshphysical_frag:Ahe,meshtoon_vert:The,meshtoon_frag:Che,points_vert:Nhe,points_frag:Rhe,shadow_vert:Phe,shadow_frag:khe,sprite_vert:Dhe,sprite_frag:Ohe},St={common:{diffuse:{value:new vn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new cn},alphaMap:{value:null},alphaMapTransform:{value:new cn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new cn}},envmap:{envMap:{value:null},envMapRotation:{value:new cn},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 cn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new cn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new cn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new cn},normalScale:{value:new sn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new cn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new cn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new cn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new cn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vn(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 vn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new cn},alphaTest:{value:0},uvTransform:{value:new cn}},sprite:{diffuse:{value:new vn(16777215)},opacity:{value:1},center:{value:new sn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new cn},alphaMap:{value:null},alphaMapTransform:{value:new cn},alphaTest:{value:0}}},Bo={basic:{uniforms:ua([St.common,St.specularmap,St.envmap,St.aomap,St.lightmap,St.fog]),vertexShader:rn.meshbasic_vert,fragmentShader:rn.meshbasic_frag},lambert:{uniforms:ua([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 vn(0)}}]),vertexShader:rn.meshlambert_vert,fragmentShader:rn.meshlambert_frag},phong:{uniforms:ua([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 vn(0)},specular:{value:new vn(1118481)},shininess:{value:30}}]),vertexShader:rn.meshphong_vert,fragmentShader:rn.meshphong_frag},standard:{uniforms:ua([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 vn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:rn.meshphysical_vert,fragmentShader:rn.meshphysical_frag},toon:{uniforms:ua([St.common,St.aomap,St.lightmap,St.emissivemap,St.bumpmap,St.normalmap,St.displacementmap,St.gradientmap,St.fog,St.lights,{emissive:{value:new vn(0)}}]),vertexShader:rn.meshtoon_vert,fragmentShader:rn.meshtoon_frag},matcap:{uniforms:ua([St.common,St.bumpmap,St.normalmap,St.displacementmap,St.fog,{matcap:{value:null}}]),vertexShader:rn.meshmatcap_vert,fragmentShader:rn.meshmatcap_frag},points:{uniforms:ua([St.points,St.fog]),vertexShader:rn.points_vert,fragmentShader:rn.points_frag},dashed:{uniforms:ua([St.common,St.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:rn.linedashed_vert,fragmentShader:rn.linedashed_frag},depth:{uniforms:ua([St.common,St.displacementmap]),vertexShader:rn.depth_vert,fragmentShader:rn.depth_frag},normal:{uniforms:ua([St.common,St.bumpmap,St.normalmap,St.displacementmap,{opacity:{value:1}}]),vertexShader:rn.meshnormal_vert,fragmentShader:rn.meshnormal_frag},sprite:{uniforms:ua([St.sprite,St.fog]),vertexShader:rn.sprite_vert,fragmentShader:rn.sprite_frag},background:{uniforms:{uvTransform:{value:new cn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:rn.background_vert,fragmentShader:rn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new cn}},vertexShader:rn.backgroundCube_vert,fragmentShader:rn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:rn.cube_vert,fragmentShader:rn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:rn.equirect_vert,fragmentShader:rn.equirect_frag},distanceRGBA:{uniforms:ua([St.common,St.displacementmap,{referencePosition:{value:new Ge},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:rn.distanceRGBA_vert,fragmentShader:rn.distanceRGBA_frag},shadow:{uniforms:ua([St.lights,St.fog,{color:{value:new vn(0)},opacity:{value:1}}]),vertexShader:rn.shadow_vert,fragmentShader:rn.shadow_frag}};Bo.physical={uniforms:ua([Bo.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new cn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new cn},clearcoatNormalScale:{value:new sn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new cn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new cn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new cn},sheen:{value:0},sheenColor:{value:new vn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new cn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new cn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new cn},transmissionSamplerSize:{value:new sn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new cn},attenuationDistance:{value:0},attenuationColor:{value:new vn(0)},specularColor:{value:new vn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new cn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new cn},anisotropyVector:{value:new sn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new cn}}]),vertexShader:rn.meshphysical_vert,fragmentShader:rn.meshphysical_frag};const eb={r:0,b:0,g:0},Pd=new Xu,Lhe=new Xi;function Ihe(t,e,n,i,r,a,s){const o=new vn(0);let l=a===!0?0:1,c,u,f=null,m=0,g=null;function y(w){let C=w.isScene===!0?w.background:null;return C&&C.isTexture&&(C=(w.backgroundBlurriness>0?n:e).get(C)),C}function _(w){let C=!1;const T=y(w);T===null?x(o,l):T&&T.isColor&&(x(T,1),C=!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||C)&&(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,C){const T=y(C);T&&(T.isCubeTexture||T.mapping===JS)?(u===void 0&&(u=new tl(new ek(1,1,1),new gc({name:"BackgroundCubeMaterial",uniforms:Kp(Bo.backgroundCube.uniforms),vertexShader:Bo.backgroundCube.vertexShader,fragmentShader:Bo.backgroundCube.fragmentShader,side:ja,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(P,A,j){this.matrixWorld.copyPosition(j.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Pd.copy(C.backgroundRotation),Pd.x*=-1,Pd.y*=-1,Pd.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Pd.y*=-1,Pd.z*=-1),u.material.uniforms.envMap.value=T,u.material.uniforms.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Lhe.makeRotationFromEuler(Pd)),u.material.toneMapped=En.getTransfer(T.colorSpace)!==Bn,(f!==T||m!==T.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=T,m=T.version,g=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null)):T&&T.isTexture&&(c===void 0&&(c=new tl(new nk(2,2),new gc({name:"BackgroundMaterial",uniforms:Kp(Bo.background.uniforms),vertexShader:Bo.background.vertexShader,fragmentShader:Bo.background.fragmentShader,side:qu,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=C.backgroundIntensity,c.material.toneMapped=En.getTransfer(T.colorSpace)!==Bn,T.matrixAutoUpdate===!0&&T.updateMatrix(),c.material.uniforms.uvTransform.value.copy(T.matrix),(f!==T||m!==T.version||g!==t.toneMapping)&&(c.material.needsUpdate=!0,f=T,m=T.version,g=t.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function x(w,C){w.getRGB(eb,F9(t)),i.buffers.color.setClear(eb.r,eb.g,eb.b,C,s)}function M(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(w,C=1){o.set(w),l=C,x(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(w){l=w,x(o,l)},render:_,addToRenderList:v,dispose:M}}function jhe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),i={},r=m(null);let a=r,s=!1;function o(k,F,I,W,D){let B=!1;const $=f(W,I,F);a!==$&&(a=$,c(a.object)),B=g(k,W,I,D),B&&y(k,W,I,D),D!==null&&e.update(D,t.ELEMENT_ARRAY_BUFFER),(B||s)&&(s=!1,C(k,F,I,W),D!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function l(){return t.createVertexArray()}function c(k){return t.bindVertexArray(k)}function u(k){return t.deleteVertexArray(k)}function f(k,F,I){const W=I.wireframe===!0;let D=i[k.id];D===void 0&&(D={},i[k.id]=D);let B=D[F.id];B===void 0&&(B={},D[F.id]=B);let $=B[W];return $===void 0&&($=m(l()),B[W]=$),$}function m(k){const F=[],I=[],W=[];for(let D=0;D<n;D++)F[D]=0,I[D]=0,W[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:I,attributeDivisors:W,object:k,attributes:{},index:null}}function g(k,F,I,W){const D=a.attributes,B=F.attributes;let $=0;const K=I.getAttributes();for(const X in K)if(K[X].location>=0){const ee=D[X];let z=B[X];if(z===void 0&&(X==="instanceMatrix"&&k.instanceMatrix&&(z=k.instanceMatrix),X==="instanceColor"&&k.instanceColor&&(z=k.instanceColor)),ee===void 0||ee.attribute!==z||z&&ee.data!==z.data)return!0;$++}return a.attributesNum!==$||a.index!==W}function y(k,F,I,W){const D={},B=F.attributes;let $=0;const K=I.getAttributes();for(const X in K)if(K[X].location>=0){let ee=B[X];ee===void 0&&(X==="instanceMatrix"&&k.instanceMatrix&&(ee=k.instanceMatrix),X==="instanceColor"&&k.instanceColor&&(ee=k.instanceColor));const z={};z.attribute=ee,ee&&ee.data&&(z.data=ee.data),D[X]=z,$++}a.attributes=D,a.attributesNum=$,a.index=W}function _(){const k=a.newAttributes;for(let F=0,I=k.length;F<I;F++)k[F]=0}function v(k){x(k,0)}function x(k,F){const I=a.newAttributes,W=a.enabledAttributes,D=a.attributeDivisors;I[k]=1,W[k]===0&&(t.enableVertexAttribArray(k),W[k]=1),D[k]!==F&&(t.vertexAttribDivisor(k,F),D[k]=F)}function M(){const k=a.newAttributes,F=a.enabledAttributes;for(let I=0,W=F.length;I<W;I++)F[I]!==k[I]&&(t.disableVertexAttribArray(I),F[I]=0)}function w(k,F,I,W,D,B,$){$===!0?t.vertexAttribIPointer(k,F,I,D,B):t.vertexAttribPointer(k,F,I,W,D,B)}function C(k,F,I,W){_();const D=W.attributes,B=I.getAttributes(),$=F.defaultAttributeValues;for(const K in B){const X=B[K];if(X.location>=0){let Y=D[K];if(Y===void 0&&(K==="instanceMatrix"&&k.instanceMatrix&&(Y=k.instanceMatrix),K==="instanceColor"&&k.instanceColor&&(Y=k.instanceColor)),Y!==void 0){const ee=Y.normalized,z=Y.itemSize,V=e.get(Y);if(V===void 0)continue;const re=V.buffer,le=V.type,ge=V.bytesPerElement,ie=le===t.INT||le===t.UNSIGNED_INT||Y.gpuType===VP;if(Y.isInterleavedBufferAttribute){const xe=Y.data,ke=xe.stride,he=Y.offset;if(xe.isInstancedInterleavedBuffer){for(let we=0;we<X.locationSize;we++)x(X.location+we,xe.meshPerAttribute);k.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=xe.meshPerAttribute*xe.count)}else for(let we=0;we<X.locationSize;we++)v(X.location+we);t.bindBuffer(t.ARRAY_BUFFER,re);for(let we=0;we<X.locationSize;we++)w(X.location+we,z/X.locationSize,le,ee,ke*ge,(he+z/X.locationSize*we)*ge,ie)}else{if(Y.isInstancedBufferAttribute){for(let xe=0;xe<X.locationSize;xe++)x(X.location+xe,Y.meshPerAttribute);k.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let xe=0;xe<X.locationSize;xe++)v(X.location+xe);t.bindBuffer(t.ARRAY_BUFFER,re);for(let xe=0;xe<X.locationSize;xe++)w(X.location+xe,z/X.locationSize,le,ee,z*ge,z/X.locationSize*xe*ge,ie)}}else if($!==void 0){const ee=$[K];if(ee!==void 0)switch(ee.length){case 2:t.vertexAttrib2fv(X.location,ee);break;case 3:t.vertexAttrib3fv(X.location,ee);break;case 4:t.vertexAttrib4fv(X.location,ee);break;default:t.vertexAttrib1fv(X.location,ee)}}}}M()}function T(){j();for(const k in i){const F=i[k];for(const I in F){const W=F[I];for(const D in W)u(W[D].object),delete W[D];delete F[I]}delete i[k]}}function P(k){if(i[k.id]===void 0)return;const F=i[k.id];for(const I in F){const W=F[I];for(const D in W)u(W[D].object),delete W[D];delete F[I]}delete i[k.id]}function A(k){for(const F in i){const I=i[F];if(I[k.id]===void 0)continue;const W=I[k.id];for(const D in W)u(W[D].object),delete W[D];delete I[k.id]}}function j(){N(),s=!0,a!==r&&(a=r,c(a.object))}function N(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:j,resetDefaultState:N,dispose:T,releaseStatesOfGeometry:P,releaseStatesOfProgram:A,initAttributes:_,enableAttribute:v,disableUnusedAttributes:M}}function Uhe(t,e,n){let i;function r(c){i=c}function a(c,u){t.drawArrays(i,c,u),n.update(u,i,1)}function s(c,u,f){f!==0&&(t.drawArraysInstanced(i,c,u,f),n.update(u,i,f))}function o(c,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,u,0,f);let g=0;for(let y=0;y<f;y++)g+=u[y];n.update(g,i,1)}function l(c,u,f,m){if(f===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let y=0;y<c.length;y++)s(c[y],u[y],m[y]);else{g.multiDrawArraysInstancedWEBGL(i,c,0,u,0,m,0,f);let y=0;for(let _=0;_<f;_++)y+=u[_]*m[_];n.update(y,i,1)}}this.setMode=r,this.render=a,this.renderInstances=s,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Fhe(t,e,n,i){let r;function a(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(A){return!(A!==go&&i.convert(A)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(A){const j=A===wm&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(A!==el&&i.convert(A)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&A!==Jl&&!j)}function l(A){if(A==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="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 u=l(c);u!==c&&(qt("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const f=n.logarithmicDepthBuffer===!0,m=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),g=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=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),C=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),T=y>0,P=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:s,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:m,maxTextures:g,maxVertexTextures:y,maxTextureSize:_,maxCubemapSize:v,maxAttributes:x,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:C,vertexTextures:T,maxSamples:P}}function zhe(t){const e=this;let n=null,i=0,r=!1,a=!1;const s=new yu,o=new cn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const g=f.length!==0||m||i!==0||r;return r=m,i=f.length,g},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=u(f,m,0)},this.setState=function(f,m,g){const y=f.clippingPlanes,_=f.clipIntersection,v=f.clipShadows,x=t.get(f);if(!r||y===null||y.length===0||a&&!v)a?u(null):c();else{const M=a?0:i,w=M*4;let C=x.clippingState||null;l.value=C,C=u(y,m,w,g);for(let T=0;T!==w;++T)C[T]=n[T];x.clippingState=C,this.numIntersection=_?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 u(f,m,g,y){const _=f!==null?f.length:0;let v=null;if(_!==0){if(v=l.value,y!==!0||v===null){const x=g+_*4,M=m.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,C=g;w!==_;++w,C+=4)s.copy(f[w]).applyMatrix4(M,o),s.normal.toArray(v,C),v[C+3]=s.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,v}}function Bhe(t){let e=new WeakMap;function n(s,o){return o===BN?s.mapping=Wp:o===HN&&(s.mapping=qp),s}function i(s){if(s&&s.isTexture){const o=s.mapping;if(o===BN||o===HN)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 Iue(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 Pu=4,DF=[.125,.215,.35,.446,.526,.582],Vd=20,Hhe=256,Hg=new q9,OF=new vn;let cT=null,uT=0,dT=0,fT=!1;const $he=new Ge;let LF=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=$he}=a;cT=this._renderer.getRenderTarget(),uT=this._renderer.getActiveCubeFace(),dT=this._renderer.getActiveMipmapLevel(),fT=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=UF(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jF(),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(cT,uT,dT),this._renderer.xr.enabled=fT,e.scissorTest=!1,zh(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Wp||e.mapping===qp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),cT=this._renderer.getRenderTarget(),uT=this._renderer.getActiveCubeFace(),dT=this._renderer.getActiveMipmapLevel(),fT=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:Bs,minFilter:Bs,generateMipmaps:!1,type:wm,format:go,colorSpace:Xp,depthBuffer:!1},r=IF(e,n,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=IF(e,n,i);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Vhe(a)),this._blurMaterial=Whe(a,e,n),this._ggxMaterial=Ghe(a,e,n)}return r}_compileMaterial(e){const n=new tl(new cl,e);this._renderer.compile(n,Hg)}_sceneToCubeUV(e,n,i,r,a){const l=new Is(90,1,n,i),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],f=this._renderer,m=f.autoClear,g=f.toneMapping;f.getClearColor(OF),f.toneMapping=Uu,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new tl(new ek,new JP({name:"PMREM.Background",side:ja,depthWrite:!1,depthTest:!1})));const _=this._backgroundBox,v=_.material;let x=!1;const M=e.background;M?M.isColor&&(v.color.copy(M),e.background=null,x=!0):(v.color.copy(OF),x=!0);for(let w=0;w<6;w++){const C=w%3;C===0?(l.up.set(0,c[w],0),l.position.set(a.x,a.y,a.z),l.lookAt(a.x+u[w],a.y,a.z)):C===1?(l.up.set(0,0,c[w]),l.position.set(a.x,a.y,a.z),l.lookAt(a.x,a.y+u[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+u[w]));const T=this._cubeSize;zh(r,C*T,w>2?T:0,T,T),f.setRenderTarget(r),x&&f.render(_,l),f.render(e,l)}f.toneMapping=g,f.autoClear=m,e.background=M}_textureToCubeUV(e,n){const i=this._renderer,r=e.mapping===Wp||e.mapping===qp;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=UF()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jF());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;zh(n,0,0,3*l,2*l),i.setRenderTarget(n),i.render(s,Hg)}_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),u=n/(this._lodMeshes.length-1),f=Math.sqrt(c*c-u*u),m=.05+c*.95,g=f*m,{_lodMax:y}=this,_=this._sizeLods[i],v=3*_*(i>y-Pu?i-y+Pu:0),x=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=g,l.mipInt.value=y-n,zh(a,v,x,3*_,2*_),r.setRenderTarget(a),r.render(o,Hg),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=y-i,zh(e,v,x,3*_,2*_),r.setRenderTarget(e),r.render(o,Hg)}_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"&&Di("blur direction must be either latitudinal or longitudinal!");const u=3,f=this._lodMeshes[r];f.material=c;const m=c.uniforms,g=this._sizeLods[i]-1,y=isFinite(a)?Math.PI/(2*g):2*Math.PI/(2*Vd-1),_=a/y,v=isFinite(a)?1+Math.floor(u*_):Vd;v>Vd&&qt(`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 A=0;A<Vd;++A){const j=A/_,N=Math.exp(-j*j/2);x.push(N),A===0?M+=N:A<v&&(M+=2*N)}for(let A=0;A<x.length;A++)x[A]=x[A]/M;m.envMap.value=e.texture,m.samples.value=v,m.weights.value=x,m.latitudinal.value=s==="latitudinal",o&&(m.poleAxis.value=o);const{_lodMax:w}=this;m.dTheta.value=y,m.mipInt.value=w-i;const C=this._sizeLods[r],T=3*C*(r>w-Pu?r-w+Pu:0),P=4*(this._cubeSize-C);zh(n,T,P,3*C,2*C),l.setRenderTarget(n),l.render(f,Hg)}};function Vhe(t){const e=[],n=[],i=[];let r=t;const a=t-Pu+1+DF.length;for(let s=0;s<a;s++){const o=Math.pow(2,r);e.push(o);let l=1/o;s>t-Pu?l=DF[s-t+Pu-1]:s===0&&(l=0),n.push(l);const c=1/(o-2),u=-c,f=1+c,m=[u,u,f,u,f,f,u,u,f,f,u,f],g=6,y=6,_=3,v=2,x=1,M=new Float32Array(_*y*g),w=new Float32Array(v*y*g),C=new Float32Array(x*y*g);for(let P=0;P<g;P++){const A=P%3*2/3-1,j=P>2?0:-1,N=[A,j,0,A+2/3,j,0,A+2/3,j+1,0,A,j,0,A+2/3,j+1,0,A,j+1,0];M.set(N,_*y*P),w.set(m,v*y*P);const k=[P,P,P,P,P,P];C.set(k,x*y*P)}const T=new cl;T.setAttribute("position",new $s(M,_)),T.setAttribute("uv",new $s(w,v)),T.setAttribute("faceIndex",new $s(C,x)),i.push(new tl(T,null)),r>Pu&&r--}return{lodMeshes:i,sizeLods:e,sigmas:n}}function IF(t,e,n){const i=new Ef(t,e,n);return i.texture.mapping=JS,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function zh(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function Ghe(t,e,n){return new gc({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Hhe,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:tw(),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:ac,depthTest:!1,depthWrite:!1})}function Whe(t,e,n){const i=new Float32Array(Vd),r=new Ge(0,1,0);return new gc({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:tw(),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:ac,depthTest:!1,depthWrite:!1})}function jF(){return new gc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:tw(),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:ac,depthTest:!1,depthWrite:!1})}function UF(){return new gc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:tw(),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:ac,depthTest:!1,depthWrite:!1})}function tw(){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 qhe(t){let e=new WeakMap,n=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===BN||l===HN,u=l===Wp||l===qp;if(c||u){let f=e.get(o);const m=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==m)return n===null&&(n=new LF(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 g=o.image;return c&&g&&g.height>0||u&&g&&r(g)?(n===null&&(n=new LF(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 u=0;u<c;u++)o[u]!==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 Xhe(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&&Jx("WebGLRenderer: "+i+" extension not supported."),r}}}function Khe(t,e,n,i){const r={},a=new WeakMap;function s(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const y in m.attributes)e.remove(m.attributes[y]);m.removeEventListener("dispose",s),delete r[m.id];const g=a.get(m);g&&(e.remove(g),a.delete(m)),i.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function o(f,m){return r[m.id]===!0||(m.addEventListener("dispose",s),r[m.id]=!0,n.memory.geometries++),m}function l(f){const m=f.attributes;for(const g in m)e.update(m[g],t.ARRAY_BUFFER)}function c(f){const m=[],g=f.index,y=f.attributes.position;let _=0;if(g!==null){const M=g.array;_=g.version;for(let w=0,C=M.length;w<C;w+=3){const T=M[w+0],P=M[w+1],A=M[w+2];m.push(T,P,P,A,A,T)}}else if(y!==void 0){const M=y.array;_=y.version;for(let w=0,C=M.length/3-1;w<C;w+=3){const T=w+0,P=w+1,A=w+2;m.push(T,P,P,A,A,T)}}else return;const v=new(A9(m)?I9:L9)(m,1);v.version=_;const x=a.get(f);x&&e.remove(x),a.set(f,v)}function u(f){const m=a.get(f);if(m){const g=f.index;g!==null&&m.version<g.version&&c(f)}else c(f);return a.get(f)}return{get:o,update:l,getWireframeAttribute:u}}function Yhe(t,e,n){let i;function r(m){i=m}let a,s;function o(m){a=m.type,s=m.bytesPerElement}function l(m,g){t.drawElements(i,g,a,m*s),n.update(g,i,1)}function c(m,g,y){y!==0&&(t.drawElementsInstanced(i,g,a,m*s,y),n.update(g,i,y))}function u(m,g,y){if(y===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,g,0,a,m,0,y);let v=0;for(let x=0;x<y;x++)v+=g[x];n.update(v,i,1)}function f(m,g,y,_){if(y===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<m.length;x++)c(m[x]/s,g[x],_[x]);else{v.multiDrawElementsInstancedWEBGL(i,g,0,a,m,0,_,0,y);let x=0;for(let M=0;M<y;M++)x+=g[M]*_[M];n.update(x,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=f}function Zhe(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:Di("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 Qhe(t,e,n){const i=new WeakMap,r=new Vi;function a(s,o,l){const c=s.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=u!==void 0?u.length:0;let m=i.get(o);if(m===void 0||m.count!==f){let k=function(){j.dispose(),i.delete(o),o.removeEventListener("dispose",k)};var g=k;m!==void 0&&m.texture.dispose();const y=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,x=o.morphAttributes.position||[],M=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let C=0;y===!0&&(C=1),_===!0&&(C=2),v===!0&&(C=3);let T=o.attributes.position.count*C,P=1;T>e.maxTextureSize&&(P=Math.ceil(T/e.maxTextureSize),T=e.maxTextureSize);const A=new Float32Array(T*P*4*f),j=new P9(A,T,P,f);j.type=Jl,j.needsUpdate=!0;const N=C*4;for(let F=0;F<f;F++){const I=x[F],W=M[F],D=w[F],B=T*P*4*F;for(let $=0;$<I.count;$++){const K=$*N;y===!0&&(r.fromBufferAttribute(I,$),A[B+K+0]=r.x,A[B+K+1]=r.y,A[B+K+2]=r.z,A[B+K+3]=0),_===!0&&(r.fromBufferAttribute(W,$),A[B+K+4]=r.x,A[B+K+5]=r.y,A[B+K+6]=r.z,A[B+K+7]=0),v===!0&&(r.fromBufferAttribute(D,$),A[B+K+8]=r.x,A[B+K+9]=r.y,A[B+K+10]=r.z,A[B+K+11]=D.itemSize===4?r.w:1)}}m={count:f,texture:j,size:new sn(T,P)},i.set(o,m),o.addEventListener("dispose",k)}if(s.isInstancedMesh===!0&&s.morphTexture!==null)l.getUniforms().setValue(t,"morphTexture",s.morphTexture,n);else{let y=0;for(let v=0;v<c.length;v++)y+=c[v];const _=o.morphTargetsRelative?1:1-y;l.getUniforms().setValue(t,"morphTargetBaseInfluence",_),l.getUniforms().setValue(t,"morphTargetInfluences",c)}l.getUniforms().setValue(t,"morphTargetsTexture",m.texture,n),l.getUniforms().setValue(t,"morphTargetsTextureSize",m.size)}return{update:a}}function Jhe(t,e,n,i){let r=new WeakMap;function a(l){const c=i.render.frame,u=l.geometry,f=e.get(l,u);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 m=l.skeleton;r.get(m)!==c&&(m.update(),r.set(m,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 K9=new To,FF=new $9(1,1),Y9=new P9,Z9=new yue,Q9=new B9,zF=[],BF=[],HF=new Float32Array(16),$F=new Float32Array(9),VF=new Float32Array(4);function Em(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let a=zF[r];if(a===void 0&&(a=new Float32Array(r),zF[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 sr(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 or(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function nw(t,e){let n=BF[e];n===void 0&&(n=new Int32Array(e),BF[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function epe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function tpe(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(sr(n,e))return;t.uniform2fv(this.addr,e),or(n,e)}}function npe(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(sr(n,e))return;t.uniform3fv(this.addr,e),or(n,e)}}function ipe(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(sr(n,e))return;t.uniform4fv(this.addr,e),or(n,e)}}function rpe(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(sr(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),or(n,e)}else{if(sr(n,i))return;VF.set(i),t.uniformMatrix2fv(this.addr,!1,VF),or(n,i)}}function ape(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(sr(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),or(n,e)}else{if(sr(n,i))return;$F.set(i),t.uniformMatrix3fv(this.addr,!1,$F),or(n,i)}}function spe(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(sr(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),or(n,e)}else{if(sr(n,i))return;HF.set(i),t.uniformMatrix4fv(this.addr,!1,HF),or(n,i)}}function ope(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function lpe(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(sr(n,e))return;t.uniform2iv(this.addr,e),or(n,e)}}function cpe(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(sr(n,e))return;t.uniform3iv(this.addr,e),or(n,e)}}function upe(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(sr(n,e))return;t.uniform4iv(this.addr,e),or(n,e)}}function dpe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function fpe(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(sr(n,e))return;t.uniform2uiv(this.addr,e),or(n,e)}}function hpe(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(sr(n,e))return;t.uniform3uiv(this.addr,e),or(n,e)}}function ppe(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(sr(n,e))return;t.uniform4uiv(this.addr,e),or(n,e)}}function mpe(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?(FF.compareFunction=E9,a=FF):a=K9,n.setTexture2D(e||a,r)}function gpe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||Z9,r)}function xpe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||Q9,r)}function vpe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||Y9,r)}function ype(t){switch(t){case 5126:return epe;case 35664:return tpe;case 35665:return npe;case 35666:return ipe;case 35674:return rpe;case 35675:return ape;case 35676:return spe;case 5124:case 35670:return ope;case 35667:case 35671:return lpe;case 35668:case 35672:return cpe;case 35669:case 35673:return upe;case 5125:return dpe;case 36294:return fpe;case 36295:return hpe;case 36296:return ppe;case 35678:case 36198:case 36298:case 36306:case 35682:return mpe;case 35679:case 36299:case 36307:return gpe;case 35680:case 36300:case 36308:case 36293:return xpe;case 36289:case 36303:case 36311:case 36292:return vpe}}function bpe(t,e){t.uniform1fv(this.addr,e)}function _pe(t,e){const n=Em(e,this.size,2);t.uniform2fv(this.addr,n)}function Spe(t,e){const n=Em(e,this.size,3);t.uniform3fv(this.addr,n)}function wpe(t,e){const n=Em(e,this.size,4);t.uniform4fv(this.addr,n)}function Mpe(t,e){const n=Em(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function Epe(t,e){const n=Em(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function Ape(t,e){const n=Em(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function Tpe(t,e){t.uniform1iv(this.addr,e)}function Cpe(t,e){t.uniform2iv(this.addr,e)}function Npe(t,e){t.uniform3iv(this.addr,e)}function Rpe(t,e){t.uniform4iv(this.addr,e)}function Ppe(t,e){t.uniform1uiv(this.addr,e)}function kpe(t,e){t.uniform2uiv(this.addr,e)}function Dpe(t,e){t.uniform3uiv(this.addr,e)}function Ope(t,e){t.uniform4uiv(this.addr,e)}function Lpe(t,e,n){const i=this.cache,r=e.length,a=nw(n,r);sr(i,a)||(t.uniform1iv(this.addr,a),or(i,a));for(let s=0;s!==r;++s)n.setTexture2D(e[s]||K9,a[s])}function Ipe(t,e,n){const i=this.cache,r=e.length,a=nw(n,r);sr(i,a)||(t.uniform1iv(this.addr,a),or(i,a));for(let s=0;s!==r;++s)n.setTexture3D(e[s]||Z9,a[s])}function jpe(t,e,n){const i=this.cache,r=e.length,a=nw(n,r);sr(i,a)||(t.uniform1iv(this.addr,a),or(i,a));for(let s=0;s!==r;++s)n.setTextureCube(e[s]||Q9,a[s])}function Upe(t,e,n){const i=this.cache,r=e.length,a=nw(n,r);sr(i,a)||(t.uniform1iv(this.addr,a),or(i,a));for(let s=0;s!==r;++s)n.setTexture2DArray(e[s]||Y9,a[s])}function Fpe(t){switch(t){case 5126:return bpe;case 35664:return _pe;case 35665:return Spe;case 35666:return wpe;case 35674:return Mpe;case 35675:return Epe;case 35676:return Ape;case 5124:case 35670:return Tpe;case 35667:case 35671:return Cpe;case 35668:case 35672:return Npe;case 35669:case 35673:return Rpe;case 5125:return Ppe;case 36294:return kpe;case 36295:return Dpe;case 36296:return Ope;case 35678:case 36198:case 36298:case 36306:case 35682:return Lpe;case 35679:case 36299:case 36307:return Ipe;case 35680:case 36300:case 36308:case 36293:return jpe;case 36289:case 36303:case 36311:case 36292:return Upe}}let zpe=class{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.setValue=ype(n.type)}},Bpe=class{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Fpe(n.type)}},Hpe=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 hT=/(\w+)(\])?(\[|\.)?/g;function GF(t,e){t.seq.push(e),t.map[e.id]=e}function $pe(t,e,n){const i=t.name,r=i.length;for(hT.lastIndex=0;;){const a=hT.exec(i),s=hT.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===r){GF(n,c===void 0?new zpe(o,t,e):new Bpe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new Hpe(o),GF(n,f)),n=f}}}let S_=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);$pe(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 WF(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const Vpe=37297;let Gpe=0;function Wpe(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 qF=new cn;function qpe(t){En._getMatrix(qF,En.workingColorSpace,t);const e=`mat3( ${qF.elements.map(n=>n.toFixed(4))} )`;switch(En.getTransfer(t)){case W_:return[e,"LinearTransferOETF"];case Bn:return[e,"sRGBTransferOETF"];default:return qt("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function XF(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+`
- `+Wpe(t.getShaderSource(e),o)}else return a}function Xpe(t,e){const n=qpe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function Kpe(t,e){let n;switch(e){case Wce:n="Linear";break;case qce:n="Reinhard";break;case Xce:n="Cineon";break;case Kce:n="ACESFilmic";break;case Zce:n="AgX";break;case Qce:n="Neutral";break;case Yce:n="Custom";break;default:qt("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const tb=new Ge;function Ype(){En.getLuminanceCoefficients(tb);const t=tb.x.toFixed(4),e=tb.y.toFixed(4),n=tb.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function Zpe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(lx).join(`
- `)}function Qpe(t){const e=[];for(const n in t){const i=t[n];i!==!1&&e.push("#define "+n+" "+i)}return e.join(`
- `)}function Jpe(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 lx(t){return t!==""}function KF(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 YF(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const eme=/^[ \t]*#include +<([\w\d./]+)>/gm;function _3(t){return t.replace(eme,nme)}const tme=new Map;function nme(t,e){let n=rn[e];if(n===void 0){const i=tme.get(e);if(i!==void 0)n=rn[i],qt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return _3(n)}const ime=/#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 ZF(t){return t.replace(ime,rme)}function rme(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 QF(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 ame(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===m9?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Ece?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Hl&&(e="SHADOWMAP_TYPE_VSM"),e}function sme(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Wp:case qp:e="ENVMAP_TYPE_CUBE";break;case JS:e="ENVMAP_TYPE_CUBE_UV";break}return e}function ome(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case qp:e="ENVMAP_MODE_REFRACTION";break}return e}function lme(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case $P:e="ENVMAP_BLENDING_MULTIPLY";break;case Vce:e="ENVMAP_BLENDING_MIX";break;case Gce:e="ENVMAP_BLENDING_ADD";break}return e}function cme(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 ume(t,e,n,i){const r=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=ame(n),c=sme(n),u=ome(n),f=lme(n),m=cme(n),g=Zpe(n),y=Qpe(a),_=r.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(lx).join(`
- `),v.length>0&&(v+=`
- `),x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(lx).join(`
- `),x.length>0&&(x+=`
- `)):(v=[QF(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,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 "+u:"",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(lx).join(`
- `),x=[QF(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,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 "+u:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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!==Uu?"#define TONE_MAPPING":"",n.toneMapping!==Uu?rn.tonemapping_pars_fragment:"",n.toneMapping!==Uu?Kpe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",rn.colorspace_pars_fragment,Xpe("linearToOutputTexel",n.outputColorSpace),Ype(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(lx).join(`
- `)),s=_3(s),s=KF(s,n),s=YF(s,n),o=_3(o),o=KF(o,n),o=YF(o,n),s=ZF(s),o=ZF(o),n.isRawShaderMaterial!==!0&&(M=`#version 300 es
- `,v=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,x=["#define varying in",n.glslVersion===aF?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===aF?"":"#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,C=M+x+o,T=WF(r,r.VERTEX_SHADER,w),P=WF(r,r.FRAGMENT_SHADER,C);r.attachShader(_,T),r.attachShader(_,P),n.index0AttributeName!==void 0?r.bindAttribLocation(_,0,n.index0AttributeName):n.morphTargets===!0&&r.bindAttribLocation(_,0,"position"),r.linkProgram(_);function A(F){if(t.debug.checkShaderErrors){const I=r.getProgramInfoLog(_)||"",W=r.getShaderInfoLog(T)||"",D=r.getShaderInfoLog(P)||"",B=I.trim(),$=W.trim(),K=D.trim();let X=!0,Y=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(X=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(r,_,T,P);else{const ee=XF(r,T,"vertex"),z=XF(r,P,"fragment");Di("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
- Material Name: `+F.name+`
- Material Type: `+F.type+`
- Program Info Log: `+B+`
- `+ee+`
- `+z)}else B!==""?qt("WebGLProgram: Program Info Log:",B):($===""||K==="")&&(Y=!1);Y&&(F.diagnostics={runnable:X,programLog:B,vertexShader:{log:$,prefix:v},fragmentShader:{log:K,prefix:x}})}r.deleteShader(T),r.deleteShader(P),j=new S_(r,_),N=Jpe(r,_)}let j;this.getUniforms=function(){return j===void 0&&A(this),j};let N;this.getAttributes=function(){return N===void 0&&A(this),N};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=r.getProgramParameter(_,Vpe)),k},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Gpe++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=T,this.fragmentShader=P,this}let dme=0,fme=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 hme(e),n.set(e,i)),i}},hme=class{constructor(e){this.id=dme++,this.code=e,this.usedTimes=0}};function pme(t,e,n,i,r,a,s){const o=new D9,l=new fme,c=new Set,u=[],f=r.logarithmicDepthBuffer,m=r.vertexTextures;let g=r.precision;const y={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 _(N){return c.add(N),N===0?"uv":`uv${N}`}function v(N,k,F,I,W){const D=I.fog,B=W.geometry,$=N.isMeshStandardMaterial?I.environment:null,K=(N.isMeshStandardMaterial?n:e).get(N.envMap||$),X=K&&K.mapping===JS?K.image.height:null,Y=y[N.type];N.precision!==null&&(g=r.getMaxPrecision(N.precision),g!==N.precision&&qt("WebGLProgram.getParameters:",N.precision,"not supported, using",g,"instead."));const ee=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,z=ee!==void 0?ee.length:0;let V=0;B.morphAttributes.position!==void 0&&(V=1),B.morphAttributes.normal!==void 0&&(V=2),B.morphAttributes.color!==void 0&&(V=3);let re,le,ge,ie;if(Y){const Rt=Bo[Y];re=Rt.vertexShader,le=Rt.fragmentShader}else re=N.vertexShader,le=N.fragmentShader,l.update(N),ge=l.getVertexShaderID(N),ie=l.getFragmentShaderID(N);const xe=t.getRenderTarget(),ke=t.state.buffers.depth.getReversed(),he=W.isInstancedMesh===!0,we=W.isBatchedMesh===!0,Ue=!!N.map,ue=!!N.matcap,lt=!!K,H=!!N.aoMap,q=!!N.lightMap,oe=!!N.bumpMap,Z=!!N.normalMap,Q=!!N.displacementMap,se=!!N.emissiveMap,Ce=!!N.metalnessMap,Ee=!!N.roughnessMap,ne=N.anisotropy>0,U=N.clearcoat>0,L=N.dispersion>0,J=N.iridescence>0,me=N.sheen>0,ye=N.transmission>0,pe=ne&&!!N.anisotropyMap,Qe=U&&!!N.clearcoatMap,Le=U&&!!N.clearcoatNormalMap,Xe=U&&!!N.clearcoatRoughnessMap,st=J&&!!N.iridescenceMap,Ie=J&&!!N.iridescenceThicknessMap,Pe=me&&!!N.sheenColorMap,pt=me&&!!N.sheenRoughnessMap,it=!!N.specularMap,nt=!!N.specularColorMap,dt=!!N.specularIntensityMap,de=ye&&!!N.transmissionMap,rt=ye&&!!N.thicknessMap,fe=!!N.gradientMap,Oe=!!N.alphaMap,Me=N.alphaTest>0,ve=!!N.alphaHash,Be=!!N.extensions;let ct=Uu;N.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(ct=t.toneMapping);const bt={shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:re,fragmentShader:le,defines:N.defines,customVertexShaderID:ge,customFragmentShaderID:ie,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:g,batching:we,batchingColor:we&&W._colorsTexture!==null,instancing:he,instancingColor:he&&W.instanceColor!==null,instancingMorph:he&&W.morphTexture!==null,supportsVertexTextures:m,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:Xp,alphaToCoverage:!!N.alphaToCoverage,map:Ue,matcap:ue,envMap:lt,envMapMode:lt&&K.mapping,envMapCubeUVHeight:X,aoMap:H,lightMap:q,bumpMap:oe,normalMap:Z,displacementMap:m&&Q,emissiveMap:se,normalMapObjectSpace:Z&&N.normalMapType===nue,normalMapTangentSpace:Z&&N.normalMapType===M9,metalnessMap:Ce,roughnessMap:Ee,anisotropy:ne,anisotropyMap:pe,clearcoat:U,clearcoatMap:Qe,clearcoatNormalMap:Le,clearcoatRoughnessMap:Xe,dispersion:L,iridescence:J,iridescenceMap:st,iridescenceThicknessMap:Ie,sheen:me,sheenColorMap:Pe,sheenRoughnessMap:pt,specularMap:it,specularColorMap:nt,specularIntensityMap:dt,transmission:ye,transmissionMap:de,thicknessMap:rt,gradientMap:fe,opaque:N.transparent===!1&&N.blending===Ap&&N.alphaToCoverage===!1,alphaMap:Oe,alphaTest:Me,alphaHash:ve,combine:N.combine,mapUv:Ue&&_(N.map.channel),aoMapUv:H&&_(N.aoMap.channel),lightMapUv:q&&_(N.lightMap.channel),bumpMapUv:oe&&_(N.bumpMap.channel),normalMapUv:Z&&_(N.normalMap.channel),displacementMapUv:Q&&_(N.displacementMap.channel),emissiveMapUv:se&&_(N.emissiveMap.channel),metalnessMapUv:Ce&&_(N.metalnessMap.channel),roughnessMapUv:Ee&&_(N.roughnessMap.channel),anisotropyMapUv:pe&&_(N.anisotropyMap.channel),clearcoatMapUv:Qe&&_(N.clearcoatMap.channel),clearcoatNormalMapUv:Le&&_(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Xe&&_(N.clearcoatRoughnessMap.channel),iridescenceMapUv:st&&_(N.iridescenceMap.channel),iridescenceThicknessMapUv:Ie&&_(N.iridescenceThicknessMap.channel),sheenColorMapUv:Pe&&_(N.sheenColorMap.channel),sheenRoughnessMapUv:pt&&_(N.sheenRoughnessMap.channel),specularMapUv:it&&_(N.specularMap.channel),specularColorMapUv:nt&&_(N.specularColorMap.channel),specularIntensityMapUv:dt&&_(N.specularIntensityMap.channel),transmissionMapUv:de&&_(N.transmissionMap.channel),thicknessMapUv:rt&&_(N.thicknessMap.channel),alphaMapUv:Oe&&_(N.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(Z||ne),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,pointsUvs:W.isPoints===!0&&!!B.attributes.uv&&(Ue||Oe),fog:!!D,useFog:N.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:N.flatShading===!0&&N.wireframe===!1,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:ke,skinning:W.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:ct,decodeVideoTexture:Ue&&N.map.isVideoTexture===!0&&En.getTransfer(N.map.colorSpace)===Bn,decodeVideoTextureEmissive:se&&N.emissiveMap.isVideoTexture===!0&&En.getTransfer(N.emissiveMap.colorSpace)===Bn,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Ho,flipSided:N.side===ja,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionClipCullDistance:Be&&N.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Be&&N.extensions.multiDraw===!0||we)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()};return bt.vertexUv1s=c.has(1),bt.vertexUv2s=c.has(2),bt.vertexUv3s=c.has(3),c.clear(),bt}function x(N){const k=[];if(N.shaderID?k.push(N.shaderID):(k.push(N.customVertexShaderID),k.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)k.push(F),k.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(M(k,N),w(k,N),k.push(t.outputColorSpace)),k.push(N.customProgramCacheKey),k.join()}function M(N,k){N.push(k.precision),N.push(k.outputColorSpace),N.push(k.envMapMode),N.push(k.envMapCubeUVHeight),N.push(k.mapUv),N.push(k.alphaMapUv),N.push(k.lightMapUv),N.push(k.aoMapUv),N.push(k.bumpMapUv),N.push(k.normalMapUv),N.push(k.displacementMapUv),N.push(k.emissiveMapUv),N.push(k.metalnessMapUv),N.push(k.roughnessMapUv),N.push(k.anisotropyMapUv),N.push(k.clearcoatMapUv),N.push(k.clearcoatNormalMapUv),N.push(k.clearcoatRoughnessMapUv),N.push(k.iridescenceMapUv),N.push(k.iridescenceThicknessMapUv),N.push(k.sheenColorMapUv),N.push(k.sheenRoughnessMapUv),N.push(k.specularMapUv),N.push(k.specularColorMapUv),N.push(k.specularIntensityMapUv),N.push(k.transmissionMapUv),N.push(k.thicknessMapUv),N.push(k.combine),N.push(k.fogExp2),N.push(k.sizeAttenuation),N.push(k.morphTargetsCount),N.push(k.morphAttributeCount),N.push(k.numDirLights),N.push(k.numPointLights),N.push(k.numSpotLights),N.push(k.numSpotLightMaps),N.push(k.numHemiLights),N.push(k.numRectAreaLights),N.push(k.numDirLightShadows),N.push(k.numPointLightShadows),N.push(k.numSpotLightShadows),N.push(k.numSpotLightShadowsWithMaps),N.push(k.numLightProbes),N.push(k.shadowMapType),N.push(k.toneMapping),N.push(k.numClippingPlanes),N.push(k.numClipIntersection),N.push(k.depthPacking)}function w(N,k){o.disableAll(),k.supportsVertexTextures&&o.enable(0),k.instancing&&o.enable(1),k.instancingColor&&o.enable(2),k.instancingMorph&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),k.dispersion&&o.enable(20),k.batchingColor&&o.enable(21),k.gradientMap&&o.enable(22),N.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.reversedDepthBuffer&&o.enable(4),k.skinning&&o.enable(5),k.morphTargets&&o.enable(6),k.morphNormals&&o.enable(7),k.morphColors&&o.enable(8),k.premultipliedAlpha&&o.enable(9),k.shadowMapEnabled&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),k.decodeVideoTextureEmissive&&o.enable(20),k.alphaToCoverage&&o.enable(21),N.push(o.mask)}function C(N){const k=y[N.type];let F;if(k){const I=Bo[k];F=kue.clone(I.uniforms)}else F=N.uniforms;return F}function T(N,k){let F;for(let I=0,W=u.length;I<W;I++){const D=u[I];if(D.cacheKey===k){F=D,++F.usedTimes;break}}return F===void 0&&(F=new ume(t,k,N,a),u.push(F)),F}function P(N){if(--N.usedTimes===0){const k=u.indexOf(N);u[k]=u[u.length-1],u.pop(),N.destroy()}}function A(N){l.remove(N)}function j(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:C,acquireProgram:T,releaseProgram:P,releaseShaderCache:A,programs:u,dispose:j}}function mme(){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 gme(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 JF(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 ez(){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,m,g,y,_,v){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:m,material:g,groupOrder:y,renderOrder:f.renderOrder,z:_,group:v},t[e]=x):(x.id=f.id,x.object=f,x.geometry=m,x.material=g,x.groupOrder=y,x.renderOrder=f.renderOrder,x.z=_,x.group=v),e++,x}function o(f,m,g,y,_,v){const x=s(f,m,g,y,_,v);g.transmission>0?i.push(x):g.transparent===!0?r.push(x):n.push(x)}function l(f,m,g,y,_,v){const x=s(f,m,g,y,_,v);g.transmission>0?i.unshift(x):g.transparent===!0?r.unshift(x):n.unshift(x)}function c(f,m){n.length>1&&n.sort(f||gme),i.length>1&&i.sort(m||JF),r.length>1&&r.sort(m||JF)}function u(){for(let f=e,m=t.length;f<m;f++){const g=t[f];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:a,push:o,unshift:l,finish:u,sort:c}}function xme(){let t=new WeakMap;function e(i,r){const a=t.get(i);let s;return a===void 0?(s=new ez,t.set(i,[s])):r>=a.length?(s=new ez,a.push(s)):s=a[r],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function vme(){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 Ge,color:new vn};break;case"SpotLight":n={position:new Ge,direction:new Ge,color:new vn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Ge,color:new vn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Ge,skyColor:new vn,groundColor:new vn};break;case"RectAreaLight":n={color:new vn,position:new Ge,halfWidth:new Ge,halfHeight:new Ge};break}return t[e.id]=n,n}}}function yme(){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 sn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new sn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let bme=0;function _me(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function Sme(t){const e=new vme,n=yme(),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 Ge);const r=new Ge,a=new Xi,s=new Xi;function o(c){let u=0,f=0,m=0;for(let N=0;N<9;N++)i.probe[N].set(0,0,0);let g=0,y=0,_=0,v=0,x=0,M=0,w=0,C=0,T=0,P=0,A=0;c.sort(_me);for(let N=0,k=c.length;N<k;N++){const F=c[N],I=F.color,W=F.intensity,D=F.distance,B=F.shadow&&F.shadow.map?F.shadow.map.texture:null;if(F.isAmbientLight)u+=I.r*W,f+=I.g*W,m+=I.b*W;else if(F.isLightProbe){for(let $=0;$<9;$++)i.probe[$].addScaledVector(F.sh.coefficients[$],W);A++}else if(F.isDirectionalLight){const $=e.get(F);if($.color.copy(F.color).multiplyScalar(F.intensity),F.castShadow){const K=F.shadow,X=n.get(F);X.shadowIntensity=K.intensity,X.shadowBias=K.bias,X.shadowNormalBias=K.normalBias,X.shadowRadius=K.radius,X.shadowMapSize=K.mapSize,i.directionalShadow[g]=X,i.directionalShadowMap[g]=B,i.directionalShadowMatrix[g]=F.shadow.matrix,M++}i.directional[g]=$,g++}else if(F.isSpotLight){const $=e.get(F);$.position.setFromMatrixPosition(F.matrixWorld),$.color.copy(I).multiplyScalar(W),$.distance=D,$.coneCos=Math.cos(F.angle),$.penumbraCos=Math.cos(F.angle*(1-F.penumbra)),$.decay=F.decay,i.spot[_]=$;const K=F.shadow;if(F.map&&(i.spotLightMap[T]=F.map,T++,K.updateMatrices(F),F.castShadow&&P++),i.spotLightMatrix[_]=K.matrix,F.castShadow){const X=n.get(F);X.shadowIntensity=K.intensity,X.shadowBias=K.bias,X.shadowNormalBias=K.normalBias,X.shadowRadius=K.radius,X.shadowMapSize=K.mapSize,i.spotShadow[_]=X,i.spotShadowMap[_]=B,C++}_++}else if(F.isRectAreaLight){const $=e.get(F);$.color.copy(I).multiplyScalar(W),$.halfWidth.set(F.width*.5,0,0),$.halfHeight.set(0,F.height*.5,0),i.rectArea[v]=$,v++}else if(F.isPointLight){const $=e.get(F);if($.color.copy(F.color).multiplyScalar(F.intensity),$.distance=F.distance,$.decay=F.decay,F.castShadow){const K=F.shadow,X=n.get(F);X.shadowIntensity=K.intensity,X.shadowBias=K.bias,X.shadowNormalBias=K.normalBias,X.shadowRadius=K.radius,X.shadowMapSize=K.mapSize,X.shadowCameraNear=K.camera.near,X.shadowCameraFar=K.camera.far,i.pointShadow[y]=X,i.pointShadowMap[y]=B,i.pointShadowMatrix[y]=F.shadow.matrix,w++}i.point[y]=$,y++}else if(F.isHemisphereLight){const $=e.get(F);$.skyColor.copy(F.color).multiplyScalar(W),$.groundColor.copy(F.groundColor).multiplyScalar(W),i.hemi[x]=$,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]=u,i.ambient[1]=f,i.ambient[2]=m;const j=i.hash;(j.directionalLength!==g||j.pointLength!==y||j.spotLength!==_||j.rectAreaLength!==v||j.hemiLength!==x||j.numDirectionalShadows!==M||j.numPointShadows!==w||j.numSpotShadows!==C||j.numSpotMaps!==T||j.numLightProbes!==A)&&(i.directional.length=g,i.spot.length=_,i.rectArea.length=v,i.point.length=y,i.hemi.length=x,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=M,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=C+T-P,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=P,i.numLightProbes=A,j.directionalLength=g,j.pointLength=y,j.spotLength=_,j.rectAreaLength=v,j.hemiLength=x,j.numDirectionalShadows=M,j.numPointShadows=w,j.numSpotShadows=C,j.numSpotMaps=T,j.numLightProbes=A,i.version=bme++)}function l(c,u){let f=0,m=0,g=0,y=0,_=0;const v=u.matrixWorldInverse;for(let x=0,M=c.length;x<M;x++){const w=c[x];if(w.isDirectionalLight){const C=i.directional[f];C.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),C.direction.sub(r),C.direction.transformDirection(v),f++}else if(w.isSpotLight){const C=i.spot[g];C.position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(v),C.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),C.direction.sub(r),C.direction.transformDirection(v),g++}else if(w.isRectAreaLight){const C=i.rectArea[y];C.position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(v),s.identity(),a.copy(w.matrixWorld),a.premultiply(v),s.extractRotation(a),C.halfWidth.set(w.width*.5,0,0),C.halfHeight.set(0,w.height*.5,0),C.halfWidth.applyMatrix4(s),C.halfHeight.applyMatrix4(s),y++}else if(w.isPointLight){const C=i.point[m];C.position.setFromMatrixPosition(w.matrixWorld),C.position.applyMatrix4(v),m++}else if(w.isHemisphereLight){const C=i.hemi[_];C.direction.setFromMatrixPosition(w.matrixWorld),C.direction.transformDirection(v),_++}}}return{setup:o,setupView:l,state:i}}function tz(t){const e=new Sme(t),n=[],i=[];function r(u){c.camera=u,n.length=0,i.length=0}function a(u){n.push(u)}function s(u){i.push(u)}function o(){e.setup(n)}function l(u){e.setupView(n,u)}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 wme(t){let e=new WeakMap;function n(r,a=0){const s=e.get(r);let o;return s===void 0?(o=new tz(t),e.set(r,[o])):a>=s.length?(o=new tz(t),s.push(o)):o=s[a],o}function i(){e=new WeakMap}return{get:n,dispose:i}}const Mme=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,Eme=`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 Ame(t,e,n){let i=new tk;const r=new sn,a=new sn,s=new Vi,o=new Wue({depthPacking:tue}),l=new que,c={},u=n.maxTextureSize,f={[qu]:ja,[ja]:qu,[Ho]:Ho},m=new gc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new sn},radius:{value:4}},vertexShader:Mme,fragmentShader:Eme}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const y=new cl;y.setAttribute("position",new $s(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new tl(y,m),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=m9;let x=this.type;this.render=function(P,A,j){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||P.length===0)return;const N=t.getRenderTarget(),k=t.getActiveCubeFace(),F=t.getActiveMipmapLevel(),I=t.state;I.setBlending(ac),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 W=x!==Hl&&this.type===Hl,D=x===Hl&&this.type!==Hl;for(let B=0,$=P.length;B<$;B++){const K=P[B],X=K.shadow;if(X===void 0){qt("WebGLShadowMap:",K,"has no shadow.");continue}if(X.autoUpdate===!1&&X.needsUpdate===!1)continue;r.copy(X.mapSize);const Y=X.getFrameExtents();if(r.multiply(Y),a.copy(X.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/Y.x),r.x=a.x*Y.x,X.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/Y.y),r.y=a.y*Y.y,X.mapSize.y=a.y)),X.map===null||W===!0||D===!0){const z=this.type!==Hl?{minFilter:us,magFilter:us}:{};X.map!==null&&X.map.dispose(),X.map=new Ef(r.x,r.y,z),X.map.texture.name=K.name+".shadowMap",X.camera.updateProjectionMatrix()}t.setRenderTarget(X.map),t.clear();const ee=X.getViewportCount();for(let z=0;z<ee;z++){const V=X.getViewport(z);s.set(a.x*V.x,a.y*V.y,a.x*V.z,a.y*V.w),I.viewport(s),X.updateMatrices(K,z),i=X.getFrustum(),C(A,j,X.camera,K,this.type)}X.isPointLightShadow!==!0&&this.type===Hl&&M(X,j),X.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(N,k,F)};function M(P,A){const j=e.update(_);m.defines.VSM_SAMPLES!==P.blurSamples&&(m.defines.VSM_SAMPLES=P.blurSamples,g.defines.VSM_SAMPLES=P.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),P.mapPass===null&&(P.mapPass=new Ef(r.x,r.y)),m.uniforms.shadow_pass.value=P.map.texture,m.uniforms.resolution.value=P.mapSize,m.uniforms.radius.value=P.radius,t.setRenderTarget(P.mapPass),t.clear(),t.renderBufferDirect(A,null,j,m,_,null),g.uniforms.shadow_pass.value=P.mapPass.texture,g.uniforms.resolution.value=P.mapSize,g.uniforms.radius.value=P.radius,t.setRenderTarget(P.map),t.clear(),t.renderBufferDirect(A,null,j,g,_,null)}function w(P,A,j,N){let k=null;const F=j.isPointLight===!0?P.customDistanceMaterial:P.customDepthMaterial;if(F!==void 0)k=F;else if(k=j.isPointLight===!0?l:o,t.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0||A.alphaToCoverage===!0){const I=k.uuid,W=A.uuid;let D=c[I];D===void 0&&(D={},c[I]=D);let B=D[W];B===void 0&&(B=k.clone(),D[W]=B,A.addEventListener("dispose",T)),k=B}if(k.visible=A.visible,k.wireframe=A.wireframe,N===Hl?k.side=A.shadowSide!==null?A.shadowSide:A.side:k.side=A.shadowSide!==null?A.shadowSide:f[A.side],k.alphaMap=A.alphaMap,k.alphaTest=A.alphaToCoverage===!0?.5:A.alphaTest,k.map=A.map,k.clipShadows=A.clipShadows,k.clippingPlanes=A.clippingPlanes,k.clipIntersection=A.clipIntersection,k.displacementMap=A.displacementMap,k.displacementScale=A.displacementScale,k.displacementBias=A.displacementBias,k.wireframeLinewidth=A.wireframeLinewidth,k.linewidth=A.linewidth,j.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const I=t.properties.get(k);I.light=j}return k}function C(P,A,j,N,k){if(P.visible===!1)return;if(P.layers.test(A.layers)&&(P.isMesh||P.isLine||P.isPoints)&&(P.castShadow||P.receiveShadow&&k===Hl)&&(!P.frustumCulled||i.intersectsObject(P))){P.modelViewMatrix.multiplyMatrices(j.matrixWorldInverse,P.matrixWorld);const W=e.update(P),D=P.material;if(Array.isArray(D)){const B=W.groups;for(let $=0,K=B.length;$<K;$++){const X=B[$],Y=D[X.materialIndex];if(Y&&Y.visible){const ee=w(P,Y,N,k);P.onBeforeShadow(t,P,A,j,W,ee,X),t.renderBufferDirect(j,null,W,ee,P,X),P.onAfterShadow(t,P,A,j,W,ee,X)}}}else if(D.visible){const B=w(P,D,N,k);P.onBeforeShadow(t,P,A,j,W,B,null),t.renderBufferDirect(j,null,W,B,P,null),P.onAfterShadow(t,P,A,j,W,B,null)}}const I=P.children;for(let W=0,D=I.length;W<D;W++)C(I[W],A,j,N,k)}function T(P){P.target.removeEventListener("dispose",T);for(const j in c){const N=c[j],k=P.target.uuid;k in N&&(N[k].dispose(),delete N[k])}}}const Tme={[ON]:LN,[IN]:FN,[jN]:zN,[Gp]:UN,[LN]:ON,[FN]:IN,[zN]:jN,[UN]:Gp};function Cme(t,e){function n(){let de=!1;const rt=new Vi;let fe=null;const Oe=new Vi(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,ve,Be,ct,bt){bt===!0&&(Me*=ct,ve*=ct,Be*=ct),rt.set(Me,ve,Be,ct),Oe.equals(rt)===!1&&(t.clearColor(Me,ve,Be,ct),Oe.copy(rt))},reset:function(){de=!1,fe=null,Oe.set(-1,0,0,0)}}}function i(){let de=!1,rt=!1,fe=null,Oe=null,Me=null;return{setReversed:function(ve){if(rt!==ve){const Be=e.get("EXT_clip_control");ve?Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.ZERO_TO_ONE_EXT):Be.clipControlEXT(Be.LOWER_LEFT_EXT,Be.NEGATIVE_ONE_TO_ONE_EXT),rt=ve;const ct=Me;Me=null,this.setClear(ct)}},getReversed:function(){return rt},setTest:function(ve){ve?xe(t.DEPTH_TEST):ke(t.DEPTH_TEST)},setMask:function(ve){fe!==ve&&!de&&(t.depthMask(ve),fe=ve)},setFunc:function(ve){if(rt&&(ve=Tme[ve]),Oe!==ve){switch(ve){case ON:t.depthFunc(t.NEVER);break;case LN:t.depthFunc(t.ALWAYS);break;case IN:t.depthFunc(t.LESS);break;case Gp:t.depthFunc(t.LEQUAL);break;case jN:t.depthFunc(t.EQUAL);break;case UN:t.depthFunc(t.GEQUAL);break;case FN:t.depthFunc(t.GREATER);break;case zN:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Oe=ve}},setLocked:function(ve){de=ve},setClear:function(ve){Me!==ve&&(rt&&(ve=1-ve),t.clearDepth(ve),Me=ve)},reset:function(){de=!1,fe=null,Oe=null,Me=null,rt=!1}}}function r(){let de=!1,rt=null,fe=null,Oe=null,Me=null,ve=null,Be=null,ct=null,bt=null;return{setTest:function(Rt){de||(Rt?xe(t.STENCIL_TEST):ke(t.STENCIL_TEST))},setMask:function(Rt){rt!==Rt&&!de&&(t.stencilMask(Rt),rt=Rt)},setFunc:function(Rt,ln,Ot){(fe!==Rt||Oe!==ln||Me!==Ot)&&(t.stencilFunc(Rt,ln,Ot),fe=Rt,Oe=ln,Me=Ot)},setOp:function(Rt,ln,Ot){(ve!==Rt||Be!==ln||ct!==Ot)&&(t.stencilOp(Rt,ln,Ot),ve=Rt,Be=ln,ct=Ot)},setLocked:function(Rt){de=Rt},setClear:function(Rt){bt!==Rt&&(t.clearStencil(Rt),bt=Rt)},reset:function(){de=!1,rt=null,fe=null,Oe=null,Me=null,ve=null,Be=null,ct=null,bt=null}}}const a=new n,s=new i,o=new r,l=new WeakMap,c=new WeakMap;let u={},f={},m=new WeakMap,g=[],y=null,_=!1,v=null,x=null,M=null,w=null,C=null,T=null,P=null,A=new vn(0,0,0),j=0,N=!1,k=null,F=null,I=null,W=null,D=null;const B=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let $=!1,K=0;const X=t.getParameter(t.VERSION);X.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(X)[1]),$=K>=1):X.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),$=K>=2);let Y=null,ee={};const z=t.getParameter(t.SCISSOR_BOX),V=t.getParameter(t.VIEWPORT),re=new Vi().fromArray(z),le=new Vi().fromArray(V);function ge(de,rt,fe,Oe){const Me=new Uint8Array(4),ve=t.createTexture();t.bindTexture(de,ve),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(rt,0,t.RGBA,1,1,Oe,0,t.RGBA,t.UNSIGNED_BYTE,Me):t.texImage2D(rt+Be,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Me);return ve}const ie={};ie[t.TEXTURE_2D]=ge(t.TEXTURE_2D,t.TEXTURE_2D,1),ie[t.TEXTURE_CUBE_MAP]=ge(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),ie[t.TEXTURE_2D_ARRAY]=ge(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ie[t.TEXTURE_3D]=ge(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),s.setClear(1),o.setClear(0),xe(t.DEPTH_TEST),s.setFunc(Gp),oe(!1),Z(JU),xe(t.CULL_FACE),H(ac);function xe(de){u[de]!==!0&&(t.enable(de),u[de]=!0)}function ke(de){u[de]!==!1&&(t.disable(de),u[de]=!1)}function he(de,rt){return f[de]!==rt?(t.bindFramebuffer(de,rt),f[de]=rt,de===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=rt),de===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=rt),!0):!1}function we(de,rt){let fe=g,Oe=!1;if(de){fe=m.get(rt),fe===void 0&&(fe=[],m.set(rt,fe));const Me=de.textures;if(fe.length!==Me.length||fe[0]!==t.COLOR_ATTACHMENT0){for(let ve=0,Be=Me.length;ve<Be;ve++)fe[ve]=t.COLOR_ATTACHMENT0+ve;fe.length=Me.length,Oe=!0}}else fe[0]!==t.BACK&&(fe[0]=t.BACK,Oe=!0);Oe&&t.drawBuffers(fe)}function Ue(de){return y!==de?(t.useProgram(de),y=de,!0):!1}const ue={[$d]:t.FUNC_ADD,[Tce]:t.FUNC_SUBTRACT,[Cce]:t.FUNC_REVERSE_SUBTRACT};ue[Nce]=t.MIN,ue[Rce]=t.MAX;const lt={[Pce]:t.ZERO,[kce]:t.ONE,[Dce]:t.SRC_COLOR,[kN]:t.SRC_ALPHA,[Fce]:t.SRC_ALPHA_SATURATE,[jce]:t.DST_COLOR,[Lce]:t.DST_ALPHA,[Oce]:t.ONE_MINUS_SRC_COLOR,[DN]:t.ONE_MINUS_SRC_ALPHA,[Uce]:t.ONE_MINUS_DST_COLOR,[Ice]:t.ONE_MINUS_DST_ALPHA,[zce]:t.CONSTANT_COLOR,[Bce]:t.ONE_MINUS_CONSTANT_COLOR,[Hce]:t.CONSTANT_ALPHA,[$ce]:t.ONE_MINUS_CONSTANT_ALPHA};function H(de,rt,fe,Oe,Me,ve,Be,ct,bt,Rt){if(de===ac){_===!0&&(ke(t.BLEND),_=!1);return}if(_===!1&&(xe(t.BLEND),_=!0),de!==Ace){if(de!==v||Rt!==N){if((x!==$d||C!==$d)&&(t.blendEquation(t.FUNC_ADD),x=$d,C=$d),Rt)switch(de){case Ap:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case eF:t.blendFunc(t.ONE,t.ONE);break;case tF:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case nF:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Di("WebGLState: Invalid blending: ",de);break}else switch(de){case Ap:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case eF:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case tF:Di("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case nF:Di("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Di("WebGLState: Invalid blending: ",de);break}M=null,w=null,T=null,P=null,A.set(0,0,0),j=0,v=de,N=Rt}return}Me=Me||rt,ve=ve||fe,Be=Be||Oe,(rt!==x||Me!==C)&&(t.blendEquationSeparate(ue[rt],ue[Me]),x=rt,C=Me),(fe!==M||Oe!==w||ve!==T||Be!==P)&&(t.blendFuncSeparate(lt[fe],lt[Oe],lt[ve],lt[Be]),M=fe,w=Oe,T=ve,P=Be),(ct.equals(A)===!1||bt!==j)&&(t.blendColor(ct.r,ct.g,ct.b,bt),A.copy(ct),j=bt),v=de,N=!1}function q(de,rt){de.side===Ho?ke(t.CULL_FACE):xe(t.CULL_FACE);let fe=de.side===ja;rt&&(fe=!fe),oe(fe),de.blending===Ap&&de.transparent===!1?H(ac):H(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 Oe=de.stencilWrite;o.setTest(Oe),Oe&&(o.setMask(de.stencilWriteMask),o.setFunc(de.stencilFunc,de.stencilRef,de.stencilFuncMask),o.setOp(de.stencilFail,de.stencilZFail,de.stencilZPass)),se(de.polygonOffset,de.polygonOffsetFactor,de.polygonOffsetUnits),de.alphaToCoverage===!0?xe(t.SAMPLE_ALPHA_TO_COVERAGE):ke(t.SAMPLE_ALPHA_TO_COVERAGE)}function oe(de){k!==de&&(de?t.frontFace(t.CW):t.frontFace(t.CCW),k=de)}function Z(de){de!==wce?(xe(t.CULL_FACE),de!==F&&(de===JU?t.cullFace(t.BACK):de===Mce?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ke(t.CULL_FACE),F=de}function Q(de){de!==I&&($&&t.lineWidth(de),I=de)}function se(de,rt,fe){de?(xe(t.POLYGON_OFFSET_FILL),(W!==rt||D!==fe)&&(t.polygonOffset(rt,fe),W=rt,D=fe)):ke(t.POLYGON_OFFSET_FILL)}function Ce(de){de?xe(t.SCISSOR_TEST):ke(t.SCISSOR_TEST)}function Ee(de){de===void 0&&(de=t.TEXTURE0+B-1),Y!==de&&(t.activeTexture(de),Y=de)}function ne(de,rt,fe){fe===void 0&&(Y===null?fe=t.TEXTURE0+B-1:fe=Y);let Oe=ee[fe];Oe===void 0&&(Oe={type:void 0,texture:void 0},ee[fe]=Oe),(Oe.type!==de||Oe.texture!==rt)&&(Y!==fe&&(t.activeTexture(fe),Y=fe),t.bindTexture(de,rt||ie[de]),Oe.type=de,Oe.texture=rt)}function U(){const de=ee[Y];de!==void 0&&de.type!==void 0&&(t.bindTexture(de.type,null),de.type=void 0,de.texture=void 0)}function L(){try{t.compressedTexImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function J(){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 pe(){try{t.compressedTexSubImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Qe(){try{t.compressedTexSubImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Le(){try{t.texStorage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Xe(){try{t.texStorage3D(...arguments)}catch(de){de("WebGLState:",de)}}function st(){try{t.texImage2D(...arguments)}catch(de){de("WebGLState:",de)}}function Ie(){try{t.texImage3D(...arguments)}catch(de){de("WebGLState:",de)}}function Pe(de){re.equals(de)===!1&&(t.scissor(de.x,de.y,de.z,de.w),re.copy(de))}function pt(de){le.equals(de)===!1&&(t.viewport(de.x,de.y,de.z,de.w),le.copy(de))}function it(de,rt){let fe=c.get(rt);fe===void 0&&(fe=new WeakMap,c.set(rt,fe));let Oe=fe.get(de);Oe===void 0&&(Oe=t.getUniformBlockIndex(rt,de.name),fe.set(de,Oe))}function nt(de,rt){const Oe=c.get(rt).get(de);l.get(rt)!==Oe&&(t.uniformBlockBinding(rt,Oe,de.__bindingPointIndex),l.set(rt,Oe))}function dt(){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),u={},Y=null,ee={},f={},m=new WeakMap,g=[],y=null,_=!1,v=null,x=null,M=null,w=null,C=null,T=null,P=null,A=new vn(0,0,0),j=0,N=!1,k=null,F=null,I=null,W=null,D=null,re.set(0,0,t.canvas.width,t.canvas.height),le.set(0,0,t.canvas.width,t.canvas.height),a.reset(),s.reset(),o.reset()}return{buffers:{color:a,depth:s,stencil:o},enable:xe,disable:ke,bindFramebuffer:he,drawBuffers:we,useProgram:Ue,setBlending:H,setMaterial:q,setFlipSided:oe,setCullFace:Z,setLineWidth:Q,setPolygonOffset:se,setScissorTest:Ce,activeTexture:Ee,bindTexture:ne,unbindTexture:U,compressedTexImage2D:L,compressedTexImage3D:J,texImage2D:st,texImage3D:Ie,updateUBOMapping:it,uniformBlockBinding:nt,texStorage2D:Le,texStorage3D:Xe,texSubImage2D:me,texSubImage3D:ye,compressedTexSubImage2D:pe,compressedTexSubImage3D:Qe,scissor:Pe,viewport:pt,reset:dt}}function Nme(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 sn,u=new WeakMap;let f;const m=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(U,L){return g?new OffscreenCanvas(U,L):X_("canvas")}function _(U,L,J){let me=1;const ye=ne(U);if((ye.width>J||ye.height>J)&&(me=J/Math.max(ye.width,ye.height)),me<1)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap||typeof VideoFrame<"u"&&U instanceof VideoFrame){const pe=Math.floor(me*ye.width),Qe=Math.floor(me*ye.height);f===void 0&&(f=y(pe,Qe));const Le=L?y(pe,Qe):f;return Le.width=pe,Le.height=Qe,Le.getContext("2d").drawImage(U,0,0,pe,Qe),qt("WebGLRenderer: Texture has been resized from ("+ye.width+"x"+ye.height+") to ("+pe+"x"+Qe+")."),Le}else return"data"in U&&qt("WebGLRenderer: Image in DataTexture is too big ("+ye.width+"x"+ye.height+")."),U;return U}function v(U){return U.generateMipmaps}function x(U){t.generateMipmap(U)}function M(U){return U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:U.isWebGL3DRenderTarget?t.TEXTURE_3D:U.isWebGLArrayRenderTarget||U.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(U,L,J,me,ye=!1){if(U!==null){if(t[U]!==void 0)return t[U];qt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let pe=L;if(L===t.RED&&(J===t.FLOAT&&(pe=t.R32F),J===t.HALF_FLOAT&&(pe=t.R16F),J===t.UNSIGNED_BYTE&&(pe=t.R8)),L===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(pe=t.R8UI),J===t.UNSIGNED_SHORT&&(pe=t.R16UI),J===t.UNSIGNED_INT&&(pe=t.R32UI),J===t.BYTE&&(pe=t.R8I),J===t.SHORT&&(pe=t.R16I),J===t.INT&&(pe=t.R32I)),L===t.RG&&(J===t.FLOAT&&(pe=t.RG32F),J===t.HALF_FLOAT&&(pe=t.RG16F),J===t.UNSIGNED_BYTE&&(pe=t.RG8)),L===t.RG_INTEGER&&(J===t.UNSIGNED_BYTE&&(pe=t.RG8UI),J===t.UNSIGNED_SHORT&&(pe=t.RG16UI),J===t.UNSIGNED_INT&&(pe=t.RG32UI),J===t.BYTE&&(pe=t.RG8I),J===t.SHORT&&(pe=t.RG16I),J===t.INT&&(pe=t.RG32I)),L===t.RGB_INTEGER&&(J===t.UNSIGNED_BYTE&&(pe=t.RGB8UI),J===t.UNSIGNED_SHORT&&(pe=t.RGB16UI),J===t.UNSIGNED_INT&&(pe=t.RGB32UI),J===t.BYTE&&(pe=t.RGB8I),J===t.SHORT&&(pe=t.RGB16I),J===t.INT&&(pe=t.RGB32I)),L===t.RGBA_INTEGER&&(J===t.UNSIGNED_BYTE&&(pe=t.RGBA8UI),J===t.UNSIGNED_SHORT&&(pe=t.RGBA16UI),J===t.UNSIGNED_INT&&(pe=t.RGBA32UI),J===t.BYTE&&(pe=t.RGBA8I),J===t.SHORT&&(pe=t.RGBA16I),J===t.INT&&(pe=t.RGBA32I)),L===t.RGB&&(J===t.UNSIGNED_INT_5_9_9_9_REV&&(pe=t.RGB9_E5),J===t.UNSIGNED_INT_10F_11F_11F_REV&&(pe=t.R11F_G11F_B10F)),L===t.RGBA){const Qe=ye?W_:En.getTransfer(me);J===t.FLOAT&&(pe=t.RGBA32F),J===t.HALF_FLOAT&&(pe=t.RGBA16F),J===t.UNSIGNED_BYTE&&(pe=Qe===Bn?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(pe=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(pe=t.RGB5_A1)}return(pe===t.R16F||pe===t.R32F||pe===t.RG16F||pe===t.RG32F||pe===t.RGBA16F||pe===t.RGBA32F)&&e.get("EXT_color_buffer_float"),pe}function C(U,L){let J;return U?L===null||L===wf||L===Yx?J=t.DEPTH24_STENCIL8:L===Jl?J=t.DEPTH32F_STENCIL8:L===Kx&&(J=t.DEPTH24_STENCIL8,qt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):L===null||L===wf||L===Yx?J=t.DEPTH_COMPONENT24:L===Jl?J=t.DEPTH_COMPONENT32F:L===Kx&&(J=t.DEPTH_COMPONENT16),J}function T(U,L){return v(U)===!0||U.isFramebufferTexture&&U.minFilter!==us&&U.minFilter!==Bs?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function P(U){const L=U.target;L.removeEventListener("dispose",P),j(L),L.isVideoTexture&&u.delete(L)}function A(U){const L=U.target;L.removeEventListener("dispose",A),k(L)}function j(U){const L=i.get(U);if(L.__webglInit===void 0)return;const J=U.source,me=m.get(J);if(me){const ye=me[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&N(U),Object.keys(me).length===0&&m.delete(J)}i.remove(U)}function N(U){const L=i.get(U);t.deleteTexture(L.__webglTexture);const J=U.source,me=m.get(J);delete me[L.__cacheKey],s.memory.textures--}function k(U){const L=i.get(U);if(U.depthTexture&&(U.depthTexture.dispose(),i.remove(U.depthTexture)),U.isWebGLCubeRenderTarget)for(let me=0;me<6;me++){if(Array.isArray(L.__webglFramebuffer[me]))for(let ye=0;ye<L.__webglFramebuffer[me].length;ye++)t.deleteFramebuffer(L.__webglFramebuffer[me][ye]);else t.deleteFramebuffer(L.__webglFramebuffer[me]);L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer[me])}else{if(Array.isArray(L.__webglFramebuffer))for(let me=0;me<L.__webglFramebuffer.length;me++)t.deleteFramebuffer(L.__webglFramebuffer[me]);else t.deleteFramebuffer(L.__webglFramebuffer);if(L.__webglDepthbuffer&&t.deleteRenderbuffer(L.__webglDepthbuffer),L.__webglMultisampledFramebuffer&&t.deleteFramebuffer(L.__webglMultisampledFramebuffer),L.__webglColorRenderbuffer)for(let me=0;me<L.__webglColorRenderbuffer.length;me++)L.__webglColorRenderbuffer[me]&&t.deleteRenderbuffer(L.__webglColorRenderbuffer[me]);L.__webglDepthRenderbuffer&&t.deleteRenderbuffer(L.__webglDepthRenderbuffer)}const J=U.textures;for(let me=0,ye=J.length;me<ye;me++){const pe=i.get(J[me]);pe.__webglTexture&&(t.deleteTexture(pe.__webglTexture),s.memory.textures--),i.remove(J[me])}i.remove(U)}let F=0;function I(){F=0}function W(){const U=F;return U>=r.maxTextures&&qt("WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+r.maxTextures),F+=1,U}function D(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function B(U,L){const J=i.get(U);if(U.isVideoTexture&&Ce(U),U.isRenderTargetTexture===!1&&U.isExternalTexture!==!0&&U.version>0&&J.__version!==U.version){const me=U.image;if(me===null)qt("WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)qt("WebGLRenderer: Texture marked for update but image is incomplete");else{ie(J,U,L);return}}else U.isExternalTexture&&(J.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+L)}function $(U,L){const J=i.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&J.__version!==U.version){ie(J,U,L);return}else U.isExternalTexture&&(J.__webglTexture=U.sourceTexture?U.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+L)}function K(U,L){const J=i.get(U);if(U.isRenderTargetTexture===!1&&U.version>0&&J.__version!==U.version){ie(J,U,L);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+L)}function X(U,L){const J=i.get(U);if(U.version>0&&J.__version!==U.version){xe(J,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+L)}const Y={[$N]:t.REPEAT,[Ql]:t.CLAMP_TO_EDGE,[VN]:t.MIRRORED_REPEAT},ee={[us]:t.NEAREST,[Jce]:t.NEAREST_MIPMAP_NEAREST,[Oy]:t.NEAREST_MIPMAP_LINEAR,[Bs]:t.LINEAR,[jA]:t.LINEAR_MIPMAP_NEAREST,[Yd]:t.LINEAR_MIPMAP_LINEAR},z={[iue]:t.NEVER,[cue]:t.ALWAYS,[rue]:t.LESS,[E9]:t.LEQUAL,[aue]:t.EQUAL,[lue]:t.GEQUAL,[sue]:t.GREATER,[oue]:t.NOTEQUAL};function V(U,L){if(L.type===Jl&&e.has("OES_texture_float_linear")===!1&&(L.magFilter===Bs||L.magFilter===jA||L.magFilter===Oy||L.magFilter===Yd||L.minFilter===Bs||L.minFilter===jA||L.minFilter===Oy||L.minFilter===Yd)&&qt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(U,t.TEXTURE_WRAP_S,Y[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,Y[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,Y[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,ee[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,ee[L.minFilter]),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,z[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(L.magFilter===us||L.minFilter!==Oy&&L.minFilter!==Yd||L.type===Jl&&e.has("OES_texture_float_linear")===!1)return;if(L.anisotropy>1||i.get(L).__currentAnisotropy){const J=e.get("EXT_texture_filter_anisotropic");t.texParameterf(U,J.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,r.getMaxAnisotropy())),i.get(L).__currentAnisotropy=L.anisotropy}}}function re(U,L){let J=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",P));const me=L.source;let ye=m.get(me);ye===void 0&&(ye={},m.set(me,ye));const pe=D(L);if(pe!==U.__cacheKey){ye[pe]===void 0&&(ye[pe]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,J=!0),ye[pe].usedTimes++;const Qe=ye[U.__cacheKey];Qe!==void 0&&(ye[U.__cacheKey].usedTimes--,Qe.usedTimes===0&&N(L)),U.__cacheKey=pe,U.__webglTexture=ye[pe].texture}return J}function le(U,L,J){return Math.floor(Math.floor(U/J)/L)}function ge(U,L,J,me){const pe=U.updateRanges;if(pe.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,L.width,L.height,J,me,L.data);else{pe.sort((Ie,Pe)=>Ie.start-Pe.start);let Qe=0;for(let Ie=1;Ie<pe.length;Ie++){const Pe=pe[Qe],pt=pe[Ie],it=Pe.start+Pe.count,nt=le(pt.start,L.width,4),dt=le(Pe.start,L.width,4);pt.start<=it+1&&nt===dt&&le(pt.start+pt.count-1,L.width,4)===nt?Pe.count=Math.max(Pe.count,pt.start+pt.count-Pe.start):(++Qe,pe[Qe]=pt)}pe.length=Qe+1;const Le=t.getParameter(t.UNPACK_ROW_LENGTH),Xe=t.getParameter(t.UNPACK_SKIP_PIXELS),st=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,L.width);for(let Ie=0,Pe=pe.length;Ie<Pe;Ie++){const pt=pe[Ie],it=Math.floor(pt.start/4),nt=Math.ceil(pt.count/4),dt=it%L.width,de=Math.floor(it/L.width),rt=nt,fe=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,dt),t.pixelStorei(t.UNPACK_SKIP_ROWS,de),n.texSubImage2D(t.TEXTURE_2D,0,dt,de,rt,fe,J,me,L.data)}U.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Le),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,st)}}function ie(U,L,J){let me=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(me=t.TEXTURE_3D);const ye=re(U,L),pe=L.source;n.bindTexture(me,U.__webglTexture,t.TEXTURE0+J);const Qe=i.get(pe);if(pe.version!==Qe.__version||ye===!0){n.activeTexture(t.TEXTURE0+J);const Le=En.getPrimaries(En.workingColorSpace),Xe=L.colorSpace===Tu?null:En.getPrimaries(L.colorSpace),st=L.colorSpace===Tu||Le===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);let Ie=_(L.image,!1,r.maxTextureSize);Ie=Ee(L,Ie);const Pe=a.convert(L.format,L.colorSpace),pt=a.convert(L.type);let it=w(L.internalFormat,Pe,pt,L.colorSpace,L.isVideoTexture);V(me,L);let nt;const dt=L.mipmaps,de=L.isVideoTexture!==!0,rt=Qe.__version===void 0||ye===!0,fe=pe.dataReady,Oe=T(L,Ie);if(L.isDepthTexture)it=C(L.format===Qx,L.type),rt&&(de?n.texStorage2D(t.TEXTURE_2D,1,it,Ie.width,Ie.height):n.texImage2D(t.TEXTURE_2D,0,it,Ie.width,Ie.height,0,Pe,pt,null));else if(L.isDataTexture)if(dt.length>0){de&&rt&&n.texStorage2D(t.TEXTURE_2D,Oe,it,dt[0].width,dt[0].height);for(let Me=0,ve=dt.length;Me<ve;Me++)nt=dt[Me],de?fe&&n.texSubImage2D(t.TEXTURE_2D,Me,0,0,nt.width,nt.height,Pe,pt,nt.data):n.texImage2D(t.TEXTURE_2D,Me,it,nt.width,nt.height,0,Pe,pt,nt.data);L.generateMipmaps=!1}else de?(rt&&n.texStorage2D(t.TEXTURE_2D,Oe,it,Ie.width,Ie.height),fe&&ge(L,Ie,Pe,pt)):n.texImage2D(t.TEXTURE_2D,0,it,Ie.width,Ie.height,0,Pe,pt,Ie.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){de&&rt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,it,dt[0].width,dt[0].height,Ie.depth);for(let Me=0,ve=dt.length;Me<ve;Me++)if(nt=dt[Me],L.format!==go)if(Pe!==null)if(de){if(fe)if(L.layerUpdates.size>0){const Be=kF(nt.width,nt.height,L.format,L.type);for(const ct of L.layerUpdates){const bt=nt.data.subarray(ct*Be/nt.data.BYTES_PER_ELEMENT,(ct+1)*Be/nt.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,ct,nt.width,nt.height,1,Pe,bt)}L.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,0,nt.width,nt.height,Ie.depth,Pe,nt.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Me,it,nt.width,nt.height,Ie.depth,0,nt.data,0,0);else qt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else de?fe&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Me,0,0,0,nt.width,nt.height,Ie.depth,Pe,pt,nt.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Me,it,nt.width,nt.height,Ie.depth,0,Pe,pt,nt.data)}else{de&&rt&&n.texStorage2D(t.TEXTURE_2D,Oe,it,dt[0].width,dt[0].height);for(let Me=0,ve=dt.length;Me<ve;Me++)nt=dt[Me],L.format!==go?Pe!==null?de?fe&&n.compressedTexSubImage2D(t.TEXTURE_2D,Me,0,0,nt.width,nt.height,Pe,nt.data):n.compressedTexImage2D(t.TEXTURE_2D,Me,it,nt.width,nt.height,0,nt.data):qt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):de?fe&&n.texSubImage2D(t.TEXTURE_2D,Me,0,0,nt.width,nt.height,Pe,pt,nt.data):n.texImage2D(t.TEXTURE_2D,Me,it,nt.width,nt.height,0,Pe,pt,nt.data)}else if(L.isDataArrayTexture)if(de){if(rt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Oe,it,Ie.width,Ie.height,Ie.depth),fe)if(L.layerUpdates.size>0){const Me=kF(Ie.width,Ie.height,L.format,L.type);for(const ve of L.layerUpdates){const Be=Ie.data.subarray(ve*Me/Ie.data.BYTES_PER_ELEMENT,(ve+1)*Me/Ie.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ve,Ie.width,Ie.height,1,Pe,pt,Be)}L.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Ie.width,Ie.height,Ie.depth,Pe,pt,Ie.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,it,Ie.width,Ie.height,Ie.depth,0,Pe,pt,Ie.data);else if(L.isData3DTexture)de?(rt&&n.texStorage3D(t.TEXTURE_3D,Oe,it,Ie.width,Ie.height,Ie.depth),fe&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Ie.width,Ie.height,Ie.depth,Pe,pt,Ie.data)):n.texImage3D(t.TEXTURE_3D,0,it,Ie.width,Ie.height,Ie.depth,0,Pe,pt,Ie.data);else if(L.isFramebufferTexture){if(rt)if(de)n.texStorage2D(t.TEXTURE_2D,Oe,it,Ie.width,Ie.height);else{let Me=Ie.width,ve=Ie.height;for(let Be=0;Be<Oe;Be++)n.texImage2D(t.TEXTURE_2D,Be,it,Me,ve,0,Pe,pt,null),Me>>=1,ve>>=1}}else if(dt.length>0){if(de&&rt){const Me=ne(dt[0]);n.texStorage2D(t.TEXTURE_2D,Oe,it,Me.width,Me.height)}for(let Me=0,ve=dt.length;Me<ve;Me++)nt=dt[Me],de?fe&&n.texSubImage2D(t.TEXTURE_2D,Me,0,0,Pe,pt,nt):n.texImage2D(t.TEXTURE_2D,Me,it,Pe,pt,nt);L.generateMipmaps=!1}else if(de){if(rt){const Me=ne(Ie);n.texStorage2D(t.TEXTURE_2D,Oe,it,Me.width,Me.height)}fe&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,Pe,pt,Ie)}else n.texImage2D(t.TEXTURE_2D,0,it,Pe,pt,Ie);v(L)&&x(me),Qe.__version=pe.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function xe(U,L,J){if(L.image.length!==6)return;const me=re(U,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+J);const pe=i.get(ye);if(ye.version!==pe.__version||me===!0){n.activeTexture(t.TEXTURE0+J);const Qe=En.getPrimaries(En.workingColorSpace),Le=L.colorSpace===Tu?null:En.getPrimaries(L.colorSpace),Xe=L.colorSpace===Tu||Qe===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,Ie=L.image[0]&&L.image[0].isDataTexture,Pe=[];for(let ve=0;ve<6;ve++)!st&&!Ie?Pe[ve]=_(L.image[ve],!0,r.maxCubemapSize):Pe[ve]=Ie?L.image[ve].image:L.image[ve],Pe[ve]=Ee(L,Pe[ve]);const pt=Pe[0],it=a.convert(L.format,L.colorSpace),nt=a.convert(L.type),dt=w(L.internalFormat,it,nt,L.colorSpace),de=L.isVideoTexture!==!0,rt=pe.__version===void 0||me===!0,fe=ye.dataReady;let Oe=T(L,pt);V(t.TEXTURE_CUBE_MAP,L);let Me;if(st){de&&rt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,dt,pt.width,pt.height);for(let ve=0;ve<6;ve++){Me=Pe[ve].mipmaps;for(let Be=0;Be<Me.length;Be++){const ct=Me[Be];L.format!==go?it!==null?de?fe&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,0,0,ct.width,ct.height,it,ct.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,dt,ct.width,ct.height,0,ct.data):qt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,0,0,ct.width,ct.height,it,nt,ct.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,dt,ct.width,ct.height,0,it,nt,ct.data)}}}else{if(Me=L.mipmaps,de&&rt){Me.length>0&&Oe++;const ve=ne(Pe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,dt,ve.width,ve.height)}for(let ve=0;ve<6;ve++)if(Ie){de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,Pe[ve].width,Pe[ve].height,it,nt,Pe[ve].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,dt,Pe[ve].width,Pe[ve].height,0,it,nt,Pe[ve].data);for(let Be=0;Be<Me.length;Be++){const bt=Me[Be].image[ve].image;de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,0,0,bt.width,bt.height,it,nt,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,dt,bt.width,bt.height,0,it,nt,bt.data)}}else{de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,it,nt,Pe[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,dt,it,nt,Pe[ve]);for(let Be=0;Be<Me.length;Be++){const ct=Me[Be];de?fe&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,0,0,it,nt,ct.image[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,dt,it,nt,ct.image[ve])}}}v(L)&&x(t.TEXTURE_CUBE_MAP),pe.__version=ye.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function ke(U,L,J,me,ye,pe){const Qe=a.convert(J.format,J.colorSpace),Le=a.convert(J.type),Xe=w(J.internalFormat,Qe,Le,J.colorSpace),st=i.get(L),Ie=i.get(J);if(Ie.__renderTarget=L,!st.__hasExternalTextures){const Pe=Math.max(1,L.width>>pe),pt=Math.max(1,L.height>>pe);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,pe,Xe,Pe,pt,L.depth,0,Qe,Le,null):n.texImage2D(ye,pe,Xe,Pe,pt,0,Qe,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,ye,Ie.__webglTexture,0,Q(L)):(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,pe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function he(U,L,J){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer){const me=L.depthTexture,ye=me&&me.isDepthTexture?me.type:null,pe=C(L.stencilBuffer,ye),Qe=L.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=Q(L);se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Le,pe,L.width,L.height):J?t.renderbufferStorageMultisample(t.RENDERBUFFER,Le,pe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,pe,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,Qe,t.RENDERBUFFER,U)}else{const me=L.textures;for(let ye=0;ye<me.length;ye++){const pe=me[ye],Qe=a.convert(pe.format,pe.colorSpace),Le=a.convert(pe.type),Xe=w(pe.internalFormat,Qe,Le,pe.colorSpace),st=Q(L);J&&se(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,Xe,L.width,L.height):se(L)?o.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function we(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const me=i.get(L.depthTexture);me.__renderTarget=L,(!me.__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),B(L.depthTexture,0);const ye=me.__webglTexture,pe=Q(L);if(L.depthTexture.format===Zx)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0,pe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,ye,0);else if(L.depthTexture.format===Qx)se(L)?o.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0,pe):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,ye,0);else throw new Error("Unknown depthTexture format")}function Ue(U){const L=i.get(U),J=U.isWebGLCubeRenderTarget===!0;if(L.__boundDepthTexture!==U.depthTexture){const me=U.depthTexture;if(L.__depthDisposeCallback&&L.__depthDisposeCallback(),me){const ye=()=>{delete L.__boundDepthTexture,delete L.__depthDisposeCallback,me.removeEventListener("dispose",ye)};me.addEventListener("dispose",ye),L.__depthDisposeCallback=ye}L.__boundDepthTexture=me}if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");const me=U.texture.mipmaps;me&&me.length>0?we(L.__webglFramebuffer[0],U):we(L.__webglFramebuffer,U)}else if(J){L.__webglDepthbuffer=[];for(let me=0;me<6;me++)if(n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[me]),L.__webglDepthbuffer[me]===void 0)L.__webglDepthbuffer[me]=t.createRenderbuffer(),he(L.__webglDepthbuffer[me],U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,pe=L.__webglDepthbuffer[me];t.bindRenderbuffer(t.RENDERBUFFER,pe),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,pe)}}else{const me=U.texture.mipmaps;if(me&&me.length>0?n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer===void 0)L.__webglDepthbuffer=t.createRenderbuffer(),he(L.__webglDepthbuffer,U,!1);else{const ye=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,pe=L.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,pe),t.framebufferRenderbuffer(t.FRAMEBUFFER,ye,t.RENDERBUFFER,pe)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(U,L,J){const me=i.get(U);L!==void 0&&ke(me.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&Ue(U)}function lt(U){const L=U.texture,J=i.get(U),me=i.get(L);U.addEventListener("dispose",A);const ye=U.textures,pe=U.isWebGLCubeRenderTarget===!0,Qe=ye.length>1;if(Qe||(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=L.version,s.memory.textures++),pe){J.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer[Le]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)J.__webglFramebuffer[Le][Xe]=t.createFramebuffer()}else J.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer=[];for(let Le=0;Le<L.mipmaps.length;Le++)J.__webglFramebuffer[Le]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(Qe)for(let Le=0,Xe=ye.length;Le<Xe;Le++){const st=i.get(ye[Le]);st.__webglTexture===void 0&&(st.__webglTexture=t.createTexture(),s.memory.textures++)}if(U.samples>0&&se(U)===!1){J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Le=0;Le<ye.length;Le++){const Xe=ye[Le];J.__webglColorRenderbuffer[Le]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Le]);const st=a.convert(Xe.format,Xe.colorSpace),Ie=a.convert(Xe.type),Pe=w(Xe.internalFormat,st,Ie,Xe.colorSpace,U.isXRRenderTarget===!0),pt=Q(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,pt,Pe,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Le,t.RENDERBUFFER,J.__webglColorRenderbuffer[Le])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),he(J.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(pe){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),V(t.TEXTURE_CUBE_MAP,L);for(let Le=0;Le<6;Le++)if(L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)ke(J.__webglFramebuffer[Le][Xe],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,Xe);else ke(J.__webglFramebuffer[Le],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);v(L)&&x(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(Qe){for(let Le=0,Xe=ye.length;Le<Xe;Le++){const st=ye[Le],Ie=i.get(st);let Pe=t.TEXTURE_2D;(U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Pe=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Pe,Ie.__webglTexture),V(Pe,st),ke(J.__webglFramebuffer,U,st,t.COLOR_ATTACHMENT0+Le,Pe,0),v(st)&&x(Pe)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(Le=U.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Le,me.__webglTexture),V(Le,L),L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)ke(J.__webglFramebuffer[Xe],U,L,t.COLOR_ATTACHMENT0,Le,Xe);else ke(J.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Le,0);v(L)&&x(Le),n.unbindTexture()}U.depthBuffer&&Ue(U)}function H(U){const L=U.textures;for(let J=0,me=L.length;J<me;J++){const ye=L[J];if(v(ye)){const pe=M(U),Qe=i.get(ye).__webglTexture;n.bindTexture(pe,Qe),x(pe),n.unbindTexture()}}}const q=[],oe=[];function Z(U){if(U.samples>0){if(se(U)===!1){const L=U.textures,J=U.width,me=U.height;let ye=t.COLOR_BUFFER_BIT;const pe=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Qe=i.get(U),Le=L.length>1;if(Le)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,Qe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Qe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Qe.__webglMultisampledFramebuffer);const Xe=U.texture.mipmaps;Xe&&Xe.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Qe.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Qe.__webglFramebuffer);for(let st=0;st<L.length;st++){if(U.resolveDepthBuffer&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&U.resolveStencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Le){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Qe.__webglColorRenderbuffer[st]);const Ie=i.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Ie,0)}t.blitFramebuffer(0,0,J,me,0,0,J,me,ye,t.NEAREST),l===!0&&(q.length=0,oe.length=0,q.push(t.COLOR_ATTACHMENT0+st),U.depthBuffer&&U.resolveDepthBuffer===!1&&(q.push(pe),oe.push(pe),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,oe)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,q))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Le)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,Qe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,Qe.__webglColorRenderbuffer[st]);const Ie=i.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Qe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ie,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Qe.__webglMultisampledFramebuffer)}else if(U.depthBuffer&&U.resolveDepthBuffer===!1&&l){const L=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[L])}}}function Q(U){return Math.min(r.maxSamples,U.samples)}function se(U){const L=i.get(U);return U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ce(U){const L=s.render.frame;u.get(U)!==L&&(u.set(U,L),U.update())}function Ee(U,L){const J=U.colorSpace,me=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||J!==Xp&&J!==Tu&&(En.getTransfer(J)===Bn?(me!==go||ye!==el)&&qt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Di("WebGLTextures: Unsupported texture color space:",J)),L}function ne(U){return typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement?(c.width=U.naturalWidth||U.width,c.height=U.naturalHeight||U.height):typeof VideoFrame<"u"&&U instanceof VideoFrame?(c.width=U.displayWidth,c.height=U.displayHeight):(c.width=U.width,c.height=U.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=I,this.setTexture2D=B,this.setTexture2DArray=$,this.setTexture3D=K,this.setTextureCube=X,this.rebindTextures=ue,this.setupRenderTarget=lt,this.updateRenderTargetMipmap=H,this.updateMultisampleRenderTarget=Z,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=ke,this.useMultisampledRTT=se}function Rme(t,e){function n(i,r=Tu){let a;const s=En.getTransfer(r);if(i===el)return t.UNSIGNED_BYTE;if(i===GP)return t.UNSIGNED_SHORT_4_4_4_4;if(i===WP)return t.UNSIGNED_SHORT_5_5_5_1;if(i===y9)return t.UNSIGNED_INT_5_9_9_9_REV;if(i===b9)return t.UNSIGNED_INT_10F_11F_11F_REV;if(i===x9)return t.BYTE;if(i===v9)return t.SHORT;if(i===Kx)return t.UNSIGNED_SHORT;if(i===VP)return t.INT;if(i===wf)return t.UNSIGNED_INT;if(i===Jl)return t.FLOAT;if(i===wm)return t.HALF_FLOAT;if(i===_9)return t.ALPHA;if(i===S9)return t.RGB;if(i===go)return t.RGBA;if(i===Zx)return t.DEPTH_COMPONENT;if(i===Qx)return t.DEPTH_STENCIL;if(i===w9)return t.RED;if(i===qP)return t.RED_INTEGER;if(i===XP)return t.RG;if(i===KP)return t.RG_INTEGER;if(i===YP)return t.RGBA_INTEGER;if(i===m_||i===g_||i===x_||i===v_)if(s===Bn)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(i===m_)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===g_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===x_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===v_)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(i===m_)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===g_)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===x_)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===v_)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===GN||i===WN||i===qN||i===XN)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(i===GN)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===WN)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===qN)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===XN)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===KN||i===YN||i===ZN)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(i===KN||i===YN)return s===Bn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===ZN)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(i===QN||i===JN||i===e3||i===t3||i===n3||i===i3||i===r3||i===a3||i===s3||i===o3||i===l3||i===c3||i===u3||i===d3)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(i===QN)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===JN)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===e3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===t3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===n3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===i3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===r3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===a3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===s3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===o3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===l3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===c3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===u3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===d3)return s===Bn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===f3||i===h3||i===p3)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(i===f3)return s===Bn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===h3)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===p3)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===m3||i===g3||i===x3||i===v3)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(i===m3)return a.COMPRESSED_RED_RGTC1_EXT;if(i===g3)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===x3)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===v3)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Yx?t.UNSIGNED_INT_24_8:t[i]!==void 0?t[i]:null}return{convert:n}}const Pme=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,kme=`
- 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 Dme{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const i=new V9(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 gc({vertexShader:Pme,fragmentShader:kme,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new tl(new nk(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let Ome=class extends Hf{constructor(e,n){super();const i=this;let r=null,a=1,s=null,o="local-floor",l=1,c=null,u=null,f=null,m=null,g=null,y=null;const _=typeof XRWebGLBinding<"u",v=new Dme,x={},M=n.getContextAttributes();let w=null,C=null;const T=[],P=[],A=new sn;let j=null;const N=new Is;N.viewport=new Vi;const k=new Is;k.viewport=new Vi;const F=[N,k],I=new Zue;let W=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ie){let xe=T[ie];return xe===void 0&&(xe=new aT,T[ie]=xe),xe.getTargetRaySpace()},this.getControllerGrip=function(ie){let xe=T[ie];return xe===void 0&&(xe=new aT,T[ie]=xe),xe.getGripSpace()},this.getHand=function(ie){let xe=T[ie];return xe===void 0&&(xe=new aT,T[ie]=xe),xe.getHandSpace()};function B(ie){const xe=P.indexOf(ie.inputSource);if(xe===-1)return;const ke=T[xe];ke!==void 0&&(ke.update(ie.inputSource,ie.frame,c||s),ke.dispatchEvent({type:ie.type,data:ie.inputSource}))}function $(){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",$),r.removeEventListener("inputsourceschange",K);for(let ie=0;ie<T.length;ie++){const xe=P[ie];xe!==null&&(P[ie]=null,T[ie].disconnect(xe))}W=null,D=null,v.reset();for(const ie in x)delete x[ie];e.setRenderTarget(w),g=null,m=null,f=null,r=null,C=null,ge.stop(),i.isPresenting=!1,e.setPixelRatio(j),e.setSize(A.width,A.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ie){a=ie,i.isPresenting===!0&&qt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ie){o=ie,i.isPresenting===!0&&qt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(ie){c=ie},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return f===null&&_&&(f=new XRWebGLBinding(r,n)),f},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(ie){if(r=ie,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",$),r.addEventListener("inputsourceschange",K),M.xrCompatible!==!0&&await n.makeXRCompatible(),j=e.getPixelRatio(),e.getSize(A),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let ke=null,he=null,we=null;M.depth&&(we=M.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ke=M.stencil?Qx:Zx,he=M.stencil?Yx:wf);const Ue={colorFormat:n.RGBA8,depthFormat:we,scaleFactor:a};f=this.getBinding(),m=f.createProjectionLayer(Ue),r.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),C=new Ef(m.textureWidth,m.textureHeight,{format:go,type:el,depthTexture:new $9(m.textureWidth,m.textureHeight,he,void 0,void 0,void 0,void 0,void 0,void 0,ke),stencilBuffer:M.stencil,colorSpace:e.outputColorSpace,samples:M.antialias?4:0,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}else{const ke={antialias:M.antialias,alpha:!0,depth:M.depth,stencil:M.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(r,n,ke),r.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),C=new Ef(g.framebufferWidth,g.framebufferHeight,{format:go,type:el,colorSpace:e.outputColorSpace,stencilBuffer:M.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}C.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await r.requestReferenceSpace(o),ge.setContext(r),ge.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function K(ie){for(let xe=0;xe<ie.removed.length;xe++){const ke=ie.removed[xe],he=P.indexOf(ke);he>=0&&(P[he]=null,T[he].disconnect(ke))}for(let xe=0;xe<ie.added.length;xe++){const ke=ie.added[xe];let he=P.indexOf(ke);if(he===-1){for(let Ue=0;Ue<T.length;Ue++)if(Ue>=P.length){P.push(ke),he=Ue;break}else if(P[Ue]===null){P[Ue]=ke,he=Ue;break}if(he===-1)break}const we=T[he];we&&we.connect(ke)}}const X=new Ge,Y=new Ge;function ee(ie,xe,ke){X.setFromMatrixPosition(xe.matrixWorld),Y.setFromMatrixPosition(ke.matrixWorld);const he=X.distanceTo(Y),we=xe.projectionMatrix.elements,Ue=ke.projectionMatrix.elements,ue=we[14]/(we[10]-1),lt=we[14]/(we[10]+1),H=(we[9]+1)/we[5],q=(we[9]-1)/we[5],oe=(we[8]-1)/we[0],Z=(Ue[8]+1)/Ue[0],Q=ue*oe,se=ue*Z,Ce=he/(-oe+Z),Ee=Ce*-oe;if(xe.matrixWorld.decompose(ie.position,ie.quaternion,ie.scale),ie.translateX(Ee),ie.translateZ(Ce),ie.matrixWorld.compose(ie.position,ie.quaternion,ie.scale),ie.matrixWorldInverse.copy(ie.matrixWorld).invert(),we[10]===-1)ie.projectionMatrix.copy(xe.projectionMatrix),ie.projectionMatrixInverse.copy(xe.projectionMatrixInverse);else{const ne=ue+Ce,U=lt+Ce,L=Q-Ee,J=se+(he-Ee),me=H*lt/U*ne,ye=q*lt/U*ne;ie.projectionMatrix.makePerspective(L,J,me,ye,ne,U),ie.projectionMatrixInverse.copy(ie.projectionMatrix).invert()}}function z(ie,xe){xe===null?ie.matrixWorld.copy(ie.matrix):ie.matrixWorld.multiplyMatrices(xe.matrixWorld,ie.matrix),ie.matrixWorldInverse.copy(ie.matrixWorld).invert()}this.updateCamera=function(ie){if(r===null)return;let xe=ie.near,ke=ie.far;v.texture!==null&&(v.depthNear>0&&(xe=v.depthNear),v.depthFar>0&&(ke=v.depthFar)),I.near=k.near=N.near=xe,I.far=k.far=N.far=ke,(W!==I.near||D!==I.far)&&(r.updateRenderState({depthNear:I.near,depthFar:I.far}),W=I.near,D=I.far),I.layers.mask=ie.layers.mask|6,N.layers.mask=I.layers.mask&3,k.layers.mask=I.layers.mask&5;const he=ie.parent,we=I.cameras;z(I,he);for(let Ue=0;Ue<we.length;Ue++)z(we[Ue],he);we.length===2?ee(I,N,k):I.projectionMatrix.copy(N.projectionMatrix),V(ie,I,he)};function V(ie,xe,ke){ke===null?ie.matrix.copy(xe.matrixWorld):(ie.matrix.copy(ke.matrixWorld),ie.matrix.invert(),ie.matrix.multiply(xe.matrixWorld)),ie.matrix.decompose(ie.position,ie.quaternion,ie.scale),ie.updateMatrixWorld(!0),ie.projectionMatrix.copy(xe.projectionMatrix),ie.projectionMatrixInverse.copy(xe.projectionMatrixInverse),ie.isPerspectiveCamera&&(ie.fov=y3*2*Math.atan(1/ie.projectionMatrix.elements[5]),ie.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(m===null&&g===null))return l},this.setFoveation=function(ie){l=ie,m!==null&&(m.fixedFoveation=ie),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=ie)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(I)},this.getCameraTexture=function(ie){return x[ie]};let re=null;function le(ie,xe){if(u=xe.getViewerPose(c||s),y=xe,u!==null){const ke=u.views;g!==null&&(e.setRenderTargetFramebuffer(C,g.framebuffer),e.setRenderTarget(C));let he=!1;ke.length!==I.cameras.length&&(I.cameras.length=0,he=!0);for(let lt=0;lt<ke.length;lt++){const H=ke[lt];let q=null;if(g!==null)q=g.getViewport(H);else{const Z=f.getViewSubImage(m,H);q=Z.viewport,lt===0&&(e.setRenderTargetTextures(C,Z.colorTexture,Z.depthStencilTexture),e.setRenderTarget(C))}let oe=F[lt];oe===void 0&&(oe=new Is,oe.layers.enable(lt),oe.viewport=new Vi,F[lt]=oe),oe.matrix.fromArray(H.transform.matrix),oe.matrix.decompose(oe.position,oe.quaternion,oe.scale),oe.projectionMatrix.fromArray(H.projectionMatrix),oe.projectionMatrixInverse.copy(oe.projectionMatrix).invert(),oe.viewport.set(q.x,q.y,q.width,q.height),lt===0&&(I.matrix.copy(oe.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),he===!0&&I.cameras.push(oe)}const we=r.enabledFeatures;if(we&&we.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&_){f=i.getBinding();const lt=f.getDepthInformation(ke[0]);lt&<.isValid&<.texture&&v.init(lt,r.renderState)}if(we&&we.includes("camera-access")&&_){e.state.unbindTexture(),f=i.getBinding();for(let lt=0;lt<ke.length;lt++){const H=ke[lt].camera;if(H){let q=x[H];q||(q=new V9,x[H]=q);const oe=f.getCameraImage(H);q.sourceTexture=oe}}}}for(let ke=0;ke<T.length;ke++){const he=P[ke],we=T[ke];he!==null&&we!==void 0&&we.update(he,xe,c||s)}re&&re(ie,xe),xe.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:xe}),y=null}const ge=new X9;ge.setAnimationLoop(le),this.setAnimationLoop=function(ie){re=ie},this.dispose=function(){}}};const kd=new Xu,Lme=new Xi;function Ime(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,F9(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,C){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),f(v,x)):x.isMeshPhongMaterial?(a(v,x),u(v,x)):x.isMeshStandardMaterial?(a(v,x),m(v,x),x.isMeshPhysicalMaterial&&g(v,x,C)):x.isMeshMatcapMaterial?(a(v,x),y(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),_(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===ja&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===ja&&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,C=M.envMapRotation;w&&(v.envMap.value=w,kd.copy(C),kd.x*=-1,kd.y*=-1,kd.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(kd.y*=-1,kd.z*=-1),v.envMapRotation.value.setFromMatrix4(Lme.makeRotationFromEuler(kd)),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 u(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 m(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 g(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===ja&&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 y(v,x){x.matcap&&(v.matcap.value=x.matcap)}function _(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 jme(t,e,n,i){let r={},a={},s=[];const o=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,w){const C=w.program;i.uniformBlockBinding(M,C)}function c(M,w){let C=r[M.id];C===void 0&&(y(M),C=u(M),r[M.id]=C,M.addEventListener("dispose",v));const T=w.program;i.updateUBOMapping(M,T);const P=e.render.frame;a[M.id]!==P&&(m(M),a[M.id]=P)}function u(M){const w=f();M.__bindingPointIndex=w;const C=t.createBuffer(),T=M.__size,P=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,C),t.bufferData(t.UNIFORM_BUFFER,T,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,C),C}function f(){for(let M=0;M<o;M++)if(s.indexOf(M)===-1)return s.push(M),M;return Di("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function m(M){const w=r[M.id],C=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let P=0,A=C.length;P<A;P++){const j=Array.isArray(C[P])?C[P]:[C[P]];for(let N=0,k=j.length;N<k;N++){const F=j[N];if(g(F,P,N,T)===!0){const I=F.__offset,W=Array.isArray(F.value)?F.value:[F.value];let D=0;for(let B=0;B<W.length;B++){const $=W[B],K=_($);typeof $=="number"||typeof $=="boolean"?(F.__data[0]=$,t.bufferSubData(t.UNIFORM_BUFFER,I+D,F.__data)):$.isMatrix3?(F.__data[0]=$.elements[0],F.__data[1]=$.elements[1],F.__data[2]=$.elements[2],F.__data[3]=0,F.__data[4]=$.elements[3],F.__data[5]=$.elements[4],F.__data[6]=$.elements[5],F.__data[7]=0,F.__data[8]=$.elements[6],F.__data[9]=$.elements[7],F.__data[10]=$.elements[8],F.__data[11]=0):($.toArray(F.__data,D),D+=K.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,I,F.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(M,w,C,T){const P=M.value,A=w+"_"+C;if(T[A]===void 0)return typeof P=="number"||typeof P=="boolean"?T[A]=P:T[A]=P.clone(),!0;{const j=T[A];if(typeof P=="number"||typeof P=="boolean"){if(j!==P)return T[A]=P,!0}else if(j.equals(P)===!1)return j.copy(P),!0}return!1}function y(M){const w=M.uniforms;let C=0;const T=16;for(let A=0,j=w.length;A<j;A++){const N=Array.isArray(w[A])?w[A]:[w[A]];for(let k=0,F=N.length;k<F;k++){const I=N[k],W=Array.isArray(I.value)?I.value:[I.value];for(let D=0,B=W.length;D<B;D++){const $=W[D],K=_($),X=C%T,Y=X%K.boundary,ee=X+Y;C+=Y,ee!==0&&T-ee<K.storage&&(C+=T-ee),I.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=C,C+=K.storage}}}const P=C%T;return P>0&&(C+=T-P),M.__size=C,M.__cache={},this}function _(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?qt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):qt("WebGLRenderer: Unsupported uniform value type.",M),w}function v(M){const w=M.target;w.removeEventListener("dispose",v);const C=s.indexOf(w.__bindingPointIndex);s.splice(C,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 Ume=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 Dl=null;function Fme(){return Dl===null&&(Dl=new Fue(Ume,32,32,XP,wm),Dl.minFilter=Bs,Dl.magFilter=Bs,Dl.wrapS=Ql,Dl.wrapT=Ql,Dl.generateMipmaps=!1,Dl.needsUpdate=!0),Dl}let zme=class{constructor(e={}){const{canvas:n=uue(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:m=!1}=e;this.isWebGLRenderer=!0;let g;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=i.getContextAttributes().alpha}else g=s;const y=new Set([YP,KP,qP]),_=new Set([el,wf,Kx,Yx,GP,WP]),v=new Uint32Array(4),x=new Int32Array(4);let M=null,w=null;const C=[],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=Uu,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let A=!1;this._outputColorSpace=Ds;let j=0,N=0,k=null,F=-1,I=null;const W=new Vi,D=new Vi;let B=null;const $=new vn(0);let K=0,X=n.width,Y=n.height,ee=1,z=null,V=null;const re=new Vi(0,0,X,Y),le=new Vi(0,0,X,Y);let ge=!1;const ie=new tk;let xe=!1,ke=!1;const he=new Xi,we=new Ge,Ue=new Vi,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let lt=!1;function H(){return k===null?ee:1}let q=i;function oe(te,be){return n.getContext(te,be)}try{const te={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${HP}`),n.addEventListener("webglcontextlost",Me,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",Be,!1),q===null){const be="webgl2";if(q=oe(be,te),q===null)throw oe(be)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(te){throw te("WebGLRenderer: "+te.message),te}let Z,Q,se,Ce,Ee,ne,U,L,J,me,ye,pe,Qe,Le,Xe,st,Ie,Pe,pt,it,nt,dt,de,rt;function fe(){Z=new Xhe(q),Z.init(),dt=new Rme(q,Z),Q=new Fhe(q,Z,e,dt),se=new Cme(q,Z),Q.reversedDepthBuffer&&m&&se.buffers.depth.setReversed(!0),Ce=new Zhe(q),Ee=new mme,ne=new Nme(q,Z,se,Ee,Q,dt,Ce),U=new Bhe(P),L=new qhe(P),J=new tde(q),de=new jhe(q,J),me=new Khe(q,J,Ce,de),ye=new Jhe(q,me,J,Ce),pt=new Qhe(q,Q,ne),st=new zhe(Ee),pe=new pme(P,U,L,Z,Q,de,st),Qe=new Ime(P,Ee),Le=new xme,Xe=new wme(Z),Pe=new Ihe(P,U,L,se,ye,g,l),Ie=new Ame(P,ye,Q),rt=new jme(q,Ce,Q,se),it=new Uhe(q,Z,Ce),nt=new Yhe(q,Z,Ce),Ce.programs=pe.programs,P.capabilities=Q,P.extensions=Z,P.properties=Ee,P.renderLists=Le,P.shadowMap=Ie,P.state=se,P.info=Ce}fe();const Oe=new Ome(P,q);this.xr=Oe,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){const te=Z.get("WEBGL_lose_context");te&&te.loseContext()},this.forceContextRestore=function(){const te=Z.get("WEBGL_lose_context");te&&te.restoreContext()},this.getPixelRatio=function(){return ee},this.setPixelRatio=function(te){te!==void 0&&(ee=te,this.setSize(X,Y,!1))},this.getSize=function(te){return te.set(X,Y)},this.setSize=function(te,be,Re=!0){if(Oe.isPresenting){qt("WebGLRenderer: Can't change size while VR device is presenting.");return}X=te,Y=be,n.width=Math.floor(te*ee),n.height=Math.floor(be*ee),Re===!0&&(n.style.width=te+"px",n.style.height=be+"px"),this.setViewport(0,0,te,be)},this.getDrawingBufferSize=function(te){return te.set(X*ee,Y*ee).floor()},this.setDrawingBufferSize=function(te,be,Re){X=te,Y=be,ee=Re,n.width=Math.floor(te*Re),n.height=Math.floor(be*Re),this.setViewport(0,0,te,be)},this.getCurrentViewport=function(te){return te.copy(W)},this.getViewport=function(te){return te.copy(re)},this.setViewport=function(te,be,Re,Ne){te.isVector4?re.set(te.x,te.y,te.z,te.w):re.set(te,be,Re,Ne),se.viewport(W.copy(re).multiplyScalar(ee).round())},this.getScissor=function(te){return te.copy(le)},this.setScissor=function(te,be,Re,Ne){te.isVector4?le.set(te.x,te.y,te.z,te.w):le.set(te,be,Re,Ne),se.scissor(D.copy(le).multiplyScalar(ee).round())},this.getScissorTest=function(){return ge},this.setScissorTest=function(te){se.setScissorTest(ge=te)},this.setOpaqueSort=function(te){z=te},this.setTransparentSort=function(te){V=te},this.getClearColor=function(te){return te.copy(Pe.getClearColor())},this.setClearColor=function(){Pe.setClearColor(...arguments)},this.getClearAlpha=function(){return Pe.getClearAlpha()},this.setClearAlpha=function(){Pe.setClearAlpha(...arguments)},this.clear=function(te=!0,be=!0,Re=!0){let Ne=0;if(te){let Se=!1;if(k!==null){const Je=k.texture.format;Se=y.has(Je)}if(Se){const Je=k.texture.type,ft=_.has(Je),vt=Pe.getClearColor(),xt=Pe.getClearAlpha(),Pt=vt.r,wt=vt.g,mt=vt.b;ft?(v[0]=Pt,v[1]=wt,v[2]=mt,v[3]=xt,q.clearBufferuiv(q.COLOR,0,v)):(x[0]=Pt,x[1]=wt,x[2]=mt,x[3]=xt,q.clearBufferiv(q.COLOR,0,x))}else Ne|=q.COLOR_BUFFER_BIT}be&&(Ne|=q.DEPTH_BUFFER_BIT),Re&&(Ne|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),q.clear(Ne)},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",ve,!1),n.removeEventListener("webglcontextcreationerror",Be,!1),Pe.dispose(),Le.dispose(),Xe.dispose(),Ee.dispose(),U.dispose(),L.dispose(),ye.dispose(),de.dispose(),rt.dispose(),pe.dispose(),Oe.dispose(),Oe.removeEventListener("sessionstart",qn),Oe.removeEventListener("sessionend",mr),Qi.stop()};function Me(te){te.preventDefault(),oF("WebGLRenderer: Context Lost."),A=!0}function ve(){oF("WebGLRenderer: Context Restored."),A=!1;const te=Ce.autoReset,be=Ie.enabled,Re=Ie.autoUpdate,Ne=Ie.needsUpdate,Se=Ie.type;fe(),Ce.autoReset=te,Ie.enabled=be,Ie.autoUpdate=Re,Ie.needsUpdate=Ne,Ie.type=Se}function Be(te){Di("WebGLRenderer: A WebGL context could not be created. Reason: ",te.statusMessage)}function ct(te){const be=te.target;be.removeEventListener("dispose",ct),bt(be)}function bt(te){Rt(te),Ee.remove(te)}function Rt(te){const be=Ee.get(te).programs;be!==void 0&&(be.forEach(function(Re){pe.releaseProgram(Re)}),te.isShaderMaterial&&pe.releaseShaderCache(te))}this.renderBufferDirect=function(te,be,Re,Ne,Se,Je){be===null&&(be=ue);const ft=Se.isMesh&&Se.matrixWorld.determinant()<0,vt=ce(te,be,Re,Ne,Se);se.setMaterial(Ne,ft);let xt=Re.index,Pt=1;if(Ne.wireframe===!0){if(xt=me.getWireframeAttribute(Re),xt===void 0)return;Pt=2}const wt=Re.drawRange,mt=Re.attributes.position;let Wt=wt.start*Pt,It=(wt.start+wt.count)*Pt;Je!==null&&(Wt=Math.max(Wt,Je.start*Pt),It=Math.min(It,(Je.start+Je.count)*Pt)),xt!==null?(Wt=Math.max(Wt,0),It=Math.min(It,xt.count)):mt!=null&&(Wt=Math.max(Wt,0),It=Math.min(It,mt.count));const tn=It-Wt;if(tn<0||tn===1/0)return;de.setup(Se,Ne,vt,Re,xt);let un,mn=it;if(xt!==null&&(un=J.get(xt),mn=nt,mn.setIndex(un)),Se.isMesh)Ne.wireframe===!0?(se.setLineWidth(Ne.wireframeLinewidth*H()),mn.setMode(q.LINES)):mn.setMode(q.TRIANGLES);else if(Se.isLine){let Lt=Ne.linewidth;Lt===void 0&&(Lt=1),se.setLineWidth(Lt*H()),Se.isLineSegments?mn.setMode(q.LINES):Se.isLineLoop?mn.setMode(q.LINE_LOOP):mn.setMode(q.LINE_STRIP)}else Se.isPoints?mn.setMode(q.POINTS):Se.isSprite&&mn.setMode(q.TRIANGLES);if(Se.isBatchedMesh)if(Se._multiDrawInstances!==null)Jx("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),mn.renderMultiDrawInstances(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount,Se._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))mn.renderMultiDraw(Se._multiDrawStarts,Se._multiDrawCounts,Se._multiDrawCount);else{const Lt=Se._multiDrawStarts,Kt=Se._multiDrawCounts,Zt=Se._multiDrawCount,yi=xt?J.get(xt).bytesPerElement:1,Ci=Ee.get(Ne).currentProgram.getUniforms();for(let Nn=0;Nn<Zt;Nn++)Ci.setValue(q,"_gl_DrawID",Nn),mn.render(Lt[Nn]/yi,Kt[Nn])}else if(Se.isInstancedMesh)mn.renderInstances(Wt,tn,Se.count);else if(Re.isInstancedBufferGeometry){const Lt=Re._maxInstanceCount!==void 0?Re._maxInstanceCount:1/0,Kt=Math.min(Re.instanceCount,Lt);mn.renderInstances(Wt,tn,Kt)}else mn.render(Wt,tn)};function ln(te,be,Re){te.transparent===!0&&te.side===Ho&&te.forceSinglePass===!1?(te.side=ja,te.needsUpdate=!0,Ti(te,be,Re),te.side=qu,te.needsUpdate=!0,Ti(te,be,Re),te.side=Ho):Ti(te,be,Re)}this.compile=function(te,be,Re=null){Re===null&&(Re=te),w=Xe.get(Re),w.init(be),T.push(w),Re.traverseVisible(function(Se){Se.isLight&&Se.layers.test(be.layers)&&(w.pushLight(Se),Se.castShadow&&w.pushShadow(Se))}),te!==Re&&te.traverseVisible(function(Se){Se.isLight&&Se.layers.test(be.layers)&&(w.pushLight(Se),Se.castShadow&&w.pushShadow(Se))}),w.setupLights();const Ne=new Set;return te.traverse(function(Se){if(!(Se.isMesh||Se.isPoints||Se.isLine||Se.isSprite))return;const Je=Se.material;if(Je)if(Array.isArray(Je))for(let ft=0;ft<Je.length;ft++){const vt=Je[ft];ln(vt,Re,Se),Ne.add(vt)}else ln(Je,Re,Se),Ne.add(Je)}),w=T.pop(),Ne},this.compileAsync=function(te,be,Re=null){const Ne=this.compile(te,be,Re);return new Promise(Se=>{function Je(){if(Ne.forEach(function(ft){Ee.get(ft).currentProgram.isReady()&&Ne.delete(ft)}),Ne.size===0){Se(te);return}setTimeout(Je,10)}Z.get("KHR_parallel_shader_compile")!==null?Je():setTimeout(Je,10)})};let Ot=null;function Rn(te){Ot&&Ot(te)}function qn(){Qi.stop()}function mr(){Qi.start()}const Qi=new X9;Qi.setAnimationLoop(Rn),typeof self<"u"&&Qi.setContext(self),this.setAnimationLoop=function(te){Ot=te,Oe.setAnimationLoop(te),te===null?Qi.stop():Qi.start()},Oe.addEventListener("sessionstart",qn),Oe.addEventListener("sessionend",mr),this.render=function(te,be){if(be!==void 0&&be.isCamera!==!0){Di("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(te.matrixWorldAutoUpdate===!0&&te.updateMatrixWorld(),be.parent===null&&be.matrixWorldAutoUpdate===!0&&be.updateMatrixWorld(),Oe.enabled===!0&&Oe.isPresenting===!0&&(Oe.cameraAutoUpdate===!0&&Oe.updateCamera(be),be=Oe.getCamera()),te.isScene===!0&&te.onBeforeRender(P,te,be,k),w=Xe.get(te,T.length),w.init(be),T.push(w),he.multiplyMatrices(be.projectionMatrix,be.matrixWorldInverse),ie.setFromProjectionMatrix(he,Go,be.reversedDepth),ke=this.localClippingEnabled,xe=st.init(this.clippingPlanes,ke),M=Le.get(te,C.length),M.init(),C.push(M),Oe.enabled===!0&&Oe.isPresenting===!0){const Je=P.xr.getDepthSensingMesh();Je!==null&&gr(Je,be,-1/0,P.sortObjects)}gr(te,be,0,P.sortObjects),M.finish(),P.sortObjects===!0&&M.sort(z,V),lt=Oe.enabled===!1||Oe.isPresenting===!1||Oe.hasDepthSensing()===!1,lt&&Pe.addToRenderList(M,te),this.info.render.frame++,xe===!0&&st.beginShadows();const Re=w.state.shadowsArray;Ie.render(Re,te,be),xe===!0&&st.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ne=M.opaque,Se=M.transmissive;if(w.setupLights(),be.isArrayCamera){const Je=be.cameras;if(Se.length>0)for(let ft=0,vt=Je.length;ft<vt;ft++){const xt=Je[ft];qr(Ne,Se,te,xt)}lt&&Pe.render(te);for(let ft=0,vt=Je.length;ft<vt;ft++){const xt=Je[ft];Pr(M,te,xt,xt.viewport)}}else Se.length>0&&qr(Ne,Se,te,be),lt&&Pe.render(te),Pr(M,te,be);k!==null&&N===0&&(ne.updateMultisampleRenderTarget(k),ne.updateRenderTargetMipmap(k)),te.isScene===!0&&te.onAfterRender(P,te,be),de.resetDefaultState(),F=-1,I=null,T.pop(),T.length>0?(w=T[T.length-1],xe===!0&&st.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,C.pop(),C.length>0?M=C[C.length-1]:M=null};function gr(te,be,Re,Ne){if(te.visible===!1)return;if(te.layers.test(be.layers)){if(te.isGroup)Re=te.renderOrder;else if(te.isLOD)te.autoUpdate===!0&&te.update(be);else if(te.isLight)w.pushLight(te),te.castShadow&&w.pushShadow(te);else if(te.isSprite){if(!te.frustumCulled||ie.intersectsSprite(te)){Ne&&Ue.setFromMatrixPosition(te.matrixWorld).applyMatrix4(he);const ft=ye.update(te),vt=te.material;vt.visible&&M.push(te,ft,vt,Re,Ue.z,null)}}else if((te.isMesh||te.isLine||te.isPoints)&&(!te.frustumCulled||ie.intersectsObject(te))){const ft=ye.update(te),vt=te.material;if(Ne&&(te.boundingSphere!==void 0?(te.boundingSphere===null&&te.computeBoundingSphere(),Ue.copy(te.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),Ue.copy(ft.boundingSphere.center)),Ue.applyMatrix4(te.matrixWorld).applyMatrix4(he)),Array.isArray(vt)){const xt=ft.groups;for(let Pt=0,wt=xt.length;Pt<wt;Pt++){const mt=xt[Pt],Wt=vt[mt.materialIndex];Wt&&Wt.visible&&M.push(te,ft,Wt,Re,Ue.z,mt)}}else vt.visible&&M.push(te,ft,vt,Re,Ue.z,null)}}const Je=te.children;for(let ft=0,vt=Je.length;ft<vt;ft++)gr(Je[ft],be,Re,Ne)}function Pr(te,be,Re,Ne){const{opaque:Se,transmissive:Je,transparent:ft}=te;w.setupLightsView(Re),xe===!0&&st.setGlobalState(P.clippingPlanes,Re),Ne&&se.viewport(W.copy(Ne)),Se.length>0&&Ii(Se,be,Re),Je.length>0&&Ii(Je,be,Re),ft.length>0&&Ii(ft,be,Re),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function qr(te,be,Re,Ne){if((Re.isScene===!0?Re.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Ne.id]===void 0&&(w.state.transmissionRenderTarget[Ne.id]=new Ef(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?wm:el,minFilter:Yd,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:En.workingColorSpace}));const Je=w.state.transmissionRenderTarget[Ne.id],ft=Ne.viewport||W;Je.setSize(ft.z*P.transmissionResolutionScale,ft.w*P.transmissionResolutionScale);const vt=P.getRenderTarget(),xt=P.getActiveCubeFace(),Pt=P.getActiveMipmapLevel();P.setRenderTarget(Je),P.getClearColor($),K=P.getClearAlpha(),K<1&&P.setClearColor(16777215,.5),P.clear(),lt&&Pe.render(Re);const wt=P.toneMapping;P.toneMapping=Uu;const mt=Ne.viewport;if(Ne.viewport!==void 0&&(Ne.viewport=void 0),w.setupLightsView(Ne),xe===!0&&st.setGlobalState(P.clippingPlanes,Ne),Ii(te,Re,Ne),ne.updateMultisampleRenderTarget(Je),ne.updateRenderTargetMipmap(Je),Z.has("WEBGL_multisampled_render_to_texture")===!1){let Wt=!1;for(let It=0,tn=be.length;It<tn;It++){const un=be[It],{object:mn,geometry:Lt,material:Kt,group:Zt}=un;if(Kt.side===Ho&&mn.layers.test(Ne.layers)){const yi=Kt.side;Kt.side=ja,Kt.needsUpdate=!0,hi(mn,Re,Ne,Lt,Kt,Zt),Kt.side=yi,Kt.needsUpdate=!0,Wt=!0}}Wt===!0&&(ne.updateMultisampleRenderTarget(Je),ne.updateRenderTargetMipmap(Je))}P.setRenderTarget(vt,xt,Pt),P.setClearColor($,K),mt!==void 0&&(Ne.viewport=mt),P.toneMapping=wt}function Ii(te,be,Re){const Ne=be.isScene===!0?be.overrideMaterial:null;for(let Se=0,Je=te.length;Se<Je;Se++){const ft=te[Se],{object:vt,geometry:xt,group:Pt}=ft;let wt=ft.material;wt.allowOverride===!0&&Ne!==null&&(wt=Ne),vt.layers.test(Re.layers)&&hi(vt,be,Re,xt,wt,Pt)}}function hi(te,be,Re,Ne,Se,Je){te.onBeforeRender(P,be,Re,Ne,Se,Je),te.modelViewMatrix.multiplyMatrices(Re.matrixWorldInverse,te.matrixWorld),te.normalMatrix.getNormalMatrix(te.modelViewMatrix),Se.onBeforeRender(P,be,Re,Ne,te,Je),Se.transparent===!0&&Se.side===Ho&&Se.forceSinglePass===!1?(Se.side=ja,Se.needsUpdate=!0,P.renderBufferDirect(Re,be,Ne,Se,te,Je),Se.side=qu,Se.needsUpdate=!0,P.renderBufferDirect(Re,be,Ne,Se,te,Je),Se.side=Ho):P.renderBufferDirect(Re,be,Ne,Se,te,Je),te.onAfterRender(P,be,Re,Ne,Se,Je)}function Ti(te,be,Re){be.isScene!==!0&&(be=ue);const Ne=Ee.get(te),Se=w.state.lights,Je=w.state.shadowsArray,ft=Se.state.version,vt=pe.getParameters(te,Se.state,Je,be,Re),xt=pe.getProgramCacheKey(vt);let Pt=Ne.programs;Ne.environment=te.isMeshStandardMaterial?be.environment:null,Ne.fog=be.fog,Ne.envMap=(te.isMeshStandardMaterial?L:U).get(te.envMap||Ne.environment),Ne.envMapRotation=Ne.environment!==null&&te.envMap===null?be.environmentRotation:te.envMapRotation,Pt===void 0&&(te.addEventListener("dispose",ct),Pt=new Map,Ne.programs=Pt);let wt=Pt.get(xt);if(wt!==void 0){if(Ne.currentProgram===wt&&Ne.lightsStateVersion===ft)return Oc(te,vt),wt}else vt.uniforms=pe.getUniforms(te),te.onBeforeCompile(vt,P),wt=pe.acquireProgram(vt,xt),Pt.set(xt,wt),Ne.uniforms=vt.uniforms;const mt=Ne.uniforms;return(!te.isShaderMaterial&&!te.isRawShaderMaterial||te.clipping===!0)&&(mt.clippingPlanes=st.uniform),Oc(te,vt),Ne.needsLights=qe(te),Ne.lightsStateVersion=ft,Ne.needsLights&&(mt.ambientLightColor.value=Se.state.ambient,mt.lightProbe.value=Se.state.probe,mt.directionalLights.value=Se.state.directional,mt.directionalLightShadows.value=Se.state.directionalShadow,mt.spotLights.value=Se.state.spot,mt.spotLightShadows.value=Se.state.spotShadow,mt.rectAreaLights.value=Se.state.rectArea,mt.ltc_1.value=Se.state.rectAreaLTC1,mt.ltc_2.value=Se.state.rectAreaLTC2,mt.pointLights.value=Se.state.point,mt.pointLightShadows.value=Se.state.pointShadow,mt.hemisphereLights.value=Se.state.hemi,mt.directionalShadowMap.value=Se.state.directionalShadowMap,mt.directionalShadowMatrix.value=Se.state.directionalShadowMatrix,mt.spotShadowMap.value=Se.state.spotShadowMap,mt.spotLightMatrix.value=Se.state.spotLightMatrix,mt.spotLightMap.value=Se.state.spotLightMap,mt.pointShadowMap.value=Se.state.pointShadowMap,mt.pointShadowMatrix.value=Se.state.pointShadowMatrix),Ne.currentProgram=wt,Ne.uniformsList=null,wt}function Qs(te){if(te.uniformsList===null){const be=te.currentProgram.getUniforms();te.uniformsList=S_.seqWithValue(be.seq,te.uniforms)}return te.uniformsList}function Oc(te,be){const Re=Ee.get(te);Re.outputColorSpace=be.outputColorSpace,Re.batching=be.batching,Re.batchingColor=be.batchingColor,Re.instancing=be.instancing,Re.instancingColor=be.instancingColor,Re.instancingMorph=be.instancingMorph,Re.skinning=be.skinning,Re.morphTargets=be.morphTargets,Re.morphNormals=be.morphNormals,Re.morphColors=be.morphColors,Re.morphTargetsCount=be.morphTargetsCount,Re.numClippingPlanes=be.numClippingPlanes,Re.numIntersection=be.numClipIntersection,Re.vertexAlphas=be.vertexAlphas,Re.vertexTangents=be.vertexTangents,Re.toneMapping=be.toneMapping}function ce(te,be,Re,Ne,Se){be.isScene!==!0&&(be=ue),ne.resetTextureUnits();const Je=be.fog,ft=Ne.isMeshStandardMaterial?be.environment:null,vt=k===null?P.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Xp,xt=(Ne.isMeshStandardMaterial?L:U).get(Ne.envMap||ft),Pt=Ne.vertexColors===!0&&!!Re.attributes.color&&Re.attributes.color.itemSize===4,wt=!!Re.attributes.tangent&&(!!Ne.normalMap||Ne.anisotropy>0),mt=!!Re.morphAttributes.position,Wt=!!Re.morphAttributes.normal,It=!!Re.morphAttributes.color;let tn=Uu;Ne.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(tn=P.toneMapping);const un=Re.morphAttributes.position||Re.morphAttributes.normal||Re.morphAttributes.color,mn=un!==void 0?un.length:0,Lt=Ee.get(Ne),Kt=w.state.lights;if(xe===!0&&(ke===!0||te!==I)){const vr=te===I&&Ne.id===F;st.setState(Ne,te,vr)}let Zt=!1;Ne.version===Lt.__version?(Lt.needsLights&&Lt.lightsStateVersion!==Kt.state.version||Lt.outputColorSpace!==vt||Se.isBatchedMesh&&Lt.batching===!1||!Se.isBatchedMesh&&Lt.batching===!0||Se.isBatchedMesh&&Lt.batchingColor===!0&&Se.colorTexture===null||Se.isBatchedMesh&&Lt.batchingColor===!1&&Se.colorTexture!==null||Se.isInstancedMesh&&Lt.instancing===!1||!Se.isInstancedMesh&&Lt.instancing===!0||Se.isSkinnedMesh&&Lt.skinning===!1||!Se.isSkinnedMesh&&Lt.skinning===!0||Se.isInstancedMesh&&Lt.instancingColor===!0&&Se.instanceColor===null||Se.isInstancedMesh&&Lt.instancingColor===!1&&Se.instanceColor!==null||Se.isInstancedMesh&&Lt.instancingMorph===!0&&Se.morphTexture===null||Se.isInstancedMesh&&Lt.instancingMorph===!1&&Se.morphTexture!==null||Lt.envMap!==xt||Ne.fog===!0&&Lt.fog!==Je||Lt.numClippingPlanes!==void 0&&(Lt.numClippingPlanes!==st.numPlanes||Lt.numIntersection!==st.numIntersection)||Lt.vertexAlphas!==Pt||Lt.vertexTangents!==wt||Lt.morphTargets!==mt||Lt.morphNormals!==Wt||Lt.morphColors!==It||Lt.toneMapping!==tn||Lt.morphTargetsCount!==mn)&&(Zt=!0):(Zt=!0,Lt.__version=Ne.version);let yi=Lt.currentProgram;Zt===!0&&(yi=Ti(Ne,be,Se));let Ci=!1,Nn=!1,Js=!1;const Pn=yi.getUniforms(),xr=Lt.uniforms;if(se.useProgram(yi.program)&&(Ci=!0,Nn=!0,Js=!0),Ne.id!==F&&(F=Ne.id,Nn=!0),Ci||I!==te){se.buffers.depth.getReversed()&&te.reversedDepth!==!0&&(te._reversedDepth=!0,te.updateProjectionMatrix()),Pn.setValue(q,"projectionMatrix",te.projectionMatrix),Pn.setValue(q,"viewMatrix",te.matrixWorldInverse);const kr=Pn.map.cameraPosition;kr!==void 0&&kr.setValue(q,we.setFromMatrixPosition(te.matrixWorld)),Q.logarithmicDepthBuffer&&Pn.setValue(q,"logDepthBufFC",2/(Math.log(te.far+1)/Math.LN2)),(Ne.isMeshPhongMaterial||Ne.isMeshToonMaterial||Ne.isMeshLambertMaterial||Ne.isMeshBasicMaterial||Ne.isMeshStandardMaterial||Ne.isShaderMaterial)&&Pn.setValue(q,"isOrthographic",te.isOrthographicCamera===!0),I!==te&&(I=te,Nn=!0,Js=!0)}if(Se.isSkinnedMesh){Pn.setOptional(q,Se,"bindMatrix"),Pn.setOptional(q,Se,"bindMatrixInverse");const vr=Se.skeleton;vr&&(vr.boneTexture===null&&vr.computeBoneTexture(),Pn.setValue(q,"boneTexture",vr.boneTexture,ne))}Se.isBatchedMesh&&(Pn.setOptional(q,Se,"batchingTexture"),Pn.setValue(q,"batchingTexture",Se._matricesTexture,ne),Pn.setOptional(q,Se,"batchingIdTexture"),Pn.setValue(q,"batchingIdTexture",Se._indirectTexture,ne),Pn.setOptional(q,Se,"batchingColorTexture"),Se._colorsTexture!==null&&Pn.setValue(q,"batchingColorTexture",Se._colorsTexture,ne));const Ji=Re.morphAttributes;if((Ji.position!==void 0||Ji.normal!==void 0||Ji.color!==void 0)&&pt.update(Se,Re,yi),(Nn||Lt.receiveShadow!==Se.receiveShadow)&&(Lt.receiveShadow=Se.receiveShadow,Pn.setValue(q,"receiveShadow",Se.receiveShadow)),Ne.isMeshGouraudMaterial&&Ne.envMap!==null&&(xr.envMap.value=xt,xr.flipEnvMap.value=xt.isCubeTexture&&xt.isRenderTargetTexture===!1?-1:1),Ne.isMeshStandardMaterial&&Ne.envMap===null&&be.environment!==null&&(xr.envMapIntensity.value=be.environmentIntensity),xr.dfgLUT!==void 0&&(xr.dfgLUT.value=Fme()),Nn&&(Pn.setValue(q,"toneMappingExposure",P.toneMappingExposure),Lt.needsLights&&je(xr,Js),Je&&Ne.fog===!0&&Qe.refreshFogUniforms(xr,Je),Qe.refreshMaterialUniforms(xr,Ne,ee,Y,w.state.transmissionRenderTarget[te.id]),S_.upload(q,Qs(Lt),xr,ne)),Ne.isShaderMaterial&&Ne.uniformsNeedUpdate===!0&&(S_.upload(q,Qs(Lt),xr,ne),Ne.uniformsNeedUpdate=!1),Ne.isSpriteMaterial&&Pn.setValue(q,"center",Se.center),Pn.setValue(q,"modelViewMatrix",Se.modelViewMatrix),Pn.setValue(q,"normalMatrix",Se.normalMatrix),Pn.setValue(q,"modelMatrix",Se.matrixWorld),Ne.isShaderMaterial||Ne.isRawShaderMaterial){const vr=Ne.uniformsGroups;for(let kr=0,No=vr.length;kr<No;kr++){const ul=vr[kr];rt.update(ul,yi),rt.bind(ul,yi)}}return yi}function je(te,be){te.ambientLightColor.needsUpdate=be,te.lightProbe.needsUpdate=be,te.directionalLights.needsUpdate=be,te.directionalLightShadows.needsUpdate=be,te.pointLights.needsUpdate=be,te.pointLightShadows.needsUpdate=be,te.spotLights.needsUpdate=be,te.spotLightShadows.needsUpdate=be,te.rectAreaLights.needsUpdate=be,te.hemisphereLights.needsUpdate=be}function qe(te){return te.isMeshLambertMaterial||te.isMeshToonMaterial||te.isMeshPhongMaterial||te.isMeshStandardMaterial||te.isShadowMaterial||te.isShaderMaterial&&te.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return N},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(te,be,Re){const Ne=Ee.get(te);Ne.__autoAllocateDepthBuffer=te.resolveDepthBuffer===!1,Ne.__autoAllocateDepthBuffer===!1&&(Ne.__useRenderToTexture=!1),Ee.get(te.texture).__webglTexture=be,Ee.get(te.depthTexture).__webglTexture=Ne.__autoAllocateDepthBuffer?void 0:Re,Ne.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(te,be){const Re=Ee.get(te);Re.__webglFramebuffer=be,Re.__useDefaultFramebuffer=be===void 0};const Ke=q.createFramebuffer();this.setRenderTarget=function(te,be=0,Re=0){k=te,j=be,N=Re;let Ne=!0,Se=null,Je=!1,ft=!1;if(te){const xt=Ee.get(te);if(xt.__useDefaultFramebuffer!==void 0)se.bindFramebuffer(q.FRAMEBUFFER,null),Ne=!1;else if(xt.__webglFramebuffer===void 0)ne.setupRenderTarget(te);else if(xt.__hasExternalTextures)ne.rebindTextures(te,Ee.get(te.texture).__webglTexture,Ee.get(te.depthTexture).__webglTexture);else if(te.depthBuffer){const mt=te.depthTexture;if(xt.__boundDepthTexture!==mt){if(mt!==null&&Ee.has(mt)&&(te.width!==mt.image.width||te.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ne.setupDepthRenderbuffer(te)}}const Pt=te.texture;(Pt.isData3DTexture||Pt.isDataArrayTexture||Pt.isCompressedArrayTexture)&&(ft=!0);const wt=Ee.get(te).__webglFramebuffer;te.isWebGLCubeRenderTarget?(Array.isArray(wt[be])?Se=wt[be][Re]:Se=wt[be],Je=!0):te.samples>0&&ne.useMultisampledRTT(te)===!1?Se=Ee.get(te).__webglMultisampledFramebuffer:Array.isArray(wt)?Se=wt[Re]:Se=wt,W.copy(te.viewport),D.copy(te.scissor),B=te.scissorTest}else W.copy(re).multiplyScalar(ee).floor(),D.copy(le).multiplyScalar(ee).floor(),B=ge;if(Re!==0&&(Se=Ke),se.bindFramebuffer(q.FRAMEBUFFER,Se)&&Ne&&se.drawBuffers(te,Se),se.viewport(W),se.scissor(D),se.setScissorTest(B),Je){const xt=Ee.get(te.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+be,xt.__webglTexture,Re)}else if(ft){const xt=be;for(let Pt=0;Pt<te.textures.length;Pt++){const wt=Ee.get(te.textures[Pt]);q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0+Pt,wt.__webglTexture,Re,xt)}}else if(te!==null&&Re!==0){const xt=Ee.get(te.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,xt.__webglTexture,Re)}F=-1},this.readRenderTargetPixels=function(te,be,Re,Ne,Se,Je,ft,vt=0){if(!(te&&te.isWebGLRenderTarget)){Di("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let xt=Ee.get(te).__webglFramebuffer;if(te.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt){se.bindFramebuffer(q.FRAMEBUFFER,xt);try{const Pt=te.textures[vt],wt=Pt.format,mt=Pt.type;if(!Q.textureFormatReadable(wt)){Di("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Q.textureTypeReadable(mt)){Di("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}be>=0&&be<=te.width-Ne&&Re>=0&&Re<=te.height-Se&&(te.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+vt),q.readPixels(be,Re,Ne,Se,dt.convert(wt),dt.convert(mt),Je))}finally{const Pt=k!==null?Ee.get(k).__webglFramebuffer:null;se.bindFramebuffer(q.FRAMEBUFFER,Pt)}}},this.readRenderTargetPixelsAsync=async function(te,be,Re,Ne,Se,Je,ft,vt=0){if(!(te&&te.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let xt=Ee.get(te).__webglFramebuffer;if(te.isWebGLCubeRenderTarget&&ft!==void 0&&(xt=xt[ft]),xt)if(be>=0&&be<=te.width-Ne&&Re>=0&&Re<=te.height-Se){se.bindFramebuffer(q.FRAMEBUFFER,xt);const Pt=te.textures[vt],wt=Pt.format,mt=Pt.type;if(!Q.textureFormatReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Q.textureTypeReadable(mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Wt=q.createBuffer();q.bindBuffer(q.PIXEL_PACK_BUFFER,Wt),q.bufferData(q.PIXEL_PACK_BUFFER,Je.byteLength,q.STREAM_READ),te.textures.length>1&&q.readBuffer(q.COLOR_ATTACHMENT0+vt),q.readPixels(be,Re,Ne,Se,dt.convert(wt),dt.convert(mt),0);const It=k!==null?Ee.get(k).__webglFramebuffer:null;se.bindFramebuffer(q.FRAMEBUFFER,It);const tn=q.fenceSync(q.SYNC_GPU_COMMANDS_COMPLETE,0);return q.flush(),await due(q,tn,4),q.bindBuffer(q.PIXEL_PACK_BUFFER,Wt),q.getBufferSubData(q.PIXEL_PACK_BUFFER,0,Je),q.deleteBuffer(Wt),q.deleteSync(tn),Je}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(te,be=null,Re=0){const Ne=Math.pow(2,-Re),Se=Math.floor(te.image.width*Ne),Je=Math.floor(te.image.height*Ne),ft=be!==null?be.x:0,vt=be!==null?be.y:0;ne.setTexture2D(te,0),q.copyTexSubImage2D(q.TEXTURE_2D,Re,0,0,ft,vt,Se,Je),se.unbindTexture()};const We=q.createFramebuffer(),_t=q.createFramebuffer();this.copyTextureToTexture=function(te,be,Re=null,Ne=null,Se=0,Je=null){Je===null&&(Se!==0?(Jx("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Je=Se,Se=0):Je=0);let ft,vt,xt,Pt,wt,mt,Wt,It,tn;const un=te.isCompressedTexture?te.mipmaps[Je]:te.image;if(Re!==null)ft=Re.max.x-Re.min.x,vt=Re.max.y-Re.min.y,xt=Re.isBox3?Re.max.z-Re.min.z:1,Pt=Re.min.x,wt=Re.min.y,mt=Re.isBox3?Re.min.z:0;else{const Ji=Math.pow(2,-Se);ft=Math.floor(un.width*Ji),vt=Math.floor(un.height*Ji),te.isDataArrayTexture?xt=un.depth:te.isData3DTexture?xt=Math.floor(un.depth*Ji):xt=1,Pt=0,wt=0,mt=0}Ne!==null?(Wt=Ne.x,It=Ne.y,tn=Ne.z):(Wt=0,It=0,tn=0);const mn=dt.convert(be.format),Lt=dt.convert(be.type);let Kt;be.isData3DTexture?(ne.setTexture3D(be,0),Kt=q.TEXTURE_3D):be.isDataArrayTexture||be.isCompressedArrayTexture?(ne.setTexture2DArray(be,0),Kt=q.TEXTURE_2D_ARRAY):(ne.setTexture2D(be,0),Kt=q.TEXTURE_2D),q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,be.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,be.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,be.unpackAlignment);const Zt=q.getParameter(q.UNPACK_ROW_LENGTH),yi=q.getParameter(q.UNPACK_IMAGE_HEIGHT),Ci=q.getParameter(q.UNPACK_SKIP_PIXELS),Nn=q.getParameter(q.UNPACK_SKIP_ROWS),Js=q.getParameter(q.UNPACK_SKIP_IMAGES);q.pixelStorei(q.UNPACK_ROW_LENGTH,un.width),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,un.height),q.pixelStorei(q.UNPACK_SKIP_PIXELS,Pt),q.pixelStorei(q.UNPACK_SKIP_ROWS,wt),q.pixelStorei(q.UNPACK_SKIP_IMAGES,mt);const Pn=te.isDataArrayTexture||te.isData3DTexture,xr=be.isDataArrayTexture||be.isData3DTexture;if(te.isDepthTexture){const Ji=Ee.get(te),vr=Ee.get(be),kr=Ee.get(Ji.__renderTarget),No=Ee.get(vr.__renderTarget);se.bindFramebuffer(q.READ_FRAMEBUFFER,kr.__webglFramebuffer),se.bindFramebuffer(q.DRAW_FRAMEBUFFER,No.__webglFramebuffer);for(let ul=0;ul<xt;ul++)Pn&&(q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Ee.get(te).__webglTexture,Se,mt+ul),q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Ee.get(be).__webglTexture,Je,tn+ul)),q.blitFramebuffer(Pt,wt,ft,vt,Wt,It,ft,vt,q.DEPTH_BUFFER_BIT,q.NEAREST);se.bindFramebuffer(q.READ_FRAMEBUFFER,null),se.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else if(Se!==0||te.isRenderTargetTexture||Ee.has(te)){const Ji=Ee.get(te),vr=Ee.get(be);se.bindFramebuffer(q.READ_FRAMEBUFFER,We),se.bindFramebuffer(q.DRAW_FRAMEBUFFER,_t);for(let kr=0;kr<xt;kr++)Pn?q.framebufferTextureLayer(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,Ji.__webglTexture,Se,mt+kr):q.framebufferTexture2D(q.READ_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,Ji.__webglTexture,Se),xr?q.framebufferTextureLayer(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,vr.__webglTexture,Je,tn+kr):q.framebufferTexture2D(q.DRAW_FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,vr.__webglTexture,Je),Se!==0?q.blitFramebuffer(Pt,wt,ft,vt,Wt,It,ft,vt,q.COLOR_BUFFER_BIT,q.NEAREST):xr?q.copyTexSubImage3D(Kt,Je,Wt,It,tn+kr,Pt,wt,ft,vt):q.copyTexSubImage2D(Kt,Je,Wt,It,Pt,wt,ft,vt);se.bindFramebuffer(q.READ_FRAMEBUFFER,null),se.bindFramebuffer(q.DRAW_FRAMEBUFFER,null)}else xr?te.isDataTexture||te.isData3DTexture?q.texSubImage3D(Kt,Je,Wt,It,tn,ft,vt,xt,mn,Lt,un.data):be.isCompressedArrayTexture?q.compressedTexSubImage3D(Kt,Je,Wt,It,tn,ft,vt,xt,mn,un.data):q.texSubImage3D(Kt,Je,Wt,It,tn,ft,vt,xt,mn,Lt,un):te.isDataTexture?q.texSubImage2D(q.TEXTURE_2D,Je,Wt,It,ft,vt,mn,Lt,un.data):te.isCompressedTexture?q.compressedTexSubImage2D(q.TEXTURE_2D,Je,Wt,It,un.width,un.height,mn,un.data):q.texSubImage2D(q.TEXTURE_2D,Je,Wt,It,ft,vt,mn,Lt,un);q.pixelStorei(q.UNPACK_ROW_LENGTH,Zt),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,yi),q.pixelStorei(q.UNPACK_SKIP_PIXELS,Ci),q.pixelStorei(q.UNPACK_SKIP_ROWS,Nn),q.pixelStorei(q.UNPACK_SKIP_IMAGES,Js),Je===0&&be.generateMipmaps&&q.generateMipmap(Kt),se.unbindTexture()},this.initRenderTarget=function(te){Ee.get(te).__webglFramebuffer===void 0&&ne.setupRenderTarget(te)},this.initTexture=function(te){te.isCubeTexture?ne.setTextureCube(te,0):te.isData3DTexture?ne.setTexture3D(te,0):te.isDataArrayTexture||te.isCompressedArrayTexture?ne.setTexture2DArray(te,0):ne.setTexture2D(te,0),se.unbindTexture()},this.resetState=function(){j=0,N=0,k=null,se.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Go}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=En._getDrawingBufferColorSpace(e),n.unpackColorSpace=En._getUnpackColorSpace()}};const nz={type:"change"},ik={type:"start"},J9={type:"end"},nb=new QP,iz=new yu,Bme=Math.cos(70*hue.DEG2RAD),tr=new Ge,Pa=2*Math.PI,Vn={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},pT=1e-6;class Hme extends Jue{constructor(e,n=null){super(e,n),this.state=Vn.NONE,this.target=new Ge,this.cursor=new Ge,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:Ep.ROTATE,MIDDLE:Ep.DOLLY,RIGHT:Ep.PAN},this.touches={ONE:vp.ROTATE,TWO:vp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Ge,this._lastQuaternion=new Mf,this._lastTargetPosition=new Ge,this._quat=new Mf().setFromUnitVectors(e.up,new Ge(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new PF,this._sphericalDelta=new PF,this._scale=1,this._panOffset=new Ge,this._rotateStart=new sn,this._rotateEnd=new sn,this._rotateDelta=new sn,this._panStart=new sn,this._panEnd=new sn,this._panDelta=new sn,this._dollyStart=new sn,this._dollyEnd=new sn,this._dollyDelta=new sn,this._dollyDirection=new Ge,this._mouse=new sn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Vme.bind(this),this._onPointerDown=$me.bind(this),this._onPointerUp=Gme.bind(this),this._onContextMenu=Qme.bind(this),this._onMouseWheel=Xme.bind(this),this._onKeyDown=Kme.bind(this),this._onTouchStart=Yme.bind(this),this._onTouchMove=Zme.bind(this),this._onMouseDown=Wme.bind(this),this._onMouseMove=qme.bind(this),this._interceptControlDown=Jme.bind(this),this._interceptControlUp=ege.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(nz),this.update(),this.state=Vn.NONE}update(e=null){const n=this.object.position;tr.copy(n).sub(this.target),tr.applyQuaternion(this._quat),this._spherical.setFromVector3(tr),this.autoRotate&&this.state===Vn.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+=Pa:i>Math.PI&&(i-=Pa),r<-Math.PI?r+=Pa:r>Math.PI&&(r-=Pa),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(tr.setFromSpherical(this._spherical),tr.applyQuaternion(this._quatInverse),n.copy(this.target).add(tr),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=tr.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 Ge(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 Ge(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),s=tr.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):(nb.origin.copy(this.object.position),nb.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(nb.direction))<Bme?this.object.lookAt(this.target):(iz.setFromNormalAndCoplanarPoint(this.object.up,this.target),nb.intersectPlane(iz,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)>pT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>pT||this._lastTargetPosition.distanceToSquared(this.target)>pT?(this.dispatchEvent(nz),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Pa/60*this.autoRotateSpeed*e:Pa/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){tr.setFromMatrixColumn(n,0),tr.multiplyScalar(-e),this._panOffset.add(tr)}_panUp(e,n){this.screenSpacePanning===!0?tr.setFromMatrixColumn(n,1):(tr.setFromMatrixColumn(n,0),tr.crossVectors(this.object.up,tr)),tr.multiplyScalar(e),this._panOffset.add(tr)}_pan(e,n){const i=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;tr.copy(r).sub(this.target);let a=tr.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(Pa*this._rotateDelta.x/n.clientHeight),this._rotateUp(Pa*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(Pa*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(-Pa*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(Pa*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(-Pa*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(Pa*this._rotateDelta.x/n.clientHeight),this._rotateUp(Pa*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 sn,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 $me(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 Vme(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function Gme(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(J9),this.state=Vn.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 Wme(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 Ep.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Vn.DOLLY;break;case Ep.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}break;case Ep.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Vn.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Vn.PAN}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(ik)}function qme(t){switch(this.state){case Vn.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Vn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Vn.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function Xme(t){this.enabled===!1||this.enableZoom===!1||this.state!==Vn.NONE||(t.preventDefault(),this.dispatchEvent(ik),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(J9))}function Kme(t){this.enabled!==!1&&this._handleKeyDown(t)}function Yme(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case vp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Vn.TOUCH_ROTATE;break;case vp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Vn.TOUCH_PAN;break;default:this.state=Vn.NONE}break;case 2:switch(this.touches.TWO){case vp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Vn.TOUCH_DOLLY_PAN;break;case vp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Vn.TOUCH_DOLLY_ROTATE;break;default:this.state=Vn.NONE}break;default:this.state=Vn.NONE}this.state!==Vn.NONE&&this.dispatchEvent(ik)}function Zme(t){switch(this._trackPointer(t),this.state){case Vn.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Vn.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Vn.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Vn.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Vn.NONE}}function Qme(t){this.enabled!==!1&&t.preventDefault()}function Jme(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ege(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function tge(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 cl;let c=0;for(let u=0;u<t.length;++u){const f=t[u];let m=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const g in f.attributes){if(!i.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+g+'" attribute exists among all geometries, or in none of them.'),null;a[g]===void 0&&(a[g]=[]),a[g].push(f.attributes[g]),m++}if(m!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". 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 "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const g in f.morphAttributes){if(!r.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;s[g]===void 0&&(s[g]=[]),s[g].push(f.morphAttributes[g])}if(e){let g;if(n)g=f.index.count;else if(f.attributes.position!==void 0)g=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,g,u),c+=g}}if(n){let u=0;const f=[];for(let m=0;m<t.length;++m){const g=t[m].index;for(let y=0;y<g.count;++y)f.push(g.getX(y)+u);u+=t[m].attributes.position.count}l.setIndex(f)}for(const u in a){const f=rz(a[u]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,f)}for(const u in s){const f=s[u][0].length;if(f===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let m=0;m<f;++m){const g=[];for(let _=0;_<s[u].length;++_)g.push(s[u][_][m]);const y=rz(g);if(!y)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(y)}}return l}function rz(t){let e,n,i,r=-1,a=0;for(let c=0;c<t.length;++c){const u=t[c];if(e===void 0&&(e=u.array.constructor),e!==u.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=u.itemSize),n!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=u.normalized),i!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=u.gpuType),r!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=u.count*n}const s=new e(a),o=new $s(s,n,i);let l=0;for(let c=0;c<t.length;++c){const u=t[c];if(u.isInterleavedBufferAttribute){const f=l/n;for(let m=0,g=u.count;m<g;m++)for(let y=0;y<n;y++){const _=u.getComponent(m,y);o.setComponent(m+f,y,_)}}else s.set(u.array,l);l+=u.count*n}return r!==void 0&&(o.gpuType=r),o}function ib(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 mT={exports:{}};var az;function nge(){return az||(az=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(i,r,a){function s(c,u){if(!r[c]){if(!i[c]){var f=typeof ib=="function"&&ib;if(!u&&f)return f(c,!0);if(o)return o(c,!0);var m=new Error("Cannot find module '"+c+"'");throw m.code="MODULE_NOT_FOUND",m}var g=r[c]={exports:{}};i[c][0].call(g.exports,function(y){var _=i[c][1][y];return s(_||y)},g,g.exports,n,i,r,a)}return r[c].exports}for(var o=typeof ib=="function"&&ib,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,u,f,m,g,y,_,v=[],x=0,M=l.length,w=M,C=a.getTypeOf(l)!=="string";x<l.length;)w=M-x,f=C?(c=l[x++],u=x<M?l[x++]:0,x<M?l[x++]:0):(c=l.charCodeAt(x++),u=x<M?l.charCodeAt(x++):0,x<M?l.charCodeAt(x++):0),m=c>>2,g=(3&c)<<4|u>>4,y=1<w?(15&u)<<2|f>>6:64,_=2<w?63&f:64,v.push(o.charAt(m)+o.charAt(g)+o.charAt(y)+o.charAt(_));return v.join("")},r.decode=function(l){var c,u,f,m,g,y,_=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);_<l.length;)c=o.indexOf(l.charAt(_++))<<2|(m=o.indexOf(l.charAt(_++)))>>4,u=(15&m)<<4|(g=o.indexOf(l.charAt(_++)))>>2,f=(3&g)<<6|(y=o.indexOf(l.charAt(_++))),M[v++]=c,g!==64&&(M[v++]=u),y!==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(u,f,m,g,y){this.compressedSize=u,this.uncompressedSize=f,this.crc32=m,this.compression=g,this.compressedContent=y}c.prototype={getContentWorker:function(){var u=new s(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return u.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},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(u,f,m){return u.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(m)).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 u=0;u<8;u++)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,u,f,m){var g=s,y=m+f;c^=-1;for(var _=m;_<y;_++)c=c>>>8^g[255&(c^u[_])];return-1^c})(0|l,o,o.length,0):(function(c,u,f,m){var g=s,y=m+f;c^=-1;for(var _=m;_<y;_++)c=c>>>8^g[255&(c^u.charCodeAt(_))];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 u(f,m){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=m,this.meta={}}r.magic="\b\0",o.inherits(u,l),u.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,f.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(m){f.push({data:m,meta:f.meta})}},r.compressWorker=function(f){return new u("Deflate",f)},r.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,i,r){function a(g,y){var _,v="";for(_=0;_<y;_++)v+=String.fromCharCode(255&g),g>>>=8;return v}function s(g,y,_,v,x,M){var w,C,T=g.file,P=g.compression,A=M!==c.utf8encode,j=o.transformTo("string",M(T.name)),N=o.transformTo("string",c.utf8encode(T.name)),k=T.comment,F=o.transformTo("string",M(k)),I=o.transformTo("string",c.utf8encode(k)),W=N.length!==T.name.length,D=I.length!==k.length,B="",$="",K="",X=T.dir,Y=T.date,ee={crc32:0,compressedSize:0,uncompressedSize:0};y&&!_||(ee.crc32=g.crc32,ee.compressedSize=g.compressedSize,ee.uncompressedSize=g.uncompressedSize);var z=0;y&&(z|=8),A||!W&&!D||(z|=2048);var V=0,re=0;X&&(V|=16),x==="UNIX"?(re=798,V|=(function(ge,ie){var xe=ge;return ge||(xe=ie?16893:33204),(65535&xe)<<16})(T.unixPermissions,X)):(re=20,V|=(function(ge){return 63&(ge||0)})(T.dosPermissions)),w=Y.getUTCHours(),w<<=6,w|=Y.getUTCMinutes(),w<<=5,w|=Y.getUTCSeconds()/2,C=Y.getUTCFullYear()-1980,C<<=4,C|=Y.getUTCMonth()+1,C<<=5,C|=Y.getUTCDate(),W&&($=a(1,1)+a(u(j),4)+N,B+="up"+a($.length,2)+$),D&&(K=a(1,1)+a(u(F),4)+I,B+="uc"+a(K.length,2)+K);var le="";return le+=`
- \0`,le+=a(z,2),le+=P.magic,le+=a(w,2),le+=a(C,2),le+=a(ee.crc32,4),le+=a(ee.compressedSize,4),le+=a(ee.uncompressedSize,4),le+=a(j.length,2),le+=a(B.length,2),{fileRecord:f.LOCAL_FILE_HEADER+le+j+B,dirRecord:f.CENTRAL_FILE_HEADER+a(re,2)+le+a(F.length,2)+"\0\0\0\0"+a(V,4)+a(v,4)+j+B+F}}var o=n("../utils"),l=n("../stream/GenericWorker"),c=n("../utf8"),u=n("../crc32"),f=n("../signature");function m(g,y,_,v){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=y,this.zipPlatform=_,this.encodeFileName=v,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(m,l),m.prototype.push=function(g){var y=g.meta.percent||0,_=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,l.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:_?(y+100*(_-v-1))/_:100}}))},m.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var y=this.streamFiles&&!g.file.dir;if(y){var _=s(g,y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:_.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(g){this.accumulate=!1;var y=this.streamFiles&&!g.file.dir,_=s(g,y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(_.dirRecord),y)this.push({data:(function(v){return f.DATA_DESCRIPTOR+a(v.crc32,4)+a(v.compressedSize,4)+a(v.uncompressedSize,4)})(g),meta:{percent:100}});else for(this.push({data:_.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var g=this.bytesWritten,y=0;y<this.dirRecords.length;y++)this.push({data:this.dirRecords[y],meta:{percent:100}});var _=this.bytesWritten-g,v=(function(x,M,w,C,T){var P=o.transformTo("string",T(C));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,_,g,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(g){this._sources.push(g);var y=this;return g.on("data",function(_){y.processChunk(_)}),g.on("end",function(){y.closedSource(y.previous.streamInfo),y._sources.length?y.prepareNextSource():y.end()}),g.on("error",function(_){y.error(_)}),this},m.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))},m.prototype.error=function(g){var y=this._sources;if(!l.prototype.error.call(this,g))return!1;for(var _=0;_<y.length;_++)try{y[_].error(g)}catch{}return!0},m.prototype.lock=function(){l.prototype.lock.call(this);for(var g=this._sources,y=0;y<g.length;y++)g[y].lock()},i.exports=m},{"../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 u=new s(l.streamFiles,c,l.platform,l.encodeFileName),f=0;try{o.forEach(function(m,g){f++;var y=(function(M,w){var C=M||w,T=a[C];if(!T)throw new Error(C+" is not a valid compression method !");return T})(g.options.compression,l.compression),_=g.options.compressionOptions||l.compressionOptions||{},v=g.dir,x=g.date;g._compressWorker(y,_).withStreamInfo("file",{name:m,dir:v,date:x,comment:g.comment||"",unixPermissions:g.unixPermissions,dosPermissions:g.dosPermissions}).pipe(u)}),u.entriesCount=f}catch(m){u.error(m)}return u}},{"../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"),u=n("./nodejsUtils");function f(m){return new s.Promise(function(g,y){var _=m.decompressed.getContentWorker().pipe(new c);_.on("error",function(v){y(v)}).on("end",function(){_.streamInfo.crc32!==m.decompressed.crc32?y(new Error("Corrupted zip : CRC32 mismatch")):g()}).resume()})}i.exports=function(m,g){var y=this;return g=a.extend(g||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),u.isNode&&u.isStream(m)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",m,!0,g.optimizedBinaryString,g.base64).then(function(_){var v=new l(g);return v.load(_),v}).then(function(_){var v=[s.Promise.resolve(_)],x=_.files;if(g.checkCRC32)for(var M=0;M<x.length;M++)v.push(f(x[M]));return s.Promise.all(v)}).then(function(_){for(var v=_.shift(),x=v.files,M=0;M<x.length;M++){var w=x[M],C=w.fileNameStr,T=a.resolve(w.fileNameStr);y.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:g.createFolders}),w.dir||(y.file(T).unsafeOriginalName=C)}return v.zipComment.length&&(y.comment=v.zipComment),y})}},{"./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(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).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 u=this;o.on("data",function(f,m){u.push(f)||u._helper.pause(),c&&c(m)}).on("error",function(f){u.emit("error",f)}).on("end",function(){u.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,A){var j,N=o.getTypeOf(P),k=o.extend(A||{},u);k.date=k.date||new Date,k.compression!==null&&(k.compression=k.compression.toUpperCase()),typeof k.unixPermissions=="string"&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(T=x(T)),k.createFolders&&(j=v(T))&&M.call(this,j,!0);var F=N==="string"&&k.binary===!1&&k.base64===!1;A&&A.binary!==void 0||(k.binary=!F),(P instanceof f&&P.uncompressedSize===0||k.dir||!P||P.length===0)&&(k.base64=!1,k.binary=!0,P="",k.compression="STORE",N="string");var I=null;I=P instanceof f||P instanceof l?P:y.isNode&&y.isStream(P)?new _(T,P):o.prepareContent(T,P,k.binary,k.optimizedBinaryString,k.base64);var W=new m(T,I,k);this.files[T]=W}var s=n("./utf8"),o=n("./utils"),l=n("./stream/GenericWorker"),c=n("./stream/StreamHelper"),u=n("./defaults"),f=n("./compressedObject"),m=n("./zipObject"),g=n("./generate"),y=n("./nodejsUtils"),_=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:u.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 C={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(T){var P,A,j;for(P in this.files)j=this.files[P],(A=P.slice(this.root.length,P.length))&&P.slice(0,this.root.length)===this.root&&T(A,j)},filter:function(T){var P=[];return this.forEach(function(A,j){T(A,j)&&P.push(j)}),P},file:function(T,P,A){if(arguments.length!==1)return T=this.root+T,a.call(this,T,P,A),this;if(w(T)){var j=T;return this.filter(function(k,F){return!F.dir&&j.test(k)})}var N=this.files[this.root+T];return N&&!N.dir?N:null},folder:function(T){if(!T)return this;if(w(T))return this.filter(function(N,k){return k.dir&&T.test(N)});var P=this.root+T,A=M.call(this,P),j=this.clone();return j.root=A.name,j},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 A=this.filter(function(N,k){return k.name.slice(0,T.length)===T}),j=0;j<A.length;j++)delete this.files[A[j].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,A={};try{if((A=o.extend(T||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),A.type==="binarystring"&&(A.type="string"),!A.type)throw new Error("No output type specified.");o.checkSupport(A.type),A.platform!=="darwin"&&A.platform!=="freebsd"&&A.platform!=="linux"&&A.platform!=="sunos"||(A.platform="UNIX"),A.platform==="win32"&&(A.platform="DOS");var j=A.comment||this.comment||"";P=g.generateWorker(this,A,j)}catch(N){(P=new l("error")).error(N)}return new c(P,A.type||"string",A.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=C},{"./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),u=o.charCodeAt(2),f=o.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===l&&this.data[m+1]===c&&this.data[m+2]===u&&this.data[m+3]===f)return m-this.zero;return-1},s.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),u=o.charCodeAt(2),f=o.charCodeAt(3),m=this.readData(4);return l===m[0]&&c===m[1]&&u===m[2]&&f===m[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"),u=n("./Uint8ArrayReader");i.exports=function(f){var m=a.getTypeOf(f);return a.checkSupport(m),m!=="string"||s.uint8array?m==="nodebuffer"?new c(f):s.uint8array?new u(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(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=a.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}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"),u=n("../external"),f=null;if(c.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(y,_){return new u.Promise(function(v,x){var M=[],w=y._internalType,C=y._outputType,T=y._mimeType;y.on("data",function(P,A){M.push(P),_&&_(A)}).on("error",function(P){M=[],x(P)}).on("end",function(){try{var P=(function(A,j,N){switch(A){case"blob":return a.newBlob(a.transformTo("arraybuffer",j),N);case"base64":return l.encode(j);default:return a.transformTo(A,j)}})(C,(function(A,j){var N,k=0,F=null,I=0;for(N=0;N<j.length;N++)I+=j[N].length;switch(A){case"string":return j.join("");case"array":return Array.prototype.concat.apply([],j);case"uint8array":for(F=new Uint8Array(I),N=0;N<j.length;N++)F.set(j[N],k),k+=j[N].length;return F;case"nodebuffer":return Buffer.concat(j);default:throw new Error("concat : unsupported type '"+A+"'")}})(w,M),T);v(P)}catch(A){x(A)}M=[]}).resume()})}function g(y,_,v){var x=_;switch(_){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=_,this._mimeType=v,a.checkSupport(x),this._worker=y.pipe(new s(x)),y.lock()}catch(M){this._worker=new o("error"),this._worker.error(M)}}g.prototype={accumulate:function(y){return m(this,y)},on:function(y,_){var v=this;return y==="data"?this._worker.on(y,function(x){_.call(v,x.data,x.meta)}):this._worker.on(y,function(){a.delay(_,arguments,v)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(y){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"},y)}},i.exports=g},{"../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),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;c[254]=c[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function m(){l.call(this,"utf-8 encode")}r.utf8encode=function(g){return s.nodebuffer?o.newBufferFrom(g,"utf-8"):(function(y){var _,v,x,M,w,C=y.length,T=0;for(M=0;M<C;M++)(64512&(v=y.charCodeAt(M)))==55296&&M+1<C&&(64512&(x=y.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),T+=v<128?1:v<2048?2:v<65536?3:4;for(_=s.uint8array?new Uint8Array(T):new Array(T),M=w=0;w<T;M++)(64512&(v=y.charCodeAt(M)))==55296&&M+1<C&&(64512&(x=y.charCodeAt(M+1)))==56320&&(v=65536+(v-55296<<10)+(x-56320),M++),v<128?_[w++]=v:(v<2048?_[w++]=192|v>>>6:(v<65536?_[w++]=224|v>>>12:(_[w++]=240|v>>>18,_[w++]=128|v>>>12&63),_[w++]=128|v>>>6&63),_[w++]=128|63&v);return _})(g)},r.utf8decode=function(g){return s.nodebuffer?a.transformTo("nodebuffer",g).toString("utf-8"):(function(y){var _,v,x,M,w=y.length,C=new Array(2*w);for(_=v=0;_<w;)if((x=y[_++])<128)C[v++]=x;else if(4<(M=c[x]))C[v++]=65533,_+=M-1;else{for(x&=M===2?31:M===3?15:7;1<M&&_<w;)x=x<<6|63&y[_++],M--;1<M?C[v++]=65533:x<65536?C[v++]=x:(x-=65536,C[v++]=55296|x>>10&1023,C[v++]=56320|1023&x)}return C.length!==v&&(C.subarray?C=C.subarray(0,v):C.length=v),a.applyFromCharCode(C)})(g=a.transformTo(s.uint8array?"uint8array":"array",g))},a.inherits(f,l),f.prototype.processChunk=function(g){var y=a.transformTo(s.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var _=y;(y=new Uint8Array(_.length+this.leftOver.length)).set(this.leftOver,0),y.set(_,this.leftOver.length)}else y=this.leftOver.concat(y);this.leftOver=null}var v=(function(M,w){var C;for((w=w||M.length)>M.length&&(w=M.length),C=w-1;0<=C&&(192&M[C])==128;)C--;return C<0||C===0?w:C+c[M[C]]>w?C:w})(y),x=y;v!==y.length&&(s.uint8array?(x=y.subarray(0,v),this.leftOver=y.subarray(v,y.length)):(x=y.slice(0,v),this.leftOver=y.slice(v,y.length))),this.push({data:r.utf8decode(x),meta:g.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(m,l),m.prototype.processChunk=function(g){this.push({data:r.utf8encode(g.data),meta:g.meta})},r.Utf8EncodeWorker=m},{"./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(_){return _}function u(_,v){for(var x=0;x<_.length;++x)v[x]=255&_.charCodeAt(x);return v}n("setimmediate"),r.newBlob=function(_,v){r.checkSupport("blob");try{return new Blob([_],{type:v})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(_),x.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(_,v,x){var M=[],w=0,C=_.length;if(C<=x)return String.fromCharCode.apply(null,_);for(;w<C;)v==="array"||v==="nodebuffer"?M.push(String.fromCharCode.apply(null,_.slice(w,Math.min(w+x,C)))):M.push(String.fromCharCode.apply(null,_.subarray(w,Math.min(w+x,C)))),w+=x;return M.join("")},stringifyByChar:function(_){for(var v="",x=0;x<_.length;x++)v+=String.fromCharCode(_[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 m(_){var v=65536,x=r.getTypeOf(_),M=!0;if(x==="uint8array"?M=f.applyCanBeUsed.uint8array:x==="nodebuffer"&&(M=f.applyCanBeUsed.nodebuffer),M)for(;1<v;)try{return f.stringifyByChunk(_,x,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(_)}function g(_,v){for(var x=0;x<_.length;x++)v[x]=_[x];return v}r.applyFromCharCode=m;var y={};y.string={string:c,array:function(_){return u(_,new Array(_.length))},arraybuffer:function(_){return y.string.uint8array(_).buffer},uint8array:function(_){return u(_,new Uint8Array(_.length))},nodebuffer:function(_){return u(_,o.allocBuffer(_.length))}},y.array={string:m,array:c,arraybuffer:function(_){return new Uint8Array(_).buffer},uint8array:function(_){return new Uint8Array(_)},nodebuffer:function(_){return o.newBufferFrom(_)}},y.arraybuffer={string:function(_){return m(new Uint8Array(_))},array:function(_){return g(new Uint8Array(_),new Array(_.byteLength))},arraybuffer:c,uint8array:function(_){return new Uint8Array(_)},nodebuffer:function(_){return o.newBufferFrom(new Uint8Array(_))}},y.uint8array={string:m,array:function(_){return g(_,new Array(_.length))},arraybuffer:function(_){return _.buffer},uint8array:c,nodebuffer:function(_){return o.newBufferFrom(_)}},y.nodebuffer={string:m,array:function(_){return g(_,new Array(_.length))},arraybuffer:function(_){return y.nodebuffer.uint8array(_).buffer},uint8array:function(_){return g(_,new Uint8Array(_.length))},nodebuffer:c},r.transformTo=function(_,v){if(v=v||"",!_)return v;r.checkSupport(_);var x=r.getTypeOf(v);return y[x][_](v)},r.resolve=function(_){for(var v=_.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(_){return typeof _=="string"?"string":Object.prototype.toString.call(_)==="[object Array]"?"array":a.nodebuffer&&o.isBuffer(_)?"nodebuffer":a.uint8array&&_ instanceof Uint8Array?"uint8array":a.arraybuffer&&_ instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(_){if(!a[_.toLowerCase()])throw new Error(_+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(_){var v,x,M="";for(x=0;x<(_||"").length;x++)M+="\\x"+((v=_.charCodeAt(x))<16?"0":"")+v.toString(16).toUpperCase();return M},r.delay=function(_,v,x){setImmediate(function(){_.apply(x||null,v||[])})},r.inherits=function(_,v){function x(){}x.prototype=v.prototype,_.prototype=new x},r.extend=function(){var _,v,x={};for(_=0;_<arguments.length;_++)for(v in arguments[_])Object.prototype.hasOwnProperty.call(arguments[_],v)&&x[v]===void 0&&(x[v]=arguments[_][v]);return x},r.prepareContent=function(_,v,x,M,w){return l.Promise.resolve(v).then(function(C){return a.blob&&(C instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C))!==-1)&&typeof FileReader<"u"?new l.Promise(function(T,P){var A=new FileReader;A.onload=function(j){T(j.target.result)},A.onerror=function(j){P(j.target.error)},A.readAsArrayBuffer(C)}):C}).then(function(C){var T=r.getTypeOf(C);return T?(T==="arraybuffer"?C=r.transformTo("uint8array",C):T==="string"&&(w?C=s.decode(C):x&&M!==!0&&(C=(function(P){return u(P,a.uint8array?new Uint8Array(P.length):new Array(P.length))})(C))),C):l.Promise.reject(new Error("Can't read the data of '"+_+"'. 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 u(f){this.files=[],this.loadOptions=f}u.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(m)+", expected "+s.pretty(f)+")")}},isSignature:function(f,m){var g=this.reader.index;this.reader.setIndex(f);var y=this.reader.readString(4)===m;return this.reader.setIndex(g),y},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),m=c.uint8array?"uint8array":"array",g=s.transformTo(m,f);this.zipComment=this.loadOptions.decodeFileName(g)},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,m,g,y=this.zip64EndOfCentralSize-44;0<y;)f=this.reader.readInt(2),m=this.reader.readInt(4),g=this.reader.readData(m),this.zip64ExtensibleData[f]={id:f,length:m,value:g}},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,m;for(f=0;f<this.files.length;f++)m=this.files[f],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.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 m=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 g=this.centralDirOffset+this.centralDirSize;this.zip64&&(g+=20,g+=12+this.zip64EndOfCentralSize);var y=m-g;if(0<y)this.isSignature(m,o.CENTRAL_FILE_HEADER)||(this.reader.zero=y);else if(y<0)throw new Error("Corrupted zip: missing "+Math.abs(y)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=u},{"./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"),u=n("./compressions"),f=n("./support");function m(g,y){this.options=g,this.loadOptions=y}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(g){var y,_;if(g.skip(22),this.fileNameLength=g.readInt(2),_=g.readInt(2),this.fileName=g.readData(this.fileNameLength),g.skip(_),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((y=(function(v){for(var x in u)if(Object.prototype.hasOwnProperty.call(u,x)&&u[x].magic===v)return u[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,y,g.readData(this.compressedSize))},readCentralPart:function(g){this.versionMadeBy=g.readInt(2),g.skip(2),this.bitFlag=g.readInt(2),this.compressionMethod=g.readString(2),this.date=g.readDate(),this.crc32=g.readInt(4),this.compressedSize=g.readInt(4),this.uncompressedSize=g.readInt(4);var y=g.readInt(2);if(this.extraFieldsLength=g.readInt(2),this.fileCommentLength=g.readInt(2),this.diskNumberStart=g.readInt(2),this.internalFileAttributes=g.readInt(2),this.externalFileAttributes=g.readInt(4),this.localHeaderOffset=g.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");g.skip(y),this.readExtraFields(g),this.parseZIP64ExtraField(g),this.fileComment=g.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var g=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),g==0&&(this.dosPermissions=63&this.externalFileAttributes),g==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=a(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var y,_,v,x=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4<x;)y=g.readInt(2),_=g.readInt(2),v=g.readData(_),this.extraFields[y]={id:y,length:_,value:v};g.setIndex(x)},handleUTF8:function(){var g=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var y=this.findExtraFieldUnicodePath();if(y!==null)this.fileNameStr=y;else{var _=s.transformTo(g,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(_)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var x=s.transformTo(g,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var g=this.extraFields[28789];if(g){var y=a(g.value);return y.readInt(1)!==1||l(this.fileName)!==y.readInt(4)?null:c.utf8decode(y.readData(g.length-5))}return null},findExtraFieldUnicodeComment:function(){var g=this.extraFields[25461];if(g){var y=a(g.value);return y.readInt(1)!==1||l(this.fileComment)!==y.readInt(4)?null:c.utf8decode(y.readData(g.length-5))}return null}},i.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,i,r){function a(y,_,v){this.name=y,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=_,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"),u=n("./stream/GenericWorker");a.prototype={internalStream:function(y){var _=null,v="string";try{if(!y)throw new Error("No output type specified.");var x=(v=y.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),_=this._decompressWorker();var M=!this._dataBinary;M&&!x&&(_=_.pipe(new l.Utf8EncodeWorker)),!M&&x&&(_=_.pipe(new l.Utf8DecodeWorker))}catch(w){(_=new u("error")).error(w)}return new s(_,v,"")},async:function(y,_){return this.internalStream(y).accumulate(_)},nodeStream:function(y,_){return this.internalStream(y||"nodebuffer").toNodejsStream(_)},_compressWorker:function(y,_){if(this._data instanceof c&&this._data.compression.magic===y.magic)return this._data.getCompressedWorker();var v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(v,y,_)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new o(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},g=0;g<f.length;g++)a.prototype[f[g]]=m;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,u=new l(y),f=a.document.createTextNode("");u.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 _=a.document.createElement("script");_.onreadystatechange=function(){y(),_.onreadystatechange=null,_.parentNode.removeChild(_),_=null},a.document.documentElement.appendChild(_)}:function(){setTimeout(y,0)};else{var m=new a.MessageChannel;m.port1.onmessage=y,s=function(){m.port2.postMessage(0)}}var g=[];function y(){var _,v;o=!0;for(var x=g.length;x;){for(v=g,g=[],_=-1;++_<x;)v[_]();x=g.length}o=!1}i.exports=function(_){g.push(_)!==1||o||s()}}).call(this,typeof Ry<"u"?Ry: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"],u=["PENDING"];function f(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,x!==s&&_(this,x)}function m(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 g(x,M,w){a(function(){var C;try{C=M(w)}catch(T){return o.reject(x,T)}C===x?o.reject(x,new TypeError("Cannot resolve promise with itself")):o.resolve(x,C)})}function y(x){var M=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof M=="function")return function(){M.apply(x,arguments)}}function _(x,M){var w=!1;function C(A){w||(w=!0,o.reject(x,A))}function T(A){w||(w=!0,o.resolve(x,A))}var P=v(function(){M(T,C)});P.status==="error"&&C(P.value)}function v(x,M){var w={};try{w.value=x(M),w.status="success"}catch(C){w.status="error",w.value=C}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!==u?g(w,this.state===c?x:M,this.outcome):this.queue.push(new m(w,x,M)),w},m.prototype.callFulfilled=function(x){o.resolve(this.promise,x)},m.prototype.otherCallFulfilled=function(x){g(this.promise,this.onFulfilled,x)},m.prototype.callRejected=function(x){o.reject(this.promise,x)},m.prototype.otherCallRejected=function(x){g(this.promise,this.onRejected,x)},o.resolve=function(x,M){var w=v(y,M);if(w.status==="error")return o.reject(x,w.value);var C=w.value;if(C)_(x,C);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,C=x.queue.length;++w<C;)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,C=!1;if(!w)return this.resolve([]);for(var T=new Array(w),P=0,A=-1,j=new this(s);++A<w;)N(x[A],A);return j;function N(k,F){M.resolve(k).then(function(I){T[F]=I,++P!==w||C||(C=!0,o.resolve(j,T))},function(I){C||(C=!0,o.reject(j,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,C=!1;if(!w)return this.resolve([]);for(var T=-1,P=new this(s);++T<w;)A=x[T],M.resolve(A).then(function(j){C||(C=!0,o.resolve(P,j))},function(j){C||(C=!0,o.reject(P,j))});var A;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"),u=Object.prototype.toString,f=0,m=-1,g=0,y=8;function _(x){if(!(this instanceof _))return new _(x);this.options=s.assign({level:m,method:y,chunkSize:16384,windowBits:15,memLevel:8,strategy:g,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 C;if(C=typeof M.dictionary=="string"?o.string2buf(M.dictionary):u.call(M.dictionary)==="[object ArrayBuffer]"?new Uint8Array(M.dictionary):M.dictionary,(w=a.deflateSetDictionary(this.strm,C))!==f)throw new Error(l[w]);this._dict_set=!0}}function v(x,M){var w=new _(M);if(w.push(x,!0),w.err)throw w.msg||l[w.err];return w.result}_.prototype.push=function(x,M){var w,C,T=this.strm,P=this.options.chunkSize;if(this.ended)return!1;C=M===~~M?M:M===!0?4:0,typeof x=="string"?T.input=o.string2buf(x):u.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,C))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);T.avail_out!==0&&(T.avail_in!==0||C!==4&&C!==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 C===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):C!==2||(this.onEnd(f),!(T.avail_out=0))},_.prototype.onData=function(x){this.chunks.push(x)},_.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=_,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"),u=n("./zlib/zstream"),f=n("./zlib/gzheader"),m=Object.prototype.toString;function g(_){if(!(this instanceof g))return new g(_);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},_||{});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)||_&&_.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 u,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 y(_,v){var x=new g(v);if(x.push(_,!0),x.err)throw x.msg||c[x.err];return x.result}g.prototype.push=function(_,v){var x,M,w,C,T,P,A=this.strm,j=this.options.chunkSize,N=this.options.dictionary,k=!1;if(this.ended)return!1;M=v===~~v?v:v===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof _=="string"?A.input=o.binstring2buf(_):m.call(_)==="[object ArrayBuffer]"?A.input=new Uint8Array(_):A.input=_,A.next_in=0,A.avail_in=A.input.length;do{if(A.avail_out===0&&(A.output=new s.Buf8(j),A.next_out=0,A.avail_out=j),(x=a.inflate(A,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&N&&(P=typeof N=="string"?o.string2buf(N):m.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,x=a.inflateSetDictionary(this.strm,P)),x===l.Z_BUF_ERROR&&k===!0&&(x=l.Z_OK,k=!1),x!==l.Z_STREAM_END&&x!==l.Z_OK)return this.onEnd(x),!(this.ended=!0);A.next_out&&(A.avail_out!==0&&x!==l.Z_STREAM_END&&(A.avail_in!==0||M!==l.Z_FINISH&&M!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=o.utf8border(A.output,A.next_out),C=A.next_out-w,T=o.buf2string(A.output,w),A.next_out=C,A.avail_out=j-C,C&&s.arraySet(A.output,A.output,w,C,0),this.onData(T)):this.onData(s.shrinkBuf(A.output,A.next_out)))),A.avail_in===0&&A.avail_out===0&&(k=!0)}while((0<A.avail_in||A.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),!(A.avail_out=0))},g.prototype.onData=function(_){this.chunks.push(_)},g.prototype.onEnd=function(_){_===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=_,this.msg=this.strm.msg},r.Inflate=g,r.inflate=y,r.inflateRaw=function(_,v){return(v=v||{}).raw=!0,y(_,v)},r.ungzip=y},{"./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 u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var f in u)u.hasOwnProperty(f)&&(l[f]=u[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,u,f,m){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+f),m);else for(var g=0;g<f;g++)l[m+g]=c[u+g]},flattenChunks:function(l){var c,u,f,m,g,y;for(c=f=0,u=l.length;c<u;c++)f+=l[c].length;for(y=new Uint8Array(f),c=m=0,u=l.length;c<u;c++)g=l[c],y.set(g,m),m+=g.length;return y}},o={arraySet:function(l,c,u,f,m){for(var g=0;g<f;g++)l[m+g]=c[u+g]},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 u(f,m){if(m<65537&&(f.subarray&&o||!f.subarray&&s))return String.fromCharCode.apply(null,a.shrinkBuf(f,m));for(var g="",y=0;y<m;y++)g+=String.fromCharCode(f[y]);return g}l[254]=l[254]=1,r.string2buf=function(f){var m,g,y,_,v,x=f.length,M=0;for(_=0;_<x;_++)(64512&(g=f.charCodeAt(_)))==55296&&_+1<x&&(64512&(y=f.charCodeAt(_+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),_++),M+=g<128?1:g<2048?2:g<65536?3:4;for(m=new a.Buf8(M),_=v=0;v<M;_++)(64512&(g=f.charCodeAt(_)))==55296&&_+1<x&&(64512&(y=f.charCodeAt(_+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),_++),g<128?m[v++]=g:(g<2048?m[v++]=192|g>>>6:(g<65536?m[v++]=224|g>>>12:(m[v++]=240|g>>>18,m[v++]=128|g>>>12&63),m[v++]=128|g>>>6&63),m[v++]=128|63&g);return m},r.buf2binstring=function(f){return u(f,f.length)},r.binstring2buf=function(f){for(var m=new a.Buf8(f.length),g=0,y=m.length;g<y;g++)m[g]=f.charCodeAt(g);return m},r.buf2string=function(f,m){var g,y,_,v,x=m||f.length,M=new Array(2*x);for(g=y=0;g<x;)if((_=f[g++])<128)M[y++]=_;else if(4<(v=l[_]))M[y++]=65533,g+=v-1;else{for(_&=v===2?31:v===3?15:7;1<v&&g<x;)_=_<<6|63&f[g++],v--;1<v?M[y++]=65533:_<65536?M[y++]=_:(_-=65536,M[y++]=55296|_>>10&1023,M[y++]=56320|1023&_)}return u(M,y)},r.utf8border=function(f,m){var g;for((m=m||f.length)>f.length&&(m=f.length),g=m-1;0<=g&&(192&f[g])==128;)g--;return g<0||g===0?m:g+l[f[g]]>m?g:m}},{"./common":41}],43:[function(n,i,r){i.exports=function(a,s,o,l){for(var c=65535&a|0,u=a>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3<o?2e3:o;u=u+(c=c+s[l++]|0)|0,--f;);c%=65521,u%=65521}return c|u<<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 u=a,f=c+l;s^=-1;for(var m=c;m<f;m++)s=s>>>8^u[255&(s^o[m])];return-1^s}},{}],46:[function(n,i,r){var a,s=n("../utils/common"),o=n("./trees"),l=n("./adler32"),c=n("./crc32"),u=n("./messages"),f=0,m=4,g=0,y=-2,_=-1,v=4,x=2,M=8,w=9,C=286,T=30,P=19,A=2*C+1,j=15,N=3,k=258,F=k+N+1,I=42,W=113,D=1,B=2,$=3,K=4;function X(H,q){return H.msg=u[q],q}function Y(H){return(H<<1)-(4<H?9:0)}function ee(H){for(var q=H.length;0<=--q;)H[q]=0}function z(H){var q=H.state,oe=q.pending;oe>H.avail_out&&(oe=H.avail_out),oe!==0&&(s.arraySet(H.output,q.pending_buf,q.pending_out,oe,H.next_out),H.next_out+=oe,q.pending_out+=oe,H.total_out+=oe,H.avail_out-=oe,q.pending-=oe,q.pending===0&&(q.pending_out=0))}function V(H,q){o._tr_flush_block(H,0<=H.block_start?H.block_start:-1,H.strstart-H.block_start,q),H.block_start=H.strstart,z(H.strm)}function re(H,q){H.pending_buf[H.pending++]=q}function le(H,q){H.pending_buf[H.pending++]=q>>>8&255,H.pending_buf[H.pending++]=255&q}function ge(H,q){var oe,Z,Q=H.max_chain_length,se=H.strstart,Ce=H.prev_length,Ee=H.nice_match,ne=H.strstart>H.w_size-F?H.strstart-(H.w_size-F):0,U=H.window,L=H.w_mask,J=H.prev,me=H.strstart+k,ye=U[se+Ce-1],pe=U[se+Ce];H.prev_length>=H.good_match&&(Q>>=2),Ee>H.lookahead&&(Ee=H.lookahead);do if(U[(oe=q)+Ce]===pe&&U[oe+Ce-1]===ye&&U[oe]===U[se]&&U[++oe]===U[se+1]){se+=2,oe++;do;while(U[++se]===U[++oe]&&U[++se]===U[++oe]&&U[++se]===U[++oe]&&U[++se]===U[++oe]&&U[++se]===U[++oe]&&U[++se]===U[++oe]&&U[++se]===U[++oe]&&U[++se]===U[++oe]&&se<me);if(Z=k-(me-se),se=me-k,Ce<Z){if(H.match_start=q,Ee<=(Ce=Z))break;ye=U[se+Ce-1],pe=U[se+Ce]}}while((q=J[q&L])>ne&&--Q!=0);return Ce<=H.lookahead?Ce:H.lookahead}function ie(H){var q,oe,Z,Q,se,Ce,Ee,ne,U,L,J=H.w_size;do{if(Q=H.window_size-H.lookahead-H.strstart,H.strstart>=J+(J-F)){for(s.arraySet(H.window,H.window,J,J,0),H.match_start-=J,H.strstart-=J,H.block_start-=J,q=oe=H.hash_size;Z=H.head[--q],H.head[q]=J<=Z?Z-J:0,--oe;);for(q=oe=J;Z=H.prev[--q],H.prev[q]=J<=Z?Z-J:0,--oe;);Q+=J}if(H.strm.avail_in===0)break;if(Ce=H.strm,Ee=H.window,ne=H.strstart+H.lookahead,U=Q,L=void 0,L=Ce.avail_in,U<L&&(L=U),oe=L===0?0:(Ce.avail_in-=L,s.arraySet(Ee,Ce.input,Ce.next_in,L,ne),Ce.state.wrap===1?Ce.adler=l(Ce.adler,Ee,L,ne):Ce.state.wrap===2&&(Ce.adler=c(Ce.adler,Ee,L,ne)),Ce.next_in+=L,Ce.total_in+=L,L),H.lookahead+=oe,H.lookahead+H.insert>=N)for(se=H.strstart-H.insert,H.ins_h=H.window[se],H.ins_h=(H.ins_h<<H.hash_shift^H.window[se+1])&H.hash_mask;H.insert&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[se+N-1])&H.hash_mask,H.prev[se&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=se,se++,H.insert--,!(H.lookahead+H.insert<N)););}while(H.lookahead<F&&H.strm.avail_in!==0)}function xe(H,q){for(var oe,Z;;){if(H.lookahead<F){if(ie(H),H.lookahead<F&&q===f)return D;if(H.lookahead===0)break}if(oe=0,H.lookahead>=N&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+N-1])&H.hash_mask,oe=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),oe!==0&&H.strstart-oe<=H.w_size-F&&(H.match_length=ge(H,oe)),H.match_length>=N)if(Z=o._tr_tally(H,H.strstart-H.match_start,H.match_length-N),H.lookahead-=H.match_length,H.match_length<=H.max_lazy_match&&H.lookahead>=N){for(H.match_length--;H.strstart++,H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+N-1])&H.hash_mask,oe=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart,--H.match_length!=0;);H.strstart++}else H.strstart+=H.match_length,H.match_length=0,H.ins_h=H.window[H.strstart],H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+1])&H.hash_mask;else Z=o._tr_tally(H,0,H.window[H.strstart]),H.lookahead--,H.strstart++;if(Z&&(V(H,!1),H.strm.avail_out===0))return D}return H.insert=H.strstart<N-1?H.strstart:N-1,q===m?(V(H,!0),H.strm.avail_out===0?$:K):H.last_lit&&(V(H,!1),H.strm.avail_out===0)?D:B}function ke(H,q){for(var oe,Z,Q;;){if(H.lookahead<F){if(ie(H),H.lookahead<F&&q===f)return D;if(H.lookahead===0)break}if(oe=0,H.lookahead>=N&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+N-1])&H.hash_mask,oe=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),H.prev_length=H.match_length,H.prev_match=H.match_start,H.match_length=N-1,oe!==0&&H.prev_length<H.max_lazy_match&&H.strstart-oe<=H.w_size-F&&(H.match_length=ge(H,oe),H.match_length<=5&&(H.strategy===1||H.match_length===N&&4096<H.strstart-H.match_start)&&(H.match_length=N-1)),H.prev_length>=N&&H.match_length<=H.prev_length){for(Q=H.strstart+H.lookahead-N,Z=o._tr_tally(H,H.strstart-1-H.prev_match,H.prev_length-N),H.lookahead-=H.prev_length-1,H.prev_length-=2;++H.strstart<=Q&&(H.ins_h=(H.ins_h<<H.hash_shift^H.window[H.strstart+N-1])&H.hash_mask,oe=H.prev[H.strstart&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=H.strstart),--H.prev_length!=0;);if(H.match_available=0,H.match_length=N-1,H.strstart++,Z&&(V(H,!1),H.strm.avail_out===0))return D}else if(H.match_available){if((Z=o._tr_tally(H,0,H.window[H.strstart-1]))&&V(H,!1),H.strstart++,H.lookahead--,H.strm.avail_out===0)return D}else H.match_available=1,H.strstart++,H.lookahead--}return H.match_available&&(Z=o._tr_tally(H,0,H.window[H.strstart-1]),H.match_available=0),H.insert=H.strstart<N-1?H.strstart:N-1,q===m?(V(H,!0),H.strm.avail_out===0?$:K):H.last_lit&&(V(H,!1),H.strm.avail_out===0)?D:B}function he(H,q,oe,Z,Q){this.good_length=H,this.max_lazy=q,this.nice_length=oe,this.max_chain=Z,this.func=Q}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*A),this.dyn_dtree=new s.Buf16(2*(2*T+1)),this.bl_tree=new s.Buf16(2*(2*P+1)),ee(this.dyn_ltree),ee(this.dyn_dtree),ee(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(j+1),this.heap=new s.Buf16(2*C+1),ee(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*C+1),ee(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 Ue(H){var q;return H&&H.state?(H.total_in=H.total_out=0,H.data_type=x,(q=H.state).pending=0,q.pending_out=0,q.wrap<0&&(q.wrap=-q.wrap),q.status=q.wrap?I:W,H.adler=q.wrap===2?0:1,q.last_flush=f,o._tr_init(q),g):X(H,y)}function ue(H){var q=Ue(H);return q===g&&(function(oe){oe.window_size=2*oe.w_size,ee(oe.head),oe.max_lazy_match=a[oe.level].max_lazy,oe.good_match=a[oe.level].good_length,oe.nice_match=a[oe.level].nice_length,oe.max_chain_length=a[oe.level].max_chain,oe.strstart=0,oe.block_start=0,oe.lookahead=0,oe.insert=0,oe.match_length=oe.prev_length=N-1,oe.match_available=0,oe.ins_h=0})(H.state),q}function lt(H,q,oe,Z,Q,se){if(!H)return y;var Ce=1;if(q===_&&(q=6),Z<0?(Ce=0,Z=-Z):15<Z&&(Ce=2,Z-=16),Q<1||w<Q||oe!==M||Z<8||15<Z||q<0||9<q||se<0||v<se)return X(H,y);Z===8&&(Z=9);var Ee=new we;return(H.state=Ee).strm=H,Ee.wrap=Ce,Ee.gzhead=null,Ee.w_bits=Z,Ee.w_size=1<<Ee.w_bits,Ee.w_mask=Ee.w_size-1,Ee.hash_bits=Q+7,Ee.hash_size=1<<Ee.hash_bits,Ee.hash_mask=Ee.hash_size-1,Ee.hash_shift=~~((Ee.hash_bits+N-1)/N),Ee.window=new s.Buf8(2*Ee.w_size),Ee.head=new s.Buf16(Ee.hash_size),Ee.prev=new s.Buf16(Ee.w_size),Ee.lit_bufsize=1<<Q+6,Ee.pending_buf_size=4*Ee.lit_bufsize,Ee.pending_buf=new s.Buf8(Ee.pending_buf_size),Ee.d_buf=1*Ee.lit_bufsize,Ee.l_buf=3*Ee.lit_bufsize,Ee.level=q,Ee.strategy=se,Ee.method=oe,ue(H)}a=[new he(0,0,0,0,function(H,q){var oe=65535;for(oe>H.pending_buf_size-5&&(oe=H.pending_buf_size-5);;){if(H.lookahead<=1){if(ie(H),H.lookahead===0&&q===f)return D;if(H.lookahead===0)break}H.strstart+=H.lookahead,H.lookahead=0;var Z=H.block_start+oe;if((H.strstart===0||H.strstart>=Z)&&(H.lookahead=H.strstart-Z,H.strstart=Z,V(H,!1),H.strm.avail_out===0)||H.strstart-H.block_start>=H.w_size-F&&(V(H,!1),H.strm.avail_out===0))return D}return H.insert=0,q===m?(V(H,!0),H.strm.avail_out===0?$:K):(H.strstart>H.block_start&&(V(H,!1),H.strm.avail_out),D)}),new he(4,4,8,4,xe),new he(4,5,16,8,xe),new he(4,6,32,32,xe),new he(4,4,16,16,ke),new he(8,16,32,32,ke),new he(8,16,128,128,ke),new he(8,32,128,256,ke),new he(32,128,258,1024,ke),new he(32,258,258,4096,ke)],r.deflateInit=function(H,q){return lt(H,q,M,15,8,0)},r.deflateInit2=lt,r.deflateReset=ue,r.deflateResetKeep=Ue,r.deflateSetHeader=function(H,q){return H&&H.state?H.state.wrap!==2?y:(H.state.gzhead=q,g):y},r.deflate=function(H,q){var oe,Z,Q,se;if(!H||!H.state||5<q||q<0)return H?X(H,y):y;if(Z=H.state,!H.output||!H.input&&H.avail_in!==0||Z.status===666&&q!==m)return X(H,H.avail_out===0?-5:y);if(Z.strm=H,oe=Z.last_flush,Z.last_flush=q,Z.status===I)if(Z.wrap===2)H.adler=0,re(Z,31),re(Z,139),re(Z,8),Z.gzhead?(re(Z,(Z.gzhead.text?1:0)+(Z.gzhead.hcrc?2:0)+(Z.gzhead.extra?4:0)+(Z.gzhead.name?8:0)+(Z.gzhead.comment?16:0)),re(Z,255&Z.gzhead.time),re(Z,Z.gzhead.time>>8&255),re(Z,Z.gzhead.time>>16&255),re(Z,Z.gzhead.time>>24&255),re(Z,Z.level===9?2:2<=Z.strategy||Z.level<2?4:0),re(Z,255&Z.gzhead.os),Z.gzhead.extra&&Z.gzhead.extra.length&&(re(Z,255&Z.gzhead.extra.length),re(Z,Z.gzhead.extra.length>>8&255)),Z.gzhead.hcrc&&(H.adler=c(H.adler,Z.pending_buf,Z.pending,0)),Z.gzindex=0,Z.status=69):(re(Z,0),re(Z,0),re(Z,0),re(Z,0),re(Z,0),re(Z,Z.level===9?2:2<=Z.strategy||Z.level<2?4:0),re(Z,3),Z.status=W);else{var Ce=M+(Z.w_bits-8<<4)<<8;Ce|=(2<=Z.strategy||Z.level<2?0:Z.level<6?1:Z.level===6?2:3)<<6,Z.strstart!==0&&(Ce|=32),Ce+=31-Ce%31,Z.status=W,le(Z,Ce),Z.strstart!==0&&(le(Z,H.adler>>>16),le(Z,65535&H.adler)),H.adler=1}if(Z.status===69)if(Z.gzhead.extra){for(Q=Z.pending;Z.gzindex<(65535&Z.gzhead.extra.length)&&(Z.pending!==Z.pending_buf_size||(Z.gzhead.hcrc&&Z.pending>Q&&(H.adler=c(H.adler,Z.pending_buf,Z.pending-Q,Q)),z(H),Q=Z.pending,Z.pending!==Z.pending_buf_size));)re(Z,255&Z.gzhead.extra[Z.gzindex]),Z.gzindex++;Z.gzhead.hcrc&&Z.pending>Q&&(H.adler=c(H.adler,Z.pending_buf,Z.pending-Q,Q)),Z.gzindex===Z.gzhead.extra.length&&(Z.gzindex=0,Z.status=73)}else Z.status=73;if(Z.status===73)if(Z.gzhead.name){Q=Z.pending;do{if(Z.pending===Z.pending_buf_size&&(Z.gzhead.hcrc&&Z.pending>Q&&(H.adler=c(H.adler,Z.pending_buf,Z.pending-Q,Q)),z(H),Q=Z.pending,Z.pending===Z.pending_buf_size)){se=1;break}se=Z.gzindex<Z.gzhead.name.length?255&Z.gzhead.name.charCodeAt(Z.gzindex++):0,re(Z,se)}while(se!==0);Z.gzhead.hcrc&&Z.pending>Q&&(H.adler=c(H.adler,Z.pending_buf,Z.pending-Q,Q)),se===0&&(Z.gzindex=0,Z.status=91)}else Z.status=91;if(Z.status===91)if(Z.gzhead.comment){Q=Z.pending;do{if(Z.pending===Z.pending_buf_size&&(Z.gzhead.hcrc&&Z.pending>Q&&(H.adler=c(H.adler,Z.pending_buf,Z.pending-Q,Q)),z(H),Q=Z.pending,Z.pending===Z.pending_buf_size)){se=1;break}se=Z.gzindex<Z.gzhead.comment.length?255&Z.gzhead.comment.charCodeAt(Z.gzindex++):0,re(Z,se)}while(se!==0);Z.gzhead.hcrc&&Z.pending>Q&&(H.adler=c(H.adler,Z.pending_buf,Z.pending-Q,Q)),se===0&&(Z.status=103)}else Z.status=103;if(Z.status===103&&(Z.gzhead.hcrc?(Z.pending+2>Z.pending_buf_size&&z(H),Z.pending+2<=Z.pending_buf_size&&(re(Z,255&H.adler),re(Z,H.adler>>8&255),H.adler=0,Z.status=W)):Z.status=W),Z.pending!==0){if(z(H),H.avail_out===0)return Z.last_flush=-1,g}else if(H.avail_in===0&&Y(q)<=Y(oe)&&q!==m)return X(H,-5);if(Z.status===666&&H.avail_in!==0)return X(H,-5);if(H.avail_in!==0||Z.lookahead!==0||q!==f&&Z.status!==666){var Ee=Z.strategy===2?(function(ne,U){for(var L;;){if(ne.lookahead===0&&(ie(ne),ne.lookahead===0)){if(U===f)return D;break}if(ne.match_length=0,L=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++,L&&(V(ne,!1),ne.strm.avail_out===0))return D}return ne.insert=0,U===m?(V(ne,!0),ne.strm.avail_out===0?$:K):ne.last_lit&&(V(ne,!1),ne.strm.avail_out===0)?D:B})(Z,q):Z.strategy===3?(function(ne,U){for(var L,J,me,ye,pe=ne.window;;){if(ne.lookahead<=k){if(ie(ne),ne.lookahead<=k&&U===f)return D;if(ne.lookahead===0)break}if(ne.match_length=0,ne.lookahead>=N&&0<ne.strstart&&(J=pe[me=ne.strstart-1])===pe[++me]&&J===pe[++me]&&J===pe[++me]){ye=ne.strstart+k;do;while(J===pe[++me]&&J===pe[++me]&&J===pe[++me]&&J===pe[++me]&&J===pe[++me]&&J===pe[++me]&&J===pe[++me]&&J===pe[++me]&&me<ye);ne.match_length=k-(ye-me),ne.match_length>ne.lookahead&&(ne.match_length=ne.lookahead)}if(ne.match_length>=N?(L=o._tr_tally(ne,1,ne.match_length-N),ne.lookahead-=ne.match_length,ne.strstart+=ne.match_length,ne.match_length=0):(L=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++),L&&(V(ne,!1),ne.strm.avail_out===0))return D}return ne.insert=0,U===m?(V(ne,!0),ne.strm.avail_out===0?$:K):ne.last_lit&&(V(ne,!1),ne.strm.avail_out===0)?D:B})(Z,q):a[Z.level].func(Z,q);if(Ee!==$&&Ee!==K||(Z.status=666),Ee===D||Ee===$)return H.avail_out===0&&(Z.last_flush=-1),g;if(Ee===B&&(q===1?o._tr_align(Z):q!==5&&(o._tr_stored_block(Z,0,0,!1),q===3&&(ee(Z.head),Z.lookahead===0&&(Z.strstart=0,Z.block_start=0,Z.insert=0))),z(H),H.avail_out===0))return Z.last_flush=-1,g}return q!==m?g:Z.wrap<=0?1:(Z.wrap===2?(re(Z,255&H.adler),re(Z,H.adler>>8&255),re(Z,H.adler>>16&255),re(Z,H.adler>>24&255),re(Z,255&H.total_in),re(Z,H.total_in>>8&255),re(Z,H.total_in>>16&255),re(Z,H.total_in>>24&255)):(le(Z,H.adler>>>16),le(Z,65535&H.adler)),z(H),0<Z.wrap&&(Z.wrap=-Z.wrap),Z.pending!==0?g:1)},r.deflateEnd=function(H){var q;return H&&H.state?(q=H.state.status)!==I&&q!==69&&q!==73&&q!==91&&q!==103&&q!==W&&q!==666?X(H,y):(H.state=null,q===W?X(H,-3):g):y},r.deflateSetDictionary=function(H,q){var oe,Z,Q,se,Ce,Ee,ne,U,L=q.length;if(!H||!H.state||(se=(oe=H.state).wrap)===2||se===1&&oe.status!==I||oe.lookahead)return y;for(se===1&&(H.adler=l(H.adler,q,L,0)),oe.wrap=0,L>=oe.w_size&&(se===0&&(ee(oe.head),oe.strstart=0,oe.block_start=0,oe.insert=0),U=new s.Buf8(oe.w_size),s.arraySet(U,q,L-oe.w_size,oe.w_size,0),q=U,L=oe.w_size),Ce=H.avail_in,Ee=H.next_in,ne=H.input,H.avail_in=L,H.next_in=0,H.input=q,ie(oe);oe.lookahead>=N;){for(Z=oe.strstart,Q=oe.lookahead-(N-1);oe.ins_h=(oe.ins_h<<oe.hash_shift^oe.window[Z+N-1])&oe.hash_mask,oe.prev[Z&oe.w_mask]=oe.head[oe.ins_h],oe.head[oe.ins_h]=Z,Z++,--Q;);oe.strstart=Z,oe.lookahead=N-1,ie(oe)}return oe.strstart+=oe.lookahead,oe.block_start=oe.strstart,oe.insert=oe.lookahead,oe.lookahead=0,oe.match_length=oe.prev_length=N-1,oe.match_available=0,H.next_in=Ee,H.input=ne,H.avail_in=Ce,oe.wrap=se,g},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,u,f,m,g,y,_,v,x,M,w,C,T,P,A,j,N,k,F,I,W,D,B;o=a.state,l=a.next_in,D=a.input,c=l+(a.avail_in-5),u=a.next_out,B=a.output,f=u-(s-a.avail_out),m=u+(a.avail_out-257),g=o.dmax,y=o.wsize,_=o.whave,v=o.wnext,x=o.window,M=o.hold,w=o.bits,C=o.lencode,T=o.distcode,P=(1<<o.lenbits)-1,A=(1<<o.distbits)-1;e:do{w<15&&(M+=D[l++]<<w,w+=8,M+=D[l++]<<w,w+=8),j=C[M&P];t:for(;;){if(M>>>=N=j>>>24,w-=N,(N=j>>>16&255)===0)B[u++]=65535&j;else{if(!(16&N)){if((64&N)==0){j=C[(65535&j)+(M&(1<<N)-1)];continue t}if(32&N){o.mode=12;break e}a.msg="invalid literal/length code",o.mode=30;break e}k=65535&j,(N&=15)&&(w<N&&(M+=D[l++]<<w,w+=8),k+=M&(1<<N)-1,M>>>=N,w-=N),w<15&&(M+=D[l++]<<w,w+=8,M+=D[l++]<<w,w+=8),j=T[M&A];n:for(;;){if(M>>>=N=j>>>24,w-=N,!(16&(N=j>>>16&255))){if((64&N)==0){j=T[(65535&j)+(M&(1<<N)-1)];continue n}a.msg="invalid distance code",o.mode=30;break e}if(F=65535&j,w<(N&=15)&&(M+=D[l++]<<w,(w+=8)<N&&(M+=D[l++]<<w,w+=8)),g<(F+=M&(1<<N)-1)){a.msg="invalid distance too far back",o.mode=30;break e}if(M>>>=N,w-=N,(N=u-f)<F){if(_<(N=F-N)&&o.sane){a.msg="invalid distance too far back",o.mode=30;break e}if(W=x,(I=0)===v){if(I+=y-N,N<k){for(k-=N;B[u++]=x[I++],--N;);I=u-F,W=B}}else if(v<N){if(I+=y+v-N,(N-=v)<k){for(k-=N;B[u++]=x[I++],--N;);if(I=0,v<k){for(k-=N=v;B[u++]=x[I++],--N;);I=u-F,W=B}}}else if(I+=v-N,N<k){for(k-=N;B[u++]=x[I++],--N;);I=u-F,W=B}for(;2<k;)B[u++]=W[I++],B[u++]=W[I++],B[u++]=W[I++],k-=3;k&&(B[u++]=W[I++],1<k&&(B[u++]=W[I++]))}else{for(I=u-F;B[u++]=B[I++],B[u++]=B[I++],B[u++]=B[I++],2<(k-=3););k&&(B[u++]=B[I++],1<k&&(B[u++]=B[I++]))}break}}break}}while(l<c&&u<m);l-=k=w>>3,M&=(1<<(w-=k<<3))-1,a.next_in=l,a.next_out=u,a.avail_in=l<c?c-l+5:5-(l-c),a.avail_out=u<m?m-u+257:257-(u-m),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"),u=1,f=2,m=0,g=-2,y=1,_=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 W;return I&&I.state?(W=I.state,I.total_in=I.total_out=W.total=0,I.msg="",W.wrap&&(I.adler=1&W.wrap),W.mode=y,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new a.Buf32(_),W.distcode=W.distdyn=new a.Buf32(v),W.sane=1,W.back=-1,m):g}function C(I){var W;return I&&I.state?((W=I.state).wsize=0,W.whave=0,W.wnext=0,w(I)):g}function T(I,W){var D,B;return I&&I.state?(B=I.state,W<0?(D=0,W=-W):(D=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?g:(B.window!==null&&B.wbits!==W&&(B.window=null),B.wrap=D,B.wbits=W,C(I))):g}function P(I,W){var D,B;return I?(B=new M,(I.state=B).window=null,(D=T(I,W))!==m&&(I.state=null),D):g}var A,j,N=!0;function k(I){if(N){var W;for(A=new a.Buf32(512),j=new a.Buf32(32),W=0;W<144;)I.lens[W++]=8;for(;W<256;)I.lens[W++]=9;for(;W<280;)I.lens[W++]=7;for(;W<288;)I.lens[W++]=8;for(c(u,I.lens,0,288,A,0,I.work,{bits:9}),W=0;W<32;)I.lens[W++]=5;c(f,I.lens,0,32,j,0,I.work,{bits:5}),N=!1}I.lencode=A,I.lenbits=9,I.distcode=j,I.distbits=5}function F(I,W,D,B){var $,K=I.state;return K.window===null&&(K.wsize=1<<K.wbits,K.wnext=0,K.whave=0,K.window=new a.Buf8(K.wsize)),B>=K.wsize?(a.arraySet(K.window,W,D-K.wsize,K.wsize,0),K.wnext=0,K.whave=K.wsize):(B<($=K.wsize-K.wnext)&&($=B),a.arraySet(K.window,W,D-B,$,K.wnext),(B-=$)?(a.arraySet(K.window,W,D-B,B,0),K.wnext=B,K.whave=K.wsize):(K.wnext+=$,K.wnext===K.wsize&&(K.wnext=0),K.whave<K.wsize&&(K.whave+=$))),0}r.inflateReset=C,r.inflateReset2=T,r.inflateResetKeep=w,r.inflateInit=function(I){return P(I,15)},r.inflateInit2=P,r.inflate=function(I,W){var D,B,$,K,X,Y,ee,z,V,re,le,ge,ie,xe,ke,he,we,Ue,ue,lt,H,q,oe,Z,Q=0,se=new a.Buf8(4),Ce=[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 g;(D=I.state).mode===12&&(D.mode=13),X=I.next_out,$=I.output,ee=I.avail_out,K=I.next_in,B=I.input,Y=I.avail_in,z=D.hold,V=D.bits,re=Y,le=ee,q=m;e:for(;;)switch(D.mode){case y:if(D.wrap===0){D.mode=13;break}for(;V<16;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(2&D.wrap&&z===35615){se[D.check=0]=255&z,se[1]=z>>>8&255,D.check=o(D.check,se,2,0),V=z=0,D.mode=2;break}if(D.flags=0,D.head&&(D.head.done=!1),!(1&D.wrap)||(((255&z)<<8)+(z>>8))%31){I.msg="incorrect header check",D.mode=30;break}if((15&z)!=8){I.msg="unknown compression method",D.mode=30;break}if(V-=4,H=8+(15&(z>>>=4)),D.wbits===0)D.wbits=H;else if(H>D.wbits){I.msg="invalid window size",D.mode=30;break}D.dmax=1<<H,I.adler=D.check=1,D.mode=512&z?10:12,V=z=0;break;case 2:for(;V<16;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(D.flags=z,(255&D.flags)!=8){I.msg="unknown compression method",D.mode=30;break}if(57344&D.flags){I.msg="unknown header flags set",D.mode=30;break}D.head&&(D.head.text=z>>8&1),512&D.flags&&(se[0]=255&z,se[1]=z>>>8&255,D.check=o(D.check,se,2,0)),V=z=0,D.mode=3;case 3:for(;V<32;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}D.head&&(D.head.time=z),512&D.flags&&(se[0]=255&z,se[1]=z>>>8&255,se[2]=z>>>16&255,se[3]=z>>>24&255,D.check=o(D.check,se,4,0)),V=z=0,D.mode=4;case 4:for(;V<16;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}D.head&&(D.head.xflags=255&z,D.head.os=z>>8),512&D.flags&&(se[0]=255&z,se[1]=z>>>8&255,D.check=o(D.check,se,2,0)),V=z=0,D.mode=5;case 5:if(1024&D.flags){for(;V<16;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}D.length=z,D.head&&(D.head.extra_len=z),512&D.flags&&(se[0]=255&z,se[1]=z>>>8&255,D.check=o(D.check,se,2,0)),V=z=0}else D.head&&(D.head.extra=null);D.mode=6;case 6:if(1024&D.flags&&(Y<(ge=D.length)&&(ge=Y),ge&&(D.head&&(H=D.head.extra_len-D.length,D.head.extra||(D.head.extra=new Array(D.head.extra_len)),a.arraySet(D.head.extra,B,K,ge,H)),512&D.flags&&(D.check=o(D.check,B,ge,K)),Y-=ge,K+=ge,D.length-=ge),D.length))break e;D.length=0,D.mode=7;case 7:if(2048&D.flags){if(Y===0)break e;for(ge=0;H=B[K+ge++],D.head&&H&&D.length<65536&&(D.head.name+=String.fromCharCode(H)),H&&ge<Y;);if(512&D.flags&&(D.check=o(D.check,B,ge,K)),Y-=ge,K+=ge,H)break e}else D.head&&(D.head.name=null);D.length=0,D.mode=8;case 8:if(4096&D.flags){if(Y===0)break e;for(ge=0;H=B[K+ge++],D.head&&H&&D.length<65536&&(D.head.comment+=String.fromCharCode(H)),H&&ge<Y;);if(512&D.flags&&(D.check=o(D.check,B,ge,K)),Y-=ge,K+=ge,H)break e}else D.head&&(D.head.comment=null);D.mode=9;case 9:if(512&D.flags){for(;V<16;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(z!==(65535&D.check)){I.msg="header crc mismatch",D.mode=30;break}V=z=0}D.head&&(D.head.hcrc=D.flags>>9&1,D.head.done=!0),I.adler=D.check=0,D.mode=12;break;case 10:for(;V<32;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}I.adler=D.check=x(z),V=z=0,D.mode=11;case 11:if(D.havedict===0)return I.next_out=X,I.avail_out=ee,I.next_in=K,I.avail_in=Y,D.hold=z,D.bits=V,2;I.adler=D.check=1,D.mode=12;case 12:if(W===5||W===6)break e;case 13:if(D.last){z>>>=7&V,V-=7&V,D.mode=27;break}for(;V<3;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}switch(D.last=1&z,V-=1,3&(z>>>=1)){case 0:D.mode=14;break;case 1:if(k(D),D.mode=20,W!==6)break;z>>>=2,V-=2;break e;case 2:D.mode=17;break;case 3:I.msg="invalid block type",D.mode=30}z>>>=2,V-=2;break;case 14:for(z>>>=7&V,V-=7&V;V<32;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if((65535&z)!=(z>>>16^65535)){I.msg="invalid stored block lengths",D.mode=30;break}if(D.length=65535&z,V=z=0,D.mode=15,W===6)break e;case 15:D.mode=16;case 16:if(ge=D.length){if(Y<ge&&(ge=Y),ee<ge&&(ge=ee),ge===0)break e;a.arraySet($,B,K,ge,X),Y-=ge,K+=ge,ee-=ge,X+=ge,D.length-=ge;break}D.mode=12;break;case 17:for(;V<14;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(D.nlen=257+(31&z),z>>>=5,V-=5,D.ndist=1+(31&z),z>>>=5,V-=5,D.ncode=4+(15&z),z>>>=4,V-=4,286<D.nlen||30<D.ndist){I.msg="too many length or distance symbols",D.mode=30;break}D.have=0,D.mode=18;case 18:for(;D.have<D.ncode;){for(;V<3;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}D.lens[Ce[D.have++]]=7&z,z>>>=3,V-=3}for(;D.have<19;)D.lens[Ce[D.have++]]=0;if(D.lencode=D.lendyn,D.lenbits=7,oe={bits:D.lenbits},q=c(0,D.lens,0,19,D.lencode,0,D.work,oe),D.lenbits=oe.bits,q){I.msg="invalid code lengths set",D.mode=30;break}D.have=0,D.mode=19;case 19:for(;D.have<D.nlen+D.ndist;){for(;he=(Q=D.lencode[z&(1<<D.lenbits)-1])>>>16&255,we=65535&Q,!((ke=Q>>>24)<=V);){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(we<16)z>>>=ke,V-=ke,D.lens[D.have++]=we;else{if(we===16){for(Z=ke+2;V<Z;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(z>>>=ke,V-=ke,D.have===0){I.msg="invalid bit length repeat",D.mode=30;break}H=D.lens[D.have-1],ge=3+(3&z),z>>>=2,V-=2}else if(we===17){for(Z=ke+3;V<Z;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}V-=ke,H=0,ge=3+(7&(z>>>=ke)),z>>>=3,V-=3}else{for(Z=ke+7;V<Z;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}V-=ke,H=0,ge=11+(127&(z>>>=ke)),z>>>=7,V-=7}if(D.have+ge>D.nlen+D.ndist){I.msg="invalid bit length repeat",D.mode=30;break}for(;ge--;)D.lens[D.have++]=H}}if(D.mode===30)break;if(D.lens[256]===0){I.msg="invalid code -- missing end-of-block",D.mode=30;break}if(D.lenbits=9,oe={bits:D.lenbits},q=c(u,D.lens,0,D.nlen,D.lencode,0,D.work,oe),D.lenbits=oe.bits,q){I.msg="invalid literal/lengths set",D.mode=30;break}if(D.distbits=6,D.distcode=D.distdyn,oe={bits:D.distbits},q=c(f,D.lens,D.nlen,D.ndist,D.distcode,0,D.work,oe),D.distbits=oe.bits,q){I.msg="invalid distances set",D.mode=30;break}if(D.mode=20,W===6)break e;case 20:D.mode=21;case 21:if(6<=Y&&258<=ee){I.next_out=X,I.avail_out=ee,I.next_in=K,I.avail_in=Y,D.hold=z,D.bits=V,l(I,le),X=I.next_out,$=I.output,ee=I.avail_out,K=I.next_in,B=I.input,Y=I.avail_in,z=D.hold,V=D.bits,D.mode===12&&(D.back=-1);break}for(D.back=0;he=(Q=D.lencode[z&(1<<D.lenbits)-1])>>>16&255,we=65535&Q,!((ke=Q>>>24)<=V);){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(he&&(240&he)==0){for(Ue=ke,ue=he,lt=we;he=(Q=D.lencode[lt+((z&(1<<Ue+ue)-1)>>Ue)])>>>16&255,we=65535&Q,!(Ue+(ke=Q>>>24)<=V);){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}z>>>=Ue,V-=Ue,D.back+=Ue}if(z>>>=ke,V-=ke,D.back+=ke,D.length=we,he===0){D.mode=26;break}if(32&he){D.back=-1,D.mode=12;break}if(64&he){I.msg="invalid literal/length code",D.mode=30;break}D.extra=15&he,D.mode=22;case 22:if(D.extra){for(Z=D.extra;V<Z;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}D.length+=z&(1<<D.extra)-1,z>>>=D.extra,V-=D.extra,D.back+=D.extra}D.was=D.length,D.mode=23;case 23:for(;he=(Q=D.distcode[z&(1<<D.distbits)-1])>>>16&255,we=65535&Q,!((ke=Q>>>24)<=V);){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if((240&he)==0){for(Ue=ke,ue=he,lt=we;he=(Q=D.distcode[lt+((z&(1<<Ue+ue)-1)>>Ue)])>>>16&255,we=65535&Q,!(Ue+(ke=Q>>>24)<=V);){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}z>>>=Ue,V-=Ue,D.back+=Ue}if(z>>>=ke,V-=ke,D.back+=ke,64&he){I.msg="invalid distance code",D.mode=30;break}D.offset=we,D.extra=15&he,D.mode=24;case 24:if(D.extra){for(Z=D.extra;V<Z;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}D.offset+=z&(1<<D.extra)-1,z>>>=D.extra,V-=D.extra,D.back+=D.extra}if(D.offset>D.dmax){I.msg="invalid distance too far back",D.mode=30;break}D.mode=25;case 25:if(ee===0)break e;if(ge=le-ee,D.offset>ge){if((ge=D.offset-ge)>D.whave&&D.sane){I.msg="invalid distance too far back",D.mode=30;break}ie=ge>D.wnext?(ge-=D.wnext,D.wsize-ge):D.wnext-ge,ge>D.length&&(ge=D.length),xe=D.window}else xe=$,ie=X-D.offset,ge=D.length;for(ee<ge&&(ge=ee),ee-=ge,D.length-=ge;$[X++]=xe[ie++],--ge;);D.length===0&&(D.mode=21);break;case 26:if(ee===0)break e;$[X++]=D.length,ee--,D.mode=21;break;case 27:if(D.wrap){for(;V<32;){if(Y===0)break e;Y--,z|=B[K++]<<V,V+=8}if(le-=ee,I.total_out+=le,D.total+=le,le&&(I.adler=D.check=D.flags?o(D.check,$,le,X-le):s(D.check,$,le,X-le)),le=ee,(D.flags?z:x(z))!==D.check){I.msg="incorrect data check",D.mode=30;break}V=z=0}D.mode=28;case 28:if(D.wrap&&D.flags){for(;V<32;){if(Y===0)break e;Y--,z+=B[K++]<<V,V+=8}if(z!==(4294967295&D.total)){I.msg="incorrect length check",D.mode=30;break}V=z=0}D.mode=29;case 29:q=1;break e;case 30:q=-3;break e;case 31:return-4;case 32:default:return g}return I.next_out=X,I.avail_out=ee,I.next_in=K,I.avail_in=Y,D.hold=z,D.bits=V,(D.wsize||le!==I.avail_out&&D.mode<30&&(D.mode<27||W!==4))&&F(I,I.output,I.next_out,le-I.avail_out)?(D.mode=31,-4):(re-=I.avail_in,le-=I.avail_out,I.total_in+=re,I.total_out+=le,D.total+=le,D.wrap&&le&&(I.adler=D.check=D.flags?o(D.check,$,le,I.next_out-le):s(D.check,$,le,I.next_out-le)),I.data_type=D.bits+(D.last?64:0)+(D.mode===12?128:0)+(D.mode===20||D.mode===15?256:0),(re==0&&le===0||W===4)&&q===m&&(q=-5),q)},r.inflateEnd=function(I){if(!I||!I.state)return g;var W=I.state;return W.window&&(W.window=null),I.state=null,m},r.inflateGetHeader=function(I,W){var D;return I&&I.state?(2&(D=I.state).wrap)==0?g:((D.head=W).done=!1,m):g},r.inflateSetDictionary=function(I,W){var D,B=W.length;return I&&I.state?(D=I.state).wrap!==0&&D.mode!==11?g:D.mode===11&&s(1,W,B,0)!==D.check?-3:F(I,W,B,B)?(D.mode=31,-4):(D.havedict=1,m):g},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(u,f,m,g,y,_,v,x){var M,w,C,T,P,A,j,N,k,F=x.bits,I=0,W=0,D=0,B=0,$=0,K=0,X=0,Y=0,ee=0,z=0,V=null,re=0,le=new a.Buf16(16),ge=new a.Buf16(16),ie=null,xe=0;for(I=0;I<=15;I++)le[I]=0;for(W=0;W<g;W++)le[f[m+W]]++;for($=F,B=15;1<=B&&le[B]===0;B--);if(B<$&&($=B),B===0)return y[_++]=20971520,y[_++]=20971520,x.bits=1,0;for(D=1;D<B&&le[D]===0;D++);for($<D&&($=D),I=Y=1;I<=15;I++)if(Y<<=1,(Y-=le[I])<0)return-1;if(0<Y&&(u===0||B!==1))return-1;for(ge[1]=0,I=1;I<15;I++)ge[I+1]=ge[I]+le[I];for(W=0;W<g;W++)f[m+W]!==0&&(v[ge[f[m+W]]++]=W);if(A=u===0?(V=ie=v,19):u===1?(V=s,re-=257,ie=o,xe-=257,256):(V=l,ie=c,-1),I=D,P=_,X=W=z=0,C=-1,T=(ee=1<<(K=$))-1,u===1&&852<ee||u===2&&592<ee)return 1;for(;;){for(j=I-X,k=v[W]<A?(N=0,v[W]):v[W]>A?(N=ie[xe+v[W]],V[re+v[W]]):(N=96,0),M=1<<I-X,D=w=1<<K;y[P+(z>>X)+(w-=M)]=j<<24|N<<16|k|0,w!==0;);for(M=1<<I-1;z&M;)M>>=1;if(M!==0?(z&=M-1,z+=M):z=0,W++,--le[I]==0){if(I===B)break;I=f[m+v[W]]}if($<I&&(z&T)!==C){for(X===0&&(X=$),P+=D,Y=1<<(K=I-X);K+X<B&&!((Y-=le[K+X])<=0);)K++,Y<<=1;if(ee+=1<<K,u===1&&852<ee||u===2&&592<ee)return 1;y[C=z&T]=$<<24|K<<16|P-_|0}}return z!==0&&(y[P+z]=I-X<<24|64<<16|0),x.bits=$,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(Q){for(var se=Q.length;0<=--se;)Q[se]=0}var c=0,u=29,f=256,m=f+1+u,g=30,y=19,_=2*m+1,v=15,x=16,M=7,w=256,C=16,T=17,P=18,A=[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],j=[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],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],F=new Array(2*(m+2));l(F);var I=new Array(2*g);l(I);var W=new Array(512);l(W);var D=new Array(256);l(D);var B=new Array(u);l(B);var $,K,X,Y=new Array(g);function ee(Q,se,Ce,Ee,ne){this.static_tree=Q,this.extra_bits=se,this.extra_base=Ce,this.elems=Ee,this.max_length=ne,this.has_stree=Q&&Q.length}function z(Q,se){this.dyn_tree=Q,this.max_code=0,this.stat_desc=se}function V(Q){return Q<256?W[Q]:W[256+(Q>>>7)]}function re(Q,se){Q.pending_buf[Q.pending++]=255&se,Q.pending_buf[Q.pending++]=se>>>8&255}function le(Q,se,Ce){Q.bi_valid>x-Ce?(Q.bi_buf|=se<<Q.bi_valid&65535,re(Q,Q.bi_buf),Q.bi_buf=se>>x-Q.bi_valid,Q.bi_valid+=Ce-x):(Q.bi_buf|=se<<Q.bi_valid&65535,Q.bi_valid+=Ce)}function ge(Q,se,Ce){le(Q,Ce[2*se],Ce[2*se+1])}function ie(Q,se){for(var Ce=0;Ce|=1&Q,Q>>>=1,Ce<<=1,0<--se;);return Ce>>>1}function xe(Q,se,Ce){var Ee,ne,U=new Array(v+1),L=0;for(Ee=1;Ee<=v;Ee++)U[Ee]=L=L+Ce[Ee-1]<<1;for(ne=0;ne<=se;ne++){var J=Q[2*ne+1];J!==0&&(Q[2*ne]=ie(U[J]++,J))}}function ke(Q){var se;for(se=0;se<m;se++)Q.dyn_ltree[2*se]=0;for(se=0;se<g;se++)Q.dyn_dtree[2*se]=0;for(se=0;se<y;se++)Q.bl_tree[2*se]=0;Q.dyn_ltree[2*w]=1,Q.opt_len=Q.static_len=0,Q.last_lit=Q.matches=0}function he(Q){8<Q.bi_valid?re(Q,Q.bi_buf):0<Q.bi_valid&&(Q.pending_buf[Q.pending++]=Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0}function we(Q,se,Ce,Ee){var ne=2*se,U=2*Ce;return Q[ne]<Q[U]||Q[ne]===Q[U]&&Ee[se]<=Ee[Ce]}function Ue(Q,se,Ce){for(var Ee=Q.heap[Ce],ne=Ce<<1;ne<=Q.heap_len&&(ne<Q.heap_len&&we(se,Q.heap[ne+1],Q.heap[ne],Q.depth)&&ne++,!we(se,Ee,Q.heap[ne],Q.depth));)Q.heap[Ce]=Q.heap[ne],Ce=ne,ne<<=1;Q.heap[Ce]=Ee}function ue(Q,se,Ce){var Ee,ne,U,L,J=0;if(Q.last_lit!==0)for(;Ee=Q.pending_buf[Q.d_buf+2*J]<<8|Q.pending_buf[Q.d_buf+2*J+1],ne=Q.pending_buf[Q.l_buf+J],J++,Ee===0?ge(Q,ne,se):(ge(Q,(U=D[ne])+f+1,se),(L=A[U])!==0&&le(Q,ne-=B[U],L),ge(Q,U=V(--Ee),Ce),(L=j[U])!==0&&le(Q,Ee-=Y[U],L)),J<Q.last_lit;);ge(Q,w,se)}function lt(Q,se){var Ce,Ee,ne,U=se.dyn_tree,L=se.stat_desc.static_tree,J=se.stat_desc.has_stree,me=se.stat_desc.elems,ye=-1;for(Q.heap_len=0,Q.heap_max=_,Ce=0;Ce<me;Ce++)U[2*Ce]!==0?(Q.heap[++Q.heap_len]=ye=Ce,Q.depth[Ce]=0):U[2*Ce+1]=0;for(;Q.heap_len<2;)U[2*(ne=Q.heap[++Q.heap_len]=ye<2?++ye:0)]=1,Q.depth[ne]=0,Q.opt_len--,J&&(Q.static_len-=L[2*ne+1]);for(se.max_code=ye,Ce=Q.heap_len>>1;1<=Ce;Ce--)Ue(Q,U,Ce);for(ne=me;Ce=Q.heap[1],Q.heap[1]=Q.heap[Q.heap_len--],Ue(Q,U,1),Ee=Q.heap[1],Q.heap[--Q.heap_max]=Ce,Q.heap[--Q.heap_max]=Ee,U[2*ne]=U[2*Ce]+U[2*Ee],Q.depth[ne]=(Q.depth[Ce]>=Q.depth[Ee]?Q.depth[Ce]:Q.depth[Ee])+1,U[2*Ce+1]=U[2*Ee+1]=ne,Q.heap[1]=ne++,Ue(Q,U,1),2<=Q.heap_len;);Q.heap[--Q.heap_max]=Q.heap[1],(function(pe,Qe){var Le,Xe,st,Ie,Pe,pt,it=Qe.dyn_tree,nt=Qe.max_code,dt=Qe.stat_desc.static_tree,de=Qe.stat_desc.has_stree,rt=Qe.stat_desc.extra_bits,fe=Qe.stat_desc.extra_base,Oe=Qe.stat_desc.max_length,Me=0;for(Ie=0;Ie<=v;Ie++)pe.bl_count[Ie]=0;for(it[2*pe.heap[pe.heap_max]+1]=0,Le=pe.heap_max+1;Le<_;Le++)Oe<(Ie=it[2*it[2*(Xe=pe.heap[Le])+1]+1]+1)&&(Ie=Oe,Me++),it[2*Xe+1]=Ie,nt<Xe||(pe.bl_count[Ie]++,Pe=0,fe<=Xe&&(Pe=rt[Xe-fe]),pt=it[2*Xe],pe.opt_len+=pt*(Ie+Pe),de&&(pe.static_len+=pt*(dt[2*Xe+1]+Pe)));if(Me!==0){do{for(Ie=Oe-1;pe.bl_count[Ie]===0;)Ie--;pe.bl_count[Ie]--,pe.bl_count[Ie+1]+=2,pe.bl_count[Oe]--,Me-=2}while(0<Me);for(Ie=Oe;Ie!==0;Ie--)for(Xe=pe.bl_count[Ie];Xe!==0;)nt<(st=pe.heap[--Le])||(it[2*st+1]!==Ie&&(pe.opt_len+=(Ie-it[2*st+1])*it[2*st],it[2*st+1]=Ie),Xe--)}})(Q,se),xe(U,ye,Q.bl_count)}function H(Q,se,Ce){var Ee,ne,U=-1,L=se[1],J=0,me=7,ye=4;for(L===0&&(me=138,ye=3),se[2*(Ce+1)+1]=65535,Ee=0;Ee<=Ce;Ee++)ne=L,L=se[2*(Ee+1)+1],++J<me&&ne===L||(J<ye?Q.bl_tree[2*ne]+=J:ne!==0?(ne!==U&&Q.bl_tree[2*ne]++,Q.bl_tree[2*C]++):J<=10?Q.bl_tree[2*T]++:Q.bl_tree[2*P]++,U=ne,ye=(J=0)===L?(me=138,3):ne===L?(me=6,3):(me=7,4))}function q(Q,se,Ce){var Ee,ne,U=-1,L=se[1],J=0,me=7,ye=4;for(L===0&&(me=138,ye=3),Ee=0;Ee<=Ce;Ee++)if(ne=L,L=se[2*(Ee+1)+1],!(++J<me&&ne===L)){if(J<ye)for(;ge(Q,ne,Q.bl_tree),--J!=0;);else ne!==0?(ne!==U&&(ge(Q,ne,Q.bl_tree),J--),ge(Q,C,Q.bl_tree),le(Q,J-3,2)):J<=10?(ge(Q,T,Q.bl_tree),le(Q,J-3,3)):(ge(Q,P,Q.bl_tree),le(Q,J-11,7));U=ne,ye=(J=0)===L?(me=138,3):ne===L?(me=6,3):(me=7,4)}}l(Y);var oe=!1;function Z(Q,se,Ce,Ee){le(Q,(c<<1)+(Ee?1:0),3),(function(ne,U,L,J){he(ne),re(ne,L),re(ne,~L),a.arraySet(ne.pending_buf,ne.window,U,L,ne.pending),ne.pending+=L})(Q,se,Ce)}r._tr_init=function(Q){oe||((function(){var se,Ce,Ee,ne,U,L=new Array(v+1);for(ne=Ee=0;ne<u-1;ne++)for(B[ne]=Ee,se=0;se<1<<A[ne];se++)D[Ee++]=ne;for(D[Ee-1]=ne,ne=U=0;ne<16;ne++)for(Y[ne]=U,se=0;se<1<<j[ne];se++)W[U++]=ne;for(U>>=7;ne<g;ne++)for(Y[ne]=U<<7,se=0;se<1<<j[ne]-7;se++)W[256+U++]=ne;for(Ce=0;Ce<=v;Ce++)L[Ce]=0;for(se=0;se<=143;)F[2*se+1]=8,se++,L[8]++;for(;se<=255;)F[2*se+1]=9,se++,L[9]++;for(;se<=279;)F[2*se+1]=7,se++,L[7]++;for(;se<=287;)F[2*se+1]=8,se++,L[8]++;for(xe(F,m+1,L),se=0;se<g;se++)I[2*se+1]=5,I[2*se]=ie(se,5);$=new ee(F,A,f+1,m,v),K=new ee(I,j,0,g,v),X=new ee(new Array(0),N,0,y,M)})(),oe=!0),Q.l_desc=new z(Q.dyn_ltree,$),Q.d_desc=new z(Q.dyn_dtree,K),Q.bl_desc=new z(Q.bl_tree,X),Q.bi_buf=0,Q.bi_valid=0,ke(Q)},r._tr_stored_block=Z,r._tr_flush_block=function(Q,se,Ce,Ee){var ne,U,L=0;0<Q.level?(Q.strm.data_type===2&&(Q.strm.data_type=(function(J){var me,ye=4093624447;for(me=0;me<=31;me++,ye>>>=1)if(1&ye&&J.dyn_ltree[2*me]!==0)return s;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return o;for(me=32;me<f;me++)if(J.dyn_ltree[2*me]!==0)return o;return s})(Q)),lt(Q,Q.l_desc),lt(Q,Q.d_desc),L=(function(J){var me;for(H(J,J.dyn_ltree,J.l_desc.max_code),H(J,J.dyn_dtree,J.d_desc.max_code),lt(J,J.bl_desc),me=y-1;3<=me&&J.bl_tree[2*k[me]+1]===0;me--);return J.opt_len+=3*(me+1)+5+5+4,me})(Q),ne=Q.opt_len+3+7>>>3,(U=Q.static_len+3+7>>>3)<=ne&&(ne=U)):ne=U=Ce+5,Ce+4<=ne&&se!==-1?Z(Q,se,Ce,Ee):Q.strategy===4||U===ne?(le(Q,2+(Ee?1:0),3),ue(Q,F,I)):(le(Q,4+(Ee?1:0),3),(function(J,me,ye,pe){var Qe;for(le(J,me-257,5),le(J,ye-1,5),le(J,pe-4,4),Qe=0;Qe<pe;Qe++)le(J,J.bl_tree[2*k[Qe]+1],3);q(J,J.dyn_ltree,me-1),q(J,J.dyn_dtree,ye-1)})(Q,Q.l_desc.max_code+1,Q.d_desc.max_code+1,L+1),ue(Q,Q.dyn_ltree,Q.dyn_dtree)),ke(Q),Ee&&he(Q)},r._tr_tally=function(Q,se,Ce){return Q.pending_buf[Q.d_buf+2*Q.last_lit]=se>>>8&255,Q.pending_buf[Q.d_buf+2*Q.last_lit+1]=255&se,Q.pending_buf[Q.l_buf+Q.last_lit]=255&Ce,Q.last_lit++,se===0?Q.dyn_ltree[2*Ce]++:(Q.matches++,se--,Q.dyn_ltree[2*(D[Ce]+f+1)]++,Q.dyn_dtree[2*V(se)]++),Q.last_lit===Q.lit_bufsize-1},r._tr_align=function(Q){le(Q,2,3),ge(Q,w,F),(function(se){se.bi_valid===16?(re(se,se.bi_buf),se.bi_buf=0,se.bi_valid=0):8<=se.bi_valid&&(se.pending_buf[se.pending++]=255&se.bi_buf,se.bi_buf>>=8,se.bi_valid-=8)})(Q)}},{"../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,u,f,m=1,g={},y=!1,_=s.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(s);v=v&&v.setTimeout?v:s,l={}.toString.call(s.process)==="[object process]"?function(C){process.nextTick(function(){M(C)})}:(function(){if(s.postMessage&&!s.importScripts){var C=!0,T=s.onmessage;return s.onmessage=function(){C=!1},s.postMessage("","*"),s.onmessage=T,C}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",w,!1):s.attachEvent("onmessage",w),function(C){s.postMessage(f+C,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(C){M(C.data)},function(C){u.port2.postMessage(C)}):_&&"onreadystatechange"in _.createElement("script")?(c=_.documentElement,function(C){var T=_.createElement("script");T.onreadystatechange=function(){M(C),T.onreadystatechange=null,c.removeChild(T),T=null},c.appendChild(T)}):function(C){setTimeout(M,0,C)},v.setImmediate=function(C){typeof C!="function"&&(C=new Function(""+C));for(var T=new Array(arguments.length-1),P=0;P<T.length;P++)T[P]=arguments[P+1];var A={callback:C,args:T};return g[m]=A,l(m),m++},v.clearImmediate=x}function x(C){delete g[C]}function M(C){if(y)setTimeout(M,0,C);else{var T=g[C];if(T){y=!0;try{(function(P){var A=P.callback,j=P.args;switch(j.length){case 0:A();break;case 1:A(j[0]);break;case 2:A(j[0],j[1]);break;case 3:A(j[0],j[1],j[2]);break;default:A.apply(o,j)}})(T)}finally{x(C),y=!1}}}}function w(C){C.source===s&&typeof C.data=="string"&&C.data.indexOf(f)===0&&M(+C.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Ry<"u"?Ry:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(mT)),mT.exports}var ige=nge();const rge=Ys(ige);function age(t){const e=new Xi;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 sz=age;async function oz(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 u=o[c];a.push(parseFloat(u.getAttribute("x")||"0"),parseFloat(u.getAttribute("y")||"0"),parseFloat(u.getAttribute("z")||"0"))}const l=r.getElementsByTagName("triangle");for(let c=0;c<l.length;c++){const u=l[c];s.push(parseInt(u.getAttribute("v1")||"0"),parseInt(u.getAttribute("v2")||"0"),parseInt(u.getAttribute("v3")||"0"))}a.length>0&&s.length>0&&e.push({vertices:a,triangles:s})}return e}async function sge(t){const e=await rge.loadAsync(t),n=new Map,i=[],r=new DOMParser;async function a(u){const f=u.startsWith("/")?u.slice(1):u,m=e.files[f];if(!m)return null;const g=await m.async("string");return r.parseFromString(g,"application/xml")}const s=Object.keys(e.files).find(u=>u==="3D/3dmodel.model"||u.endsWith("/3dmodel.model"));if(!s){const u=Object.keys(e.files).find(f=>f.endsWith(".model"));if(u){const f=await a(u);if(f){const m=await oz(f);m.length>0&&n.set("1",{id:"1",meshes:m})}}return{objects:n,buildItems:i}}const o=await a(s);if(!o)return{objects:n,buildItems:i};const l=o.getElementsByTagName("object");for(let u=0;u<l.length;u++){const f=l[u],m=f.getAttribute("id");if(!m)continue;const g=[],y=f.getElementsByTagName("mesh");for(let v=0;v<y.length;v++){const x=y[v],M=[],w=[],C=x.getElementsByTagName("vertex");for(let P=0;P<C.length;P++){const A=C[P];M.push(parseFloat(A.getAttribute("x")||"0"),parseFloat(A.getAttribute("y")||"0"),parseFloat(A.getAttribute("z")||"0"))}const T=x.getElementsByTagName("triangle");for(let P=0;P<T.length;P++){const A=T[P];w.push(parseInt(A.getAttribute("v1")||"0"),parseInt(A.getAttribute("v2")||"0"),parseInt(A.getAttribute("v3")||"0"))}M.length>0&&w.length>0&&g.push({vertices:M,triangles:w})}const _=f.getElementsByTagName("component");for(let v=0;v<_.length;v++){const x=_[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 C=await oz(w),T=x.getAttribute("transform"),P=sz(T);for(const A of C)if(T){const j=[];for(let N=0;N<A.vertices.length;N+=3){const k=new Ge(A.vertices[N],A.vertices[N+1],A.vertices[N+2]);k.applyMatrix4(P),j.push(k.x,k.y,k.z)}g.push({vertices:j,triangles:A.triangles})}else g.push(A)}}}g.length>0&&n.set(m,{id:m,meshes:g})}const c=o.getElementsByTagName("build");if(c.length>0){const u=c[0].getElementsByTagName("item");for(let f=0;f<u.length;f++){const m=u[f],g=m.getAttribute("objectid");if(!g)continue;const y=sz(m.getAttribute("transform"));i.push({objectId:g,transform:y})}}return{objects:n,buildItems:i}}function lz(t){const e=new cl,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 $s(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function oge({url:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const i=E.useRef(null),r=E.useRef(null),a=E.useRef(null),s=E.useRef(null),o=E.useRef(null),[l,c]=E.useState(!0),[u,f]=E.useState(null);E.useEffect(()=>{if(!i.current)return;const y=i.current,_=y.clientWidth,v=y.clientHeight,x=new Uue;x.background=new vn(1710618),a.current=x;const M=new Is(45,_/v,.1,1e4);M.position.set(150,150,150),s.current=M;const w=new zme({antialias:!0});w.setSize(_,v),w.setPixelRatio(window.devicePixelRatio),y.appendChild(w.domElement),r.current=w;const C=new Hme(M,w.domElement);C.enableDamping=!0,C.dampingFactor=.05,o.current=C;const T=new Yue(16777215,.6);x.add(T);const P=new RF(16777215,.8);P.position.set(100,100,100),x.add(P);const A=new RF(16777215,.4);A.position.set(-100,50,-100),x.add(A);const j=Math.max(e.x,e.y),N=Math.ceil(j/16),k=new Que(j,N,4473924,3355443);x.add(k);const F=new nk(e.x,e.y),I=new JP({color:44610,transparent:!0,opacity:.15,side:Ho}),W=new tl(F,I);W.rotation.x=-Math.PI/2,W.position.y=-.5,x.add(W);let D;const B=()=>{D=requestAnimationFrame(B),C.update(),w.render(x,M)};B(),fetch(t).then(K=>{if(!K.ok)throw new Error("Failed to load file");return K.arrayBuffer()}).then(sge).then(({objects:K,buildItems:X})=>{if(K.size===0)throw new Error("No meshes found in 3MF file");const Y=new Gue({color:44610,shininess:30,flatShading:!1}),ee=new ox,z=[];if(X.length>0)for(const he of X){const we=K.get(he.objectId);if(we)for(const Ue of we.meshes){const ue=[];for(let H=0;H<Ue.vertices.length;H+=3){const q=new Ge(Ue.vertices[H],Ue.vertices[H+1],Ue.vertices[H+2]);q.applyMatrix4(he.transform),ue.push(q.x,q.y,q.z)}const lt=lz({vertices:ue,triangles:Ue.triangles});z.push(lt)}}else for(const he of K.values())for(const we of he.meshes){const Ue=lz(we);z.push(Ue)}if(z.length>0){const he=z.length===1?z[0]:tge(z,!1);if(he){const we=new tl(he,Y);ee.add(we)}if(z.length>1)for(const we of z)we.dispose()}const V=new Af().setFromObject(ee),re=V.getCenter(new Ge);ee.position.y=-V.min.y,X.length===0&&(ee.position.x=-re.x,ee.position.z=-re.z),x.add(ee);const le=new Af().setFromObject(ee),ge=le.getCenter(new Ge),ie=le.getSize(new Ge),ke=Math.max(ie.x,ie.y,ie.z)*1.8;M.position.set(ge.x+ke*.7,ge.y+ke*.5,ge.z+ke*.7),C.target.copy(ge),C.update(),c(!1)}).catch(K=>{f(K.message),c(!1)});const $=()=>{if(!y)return;const K=y.clientWidth,X=y.clientHeight;M.aspect=K/X,M.updateProjectionMatrix(),w.setSize(K,X)};return window.addEventListener("resize",$),()=>{window.removeEventListener("resize",$),cancelAnimationFrame(D),C.dispose(),w.dispose(),y.removeChild(w.domElement)}},[t,e]);const m=()=>{s.current&&o.current&&(s.current.position.set(150,150,150),o.current.target.set(0,50,0),o.current.update())},g=y=>{s.current&&s.current.position.multiplyScalar(y)};return h.jsxs("div",{className:`relative ${n}`,children:[h.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),l&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}),u&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsx("p",{className:"text-red-400",children:u})}),!l&&!u&&h.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[h.jsx(Ye,{variant:"secondary",size:"sm",onClick:()=>g(.8),children:h.jsx(Dle,{className:"w-4 h-4"})}),h.jsx(Ye,{variant:"secondary",size:"sm",onClick:()=>g(1.25),children:h.jsx(Ile,{className:"w-4 h-4"})}),h.jsx(Ye,{variant:"secondary",size:"sm",onClick:m,children:h.jsx(ZS,{className:"w-4 h-4"})})]})]})}const iw="159",Bh={ROTATE:0,DOLLY:1,PAN:2},Hh={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lge=0,cz=1,cge=2,e7=1,uge=2,$l=3,Ku=0,Ua=1,Xl=2,Fu=0,Cp=1,uz=2,dz=3,fz=4,dge=5,Gd=100,fge=101,hge=102,hz=103,pz=104,pge=200,mge=201,gge=202,xge=203,S3=204,w3=205,vge=206,yge=207,bge=208,_ge=209,Sge=210,wge=211,Mge=212,Ege=213,Age=214,Tge=0,Cge=1,Nge=2,Z_=3,Rge=4,Pge=5,kge=6,Dge=7,rk=0,Oge=1,Lge=2,zu=0,Ige=1,jge=2,Uge=3,Fge=4,zge=5,t7=300,Yp=301,Zp=302,M3=303,E3=304,rw=306,A3=1e3,uo=1001,T3=1002,Hr=1003,mz=1004,gT=1005,js=1006,Bge=1007,e0=1008,Bu=1009,Hge=1010,$ge=1011,ak=1012,n7=1013,ku=1014,ec=1015,t0=1016,i7=1017,r7=1018,af=1020,Vge=1021,Us=1023,Gge=1024,Wge=1025,sf=1026,Qp=1027,qge=1028,a7=1029,Xge=1030,s7=1031,o7=1033,xT=33776,vT=33777,yT=33778,bT=33779,gz=35840,xz=35841,vz=35842,yz=35843,l7=36196,bz=37492,_z=37496,Sz=37808,wz=37809,Mz=37810,Ez=37811,Az=37812,Tz=37813,Cz=37814,Nz=37815,Rz=37816,Pz=37817,kz=37818,Dz=37819,Oz=37820,Lz=37821,_T=36492,Iz=36494,jz=36495,Kge=36283,Uz=36284,Fz=36285,zz=36286,c7=3e3,of=3001,Yge=3200,Zge=3201,u7=0,Qge=1,Fs="",$r="srgb",xc="srgb-linear",sk="display-p3",aw="display-p3-linear",Q_="linear",ii="srgb",J_="rec709",e1="p3",$h=7680,Bz=519,Jge=512,exe=513,txe=514,d7=515,nxe=516,ixe=517,rxe=518,axe=519,C3=35044,Hz="300 es",N3=1035,Wo=2e3,n0=2001;class $f{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 Zr=["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 $z=1234567;const bx=Math.PI/180,i0=180/Math.PI;function oc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Zr[t&255]+Zr[t>>8&255]+Zr[t>>16&255]+Zr[t>>24&255]+"-"+Zr[e&255]+Zr[e>>8&255]+"-"+Zr[e>>16&15|64]+Zr[e>>24&255]+"-"+Zr[n&63|128]+Zr[n>>8&255]+"-"+Zr[n>>16&255]+Zr[n>>24&255]+Zr[i&255]+Zr[i>>8&255]+Zr[i>>16&255]+Zr[i>>24&255]).toLowerCase()}function Vr(t,e,n){return Math.max(e,Math.min(n,t))}function ok(t,e){return(t%e+e)%e}function sxe(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)}function oxe(t,e,n){return t!==e?(n-t)/(e-t):0}function _x(t,e,n){return(1-n)*t+n*e}function lxe(t,e,n,i){return _x(t,e,1-Math.exp(-n*i))}function cxe(t,e=1){return e-Math.abs(ok(t,e*2)-e)}function uxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function dxe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function fxe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function hxe(t,e){return t+Math.random()*(e-t)}function pxe(t){return t*(.5-Math.random())}function mxe(t){t!==void 0&&($z=t);let e=$z+=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 gxe(t){return t*bx}function xxe(t){return t*i0}function R3(t){return(t&t-1)===0&&t!==0}function vxe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function t1(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function yxe(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),u=s((e+i)/2),f=a((e-i)/2),m=s((e-i)/2),g=a((i-e)/2),y=s((i-e)/2);switch(r){case"XYX":t.set(o*u,l*f,l*m,o*c);break;case"YZY":t.set(l*m,o*u,l*f,o*c);break;case"ZXZ":t.set(l*f,l*m,o*u,o*c);break;case"XZX":t.set(o*u,l*y,l*g,o*c);break;case"YXY":t.set(l*g,o*u,l*y,o*c);break;case"ZYZ":t.set(l*y,l*g,o*u,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function $o(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 Hn(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 f7={DEG2RAD:bx,RAD2DEG:i0,generateUUID:oc,clamp:Vr,euclideanModulo:ok,mapLinear:sxe,inverseLerp:oxe,lerp:_x,damp:lxe,pingpong:cxe,smoothstep:uxe,smootherstep:dxe,randInt:fxe,randFloat:hxe,randFloatSpread:pxe,seededRandom:mxe,degToRad:gxe,radToDeg:xxe,isPowerOfTwo:R3,ceilPowerOfTwo:vxe,floorPowerOfTwo:t1,setQuaternionFromProperEuler:yxe,normalize:Hn,denormalize:$o};class Xt{constructor(e=0,n=0){Xt.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(Vr(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 dn{constructor(e,n,i,r,a,s,o,l,c){dn.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 u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=n,u[4]=a,u[5]=l,u[6]=i,u[7]=s,u[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],u=i[4],f=i[7],m=i[2],g=i[5],y=i[8],_=r[0],v=r[3],x=r[6],M=r[1],w=r[4],C=r[7],T=r[2],P=r[5],A=r[8];return a[0]=s*_+o*M+l*T,a[3]=s*v+o*w+l*P,a[6]=s*x+o*C+l*A,a[1]=c*_+u*M+f*T,a[4]=c*v+u*w+f*P,a[7]=c*x+u*C+f*A,a[2]=m*_+g*M+y*T,a[5]=m*v+g*w+y*P,a[8]=m*x+g*C+y*A,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],u=e[8];return n*s*u-n*o*c-i*a*u+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],u=e[8],f=u*s-o*c,m=o*l-u*a,g=c*a-s*l,y=n*f+i*m+r*g;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return e[0]=f*_,e[1]=(r*c-u*i)*_,e[2]=(o*i-r*s)*_,e[3]=m*_,e[4]=(u*n-r*l)*_,e[5]=(r*a-o*n)*_,e[6]=g*_,e[7]=(i*l-c*n)*_,e[8]=(s*n-i*a)*_,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(ST.makeScale(e,n)),this}rotate(e){return this.premultiply(ST.makeRotation(-e)),this}translate(e,n){return this.premultiply(ST.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 ST=new dn;function h7(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function n1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function bxe(){const t=n1("canvas");return t.style.display="block",t}const Vz={};function Sx(t){t in Vz||(Vz[t]=!0,console.warn(t))}const Gz=new dn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Wz=new dn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),rb={[xc]:{transfer:Q_,primaries:J_,toReference:t=>t,fromReference:t=>t},[$r]:{transfer:ii,primaries:J_,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[aw]:{transfer:Q_,primaries:e1,toReference:t=>t.applyMatrix3(Wz),fromReference:t=>t.applyMatrix3(Gz)},[sk]:{transfer:ii,primaries:e1,toReference:t=>t.convertSRGBToLinear().applyMatrix3(Wz),fromReference:t=>t.applyMatrix3(Gz).convertLinearToSRGB()}},_xe=new Set([xc,aw]),$n={enabled:!0,_workingColorSpace:xc,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(!_xe.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=rb[e].toReference,r=rb[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 rb[t].primaries},getTransfer:function(t){return t===Fs?Q_:rb[t].transfer}};function Np(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function wT(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Vh;class p7{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Vh===void 0&&(Vh=n1("canvas")),Vh.width=e.width,Vh.height=e.height;const i=Vh.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Vh}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=n1("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]=Np(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(Np(n[i]/255)*255):n[i]=Np(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 Sxe=0;class m7{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Sxe++}),this.uuid=oc(),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(MT(r[s].image)):a.push(MT(r[s]))}else a=MT(r);i.url=a}return n||(e.images[this.uuid]=i),i}}function MT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?p7.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 wxe=0;class Fa extends $f{constructor(e=Fa.DEFAULT_IMAGE,n=Fa.DEFAULT_MAPPING,i=uo,r=uo,a=js,s=e0,o=Us,l=Bu,c=Fa.DEFAULT_ANISOTROPY,u=Fs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:wxe++}),this.uuid=oc(),this.name="",this.source=new m7(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 Xt(0,0),this.repeat=new Xt(1,1),this.center=new Xt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof u=="string"?this.colorSpace=u:(Sx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=u===of?$r:Fs),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!==t7)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case A3:e.x=e.x-Math.floor(e.x);break;case uo:e.x=e.x<0?0:1;break;case T3: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 A3:e.y=e.y-Math.floor(e.y);break;case uo:e.y=e.y<0?0:1;break;case T3: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 Sx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===$r?of:c7}set encoding(e){Sx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===of?$r:Fs}}Fa.DEFAULT_IMAGE=null;Fa.DEFAULT_MAPPING=t7;Fa.DEFAULT_ANISOTROPY=1;class Gn{constructor(e=0,n=0,i=0,r=1){Gn.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],u=l[4],f=l[8],m=l[1],g=l[5],y=l[9],_=l[2],v=l[6],x=l[10];if(Math.abs(u-m)<.01&&Math.abs(f-_)<.01&&Math.abs(y-v)<.01){if(Math.abs(u+m)<.1&&Math.abs(f+_)<.1&&Math.abs(y+v)<.1&&Math.abs(c+g+x-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(c+1)/2,C=(g+1)/2,T=(x+1)/2,P=(u+m)/4,A=(f+_)/4,j=(y+v)/4;return w>C&&w>T?w<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(w),r=P/i,a=A/i):C>T?C<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(C),i=P/r,a=j/r):T<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(T),i=A/a,r=j/a),this.set(i,r,a,n),this}let M=Math.sqrt((v-y)*(v-y)+(f-_)*(f-_)+(m-u)*(m-u));return Math.abs(M)<.001&&(M=1),this.x=(v-y)/M,this.y=(f-_)/M,this.z=(m-u)/M,this.w=Math.acos((c+g+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 Mxe extends $f{constructor(e=1,n=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Gn(0,0,e,n),this.scissorTest=!1,this.viewport=new Gn(0,0,e,n);const r={width:e,height:n,depth:1};i.encoding!==void 0&&(Sx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===of?$r:Fs),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:js,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new Fa(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 m7(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 Tf extends Mxe{constructor(e=1,n=1,i={}){super(e,n,i),this.isWebGLRenderTarget=!0}}class g7 extends Fa{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=Hr,this.minFilter=Hr,this.wrapR=uo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Exe extends Fa{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=Hr,this.minFilter=Hr,this.wrapR=uo,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Cf{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],u=i[r+2],f=i[r+3];const m=a[s+0],g=a[s+1],y=a[s+2],_=a[s+3];if(o===0){e[n+0]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f;return}if(o===1){e[n+0]=m,e[n+1]=g,e[n+2]=y,e[n+3]=_;return}if(f!==_||l!==m||c!==g||u!==y){let v=1-o;const x=l*m+c*g+u*y+f*_,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 C=o*M;if(l=l*v+m*C,c=c*v+g*C,u=u*v+y*C,f=f*v+_*C,v===1-o){const T=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=T,c*=T,u*=T,f*=T}}e[n]=l,e[n+1]=c,e[n+2]=u,e[n+3]=f}static multiplyQuaternionsFlat(e,n,i,r,a,s){const o=i[r],l=i[r+1],c=i[r+2],u=i[r+3],f=a[s],m=a[s+1],g=a[s+2],y=a[s+3];return e[n]=o*y+u*f+l*g-c*m,e[n+1]=l*y+u*m+c*f-o*g,e[n+2]=c*y+u*g+o*m-l*f,e[n+3]=u*y-o*f-l*m-c*g,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),u=o(r/2),f=o(a/2),m=l(i/2),g=l(r/2),y=l(a/2);switch(s){case"XYZ":this._x=m*u*f+c*g*y,this._y=c*g*f-m*u*y,this._z=c*u*y+m*g*f,this._w=c*u*f-m*g*y;break;case"YXZ":this._x=m*u*f+c*g*y,this._y=c*g*f-m*u*y,this._z=c*u*y-m*g*f,this._w=c*u*f+m*g*y;break;case"ZXY":this._x=m*u*f-c*g*y,this._y=c*g*f+m*u*y,this._z=c*u*y+m*g*f,this._w=c*u*f-m*g*y;break;case"ZYX":this._x=m*u*f-c*g*y,this._y=c*g*f+m*u*y,this._z=c*u*y-m*g*f,this._w=c*u*f+m*g*y;break;case"YZX":this._x=m*u*f+c*g*y,this._y=c*g*f+m*u*y,this._z=c*u*y-m*g*f,this._w=c*u*f-m*g*y;break;case"XZY":this._x=m*u*f-c*g*y,this._y=c*g*f-m*u*y,this._z=c*u*y+m*g*f,this._w=c*u*f+m*g*y;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],u=n[6],f=n[10],m=i+o+f;if(m>0){const g=.5/Math.sqrt(m+1);this._w=.25/g,this._x=(u-l)*g,this._y=(a-c)*g,this._z=(s-r)*g}else if(i>o&&i>f){const g=2*Math.sqrt(1+i-o-f);this._w=(u-l)/g,this._x=.25*g,this._y=(r+s)/g,this._z=(a+c)/g}else if(o>f){const g=2*Math.sqrt(1+o-i-f);this._w=(a-c)/g,this._x=(r+s)/g,this._y=.25*g,this._z=(l+u)/g}else{const g=2*Math.sqrt(1+f-i-o);this._w=(s-r)/g,this._x=(a+c)/g,this._y=(l+u)/g,this._z=.25*g}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(Vr(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,u=n._w;return this._x=i*u+s*o+r*c-a*l,this._y=r*u+s*l+a*o-i*c,this._z=a*u+s*c+i*l-r*o,this._w=s*u-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 g=1-n;return this._w=g*s+n*this._w,this._x=g*i+n*this._x,this._y=g*r+n*this._y,this._z=g*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),u=Math.atan2(c,o),f=Math.sin((1-n)*u)/c,m=Math.sin(n*u)/c;return this._w=s*f+this._w*m,this._x=i*f+this._x*m,this._y=r*f+this._y*m,this._z=a*f+this._z*m,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 Te{constructor(e=0,n=0,i=0){Te.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(qz.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(qz.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),u=2*(o*n-a*r),f=2*(a*i-s*n);return this.x=n+l*c+s*f-o*u,this.y=i+l*u+o*c-a*f,this.z=r+l*f+a*u-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 ET.copy(this).projectOnVector(e),this.sub(ET)}reflect(e){return this.sub(ET.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(Vr(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 ET=new Te,qz=new Cf;class Vs{constructor(e=new Te(1/0,1/0,1/0),n=new Te(-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(so.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,i=e.count;n<i;n++)this.expandByPoint(so.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=so.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,so):so.fromBufferAttribute(a,s),so.applyMatrix4(e.matrixWorld),this.expandByPoint(so);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ab.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),ab.copy(i.boundingBox)),ab.applyMatrix4(e.matrixWorld),this.union(ab)}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,so),so.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($g),sb.subVectors(this.max,$g),Gh.subVectors(e.a,$g),Wh.subVectors(e.b,$g),qh.subVectors(e.c,$g),uu.subVectors(Wh,Gh),du.subVectors(qh,Wh),Dd.subVectors(Gh,qh);let n=[0,-uu.z,uu.y,0,-du.z,du.y,0,-Dd.z,Dd.y,uu.z,0,-uu.x,du.z,0,-du.x,Dd.z,0,-Dd.x,-uu.y,uu.x,0,-du.y,du.x,0,-Dd.y,Dd.x,0];return!AT(n,Gh,Wh,qh,sb)||(n=[1,0,0,0,1,0,0,0,1],!AT(n,Gh,Wh,qh,sb))?!1:(ob.crossVectors(uu,du),n=[ob.x,ob.y,ob.z],AT(n,Gh,Wh,qh,sb))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,so).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(so).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:(Ol[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ol[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ol[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ol[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ol[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ol[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ol[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ol[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ol),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 Ol=[new Te,new Te,new Te,new Te,new Te,new Te,new Te,new Te],so=new Te,ab=new Vs,Gh=new Te,Wh=new Te,qh=new Te,uu=new Te,du=new Te,Dd=new Te,$g=new Te,sb=new Te,ob=new Te,Od=new Te;function AT(t,e,n,i,r){for(let a=0,s=t.length-3;a<=s;a+=3){Od.fromArray(t,a);const o=r.x*Math.abs(Od.x)+r.y*Math.abs(Od.y)+r.z*Math.abs(Od.z),l=e.dot(Od),c=n.dot(Od),u=i.dot(Od);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Axe=new Vs,Vg=new Te,TT=new Te;class Xo{constructor(e=new Te,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):Axe.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):(TT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Vg.copy(e.center).add(TT)),this.expandByPoint(Vg.copy(e.center).sub(TT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ll=new Te,CT=new Te,lb=new Te,fu=new Te,NT=new Te,cb=new Te,RT=new Te;class lk{constructor(e=new Te,n=new Te(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,Ll)),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=Ll.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Ll.copy(this.origin).addScaledVector(this.direction,n),Ll.distanceToSquared(e))}distanceSqToSegment(e,n,i,r){CT.copy(e).add(n).multiplyScalar(.5),lb.copy(n).sub(e).normalize(),fu.copy(this.origin).sub(CT);const a=e.distanceTo(n)*.5,s=-this.direction.dot(lb),o=fu.dot(this.direction),l=-fu.dot(lb),c=fu.lengthSq(),u=Math.abs(1-s*s);let f,m,g,y;if(u>0)if(f=s*l-o,m=s*o-l,y=a*u,f>=0)if(m>=-y)if(m<=y){const _=1/u;f*=_,m*=_,g=f*(f+s*m+2*o)+m*(s*f+m+2*l)+c}else m=a,f=Math.max(0,-(s*m+o)),g=-f*f+m*(m+2*l)+c;else m=-a,f=Math.max(0,-(s*m+o)),g=-f*f+m*(m+2*l)+c;else m<=-y?(f=Math.max(0,-(-s*a+o)),m=f>0?-a:Math.min(Math.max(-a,-l),a),g=-f*f+m*(m+2*l)+c):m<=y?(f=0,m=Math.min(Math.max(-a,-l),a),g=m*(m+2*l)+c):(f=Math.max(0,-(s*a+o)),m=f>0?a:Math.min(Math.max(-a,-l),a),g=-f*f+m*(m+2*l)+c);else m=s>0?-a:a,f=Math.max(0,-(s*m+o)),g=-f*f+m*(m+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(CT).addScaledVector(lb,m),g}intersectSphere(e,n){Ll.subVectors(e.center,this.origin);const i=Ll.dot(this.direction),r=Ll.dot(Ll)-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,u=1/this.direction.y,f=1/this.direction.z,m=this.origin;return c>=0?(i=(e.min.x-m.x)*c,r=(e.max.x-m.x)*c):(i=(e.max.x-m.x)*c,r=(e.min.x-m.x)*c),u>=0?(a=(e.min.y-m.y)*u,s=(e.max.y-m.y)*u):(a=(e.max.y-m.y)*u,s=(e.min.y-m.y)*u),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),f>=0?(o=(e.min.z-m.z)*f,l=(e.max.z-m.z)*f):(o=(e.max.z-m.z)*f,l=(e.min.z-m.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,Ll)!==null}intersectTriangle(e,n,i,r,a){NT.subVectors(n,e),cb.subVectors(i,e),RT.crossVectors(NT,cb);let s=this.direction.dot(RT),o;if(s>0){if(r)return null;o=1}else if(s<0)o=-1,s=-s;else return null;fu.subVectors(this.origin,e);const l=o*this.direction.dot(cb.crossVectors(fu,cb));if(l<0)return null;const c=o*this.direction.dot(NT.cross(fu));if(c<0||l+c>s)return null;const u=-o*fu.dot(RT);return u<0?null:this.at(u/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 Jn{constructor(e,n,i,r,a,s,o,l,c,u,f,m,g,y,_,v){Jn.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,u,f,m,g,y,_,v)}set(e,n,i,r,a,s,o,l,c,u,f,m,g,y,_,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]=u,x[10]=f,x[14]=m,x[3]=g,x[7]=y,x[11]=_,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 Jn().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/Xh.setFromMatrixColumn(e,0).length(),a=1/Xh.setFromMatrixColumn(e,1).length(),s=1/Xh.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),u=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const m=s*u,g=s*f,y=o*u,_=o*f;n[0]=l*u,n[4]=-l*f,n[8]=c,n[1]=g+y*c,n[5]=m-_*c,n[9]=-o*l,n[2]=_-m*c,n[6]=y+g*c,n[10]=s*l}else if(e.order==="YXZ"){const m=l*u,g=l*f,y=c*u,_=c*f;n[0]=m+_*o,n[4]=y*o-g,n[8]=s*c,n[1]=s*f,n[5]=s*u,n[9]=-o,n[2]=g*o-y,n[6]=_+m*o,n[10]=s*l}else if(e.order==="ZXY"){const m=l*u,g=l*f,y=c*u,_=c*f;n[0]=m-_*o,n[4]=-s*f,n[8]=y+g*o,n[1]=g+y*o,n[5]=s*u,n[9]=_-m*o,n[2]=-s*c,n[6]=o,n[10]=s*l}else if(e.order==="ZYX"){const m=s*u,g=s*f,y=o*u,_=o*f;n[0]=l*u,n[4]=y*c-g,n[8]=m*c+_,n[1]=l*f,n[5]=_*c+m,n[9]=g*c-y,n[2]=-c,n[6]=o*l,n[10]=s*l}else if(e.order==="YZX"){const m=s*l,g=s*c,y=o*l,_=o*c;n[0]=l*u,n[4]=_-m*f,n[8]=y*f+g,n[1]=f,n[5]=s*u,n[9]=-o*u,n[2]=-c*u,n[6]=g*f+y,n[10]=m-_*f}else if(e.order==="XZY"){const m=s*l,g=s*c,y=o*l,_=o*c;n[0]=l*u,n[4]=-f,n[8]=c*u,n[1]=m*f+_,n[5]=s*u,n[9]=g*f-y,n[2]=y*f-g,n[6]=o*u,n[10]=_*f+m}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(Txe,e,Cxe)}lookAt(e,n,i){const r=this.elements;return ts.subVectors(e,n),ts.lengthSq()===0&&(ts.z=1),ts.normalize(),hu.crossVectors(i,ts),hu.lengthSq()===0&&(Math.abs(i.z)===1?ts.x+=1e-4:ts.z+=1e-4,ts.normalize(),hu.crossVectors(i,ts)),hu.normalize(),ub.crossVectors(ts,hu),r[0]=hu.x,r[4]=ub.x,r[8]=ts.x,r[1]=hu.y,r[5]=ub.y,r[9]=ts.y,r[2]=hu.z,r[6]=ub.z,r[10]=ts.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],u=i[1],f=i[5],m=i[9],g=i[13],y=i[2],_=i[6],v=i[10],x=i[14],M=i[3],w=i[7],C=i[11],T=i[15],P=r[0],A=r[4],j=r[8],N=r[12],k=r[1],F=r[5],I=r[9],W=r[13],D=r[2],B=r[6],$=r[10],K=r[14],X=r[3],Y=r[7],ee=r[11],z=r[15];return a[0]=s*P+o*k+l*D+c*X,a[4]=s*A+o*F+l*B+c*Y,a[8]=s*j+o*I+l*$+c*ee,a[12]=s*N+o*W+l*K+c*z,a[1]=u*P+f*k+m*D+g*X,a[5]=u*A+f*F+m*B+g*Y,a[9]=u*j+f*I+m*$+g*ee,a[13]=u*N+f*W+m*K+g*z,a[2]=y*P+_*k+v*D+x*X,a[6]=y*A+_*F+v*B+x*Y,a[10]=y*j+_*I+v*$+x*ee,a[14]=y*N+_*W+v*K+x*z,a[3]=M*P+w*k+C*D+T*X,a[7]=M*A+w*F+C*B+T*Y,a[11]=M*j+w*I+C*$+T*ee,a[15]=M*N+w*W+C*K+T*z,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],u=e[2],f=e[6],m=e[10],g=e[14],y=e[3],_=e[7],v=e[11],x=e[15];return y*(+a*l*f-r*c*f-a*o*m+i*c*m+r*o*g-i*l*g)+_*(+n*l*g-n*c*m+a*s*m-r*s*g+r*c*u-a*l*u)+v*(+n*c*f-n*o*g-a*s*f+i*s*g+a*o*u-i*c*u)+x*(-r*o*u-n*l*f+n*o*m+r*s*f-i*s*m+i*l*u)}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],u=e[8],f=e[9],m=e[10],g=e[11],y=e[12],_=e[13],v=e[14],x=e[15],M=f*v*c-_*m*c+_*l*g-o*v*g-f*l*x+o*m*x,w=y*m*c-u*v*c-y*l*g+s*v*g+u*l*x-s*m*x,C=u*_*c-y*f*c+y*o*g-s*_*g-u*o*x+s*f*x,T=y*f*l-u*_*l-y*o*m+s*_*m+u*o*v-s*f*v,P=n*M+i*w+r*C+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 A=1/P;return e[0]=M*A,e[1]=(_*m*a-f*v*a-_*r*g+i*v*g+f*r*x-i*m*x)*A,e[2]=(o*v*a-_*l*a+_*r*c-i*v*c-o*r*x+i*l*x)*A,e[3]=(f*l*a-o*m*a-f*r*c+i*m*c+o*r*g-i*l*g)*A,e[4]=w*A,e[5]=(u*v*a-y*m*a+y*r*g-n*v*g-u*r*x+n*m*x)*A,e[6]=(y*l*a-s*v*a-y*r*c+n*v*c+s*r*x-n*l*x)*A,e[7]=(s*m*a-u*l*a+u*r*c-n*m*c-s*r*g+n*l*g)*A,e[8]=C*A,e[9]=(y*f*a-u*_*a-y*i*g+n*_*g+u*i*x-n*f*x)*A,e[10]=(s*_*a-y*o*a+y*i*c-n*_*c-s*i*x+n*o*x)*A,e[11]=(u*o*a-s*f*a-u*i*c+n*f*c+s*i*g-n*o*g)*A,e[12]=T*A,e[13]=(u*_*r-y*f*r+y*i*m-n*_*m-u*i*v+n*f*v)*A,e[14]=(y*o*r-s*_*r-y*i*l+n*_*l+s*i*v-n*o*v)*A,e[15]=(s*f*r-u*o*r+u*i*l-n*f*l-s*i*m+n*o*m)*A,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,u=a*o;return this.set(c*s+i,c*o-r*l,c*l+r*o,0,c*o+r*l,u*o+i,u*l-r*s,0,c*l-r*o,u*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,u=s+s,f=o+o,m=a*c,g=a*u,y=a*f,_=s*u,v=s*f,x=o*f,M=l*c,w=l*u,C=l*f,T=i.x,P=i.y,A=i.z;return r[0]=(1-(_+x))*T,r[1]=(g+C)*T,r[2]=(y-w)*T,r[3]=0,r[4]=(g-C)*P,r[5]=(1-(m+x))*P,r[6]=(v+M)*P,r[7]=0,r[8]=(y+w)*A,r[9]=(v-M)*A,r[10]=(1-(m+_))*A,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=Xh.set(r[0],r[1],r[2]).length();const s=Xh.set(r[4],r[5],r[6]).length(),o=Xh.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],oo.copy(this);const c=1/a,u=1/s,f=1/o;return oo.elements[0]*=c,oo.elements[1]*=c,oo.elements[2]*=c,oo.elements[4]*=u,oo.elements[5]*=u,oo.elements[6]*=u,oo.elements[8]*=f,oo.elements[9]*=f,oo.elements[10]*=f,n.setFromRotationMatrix(oo),i.x=a,i.y=s,i.z=o,this}makePerspective(e,n,i,r,a,s,o=Wo){const l=this.elements,c=2*a/(n-e),u=2*a/(i-r),f=(n+e)/(n-e),m=(i+r)/(i-r);let g,y;if(o===Wo)g=-(s+a)/(s-a),y=-2*s*a/(s-a);else if(o===n0)g=-s/(s-a),y=-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]=u,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,n,i,r,a,s,o=Wo){const l=this.elements,c=1/(n-e),u=1/(i-r),f=1/(s-a),m=(n+e)*c,g=(i+r)*u;let y,_;if(o===Wo)y=(s+a)*f,_=-2*f;else if(o===n0)y=a*f,_=-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]=-m,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-g,l[2]=0,l[6]=0,l[10]=_,l[14]=-y,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 Xh=new Te,oo=new Jn,Txe=new Te(0,0,0),Cxe=new Te(1,1,1),hu=new Te,ub=new Te,ts=new Te,Xz=new Jn,Kz=new Cf;class F0{constructor(e=0,n=0,i=0,r=F0.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],u=r[9],f=r[2],m=r[6],g=r[10];switch(n){case"XYZ":this._y=Math.asin(Vr(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,g),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(m,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Vr(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Vr(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Vr(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(m,g),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(Vr(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-Vr(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(m,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-u,g),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 Xz.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Xz,n,i)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return Kz.setFromEuler(this),this.setFromQuaternion(Kz,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}}F0.DEFAULT_ORDER="XYZ";class x7{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 Nxe=0;const Yz=new Te,Kh=new Cf,Il=new Jn,db=new Te,Gg=new Te,Rxe=new Te,Pxe=new Cf,Zz=new Te(1,0,0),Qz=new Te(0,1,0),Jz=new Te(0,0,1),kxe={type:"added"},Dxe={type:"removed"};class ga extends $f{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Nxe++}),this.uuid=oc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ga.DEFAULT_UP.clone();const e=new Te,n=new F0,i=new Cf,r=new Te(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 Jn},normalMatrix:{value:new dn}}),this.matrix=new Jn,this.matrixWorld=new Jn,this.matrixAutoUpdate=ga.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ga.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new x7,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 Kh.setFromAxisAngle(e,n),this.quaternion.multiply(Kh),this}rotateOnWorldAxis(e,n){return Kh.setFromAxisAngle(e,n),this.quaternion.premultiply(Kh),this}rotateX(e){return this.rotateOnAxis(Zz,e)}rotateY(e){return this.rotateOnAxis(Qz,e)}rotateZ(e){return this.rotateOnAxis(Jz,e)}translateOnAxis(e,n){return Yz.copy(e).applyQuaternion(this.quaternion),this.position.add(Yz.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(Zz,e)}translateY(e){return this.translateOnAxis(Qz,e)}translateZ(e){return this.translateOnAxis(Jz,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Il.copy(this.matrixWorld).invert())}lookAt(e,n,i){e.isVector3?db.copy(e):db.set(e,n,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Gg.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Il.lookAt(Gg,db,this.up):Il.lookAt(db,Gg,this.up),this.quaternion.setFromRotationMatrix(Il),r&&(Il.extractRotation(r.matrixWorld),Kh.setFromRotationMatrix(Il),this.quaternion.premultiply(Kh.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(kxe)):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(Dxe)),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),Il.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Il.multiply(e.parent.matrixWorld)),e.applyMatrix4(Il),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(Gg,e,Rxe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gg,Pxe,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,u=l.length;c<u;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),u=s(e.images),f=s(e.shapes),m=s(e.skeletons),g=s(e.animations),y=s(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),f.length>0&&(i.shapes=f),m.length>0&&(i.skeletons=m),g.length>0&&(i.animations=g),y.length>0&&(i.nodes=y)}return i.object=r,i;function s(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}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}}ga.DEFAULT_UP=new Te(0,1,0);ga.DEFAULT_MATRIX_AUTO_UPDATE=!0;ga.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const lo=new Te,jl=new Te,PT=new Te,Ul=new Te,Yh=new Te,Zh=new Te,e5=new Te,kT=new Te,DT=new Te,OT=new Te;let fb=!1;class co{constructor(e=new Te,n=new Te,i=new Te){this.a=e,this.b=n,this.c=i}static getNormal(e,n,i,r){r.subVectors(i,n),lo.subVectors(e,n),r.cross(lo);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){lo.subVectors(r,n),jl.subVectors(i,n),PT.subVectors(e,n);const s=lo.dot(lo),o=lo.dot(jl),l=lo.dot(PT),c=jl.dot(jl),u=jl.dot(PT),f=s*c-o*o;if(f===0)return a.set(-2,-1,-1);const m=1/f,g=(c*l-o*u)*m,y=(s*u-o*l)*m;return a.set(1-g-y,y,g)}static containsPoint(e,n,i,r){return this.getBarycoord(e,n,i,r,Ul),Ul.x>=0&&Ul.y>=0&&Ul.x+Ul.y<=1}static getUV(e,n,i,r,a,s,o,l){return fb===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fb=!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,Ul),l.setScalar(0),l.addScaledVector(a,Ul.x),l.addScaledVector(s,Ul.y),l.addScaledVector(o,Ul.z),l}static isFrontFacing(e,n,i,r){return lo.subVectors(i,n),jl.subVectors(e,n),lo.cross(jl).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 lo.subVectors(this.c,this.b),jl.subVectors(this.a,this.b),lo.cross(jl).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return co.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return co.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,i,r,a){return fb===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fb=!0),co.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}getInterpolation(e,n,i,r,a){return co.getInterpolation(e,this.a,this.b,this.c,n,i,r,a)}containsPoint(e){return co.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return co.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;Yh.subVectors(r,i),Zh.subVectors(a,i),kT.subVectors(e,i);const l=Yh.dot(kT),c=Zh.dot(kT);if(l<=0&&c<=0)return n.copy(i);DT.subVectors(e,r);const u=Yh.dot(DT),f=Zh.dot(DT);if(u>=0&&f<=u)return n.copy(r);const m=l*f-u*c;if(m<=0&&l>=0&&u<=0)return s=l/(l-u),n.copy(i).addScaledVector(Yh,s);OT.subVectors(e,a);const g=Yh.dot(OT),y=Zh.dot(OT);if(y>=0&&g<=y)return n.copy(a);const _=g*c-l*y;if(_<=0&&c>=0&&y<=0)return o=c/(c-y),n.copy(i).addScaledVector(Zh,o);const v=u*y-g*f;if(v<=0&&f-u>=0&&g-y>=0)return e5.subVectors(a,r),o=(f-u)/(f-u+(g-y)),n.copy(r).addScaledVector(e5,o);const x=1/(v+_+m);return s=_*x,o=m*x,n.copy(i).addScaledVector(Yh,s).addScaledVector(Zh,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const v7={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},pu={h:0,s:0,l:0},hb={h:0,s:0,l:0};function LT(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 zt=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=$r){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,$n.toWorkingColorSpace(this,n),this}setRGB(e,n,i,r=$n.workingColorSpace){return this.r=e,this.g=n,this.b=i,$n.toWorkingColorSpace(this,r),this}setHSL(e,n,i,r=$n.workingColorSpace){if(e=ok(e,1),n=Vr(n,0,1),i=Vr(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=LT(s,a,e+1/3),this.g=LT(s,a,e),this.b=LT(s,a,e-1/3)}return $n.toWorkingColorSpace(this,r),this}setStyle(e,n=$r){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=$r){const i=v7[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=Np(e.r),this.g=Np(e.g),this.b=Np(e.b),this}copyLinearToSRGB(e){return this.r=wT(e.r),this.g=wT(e.g),this.b=wT(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=$r){return $n.fromWorkingColorSpace(Qr.copy(this),e),Math.round(Vr(Qr.r*255,0,255))*65536+Math.round(Vr(Qr.g*255,0,255))*256+Math.round(Vr(Qr.b*255,0,255))}getHexString(e=$r){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=$n.workingColorSpace){$n.fromWorkingColorSpace(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 u=(o+s)/2;if(o===s)l=0,c=0;else{const f=s-o;switch(c=u<=.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=u,e}getRGB(e,n=$n.workingColorSpace){return $n.fromWorkingColorSpace(Qr.copy(this),n),e.r=Qr.r,e.g=Qr.g,e.b=Qr.b,e}getStyle(e=$r){$n.fromWorkingColorSpace(Qr.copy(this),e);const n=Qr.r,i=Qr.g,r=Qr.b;return e!==$r?`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(pu),this.setHSL(pu.h+e,pu.s+n,pu.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(pu),e.getHSL(hb);const i=_x(pu.h,hb.h,n),r=_x(pu.s,hb.s,n),a=_x(pu.l,hb.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 zt;zt.NAMES=v7;let Oxe=0;class Am extends $f{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Oxe++}),this.uuid=oc(),this.name="",this.type="Material",this.blending=Cp,this.side=Ku,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=S3,this.blendDst=w3,this.blendEquation=Gd,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new zt(0,0,0),this.blendAlpha=0,this.depthFunc=Z_,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Bz,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$h,this.stencilZFail=$h,this.stencilZPass=$h,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!==Cp&&(i.blending=this.blending),this.side!==Ku&&(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!==S3&&(i.blendSrc=this.blendSrc),this.blendDst!==w3&&(i.blendDst=this.blendDst),this.blendEquation!==Gd&&(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!==Z_&&(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!==Bz&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$h&&(i.stencilFail=this.stencilFail),this.stencilZFail!==$h&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==$h&&(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 y7 extends Am{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new zt(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=rk,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 Hi=new Te,pb=new Xt;class ds{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=C3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=ec,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++)pb.fromBufferAttribute(this,n),pb.applyMatrix3(e),this.setXY(n,pb.x,pb.y);else if(this.itemSize===3)for(let n=0,i=this.count;n<i;n++)Hi.fromBufferAttribute(this,n),Hi.applyMatrix3(e),this.setXYZ(n,Hi.x,Hi.y,Hi.z);return this}applyMatrix4(e){for(let n=0,i=this.count;n<i;n++)Hi.fromBufferAttribute(this,n),Hi.applyMatrix4(e),this.setXYZ(n,Hi.x,Hi.y,Hi.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)Hi.fromBufferAttribute(this,n),Hi.applyNormalMatrix(e),this.setXYZ(n,Hi.x,Hi.y,Hi.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)Hi.fromBufferAttribute(this,n),Hi.transformDirection(e),this.setXYZ(n,Hi.x,Hi.y,Hi.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=$o(i,this.array)),i}setComponent(e,n,i){return this.normalized&&(i=Hn(i,this.array)),this.array[e*this.itemSize+n]=i,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=$o(n,this.array)),n}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=$o(n,this.array)),n}setY(e,n){return this.normalized&&(n=Hn(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=$o(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Hn(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=$o(n,this.array)),n}setW(e,n){return this.normalized&&(n=Hn(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,i){return e*=this.itemSize,this.normalized&&(n=Hn(n,this.array),i=Hn(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=Hn(n,this.array),i=Hn(i,this.array),r=Hn(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=Hn(n,this.array),i=Hn(i,this.array),r=Hn(r,this.array),a=Hn(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!==C3&&(e.usage=this.usage),e}}class b7 extends ds{constructor(e,n,i){super(new Uint16Array(e),n,i)}}class _7 extends ds{constructor(e,n,i){super(new Uint32Array(e),n,i)}}class Oi extends ds{constructor(e,n,i){super(new Float32Array(e),n,i)}}let Lxe=0;const Es=new Jn,IT=new ga,Qh=new Te,ns=new Vs,Wg=new Vs,_r=new Te;class aa extends $f{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Lxe++}),this.uuid=oc(),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(h7(e)?_7:b7)(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 dn().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 Es.makeRotationFromQuaternion(e),this.applyMatrix4(Es),this}rotateX(e){return Es.makeRotationX(e),this.applyMatrix4(Es),this}rotateY(e){return Es.makeRotationY(e),this.applyMatrix4(Es),this}rotateZ(e){return Es.makeRotationZ(e),this.applyMatrix4(Es),this}translate(e,n,i){return Es.makeTranslation(e,n,i),this.applyMatrix4(Es),this}scale(e,n,i){return Es.makeScale(e,n,i),this.applyMatrix4(Es),this}lookAt(e){return IT.lookAt(e),IT.updateMatrix(),this.applyMatrix4(IT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qh).negate(),this.translate(Qh.x,Qh.y,Qh.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 Oi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Vs);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 Te(-1/0,-1/0,-1/0),new Te(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];ns.setFromBufferAttribute(a),this.morphTargetsRelative?(_r.addVectors(this.boundingBox.min,ns.min),this.boundingBox.expandByPoint(_r),_r.addVectors(this.boundingBox.max,ns.max),this.boundingBox.expandByPoint(_r)):(this.boundingBox.expandByPoint(ns.min),this.boundingBox.expandByPoint(ns.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 Xo);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 Te,1/0);return}if(e){const i=this.boundingSphere.center;if(ns.setFromBufferAttribute(e),n)for(let a=0,s=n.length;a<s;a++){const o=n[a];Wg.setFromBufferAttribute(o),this.morphTargetsRelative?(_r.addVectors(ns.min,Wg.min),ns.expandByPoint(_r),_r.addVectors(ns.max,Wg.max),ns.expandByPoint(_r)):(ns.expandByPoint(Wg.min),ns.expandByPoint(Wg.max))}ns.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)_r.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(_r));if(n)for(let a=0,s=n.length;a<s;a++){const o=n[a],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)_r.fromBufferAttribute(o,c),l&&(Qh.fromBufferAttribute(e,c),_r.add(Qh)),r=Math.max(r,i.distanceToSquared(_r))}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 ds(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],u=[];for(let k=0;k<o;k++)c[k]=new Te,u[k]=new Te;const f=new Te,m=new Te,g=new Te,y=new Xt,_=new Xt,v=new Xt,x=new Te,M=new Te;function w(k,F,I){f.fromArray(r,k*3),m.fromArray(r,F*3),g.fromArray(r,I*3),y.fromArray(s,k*2),_.fromArray(s,F*2),v.fromArray(s,I*2),m.sub(f),g.sub(f),_.sub(y),v.sub(y);const W=1/(_.x*v.y-v.x*_.y);isFinite(W)&&(x.copy(m).multiplyScalar(v.y).addScaledVector(g,-_.y).multiplyScalar(W),M.copy(g).multiplyScalar(_.x).addScaledVector(m,-v.x).multiplyScalar(W),c[k].add(x),c[F].add(x),c[I].add(x),u[k].add(M),u[F].add(M),u[I].add(M))}let C=this.groups;C.length===0&&(C=[{start:0,count:i.length}]);for(let k=0,F=C.length;k<F;++k){const I=C[k],W=I.start,D=I.count;for(let B=W,$=W+D;B<$;B+=3)w(i[B+0],i[B+1],i[B+2])}const T=new Te,P=new Te,A=new Te,j=new Te;function N(k){A.fromArray(a,k*3),j.copy(A);const F=c[k];T.copy(F),T.sub(A.multiplyScalar(A.dot(F))).normalize(),P.crossVectors(j,F);const W=P.dot(u[k])<0?-1:1;l[k*4]=T.x,l[k*4+1]=T.y,l[k*4+2]=T.z,l[k*4+3]=W}for(let k=0,F=C.length;k<F;++k){const I=C[k],W=I.start,D=I.count;for(let B=W,$=W+D;B<$;B+=3)N(i[B+0]),N(i[B+1]),N(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 ds(new Float32Array(n.count*3),3),this.setAttribute("normal",i);else for(let m=0,g=i.count;m<g;m++)i.setXYZ(m,0,0,0);const r=new Te,a=new Te,s=new Te,o=new Te,l=new Te,c=new Te,u=new Te,f=new Te;if(e)for(let m=0,g=e.count;m<g;m+=3){const y=e.getX(m+0),_=e.getX(m+1),v=e.getX(m+2);r.fromBufferAttribute(n,y),a.fromBufferAttribute(n,_),s.fromBufferAttribute(n,v),u.subVectors(s,a),f.subVectors(r,a),u.cross(f),o.fromBufferAttribute(i,y),l.fromBufferAttribute(i,_),c.fromBufferAttribute(i,v),o.add(u),l.add(u),c.add(u),i.setXYZ(y,o.x,o.y,o.z),i.setXYZ(_,l.x,l.y,l.z),i.setXYZ(v,c.x,c.y,c.z)}else for(let m=0,g=n.count;m<g;m+=3)r.fromBufferAttribute(n,m+0),a.fromBufferAttribute(n,m+1),s.fromBufferAttribute(n,m+2),u.subVectors(s,a),f.subVectors(r,a),u.cross(f),i.setXYZ(m+0,u.x,u.y,u.z),i.setXYZ(m+1,u.x,u.y,u.z),i.setXYZ(m+2,u.x,u.y,u.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,i=e.count;n<i;n++)_r.fromBufferAttribute(e,n),_r.normalize(),e.setXYZ(n,_r.x,_r.y,_r.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,f=o.normalized,m=new c.constructor(l.length*u);let g=0,y=0;for(let _=0,v=l.length;_<v;_++){o.isInterleavedBufferAttribute?g=l[_]*o.data.stride+o.offset:g=l[_]*u;for(let x=0;x<u;x++)m[y++]=c[g++]}return new ds(m,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new aa,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 u=0,f=c.length;u<f;u++){const m=c[u],g=e(m,i);l.push(g)}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],u=[];for(let f=0,m=c.length;f<m;f++){const g=c[f];u.push(g.toJSON(e.data))}u.length>0&&(r[l]=u,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 u=r[c];this.setAttribute(c,u.clone(n))}const a=e.morphAttributes;for(const c in a){const u=[],f=a[c];for(let m=0,g=f.length;m<g;m++)u.push(f[m].clone(n));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,u=s.length;c<u;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 t5=new Jn,Ld=new lk,mb=new Xo,n5=new Te,Jh=new Te,ep=new Te,tp=new Te,jT=new Te,gb=new Te,xb=new Xt,vb=new Xt,yb=new Xt,i5=new Te,r5=new Te,a5=new Te,bb=new Te,_b=new Te;class xo extends ga{constructor(e=new aa,n=new y7){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){gb.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const u=o[l],f=a[l];u!==0&&(jT.fromBufferAttribute(f,e),s?gb.addScaledVector(jT,u):gb.addScaledVector(jT.sub(n),u))}n.add(gb)}return n}raycast(e,n){const i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),mb.copy(i.boundingSphere),mb.applyMatrix4(a),Ld.copy(e.ray).recast(e.near),!(mb.containsPoint(Ld.origin)===!1&&(Ld.intersectSphere(mb,n5)===null||Ld.origin.distanceToSquared(n5)>(e.far-e.near)**2))&&(t5.copy(a).invert(),Ld.copy(e.ray).applyMatrix4(t5),!(i.boundingBox!==null&&Ld.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,n,Ld)))}_computeIntersections(e,n,i){let r;const a=this.geometry,s=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,u=a.attributes.uv1,f=a.attributes.normal,m=a.groups,g=a.drawRange;if(o!==null)if(Array.isArray(s))for(let y=0,_=m.length;y<_;y++){const v=m[y],x=s[v.materialIndex],M=Math.max(v.start,g.start),w=Math.min(o.count,Math.min(v.start+v.count,g.start+g.count));for(let C=M,T=w;C<T;C+=3){const P=o.getX(C),A=o.getX(C+1),j=o.getX(C+2);r=Sb(this,x,e,i,c,u,f,P,A,j),r&&(r.faceIndex=Math.floor(C/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const y=Math.max(0,g.start),_=Math.min(o.count,g.start+g.count);for(let v=y,x=_;v<x;v+=3){const M=o.getX(v),w=o.getX(v+1),C=o.getX(v+2);r=Sb(this,s,e,i,c,u,f,M,w,C),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}else if(l!==void 0)if(Array.isArray(s))for(let y=0,_=m.length;y<_;y++){const v=m[y],x=s[v.materialIndex],M=Math.max(v.start,g.start),w=Math.min(l.count,Math.min(v.start+v.count,g.start+g.count));for(let C=M,T=w;C<T;C+=3){const P=C,A=C+1,j=C+2;r=Sb(this,x,e,i,c,u,f,P,A,j),r&&(r.faceIndex=Math.floor(C/3),r.face.materialIndex=v.materialIndex,n.push(r))}}else{const y=Math.max(0,g.start),_=Math.min(l.count,g.start+g.count);for(let v=y,x=_;v<x;v+=3){const M=v,w=v+1,C=v+2;r=Sb(this,s,e,i,c,u,f,M,w,C),r&&(r.faceIndex=Math.floor(v/3),n.push(r))}}}}function Ixe(t,e,n,i,r,a,s,o){let l;if(e.side===Ua?l=i.intersectTriangle(s,a,r,!0,o):l=i.intersectTriangle(r,a,s,e.side===Ku,o),l===null)return null;_b.copy(o),_b.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo(_b);return c<n.near||c>n.far?null:{distance:c,point:_b.clone(),object:t}}function Sb(t,e,n,i,r,a,s,o,l,c){t.getVertexPosition(o,Jh),t.getVertexPosition(l,ep),t.getVertexPosition(c,tp);const u=Ixe(t,e,n,i,Jh,ep,tp,bb);if(u){r&&(xb.fromBufferAttribute(r,o),vb.fromBufferAttribute(r,l),yb.fromBufferAttribute(r,c),u.uv=co.getInterpolation(bb,Jh,ep,tp,xb,vb,yb,new Xt)),a&&(xb.fromBufferAttribute(a,o),vb.fromBufferAttribute(a,l),yb.fromBufferAttribute(a,c),u.uv1=co.getInterpolation(bb,Jh,ep,tp,xb,vb,yb,new Xt),u.uv2=u.uv1),s&&(i5.fromBufferAttribute(s,o),r5.fromBufferAttribute(s,l),a5.fromBufferAttribute(s,c),u.normal=co.getInterpolation(bb,Jh,ep,tp,i5,r5,a5,new Te),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const f={a:o,b:l,c,normal:new Te,materialIndex:0};co.getNormal(Jh,ep,tp,f.normal),u.face=f}return u}class z0 extends aa{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=[],u=[],f=[];let m=0,g=0;y("z","y","x",-1,-1,i,n,e,s,a,0),y("z","y","x",1,-1,i,n,-e,s,a,1),y("x","z","y",1,1,e,i,n,r,s,2),y("x","z","y",1,-1,e,i,-n,r,s,3),y("x","y","z",1,-1,e,n,i,r,a,4),y("x","y","z",-1,-1,e,n,-i,r,a,5),this.setIndex(l),this.setAttribute("position",new Oi(c,3)),this.setAttribute("normal",new Oi(u,3)),this.setAttribute("uv",new Oi(f,2));function y(_,v,x,M,w,C,T,P,A,j,N){const k=C/A,F=T/j,I=C/2,W=T/2,D=P/2,B=A+1,$=j+1;let K=0,X=0;const Y=new Te;for(let ee=0;ee<$;ee++){const z=ee*F-W;for(let V=0;V<B;V++){const re=V*k-I;Y[_]=re*M,Y[v]=z*w,Y[x]=D,c.push(Y.x,Y.y,Y.z),Y[_]=0,Y[v]=0,Y[x]=P>0?1:-1,u.push(Y.x,Y.y,Y.z),f.push(V/A),f.push(1-ee/j),K+=1}}for(let ee=0;ee<j;ee++)for(let z=0;z<A;z++){const V=m+z+B*ee,re=m+z+B*(ee+1),le=m+(z+1)+B*(ee+1),ge=m+(z+1)+B*ee;l.push(V,re,ge),l.push(re,le,ge),X+=6}o.addGroup(g,X,N),g+=X,m+=K}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new z0(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 da(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 jxe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function S7(t){return t.getRenderTarget()===null?t.outputColorSpace:$n.workingColorSpace}const ck={clone:Jp,merge:da};var Uxe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Fxe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Yu extends Am{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Uxe,this.fragmentShader=Fxe,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=jxe(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 w7 extends ga{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jn,this.projectionMatrix=new Jn,this.projectionMatrixInverse=new Jn,this.coordinateSystem=Wo}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 as extends w7{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=i0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(bx*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return i0*2*Math.atan(Math.tan(bx*.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(bx*.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 np=-90,ip=1;class zxe extends ga{constructor(e,n,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new as(np,ip,e,n);r.layers=this.layers,this.add(r);const a=new as(np,ip,e,n);a.layers=this.layers,this.add(a);const s=new as(np,ip,e,n);s.layers=this.layers,this.add(s);const o=new as(np,ip,e,n);o.layers=this.layers,this.add(o);const l=new as(np,ip,e,n);l.layers=this.layers,this.add(l);const c=new as(np,ip,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===Wo)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===n0)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,u]=this.children,f=e.getRenderTarget(),m=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),y=e.xr.enabled;e.xr.enabled=!1;const _=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=_,e.setRenderTarget(i,5,r),e.render(n,u),e.setRenderTarget(f,m,g),e.xr.enabled=y,i.texture.needsPMREMUpdate=!0}}class M7 extends Fa{constructor(e,n,i,r,a,s,o,l,c,u){e=e!==void 0?e:[],n=n!==void 0?n:Yp,super(e,n,i,r,a,s,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Bxe extends Tf{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&&(Sx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===of?$r:Fs),this.texture=new M7(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:js}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 z0(5,5,5),a=new Yu({name:"CubemapFromEquirect",uniforms:Jp(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ua,blending:Fu});a.uniforms.tEquirect.value=n;const s=new xo(r,a),o=n.minFilter;return n.minFilter===e0&&(n.minFilter=js),new zxe(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 UT=new Te,Hxe=new Te,$xe=new dn;class bu{constructor(e=new Te(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=UT.subVectors(i,n).cross(Hxe.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(UT),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||$xe.getNormalMatrix(e),r=this.coplanarPoint(UT).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 Id=new Xo,wb=new Te;class sw{constructor(e=new bu,n=new bu,i=new bu,r=new bu,a=new bu,s=new bu){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=Wo){const i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],c=r[4],u=r[5],f=r[6],m=r[7],g=r[8],y=r[9],_=r[10],v=r[11],x=r[12],M=r[13],w=r[14],C=r[15];if(i[0].setComponents(l-a,m-c,v-g,C-x).normalize(),i[1].setComponents(l+a,m+c,v+g,C+x).normalize(),i[2].setComponents(l+s,m+u,v+y,C+M).normalize(),i[3].setComponents(l-s,m-u,v-y,C-M).normalize(),i[4].setComponents(l-o,m-f,v-_,C-w).normalize(),n===Wo)i[5].setComponents(l+o,m+f,v+_,C+w).normalize();else if(n===n0)i[5].setComponents(o,f,_,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(),Id.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Id.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Id)}intersectsSprite(e){return Id.center.set(0,0,0),Id.radius=.7071067811865476,Id.applyMatrix4(e.matrixWorld),this.intersectsSphere(Id)}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(wb.x=r.normal.x>0?e.max.x:e.min.x,wb.y=r.normal.y>0?e.max.y:e.min.y,wb.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(wb)<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 E7(){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 Vxe(t,e){const n=e.isWebGL2,i=new WeakMap;function r(c,u){const f=c.array,m=c.usage,g=f.byteLength,y=t.createBuffer();t.bindBuffer(u,y),t.bufferData(u,f,m),c.onUploadCallback();let _;if(f instanceof Float32Array)_=t.FLOAT;else if(f instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(n)_=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else _=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)_=t.SHORT;else if(f instanceof Uint32Array)_=t.UNSIGNED_INT;else if(f instanceof Int32Array)_=t.INT;else if(f instanceof Int8Array)_=t.BYTE;else if(f instanceof Uint8Array)_=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)_=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:y,type:_,bytesPerElement:f.BYTES_PER_ELEMENT,version:c.version,size:g}}function a(c,u,f){const m=u.array,g=u._updateRange,y=u.updateRanges;if(t.bindBuffer(f,c),g.count===-1&&y.length===0&&t.bufferSubData(f,0,m),y.length!==0){for(let _=0,v=y.length;_<v;_++){const x=y[_];n?t.bufferSubData(f,x.start*m.BYTES_PER_ELEMENT,m,x.start,x.count):t.bufferSubData(f,x.start*m.BYTES_PER_ELEMENT,m.subarray(x.start,x.start+x.count))}u.clearUpdateRanges()}g.count!==-1&&(n?t.bufferSubData(f,g.offset*m.BYTES_PER_ELEMENT,m,g.offset,g.count):t.bufferSubData(f,g.offset*m.BYTES_PER_ELEMENT,m.subarray(g.offset,g.offset+g.count)),g.count=-1),u.onUploadCallback()}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=i.get(c);u&&(t.deleteBuffer(u.buffer),i.delete(c))}function l(c,u){if(c.isGLBufferAttribute){const m=i.get(c);(!m||m.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,u));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,u),f.version=c.version}}return{get:s,remove:o,update:l}}class uk extends aa{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,u=l+1,f=e/o,m=n/l,g=[],y=[],_=[],v=[];for(let x=0;x<u;x++){const M=x*m-s;for(let w=0;w<c;w++){const C=w*f-a;y.push(C,-M,0),_.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,C=M+c*(x+1),T=M+1+c*(x+1),P=M+1+c*x;g.push(w,C,P),g.push(C,T,P)}this.setIndex(g),this.setAttribute("position",new Oi(y,3)),this.setAttribute("normal",new Oi(_,3)),this.setAttribute("uv",new Oi(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uk(e.width,e.height,e.widthSegments,e.heightSegments)}}var Gxe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Wxe=`#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`,qxe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Xxe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,Kxe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,Yxe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Zxe=`#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`,Qxe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Jxe=`#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`,e0e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,t0e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,n0e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,i0e=`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`,r0e=`#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`,a0e=`#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`,s0e=`#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`,o0e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,l0e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,c0e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,u0e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,d0e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,f0e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,h0e=`#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`,p0e=`#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`,m0e=`#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`,g0e=`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`,x0e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,v0e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,y0e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,b0e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,_0e="gl_FragColor = linearToOutputTexel( gl_FragColor );",S0e=`
- 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 );
- }`,w0e=`#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`,M0e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,E0e=`#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`,A0e=`#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`,T0e=`#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`,C0e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,N0e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,R0e=`#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`,P0e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,k0e=`#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
- }`,D0e=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,O0e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,L0e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,I0e=`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`,j0e=`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`,U0e=`#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`,F0e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,z0e=`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`,B0e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,H0e=`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`,$0e=`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`,V0e=`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 );
- }`,G0e=`
- 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`,W0e=`#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`,q0e=`#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`,X0e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,K0e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,Y0e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,Z0e=`#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`,Q0e=`#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`,J0e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,eve=`#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`,tve=`#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`,nve=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,ive=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,rve=`#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`,ave=`#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`,sve=`#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`,ove=`#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`,lve=`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;`,cve=`#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`,uve=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,dve=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,fve=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,hve=`#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`,pve=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,mve=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,gve=`#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`,xve=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,vve=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,yve=`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 );
- }`,bve=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,_ve=`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;`,Sve=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,wve=`#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`,Mve=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,Eve=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,Ave=`#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`,Tve=`#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`,Cve=`#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`,Nve=`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;
- }`,Rve=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,Pve=`#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`,kve=`#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`,Dve=`#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`,Ove=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,Lve=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,Ive=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,jve=`#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; }`,Uve=`#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`,Fve=`#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`,zve=`#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`,Bve=`#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`,Hve=`#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`,$ve=`#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 Vve=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,Gve=`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>
- }`,Wve=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,qve=`#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>
- }`,Xve=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Kve=`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>
- }`,Yve=`#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;
- }`,Zve=`#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
- }`,Qve=`#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;
- }`,Jve=`#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 );
- }`,eye=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,tye=`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>
- }`,nye=`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>
- }`,iye=`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>
- }`,rye=`#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>
- }`,aye=`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>
- }`,sye=`#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>
- }`,oye=`#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>
- }`,lye=`#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;
- }`,cye=`#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>
- }`,uye=`#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
- }`,dye=`#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
- }`,fye=`#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>
- }`,hye=`#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>
- }`,pye=`#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
- }`,mye=`#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>
- }`,gye=`#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>
- }`,xye=`#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>
- }`,vye=`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>
- }`,yye=`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>
- }`,bye=`#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>
- }`,_ye=`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>
- }`,Sye=`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>
- }`,wye=`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>
- }`,an={alphahash_fragment:Gxe,alphahash_pars_fragment:Wxe,alphamap_fragment:qxe,alphamap_pars_fragment:Xxe,alphatest_fragment:Kxe,alphatest_pars_fragment:Yxe,aomap_fragment:Zxe,aomap_pars_fragment:Qxe,batching_pars_vertex:Jxe,batching_vertex:e0e,begin_vertex:t0e,beginnormal_vertex:n0e,bsdfs:i0e,iridescence_fragment:r0e,bumpmap_pars_fragment:a0e,clipping_planes_fragment:s0e,clipping_planes_pars_fragment:o0e,clipping_planes_pars_vertex:l0e,clipping_planes_vertex:c0e,color_fragment:u0e,color_pars_fragment:d0e,color_pars_vertex:f0e,color_vertex:h0e,common:p0e,cube_uv_reflection_fragment:m0e,defaultnormal_vertex:g0e,displacementmap_pars_vertex:x0e,displacementmap_vertex:v0e,emissivemap_fragment:y0e,emissivemap_pars_fragment:b0e,colorspace_fragment:_0e,colorspace_pars_fragment:S0e,envmap_fragment:w0e,envmap_common_pars_fragment:M0e,envmap_pars_fragment:E0e,envmap_pars_vertex:A0e,envmap_physical_pars_fragment:U0e,envmap_vertex:T0e,fog_vertex:C0e,fog_pars_vertex:N0e,fog_fragment:R0e,fog_pars_fragment:P0e,gradientmap_pars_fragment:k0e,lightmap_fragment:D0e,lightmap_pars_fragment:O0e,lights_lambert_fragment:L0e,lights_lambert_pars_fragment:I0e,lights_pars_begin:j0e,lights_toon_fragment:F0e,lights_toon_pars_fragment:z0e,lights_phong_fragment:B0e,lights_phong_pars_fragment:H0e,lights_physical_fragment:$0e,lights_physical_pars_fragment:V0e,lights_fragment_begin:G0e,lights_fragment_maps:W0e,lights_fragment_end:q0e,logdepthbuf_fragment:X0e,logdepthbuf_pars_fragment:K0e,logdepthbuf_pars_vertex:Y0e,logdepthbuf_vertex:Z0e,map_fragment:Q0e,map_pars_fragment:J0e,map_particle_fragment:eve,map_particle_pars_fragment:tve,metalnessmap_fragment:nve,metalnessmap_pars_fragment:ive,morphcolor_vertex:rve,morphnormal_vertex:ave,morphtarget_pars_vertex:sve,morphtarget_vertex:ove,normal_fragment_begin:lve,normal_fragment_maps:cve,normal_pars_fragment:uve,normal_pars_vertex:dve,normal_vertex:fve,normalmap_pars_fragment:hve,clearcoat_normal_fragment_begin:pve,clearcoat_normal_fragment_maps:mve,clearcoat_pars_fragment:gve,iridescence_pars_fragment:xve,opaque_fragment:vve,packing:yve,premultiplied_alpha_fragment:bve,project_vertex:_ve,dithering_fragment:Sve,dithering_pars_fragment:wve,roughnessmap_fragment:Mve,roughnessmap_pars_fragment:Eve,shadowmap_pars_fragment:Ave,shadowmap_pars_vertex:Tve,shadowmap_vertex:Cve,shadowmask_pars_fragment:Nve,skinbase_vertex:Rve,skinning_pars_vertex:Pve,skinning_vertex:kve,skinnormal_vertex:Dve,specularmap_fragment:Ove,specularmap_pars_fragment:Lve,tonemapping_fragment:Ive,tonemapping_pars_fragment:jve,transmission_fragment:Uve,transmission_pars_fragment:Fve,uv_pars_fragment:zve,uv_pars_vertex:Bve,uv_vertex:Hve,worldpos_vertex:$ve,background_vert:Vve,background_frag:Gve,backgroundCube_vert:Wve,backgroundCube_frag:qve,cube_vert:Xve,cube_frag:Kve,depth_vert:Yve,depth_frag:Zve,distanceRGBA_vert:Qve,distanceRGBA_frag:Jve,equirect_vert:eye,equirect_frag:tye,linedashed_vert:nye,linedashed_frag:iye,meshbasic_vert:rye,meshbasic_frag:aye,meshlambert_vert:sye,meshlambert_frag:oye,meshmatcap_vert:lye,meshmatcap_frag:cye,meshnormal_vert:uye,meshnormal_frag:dye,meshphong_vert:fye,meshphong_frag:hye,meshphysical_vert:pye,meshphysical_frag:mye,meshtoon_vert:gye,meshtoon_frag:xye,points_vert:vye,points_frag:yye,shadow_vert:bye,shadow_frag:_ye,sprite_vert:Sye,sprite_frag:wye},yt={common:{diffuse:{value:new zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new dn}},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 dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new dn},normalScale:{value:new Xt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new dn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new dn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new dn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new dn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zt(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 zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0},uvTransform:{value:new dn}},sprite:{diffuse:{value:new zt(16777215)},opacity:{value:1},center:{value:new Xt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new dn},alphaMap:{value:null},alphaMapTransform:{value:new dn},alphaTest:{value:0}}},Da={basic:{uniforms:da([yt.common,yt.specularmap,yt.envmap,yt.aomap,yt.lightmap,yt.fog]),vertexShader:an.meshbasic_vert,fragmentShader:an.meshbasic_frag},lambert:{uniforms:da([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 zt(0)}}]),vertexShader:an.meshlambert_vert,fragmentShader:an.meshlambert_frag},phong:{uniforms:da([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 zt(0)},specular:{value:new zt(1118481)},shininess:{value:30}}]),vertexShader:an.meshphong_vert,fragmentShader:an.meshphong_frag},standard:{uniforms:da([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 zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag},toon:{uniforms:da([yt.common,yt.aomap,yt.lightmap,yt.emissivemap,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.gradientmap,yt.fog,yt.lights,{emissive:{value:new zt(0)}}]),vertexShader:an.meshtoon_vert,fragmentShader:an.meshtoon_frag},matcap:{uniforms:da([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,yt.fog,{matcap:{value:null}}]),vertexShader:an.meshmatcap_vert,fragmentShader:an.meshmatcap_frag},points:{uniforms:da([yt.points,yt.fog]),vertexShader:an.points_vert,fragmentShader:an.points_frag},dashed:{uniforms:da([yt.common,yt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:an.linedashed_vert,fragmentShader:an.linedashed_frag},depth:{uniforms:da([yt.common,yt.displacementmap]),vertexShader:an.depth_vert,fragmentShader:an.depth_frag},normal:{uniforms:da([yt.common,yt.bumpmap,yt.normalmap,yt.displacementmap,{opacity:{value:1}}]),vertexShader:an.meshnormal_vert,fragmentShader:an.meshnormal_frag},sprite:{uniforms:da([yt.sprite,yt.fog]),vertexShader:an.sprite_vert,fragmentShader:an.sprite_frag},background:{uniforms:{uvTransform:{value:new dn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:an.background_vert,fragmentShader:an.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:an.backgroundCube_vert,fragmentShader:an.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:an.cube_vert,fragmentShader:an.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:an.equirect_vert,fragmentShader:an.equirect_frag},distanceRGBA:{uniforms:da([yt.common,yt.displacementmap,{referencePosition:{value:new Te},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:an.distanceRGBA_vert,fragmentShader:an.distanceRGBA_frag},shadow:{uniforms:da([yt.lights,yt.fog,{color:{value:new zt(0)},opacity:{value:1}}]),vertexShader:an.shadow_vert,fragmentShader:an.shadow_frag}};Da.physical={uniforms:da([Da.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new dn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new dn},clearcoatNormalScale:{value:new Xt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new dn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new dn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new dn},sheen:{value:0},sheenColor:{value:new zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new dn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new dn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new dn},transmissionSamplerSize:{value:new Xt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new dn},attenuationDistance:{value:0},attenuationColor:{value:new zt(0)},specularColor:{value:new zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new dn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new dn},anisotropyVector:{value:new Xt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new dn}}]),vertexShader:an.meshphysical_vert,fragmentShader:an.meshphysical_frag};const Mb={r:0,b:0,g:0};function Mye(t,e,n,i,r,a,s){const o=new zt(0);let l=a===!0?0:1,c,u,f=null,m=0,g=null;function y(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?_(o,l):w&&w.isColor&&(_(w,1),M=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?i.buffers.color.setClear(0,0,0,1,s):C==="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===rw)?(u===void 0&&(u=new xo(new z0(1,1,1),new Yu({name:"BackgroundCubeMaterial",uniforms:Jp(Da.backgroundCube.uniforms),vertexShader:Da.backgroundCube.vertexShader,fragmentShader:Da.backgroundCube.fragmentShader,side:Ua,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(T,P,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),u.material.uniforms.envMap.value=w,u.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.toneMapped=$n.getTransfer(w.colorSpace)!==ii,(f!==w||m!==w.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,m=w.version,g=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null)):w&&w.isTexture&&(c===void 0&&(c=new xo(new uk(2,2),new Yu({name:"BackgroundMaterial",uniforms:Jp(Da.background.uniforms),vertexShader:Da.background.vertexShader,fragmentShader:Da.background.fragmentShader,side:Ku,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=$n.getTransfer(w.colorSpace)!==ii,w.matrixAutoUpdate===!0&&w.updateMatrix(),c.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||m!==w.version||g!==t.toneMapping)&&(c.material.needsUpdate=!0,f=w,m=w.version,g=t.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function _(v,x){v.getRGB(Mb,S7(t)),i.buffers.color.setClear(Mb.r,Mb.g,Mb.b,x,s)}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),l=x,_(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,_(o,l)},render:y}}function Eye(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,u=!1;function f(D,B,$,K,X){let Y=!1;if(s){const ee=_(K,$,B);c!==ee&&(c=ee,g(c.object)),Y=x(D,K,$,X),Y&&M(D,K,$,X)}else{const ee=B.wireframe===!0;(c.geometry!==K.id||c.program!==$.id||c.wireframe!==ee)&&(c.geometry=K.id,c.program=$.id,c.wireframe=ee,Y=!0)}X!==null&&n.update(X,t.ELEMENT_ARRAY_BUFFER),(Y||u)&&(u=!1,j(D,B,$,K),X!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(X).buffer))}function m(){return i.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function g(D){return i.isWebGL2?t.bindVertexArray(D):a.bindVertexArrayOES(D)}function y(D){return i.isWebGL2?t.deleteVertexArray(D):a.deleteVertexArrayOES(D)}function _(D,B,$){const K=$.wireframe===!0;let X=o[D.id];X===void 0&&(X={},o[D.id]=X);let Y=X[B.id];Y===void 0&&(Y={},X[B.id]=Y);let ee=Y[K];return ee===void 0&&(ee=v(m()),Y[K]=ee),ee}function v(D){const B=[],$=[],K=[];for(let X=0;X<r;X++)B[X]=0,$[X]=0,K[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:$,attributeDivisors:K,object:D,attributes:{},index:null}}function x(D,B,$,K){const X=c.attributes,Y=B.attributes;let ee=0;const z=$.getAttributes();for(const V in z)if(z[V].location>=0){const le=X[V];let ge=Y[V];if(ge===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(ge=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(ge=D.instanceColor)),le===void 0||le.attribute!==ge||ge&&le.data!==ge.data)return!0;ee++}return c.attributesNum!==ee||c.index!==K}function M(D,B,$,K){const X={},Y=B.attributes;let ee=0;const z=$.getAttributes();for(const V in z)if(z[V].location>=0){let le=Y[V];le===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(le=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(le=D.instanceColor));const ge={};ge.attribute=le,le&&le.data&&(ge.data=le.data),X[V]=ge,ee++}c.attributes=X,c.attributesNum=ee,c.index=K}function w(){const D=c.newAttributes;for(let B=0,$=D.length;B<$;B++)D[B]=0}function C(D){T(D,0)}function T(D,B){const $=c.newAttributes,K=c.enabledAttributes,X=c.attributeDivisors;$[D]=1,K[D]===0&&(t.enableVertexAttribArray(D),K[D]=1),X[D]!==B&&((i.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,B),X[D]=B)}function P(){const D=c.newAttributes,B=c.enabledAttributes;for(let $=0,K=B.length;$<K;$++)B[$]!==D[$]&&(t.disableVertexAttribArray($),B[$]=0)}function A(D,B,$,K,X,Y,ee){ee===!0?t.vertexAttribIPointer(D,B,$,X,Y):t.vertexAttribPointer(D,B,$,K,X,Y)}function j(D,B,$,K){if(i.isWebGL2===!1&&(D.isInstancedMesh||K.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const X=K.attributes,Y=$.getAttributes(),ee=B.defaultAttributeValues;for(const z in Y){const V=Y[z];if(V.location>=0){let re=X[z];if(re===void 0&&(z==="instanceMatrix"&&D.instanceMatrix&&(re=D.instanceMatrix),z==="instanceColor"&&D.instanceColor&&(re=D.instanceColor)),re!==void 0){const le=re.normalized,ge=re.itemSize,ie=n.get(re);if(ie===void 0)continue;const xe=ie.buffer,ke=ie.type,he=ie.bytesPerElement,we=i.isWebGL2===!0&&(ke===t.INT||ke===t.UNSIGNED_INT||re.gpuType===n7);if(re.isInterleavedBufferAttribute){const Ue=re.data,ue=Ue.stride,lt=re.offset;if(Ue.isInstancedInterleavedBuffer){for(let H=0;H<V.locationSize;H++)T(V.location+H,Ue.meshPerAttribute);D.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=Ue.meshPerAttribute*Ue.count)}else for(let H=0;H<V.locationSize;H++)C(V.location+H);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let H=0;H<V.locationSize;H++)A(V.location+H,ge/V.locationSize,ke,le,ue*he,(lt+ge/V.locationSize*H)*he,we)}else{if(re.isInstancedBufferAttribute){for(let Ue=0;Ue<V.locationSize;Ue++)T(V.location+Ue,re.meshPerAttribute);D.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Ue=0;Ue<V.locationSize;Ue++)C(V.location+Ue);t.bindBuffer(t.ARRAY_BUFFER,xe);for(let Ue=0;Ue<V.locationSize;Ue++)A(V.location+Ue,ge/V.locationSize,ke,le,ge*he,ge/V.locationSize*Ue*he,we)}}else if(ee!==void 0){const le=ee[z];if(le!==void 0)switch(le.length){case 2:t.vertexAttrib2fv(V.location,le);break;case 3:t.vertexAttrib3fv(V.location,le);break;case 4:t.vertexAttrib4fv(V.location,le);break;default:t.vertexAttrib1fv(V.location,le)}}}}P()}function N(){I();for(const D in o){const B=o[D];for(const $ in B){const K=B[$];for(const X in K)y(K[X].object),delete K[X];delete B[$]}delete o[D]}}function k(D){if(o[D.id]===void 0)return;const B=o[D.id];for(const $ in B){const K=B[$];for(const X in K)y(K[X].object),delete K[X];delete B[$]}delete o[D.id]}function F(D){for(const B in o){const $=o[B];if($[D.id]===void 0)continue;const K=$[D.id];for(const X in K)y(K[X].object),delete K[X];delete $[D.id]}}function I(){W(),u=!0,c!==l&&(c=l,g(c.object))}function W(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:f,reset:I,resetDefaultState:W,dispose:N,releaseStatesOfGeometry:k,releaseStatesOfProgram:F,initAttributes:w,enableAttribute:C,disableUnusedAttributes:P}}function Aye(t,e,n,i){const r=i.isWebGL2;let a;function s(u){a=u}function o(u,f){t.drawArrays(a,u,f),n.update(f,a,1)}function l(u,f,m){if(m===0)return;let g,y;if(r)g=t,y="drawArraysInstanced";else if(g=e.get("ANGLE_instanced_arrays"),y="drawArraysInstancedANGLE",g===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[y](a,u,f,m),n.update(f,a,m)}function c(u,f,m){if(m===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let y=0;y<m;y++)this.render(u[y],f[y]);else{g.multiDrawArraysWEBGL(a,u,0,f,0,m);let y=0;for(let _=0;_<m;_++)y+=f[_];n.update(y,a,1)}}this.setMode=s,this.render=o,this.renderInstances=l,this.renderMultiDraw=c}function Tye(t,e,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(A){if(A==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="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"),u=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_TEXTURE_SIZE),y=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),_=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=m>0,C=s||e.has("OES_texture_float"),T=w&&C,P=s?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:c,getMaxAnisotropy:r,getMaxPrecision:a,precision:o,logarithmicDepthBuffer:u,maxTextures:f,maxVertexTextures:m,maxTextureSize:g,maxCubemapSize:y,maxAttributes:_,maxVertexUniforms:v,maxVaryings:x,maxFragmentUniforms:M,vertexTextures:w,floatFragmentTextures:C,floatVertexTextures:T,maxSamples:P}}function Cye(t){const e=this;let n=null,i=0,r=!1,a=!1;const s=new bu,o=new dn,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,m){const g=f.length!==0||m||i!==0||r;return r=m,i=f.length,g},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,m){n=u(f,m,0)},this.setState=function(f,m,g){const y=f.clippingPlanes,_=f.clipIntersection,v=f.clipShadows,x=t.get(f);if(!r||y===null||y.length===0||a&&!v)a?u(null):c();else{const M=a?0:i,w=M*4;let C=x.clippingState||null;l.value=C,C=u(y,m,w,g);for(let T=0;T!==w;++T)C[T]=n[T];x.clippingState=C,this.numIntersection=_?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 u(f,m,g,y){const _=f!==null?f.length:0;let v=null;if(_!==0){if(v=l.value,y!==!0||v===null){const x=g+_*4,M=m.matrixWorldInverse;o.getNormalMatrix(M),(v===null||v.length<x)&&(v=new Float32Array(x));for(let w=0,C=g;w!==_;++w,C+=4)s.copy(f[w]).applyMatrix4(M,o),s.normal.toArray(v,C),v[C+3]=s.constant}l.value=v,l.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,v}}function Nye(t){let e=new WeakMap;function n(s,o){return o===M3?s.mapping=Yp:o===E3&&(s.mapping=Zp),s}function i(s){if(s&&s.isTexture){const o=s.mapping;if(o===M3||o===E3)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 Bxe(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 Rye extends w7{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,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,o-=u*this.view.offsetY,l=o-u*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 yp=4,s5=[.125,.215,.35,.446,.526,.582],Wd=20,FT=new Rye,o5=new zt;let zT=null,BT=0,HT=0;const Fd=(1+Math.sqrt(5))/2,rp=1/Fd,l5=[new Te(1,1,1),new Te(-1,1,1),new Te(1,1,-1),new Te(-1,1,-1),new Te(0,Fd,rp),new Te(0,Fd,-rp),new Te(rp,0,Fd),new Te(-rp,0,Fd),new Te(Fd,rp,0),new Te(-Fd,rp,0)];class c5{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){zT=this._renderer.getRenderTarget(),BT=this._renderer.getActiveCubeFace(),HT=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=f5(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=d5(),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(zT,BT,HT),e.scissorTest=!1,Eb(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Yp||e.mapping===Zp?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zT=this._renderer.getRenderTarget(),BT=this._renderer.getActiveCubeFace(),HT=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:js,minFilter:js,generateMipmaps:!1,type:t0,format:Us,colorSpace:xc,depthBuffer:!1},r=u5(e,n,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=u5(e,n,i);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Pye(a)),this._blurMaterial=kye(a,e,n)}return r}_compileMaterial(e){const n=new xo(this._lodPlanes[0],e);this._renderer.compile(n,FT)}_sceneToCubeUV(e,n,i,r){const o=new as(90,1,n,i),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,f=u.autoClear,m=u.toneMapping;u.getClearColor(o5),u.toneMapping=zu,u.autoClear=!1;const g=new y7({name:"PMREM.Background",side:Ua,depthWrite:!1,depthTest:!1}),y=new xo(new z0,g);let _=!1;const v=e.background;v?v.isColor&&(g.color.copy(v),e.background=null,_=!0):(g.color.copy(o5),_=!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;Eb(r,M*w,x>2?w:0,w,w),u.setRenderTarget(r),_&&u.render(y,o),u.render(e,o)}y.geometry.dispose(),y.material.dispose(),u.toneMapping=m,u.autoClear=f,e.background=v}_textureToCubeUV(e,n){const i=this._renderer,r=e.mapping===Yp||e.mapping===Zp;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=f5()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=d5());const a=r?this._cubemapMaterial:this._equirectMaterial,s=new xo(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=e;const l=this._cubeSize;Eb(n,0,0,3*l,2*l),i.setRenderTarget(n),i.render(s,FT)}_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=l5[(r-1)%l5.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 u=3,f=new xo(this._lodPlanes[r],c),m=c.uniforms,g=this._sizeLods[i]-1,y=isFinite(a)?Math.PI/(2*g):2*Math.PI/(2*Wd-1),_=a/y,v=isFinite(a)?1+Math.floor(u*_):Wd;v>Wd&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Wd}`);const x=[];let M=0;for(let A=0;A<Wd;++A){const j=A/_,N=Math.exp(-j*j/2);x.push(N),A===0?M+=N:A<v&&(M+=2*N)}for(let A=0;A<x.length;A++)x[A]=x[A]/M;m.envMap.value=e.texture,m.samples.value=v,m.weights.value=x,m.latitudinal.value=s==="latitudinal",o&&(m.poleAxis.value=o);const{_lodMax:w}=this;m.dTheta.value=y,m.mipInt.value=w-i;const C=this._sizeLods[r],T=3*C*(r>w-yp?r-w+yp:0),P=4*(this._cubeSize-C);Eb(n,T,P,3*C,2*C),l.setRenderTarget(n),l.render(f,FT)}}function Pye(t){const e=[],n=[],i=[];let r=t;const a=t-yp+1+s5.length;for(let s=0;s<a;s++){const o=Math.pow(2,r);n.push(o);let l=1/o;s>t-yp?l=s5[s-t+yp-1]:s===0&&(l=0),i.push(l);const c=1/(o-2),u=-c,f=1+c,m=[u,u,f,u,f,f,u,u,f,f,u,f],g=6,y=6,_=3,v=2,x=1,M=new Float32Array(_*y*g),w=new Float32Array(v*y*g),C=new Float32Array(x*y*g);for(let P=0;P<g;P++){const A=P%3*2/3-1,j=P>2?0:-1,N=[A,j,0,A+2/3,j,0,A+2/3,j+1,0,A,j,0,A+2/3,j+1,0,A,j+1,0];M.set(N,_*y*P),w.set(m,v*y*P);const k=[P,P,P,P,P,P];C.set(k,x*y*P)}const T=new aa;T.setAttribute("position",new ds(M,_)),T.setAttribute("uv",new ds(w,v)),T.setAttribute("faceIndex",new ds(C,x)),e.push(T),r>yp&&r--}return{lodPlanes:e,sizeLods:n,sigmas:i}}function u5(t,e,n){const i=new Tf(t,e,n);return i.texture.mapping=rw,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Eb(t,e,n,i,r){t.viewport.set(e,n,i,r),t.scissor.set(e,n,i,r)}function kye(t,e,n){const i=new Float32Array(Wd),r=new Te(0,1,0);return new Yu({name:"SphericalGaussianBlur",defines:{n:Wd,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:dk(),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:Fu,depthTest:!1,depthWrite:!1})}function d5(){return new Yu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:dk(),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:Fu,depthTest:!1,depthWrite:!1})}function f5(){return new Yu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:dk(),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:Fu,depthTest:!1,depthWrite:!1})}function dk(){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 Dye(t){let e=new WeakMap,n=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===M3||l===E3,u=l===Yp||l===Zp;if(c||u)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let f=e.get(o);return n===null&&(n=new c5(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||u&&f&&r(f)){n===null&&(n=new c5(t));const m=c?n.fromEquirectangular(o):n.fromCubemap(o);return e.set(o,m),o.addEventListener("dispose",a),m.texture}else return null}}}return o}function r(o){let l=0;const c=6;for(let u=0;u<c;u++)o[u]!==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 Oye(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 Lye(t,e,n,i){const r={},a=new WeakMap;function s(f){const m=f.target;m.index!==null&&e.remove(m.index);for(const y in m.attributes)e.remove(m.attributes[y]);for(const y in m.morphAttributes){const _=m.morphAttributes[y];for(let v=0,x=_.length;v<x;v++)e.remove(_[v])}m.removeEventListener("dispose",s),delete r[m.id];const g=a.get(m);g&&(e.remove(g),a.delete(m)),i.releaseStatesOfGeometry(m),m.isInstancedBufferGeometry===!0&&delete m._maxInstanceCount,n.memory.geometries--}function o(f,m){return r[m.id]===!0||(m.addEventListener("dispose",s),r[m.id]=!0,n.memory.geometries++),m}function l(f){const m=f.attributes;for(const y in m)e.update(m[y],t.ARRAY_BUFFER);const g=f.morphAttributes;for(const y in g){const _=g[y];for(let v=0,x=_.length;v<x;v++)e.update(_[v],t.ARRAY_BUFFER)}}function c(f){const m=[],g=f.index,y=f.attributes.position;let _=0;if(g!==null){const M=g.array;_=g.version;for(let w=0,C=M.length;w<C;w+=3){const T=M[w+0],P=M[w+1],A=M[w+2];m.push(T,P,P,A,A,T)}}else if(y!==void 0){const M=y.array;_=y.version;for(let w=0,C=M.length/3-1;w<C;w+=3){const T=w+0,P=w+1,A=w+2;m.push(T,P,P,A,A,T)}}else return;const v=new(h7(m)?_7:b7)(m,1);v.version=_;const x=a.get(f);x&&e.remove(x),a.set(f,v)}function u(f){const m=a.get(f);if(m){const g=f.index;g!==null&&m.version<g.version&&c(f)}else c(f);return a.get(f)}return{get:o,update:l,getWireframeAttribute:u}}function Iye(t,e,n,i){const r=i.isWebGL2;let a;function s(g){a=g}let o,l;function c(g){o=g.type,l=g.bytesPerElement}function u(g,y){t.drawElements(a,y,o,g*l),n.update(y,a,1)}function f(g,y,_){if(_===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,y,o,g*l,_),n.update(y,a,_)}function m(g,y,_){if(_===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let x=0;x<_;x++)this.render(g[x]/l,y[x]);else{v.multiDrawElementsWEBGL(a,y,0,o,g,0,_);let x=0;for(let M=0;M<_;M++)x+=y[M];n.update(x,a,1)}}this.setMode=s,this.setIndex=c,this.render=u,this.renderInstances=f,this.renderMultiDraw=m}function jye(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 Uye(t,e){return t[0]-e[0]}function Fye(t,e){return Math.abs(e[1])-Math.abs(t[1])}function zye(t,e,n){const i={},r=new Float32Array(8),a=new WeakMap,s=new Gn,o=[];for(let c=0;c<8;c++)o[c]=[c,0];function l(c,u,f){const m=c.morphTargetInfluences;if(e.isWebGL2===!0){const y=u.morphAttributes.position||u.morphAttributes.normal||u.morphAttributes.color,_=y!==void 0?y.length:0;let v=a.get(u);if(v===void 0||v.count!==_){let B=function(){W.dispose(),a.delete(u),u.removeEventListener("dispose",B)};var g=B;v!==void 0&&v.texture.dispose();const w=u.morphAttributes.position!==void 0,C=u.morphAttributes.normal!==void 0,T=u.morphAttributes.color!==void 0,P=u.morphAttributes.position||[],A=u.morphAttributes.normal||[],j=u.morphAttributes.color||[];let N=0;w===!0&&(N=1),C===!0&&(N=2),T===!0&&(N=3);let k=u.attributes.position.count*N,F=1;k>e.maxTextureSize&&(F=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const I=new Float32Array(k*F*4*_),W=new g7(I,k,F,_);W.type=ec,W.needsUpdate=!0;const D=N*4;for(let $=0;$<_;$++){const K=P[$],X=A[$],Y=j[$],ee=k*F*4*$;for(let z=0;z<K.count;z++){const V=z*D;w===!0&&(s.fromBufferAttribute(K,z),I[ee+V+0]=s.x,I[ee+V+1]=s.y,I[ee+V+2]=s.z,I[ee+V+3]=0),C===!0&&(s.fromBufferAttribute(X,z),I[ee+V+4]=s.x,I[ee+V+5]=s.y,I[ee+V+6]=s.z,I[ee+V+7]=0),T===!0&&(s.fromBufferAttribute(Y,z),I[ee+V+8]=s.x,I[ee+V+9]=s.y,I[ee+V+10]=s.z,I[ee+V+11]=Y.itemSize===4?s.w:1)}}v={count:_,texture:W,size:new Xt(k,F)},a.set(u,v),u.addEventListener("dispose",B)}let x=0;for(let w=0;w<m.length;w++)x+=m[w];const M=u.morphTargetsRelative?1:1-x;f.getUniforms().setValue(t,"morphTargetBaseInfluence",M),f.getUniforms().setValue(t,"morphTargetInfluences",m),f.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const y=m===void 0?0:m.length;let _=i[u.id];if(_===void 0||_.length!==y){_=[];for(let C=0;C<y;C++)_[C]=[C,0];i[u.id]=_}for(let C=0;C<y;C++){const T=_[C];T[0]=C,T[1]=m[C]}_.sort(Fye);for(let C=0;C<8;C++)C<y&&_[C][1]?(o[C][0]=_[C][0],o[C][1]=_[C][1]):(o[C][0]=Number.MAX_SAFE_INTEGER,o[C][1]=0);o.sort(Uye);const v=u.morphAttributes.position,x=u.morphAttributes.normal;let M=0;for(let C=0;C<8;C++){const T=o[C],P=T[0],A=T[1];P!==Number.MAX_SAFE_INTEGER&&A?(v&&u.getAttribute("morphTarget"+C)!==v[P]&&u.setAttribute("morphTarget"+C,v[P]),x&&u.getAttribute("morphNormal"+C)!==x[P]&&u.setAttribute("morphNormal"+C,x[P]),r[C]=A,M+=A):(v&&u.hasAttribute("morphTarget"+C)===!0&&u.deleteAttribute("morphTarget"+C),x&&u.hasAttribute("morphNormal"+C)===!0&&u.deleteAttribute("morphNormal"+C),r[C]=0)}const w=u.morphTargetsRelative?1:1-M;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",r)}}return{update:l}}function Bye(t,e,n,i){let r=new WeakMap;function a(l){const c=i.render.frame,u=l.geometry,f=e.get(l,u);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 m=l.skeleton;r.get(m)!==c&&(m.update(),r.set(m,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 A7 extends Fa{constructor(e,n,i,r,a,s,o,l,c,u){if(u=u!==void 0?u:sf,u!==sf&&u!==Qp)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&u===sf&&(i=ku),i===void 0&&u===Qp&&(i=af),super(null,r,a,s,o,l,u,i,c),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=o!==void 0?o:Hr,this.minFilter=l!==void 0?l:Hr,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 T7=new Fa,C7=new A7(1,1);C7.compareFunction=d7;const N7=new g7,R7=new Exe,P7=new M7,h5=[],p5=[],m5=new Float32Array(16),g5=new Float32Array(9),x5=new Float32Array(4);function Tm(t,e,n){const i=t[0];if(i<=0||i>0)return t;const r=e*n;let a=h5[r];if(a===void 0&&(a=new Float32Array(r),h5[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 lr(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 cr(t,e){for(let n=0,i=e.length;n<i;n++)t[n]=e[n]}function ow(t,e){let n=p5[e];n===void 0&&(n=new Int32Array(e),p5[e]=n);for(let i=0;i!==e;++i)n[i]=t.allocateTextureUnit();return n}function Hye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $ye(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(lr(n,e))return;t.uniform2fv(this.addr,e),cr(n,e)}}function Vye(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(lr(n,e))return;t.uniform3fv(this.addr,e),cr(n,e)}}function Gye(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(lr(n,e))return;t.uniform4fv(this.addr,e),cr(n,e)}}function Wye(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(lr(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),cr(n,e)}else{if(lr(n,i))return;x5.set(i),t.uniformMatrix2fv(this.addr,!1,x5),cr(n,i)}}function qye(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(lr(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),cr(n,e)}else{if(lr(n,i))return;g5.set(i),t.uniformMatrix3fv(this.addr,!1,g5),cr(n,i)}}function Xye(t,e){const n=this.cache,i=e.elements;if(i===void 0){if(lr(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),cr(n,e)}else{if(lr(n,i))return;m5.set(i),t.uniformMatrix4fv(this.addr,!1,m5),cr(n,i)}}function Kye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Yye(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(lr(n,e))return;t.uniform2iv(this.addr,e),cr(n,e)}}function Zye(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(lr(n,e))return;t.uniform3iv(this.addr,e),cr(n,e)}}function Qye(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(lr(n,e))return;t.uniform4iv(this.addr,e),cr(n,e)}}function Jye(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function ebe(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(lr(n,e))return;t.uniform2uiv(this.addr,e),cr(n,e)}}function tbe(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(lr(n,e))return;t.uniform3uiv(this.addr,e),cr(n,e)}}function nbe(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(lr(n,e))return;t.uniform4uiv(this.addr,e),cr(n,e)}}function ibe(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?C7:T7;n.setTexture2D(e||a,r)}function rbe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(e||R7,r)}function abe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(e||P7,r)}function sbe(t,e,n){const i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(t.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(e||N7,r)}function obe(t){switch(t){case 5126:return Hye;case 35664:return $ye;case 35665:return Vye;case 35666:return Gye;case 35674:return Wye;case 35675:return qye;case 35676:return Xye;case 5124:case 35670:return Kye;case 35667:case 35671:return Yye;case 35668:case 35672:return Zye;case 35669:case 35673:return Qye;case 5125:return Jye;case 36294:return ebe;case 36295:return tbe;case 36296:return nbe;case 35678:case 36198:case 36298:case 36306:case 35682:return ibe;case 35679:case 36299:case 36307:return rbe;case 35680:case 36300:case 36308:case 36293:return abe;case 36289:case 36303:case 36311:case 36292:return sbe}}function lbe(t,e){t.uniform1fv(this.addr,e)}function cbe(t,e){const n=Tm(e,this.size,2);t.uniform2fv(this.addr,n)}function ube(t,e){const n=Tm(e,this.size,3);t.uniform3fv(this.addr,n)}function dbe(t,e){const n=Tm(e,this.size,4);t.uniform4fv(this.addr,n)}function fbe(t,e){const n=Tm(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function hbe(t,e){const n=Tm(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function pbe(t,e){const n=Tm(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function mbe(t,e){t.uniform1iv(this.addr,e)}function gbe(t,e){t.uniform2iv(this.addr,e)}function xbe(t,e){t.uniform3iv(this.addr,e)}function vbe(t,e){t.uniform4iv(this.addr,e)}function ybe(t,e){t.uniform1uiv(this.addr,e)}function bbe(t,e){t.uniform2uiv(this.addr,e)}function _be(t,e){t.uniform3uiv(this.addr,e)}function Sbe(t,e){t.uniform4uiv(this.addr,e)}function wbe(t,e,n){const i=this.cache,r=e.length,a=ow(n,r);lr(i,a)||(t.uniform1iv(this.addr,a),cr(i,a));for(let s=0;s!==r;++s)n.setTexture2D(e[s]||T7,a[s])}function Mbe(t,e,n){const i=this.cache,r=e.length,a=ow(n,r);lr(i,a)||(t.uniform1iv(this.addr,a),cr(i,a));for(let s=0;s!==r;++s)n.setTexture3D(e[s]||R7,a[s])}function Ebe(t,e,n){const i=this.cache,r=e.length,a=ow(n,r);lr(i,a)||(t.uniform1iv(this.addr,a),cr(i,a));for(let s=0;s!==r;++s)n.setTextureCube(e[s]||P7,a[s])}function Abe(t,e,n){const i=this.cache,r=e.length,a=ow(n,r);lr(i,a)||(t.uniform1iv(this.addr,a),cr(i,a));for(let s=0;s!==r;++s)n.setTexture2DArray(e[s]||N7,a[s])}function Tbe(t){switch(t){case 5126:return lbe;case 35664:return cbe;case 35665:return ube;case 35666:return dbe;case 35674:return fbe;case 35675:return hbe;case 35676:return pbe;case 5124:case 35670:return mbe;case 35667:case 35671:return gbe;case 35668:case 35672:return xbe;case 35669:case 35673:return vbe;case 5125:return ybe;case 36294:return bbe;case 36295:return _be;case 36296:return Sbe;case 35678:case 36198:case 36298:case 36306:case 35682:return wbe;case 35679:case 36299:case 36307:return Mbe;case 35680:case 36300:case 36308:case 36293:return Ebe;case 36289:case 36303:case 36311:case 36292:return Abe}}class Cbe{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.setValue=obe(n.type)}}class Nbe{constructor(e,n,i){this.id=e,this.addr=i,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Tbe(n.type)}}class Rbe{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 $T=/(\w+)(\])?(\[|\.)?/g;function v5(t,e){t.seq.push(e),t.map[e.id]=e}function Pbe(t,e,n){const i=t.name,r=i.length;for($T.lastIndex=0;;){const a=$T.exec(i),s=$T.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&s+2===r){v5(n,c===void 0?new Cbe(o,t,e):new Nbe(o,t,e));break}else{let f=n.map[o];f===void 0&&(f=new Rbe(o),v5(n,f)),n=f}}}class w_{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);Pbe(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 y5(t,e,n){const i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),i}const kbe=37297;let Dbe=0;function Obe(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 Lbe(t){const e=$n.getPrimaries($n.workingColorSpace),n=$n.getPrimaries(t);let i;switch(e===n?i="":e===e1&&n===J_?i="LinearDisplayP3ToLinearSRGB":e===J_&&n===e1&&(i="LinearSRGBToLinearDisplayP3"),t){case xc:case aw:return[i,"LinearTransferOETF"];case $r:case sk:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[i,"LinearTransferOETF"]}}function b5(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+`
- `+Obe(t.getShaderSource(e),s)}else return r}function Ibe(t,e){const n=Lbe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function jbe(t,e){let n;switch(e){case Ige:n="Linear";break;case jge:n="Reinhard";break;case Uge:n="OptimizedCineon";break;case Fge:n="ACESFilmic";break;case zge:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Ube(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(cx).join(`
- `)}function Fbe(t){const e=[];for(const n in t){const i=t[n];i!==!1&&e.push("#define "+n+" "+i)}return e.join(`
- `)}function zbe(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 cx(t){return t!==""}function _5(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 S5(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Bbe=/^[ \t]*#include +<([\w\d./]+)>/gm;function P3(t){return t.replace(Bbe,$be)}const Hbe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function $be(t,e){let n=an[e];if(n===void 0){const i=Hbe.get(e);if(i!==void 0)n=an[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 P3(n)}const Vbe=/#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 w5(t){return t.replace(Vbe,Gbe)}function Gbe(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 M5(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 Wbe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===e7?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===uge?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===$l&&(e="SHADOWMAP_TYPE_VSM"),e}function qbe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Yp:case Zp:e="ENVMAP_TYPE_CUBE";break;case rw:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Xbe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Zp:e="ENVMAP_MODE_REFRACTION";break}return e}function Kbe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case rk:e="ENVMAP_BLENDING_MULTIPLY";break;case Oge:e="ENVMAP_BLENDING_MIX";break;case Lge:e="ENVMAP_BLENDING_ADD";break}return e}function Ybe(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 Zbe(t,e,n,i){const r=t.getContext(),a=n.defines;let s=n.vertexShader,o=n.fragmentShader;const l=Wbe(n),c=qbe(n),u=Xbe(n),f=Kbe(n),m=Ybe(n),g=n.isWebGL2?"":Ube(n),y=Fbe(a),_=r.createProgram();let v,x,M=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(cx).join(`
- `),v.length>0&&(v+=`
- `),x=[g,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y].filter(cx).join(`
- `),x.length>0&&(x+=`
- `)):(v=[M5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,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 "+u:"",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(cx).join(`
- `),x=[g,M5(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,y,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 "+u:"",n.envMap?"#define "+f:"",m?"#define CUBEUV_TEXEL_WIDTH "+m.texelWidth:"",m?"#define CUBEUV_TEXEL_HEIGHT "+m.texelHeight:"",m?"#define CUBEUV_MAX_MIP "+m.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!==zu?"#define TONE_MAPPING":"",n.toneMapping!==zu?an.tonemapping_pars_fragment:"",n.toneMapping!==zu?jbe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",an.colorspace_pars_fragment,Ibe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(cx).join(`
- `)),s=P3(s),s=_5(s,n),s=S5(s,n),o=P3(o),o=_5(o,n),o=S5(o,n),s=w5(s),o=w5(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===Hz?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Hz?"":"#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,C=M+x+o,T=y5(r,r.VERTEX_SHADER,w),P=y5(r,r.FRAGMENT_SHADER,C);r.attachShader(_,T),r.attachShader(_,P),n.index0AttributeName!==void 0?r.bindAttribLocation(_,0,n.index0AttributeName):n.morphTargets===!0&&r.bindAttribLocation(_,0,"position"),r.linkProgram(_);function A(F){if(t.debug.checkShaderErrors){const I=r.getProgramInfoLog(_).trim(),W=r.getShaderInfoLog(T).trim(),D=r.getShaderInfoLog(P).trim();let B=!0,$=!0;if(r.getProgramParameter(_,r.LINK_STATUS)===!1)if(B=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(r,_,T,P);else{const K=b5(r,T,"vertex"),X=b5(r,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(_,r.VALIDATE_STATUS)+`
- Program Info Log: `+I+`
- `+K+`
- `+X)}else I!==""?console.warn("THREE.WebGLProgram: Program Info Log:",I):(W===""||D==="")&&($=!1);$&&(F.diagnostics={runnable:B,programLog:I,vertexShader:{log:W,prefix:v},fragmentShader:{log:D,prefix:x}})}r.deleteShader(T),r.deleteShader(P),j=new w_(r,_),N=zbe(r,_)}let j;this.getUniforms=function(){return j===void 0&&A(this),j};let N;this.getAttributes=function(){return N===void 0&&A(this),N};let k=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return k===!1&&(k=r.getProgramParameter(_,kbe)),k},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(_),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Dbe++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=T,this.fragmentShader=P,this}let Qbe=0;class Jbe{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 e_e(e),n.set(e,i)),i}}class e_e{constructor(e){this.id=Qbe++,this.code=e,this.usedTimes=0}}function t_e(t,e,n,i,r,a,s){const o=new x7,l=new Jbe,c=[],u=r.isWebGL2,f=r.logarithmicDepthBuffer,m=r.vertexTextures;let g=r.precision;const y={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 _(N){return N===0?"uv":`uv${N}`}function v(N,k,F,I,W){const D=I.fog,B=W.geometry,$=N.isMeshStandardMaterial?I.environment:null,K=(N.isMeshStandardMaterial?n:e).get(N.envMap||$),X=K&&K.mapping===rw?K.image.height:null,Y=y[N.type];N.precision!==null&&(g=r.getMaxPrecision(N.precision),g!==N.precision&&console.warn("THREE.WebGLProgram.getParameters:",N.precision,"not supported, using",g,"instead."));const ee=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,z=ee!==void 0?ee.length:0;let V=0;B.morphAttributes.position!==void 0&&(V=1),B.morphAttributes.normal!==void 0&&(V=2),B.morphAttributes.color!==void 0&&(V=3);let re,le,ge,ie;if(Y){const ln=Da[Y];re=ln.vertexShader,le=ln.fragmentShader}else re=N.vertexShader,le=N.fragmentShader,l.update(N),ge=l.getVertexShaderID(N),ie=l.getFragmentShaderID(N);const xe=t.getRenderTarget(),ke=W.isInstancedMesh===!0,he=W.isBatchedMesh===!0,we=!!N.map,Ue=!!N.matcap,ue=!!K,lt=!!N.aoMap,H=!!N.lightMap,q=!!N.bumpMap,oe=!!N.normalMap,Z=!!N.displacementMap,Q=!!N.emissiveMap,se=!!N.metalnessMap,Ce=!!N.roughnessMap,Ee=N.anisotropy>0,ne=N.clearcoat>0,U=N.iridescence>0,L=N.sheen>0,J=N.transmission>0,me=Ee&&!!N.anisotropyMap,ye=ne&&!!N.clearcoatMap,pe=ne&&!!N.clearcoatNormalMap,Qe=ne&&!!N.clearcoatRoughnessMap,Le=U&&!!N.iridescenceMap,Xe=U&&!!N.iridescenceThicknessMap,st=L&&!!N.sheenColorMap,Ie=L&&!!N.sheenRoughnessMap,Pe=!!N.specularMap,pt=!!N.specularColorMap,it=!!N.specularIntensityMap,nt=J&&!!N.transmissionMap,dt=J&&!!N.thicknessMap,de=!!N.gradientMap,rt=!!N.alphaMap,fe=N.alphaTest>0,Oe=!!N.alphaHash,Me=!!N.extensions,ve=!!B.attributes.uv1,Be=!!B.attributes.uv2,ct=!!B.attributes.uv3;let bt=zu;return N.toneMapped&&(xe===null||xe.isXRRenderTarget===!0)&&(bt=t.toneMapping),{isWebGL2:u,shaderID:Y,shaderType:N.type,shaderName:N.name,vertexShader:re,fragmentShader:le,defines:N.defines,customVertexShaderID:ge,customFragmentShaderID:ie,isRawShaderMaterial:N.isRawShaderMaterial===!0,glslVersion:N.glslVersion,precision:g,batching:he,instancing:ke,instancingColor:ke&&W.instanceColor!==null,supportsVertexTextures:m,outputColorSpace:xe===null?t.outputColorSpace:xe.isXRRenderTarget===!0?xe.texture.colorSpace:xc,map:we,matcap:Ue,envMap:ue,envMapMode:ue&&K.mapping,envMapCubeUVHeight:X,aoMap:lt,lightMap:H,bumpMap:q,normalMap:oe,displacementMap:m&&Z,emissiveMap:Q,normalMapObjectSpace:oe&&N.normalMapType===Qge,normalMapTangentSpace:oe&&N.normalMapType===u7,metalnessMap:se,roughnessMap:Ce,anisotropy:Ee,anisotropyMap:me,clearcoat:ne,clearcoatMap:ye,clearcoatNormalMap:pe,clearcoatRoughnessMap:Qe,iridescence:U,iridescenceMap:Le,iridescenceThicknessMap:Xe,sheen:L,sheenColorMap:st,sheenRoughnessMap:Ie,specularMap:Pe,specularColorMap:pt,specularIntensityMap:it,transmission:J,transmissionMap:nt,thicknessMap:dt,gradientMap:de,opaque:N.transparent===!1&&N.blending===Cp,alphaMap:rt,alphaTest:fe,alphaHash:Oe,combine:N.combine,mapUv:we&&_(N.map.channel),aoMapUv:lt&&_(N.aoMap.channel),lightMapUv:H&&_(N.lightMap.channel),bumpMapUv:q&&_(N.bumpMap.channel),normalMapUv:oe&&_(N.normalMap.channel),displacementMapUv:Z&&_(N.displacementMap.channel),emissiveMapUv:Q&&_(N.emissiveMap.channel),metalnessMapUv:se&&_(N.metalnessMap.channel),roughnessMapUv:Ce&&_(N.roughnessMap.channel),anisotropyMapUv:me&&_(N.anisotropyMap.channel),clearcoatMapUv:ye&&_(N.clearcoatMap.channel),clearcoatNormalMapUv:pe&&_(N.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Qe&&_(N.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&_(N.iridescenceMap.channel),iridescenceThicknessMapUv:Xe&&_(N.iridescenceThicknessMap.channel),sheenColorMapUv:st&&_(N.sheenColorMap.channel),sheenRoughnessMapUv:Ie&&_(N.sheenRoughnessMap.channel),specularMapUv:Pe&&_(N.specularMap.channel),specularColorMapUv:pt&&_(N.specularColorMap.channel),specularIntensityMapUv:it&&_(N.specularIntensityMap.channel),transmissionMapUv:nt&&_(N.transmissionMap.channel),thicknessMapUv:dt&&_(N.thicknessMap.channel),alphaMapUv:rt&&_(N.alphaMap.channel),vertexTangents:!!B.attributes.tangent&&(oe||Ee),vertexColors:N.vertexColors,vertexAlphas:N.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,vertexUv1s:ve,vertexUv2s:Be,vertexUv3s:ct,pointsUvs:W.isPoints===!0&&!!B.attributes.uv&&(we||rt),fog:!!D,useFog:N.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:N.flatShading===!0,sizeAttenuation:N.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:W.isSkinnedMesh===!0,morphTargets:B.morphAttributes.position!==void 0,morphNormals:B.morphAttributes.normal!==void 0,morphColors:B.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:V,numDirLights:k.directional.length,numPointLights:k.point.length,numSpotLights:k.spot.length,numSpotLightMaps:k.spotLightMap.length,numRectAreaLights:k.rectArea.length,numHemiLights:k.hemi.length,numDirLightShadows:k.directionalShadowMap.length,numPointLightShadows:k.pointShadowMap.length,numSpotLightShadows:k.spotShadowMap.length,numSpotLightShadowsWithMaps:k.numSpotLightShadowsWithMaps,numLightProbes:k.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:N.dithering,shadowMapEnabled:t.shadowMap.enabled&&F.length>0,shadowMapType:t.shadowMap.type,toneMapping:bt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:we&&N.map.isVideoTexture===!0&&$n.getTransfer(N.map.colorSpace)===ii,premultipliedAlpha:N.premultipliedAlpha,doubleSided:N.side===Xl,flipSided:N.side===Ua,useDepthPacking:N.depthPacking>=0,depthPacking:N.depthPacking||0,index0AttributeName:N.index0AttributeName,extensionDerivatives:Me&&N.extensions.derivatives===!0,extensionFragDepth:Me&&N.extensions.fragDepth===!0,extensionDrawBuffers:Me&&N.extensions.drawBuffers===!0,extensionShaderTextureLOD:Me&&N.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:N.customProgramCacheKey()}}function x(N){const k=[];if(N.shaderID?k.push(N.shaderID):(k.push(N.customVertexShaderID),k.push(N.customFragmentShaderID)),N.defines!==void 0)for(const F in N.defines)k.push(F),k.push(N.defines[F]);return N.isRawShaderMaterial===!1&&(M(k,N),w(k,N),k.push(t.outputColorSpace)),k.push(N.customProgramCacheKey),k.join()}function M(N,k){N.push(k.precision),N.push(k.outputColorSpace),N.push(k.envMapMode),N.push(k.envMapCubeUVHeight),N.push(k.mapUv),N.push(k.alphaMapUv),N.push(k.lightMapUv),N.push(k.aoMapUv),N.push(k.bumpMapUv),N.push(k.normalMapUv),N.push(k.displacementMapUv),N.push(k.emissiveMapUv),N.push(k.metalnessMapUv),N.push(k.roughnessMapUv),N.push(k.anisotropyMapUv),N.push(k.clearcoatMapUv),N.push(k.clearcoatNormalMapUv),N.push(k.clearcoatRoughnessMapUv),N.push(k.iridescenceMapUv),N.push(k.iridescenceThicknessMapUv),N.push(k.sheenColorMapUv),N.push(k.sheenRoughnessMapUv),N.push(k.specularMapUv),N.push(k.specularColorMapUv),N.push(k.specularIntensityMapUv),N.push(k.transmissionMapUv),N.push(k.thicknessMapUv),N.push(k.combine),N.push(k.fogExp2),N.push(k.sizeAttenuation),N.push(k.morphTargetsCount),N.push(k.morphAttributeCount),N.push(k.numDirLights),N.push(k.numPointLights),N.push(k.numSpotLights),N.push(k.numSpotLightMaps),N.push(k.numHemiLights),N.push(k.numRectAreaLights),N.push(k.numDirLightShadows),N.push(k.numPointLightShadows),N.push(k.numSpotLightShadows),N.push(k.numSpotLightShadowsWithMaps),N.push(k.numLightProbes),N.push(k.shadowMapType),N.push(k.toneMapping),N.push(k.numClippingPlanes),N.push(k.numClipIntersection),N.push(k.depthPacking)}function w(N,k){o.disableAll(),k.isWebGL2&&o.enable(0),k.supportsVertexTextures&&o.enable(1),k.instancing&&o.enable(2),k.instancingColor&&o.enable(3),k.matcap&&o.enable(4),k.envMap&&o.enable(5),k.normalMapObjectSpace&&o.enable(6),k.normalMapTangentSpace&&o.enable(7),k.clearcoat&&o.enable(8),k.iridescence&&o.enable(9),k.alphaTest&&o.enable(10),k.vertexColors&&o.enable(11),k.vertexAlphas&&o.enable(12),k.vertexUv1s&&o.enable(13),k.vertexUv2s&&o.enable(14),k.vertexUv3s&&o.enable(15),k.vertexTangents&&o.enable(16),k.anisotropy&&o.enable(17),k.alphaHash&&o.enable(18),k.batching&&o.enable(19),N.push(o.mask),o.disableAll(),k.fog&&o.enable(0),k.useFog&&o.enable(1),k.flatShading&&o.enable(2),k.logarithmicDepthBuffer&&o.enable(3),k.skinning&&o.enable(4),k.morphTargets&&o.enable(5),k.morphNormals&&o.enable(6),k.morphColors&&o.enable(7),k.premultipliedAlpha&&o.enable(8),k.shadowMapEnabled&&o.enable(9),k.useLegacyLights&&o.enable(10),k.doubleSided&&o.enable(11),k.flipSided&&o.enable(12),k.useDepthPacking&&o.enable(13),k.dithering&&o.enable(14),k.transmission&&o.enable(15),k.sheen&&o.enable(16),k.opaque&&o.enable(17),k.pointsUvs&&o.enable(18),k.decodeVideoTexture&&o.enable(19),N.push(o.mask)}function C(N){const k=y[N.type];let F;if(k){const I=Da[k];F=ck.clone(I.uniforms)}else F=N.uniforms;return F}function T(N,k){let F;for(let I=0,W=c.length;I<W;I++){const D=c[I];if(D.cacheKey===k){F=D,++F.usedTimes;break}}return F===void 0&&(F=new Zbe(t,k,N,a),c.push(F)),F}function P(N){if(--N.usedTimes===0){const k=c.indexOf(N);c[k]=c[c.length-1],c.pop(),N.destroy()}}function A(N){l.remove(N)}function j(){l.dispose()}return{getParameters:v,getProgramCacheKey:x,getUniforms:C,acquireProgram:T,releaseProgram:P,releaseShaderCache:A,programs:c,dispose:j}}function n_e(){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 i_e(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 E5(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 A5(){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,m,g,y,_,v){let x=t[e];return x===void 0?(x={id:f.id,object:f,geometry:m,material:g,groupOrder:y,renderOrder:f.renderOrder,z:_,group:v},t[e]=x):(x.id=f.id,x.object=f,x.geometry=m,x.material=g,x.groupOrder=y,x.renderOrder=f.renderOrder,x.z=_,x.group=v),e++,x}function o(f,m,g,y,_,v){const x=s(f,m,g,y,_,v);g.transmission>0?i.push(x):g.transparent===!0?r.push(x):n.push(x)}function l(f,m,g,y,_,v){const x=s(f,m,g,y,_,v);g.transmission>0?i.unshift(x):g.transparent===!0?r.unshift(x):n.unshift(x)}function c(f,m){n.length>1&&n.sort(f||i_e),i.length>1&&i.sort(m||E5),r.length>1&&r.sort(m||E5)}function u(){for(let f=e,m=t.length;f<m;f++){const g=t[f];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:n,transmissive:i,transparent:r,init:a,push:o,unshift:l,finish:u,sort:c}}function r_e(){let t=new WeakMap;function e(i,r){const a=t.get(i);let s;return a===void 0?(s=new A5,t.set(i,[s])):r>=a.length?(s=new A5,a.push(s)):s=a[r],s}function n(){t=new WeakMap}return{get:e,dispose:n}}function a_e(){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 Te,color:new zt};break;case"SpotLight":n={position:new Te,direction:new Te,color:new zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Te,color:new zt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Te,skyColor:new zt,groundColor:new zt};break;case"RectAreaLight":n={color:new zt,position:new Te,halfWidth:new Te,halfHeight:new Te};break}return t[e.id]=n,n}}}function s_e(){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 Xt};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Xt,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let o_e=0;function l_e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function c_e(t,e){const n=new a_e,i=s_e(),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 u=0;u<9;u++)r.probe.push(new Te);const a=new Te,s=new Jn,o=new Jn;function l(u,f){let m=0,g=0,y=0;for(let I=0;I<9;I++)r.probe[I].set(0,0,0);let _=0,v=0,x=0,M=0,w=0,C=0,T=0,P=0,A=0,j=0,N=0;u.sort(l_e);const k=f===!0?Math.PI:1;for(let I=0,W=u.length;I<W;I++){const D=u[I],B=D.color,$=D.intensity,K=D.distance,X=D.shadow&&D.shadow.map?D.shadow.map.texture:null;if(D.isAmbientLight)m+=B.r*$*k,g+=B.g*$*k,y+=B.b*$*k;else if(D.isLightProbe){for(let Y=0;Y<9;Y++)r.probe[Y].addScaledVector(D.sh.coefficients[Y],$);N++}else if(D.isDirectionalLight){const Y=n.get(D);if(Y.color.copy(D.color).multiplyScalar(D.intensity*k),D.castShadow){const ee=D.shadow,z=i.get(D);z.shadowBias=ee.bias,z.shadowNormalBias=ee.normalBias,z.shadowRadius=ee.radius,z.shadowMapSize=ee.mapSize,r.directionalShadow[_]=z,r.directionalShadowMap[_]=X,r.directionalShadowMatrix[_]=D.shadow.matrix,C++}r.directional[_]=Y,_++}else if(D.isSpotLight){const Y=n.get(D);Y.position.setFromMatrixPosition(D.matrixWorld),Y.color.copy(B).multiplyScalar($*k),Y.distance=K,Y.coneCos=Math.cos(D.angle),Y.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),Y.decay=D.decay,r.spot[x]=Y;const ee=D.shadow;if(D.map&&(r.spotLightMap[A]=D.map,A++,ee.updateMatrices(D),D.castShadow&&j++),r.spotLightMatrix[x]=ee.matrix,D.castShadow){const z=i.get(D);z.shadowBias=ee.bias,z.shadowNormalBias=ee.normalBias,z.shadowRadius=ee.radius,z.shadowMapSize=ee.mapSize,r.spotShadow[x]=z,r.spotShadowMap[x]=X,P++}x++}else if(D.isRectAreaLight){const Y=n.get(D);Y.color.copy(B).multiplyScalar($),Y.halfWidth.set(D.width*.5,0,0),Y.halfHeight.set(0,D.height*.5,0),r.rectArea[M]=Y,M++}else if(D.isPointLight){const Y=n.get(D);if(Y.color.copy(D.color).multiplyScalar(D.intensity*k),Y.distance=D.distance,Y.decay=D.decay,D.castShadow){const ee=D.shadow,z=i.get(D);z.shadowBias=ee.bias,z.shadowNormalBias=ee.normalBias,z.shadowRadius=ee.radius,z.shadowMapSize=ee.mapSize,z.shadowCameraNear=ee.camera.near,z.shadowCameraFar=ee.camera.far,r.pointShadow[v]=z,r.pointShadowMap[v]=X,r.pointShadowMatrix[v]=D.shadow.matrix,T++}r.point[v]=Y,v++}else if(D.isHemisphereLight){const Y=n.get(D);Y.skyColor.copy(D.color).multiplyScalar($*k),Y.groundColor.copy(D.groundColor).multiplyScalar($*k),r.hemi[w]=Y,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]=m,r.ambient[1]=g,r.ambient[2]=y;const F=r.hash;(F.directionalLength!==_||F.pointLength!==v||F.spotLength!==x||F.rectAreaLength!==M||F.hemiLength!==w||F.numDirectionalShadows!==C||F.numPointShadows!==T||F.numSpotShadows!==P||F.numSpotMaps!==A||F.numLightProbes!==N)&&(r.directional.length=_,r.spot.length=x,r.rectArea.length=M,r.point.length=v,r.hemi.length=w,r.directionalShadow.length=C,r.directionalShadowMap.length=C,r.pointShadow.length=T,r.pointShadowMap.length=T,r.spotShadow.length=P,r.spotShadowMap.length=P,r.directionalShadowMatrix.length=C,r.pointShadowMatrix.length=T,r.spotLightMatrix.length=P+A-j,r.spotLightMap.length=A,r.numSpotLightShadowsWithMaps=j,r.numLightProbes=N,F.directionalLength=_,F.pointLength=v,F.spotLength=x,F.rectAreaLength=M,F.hemiLength=w,F.numDirectionalShadows=C,F.numPointShadows=T,F.numSpotShadows=P,F.numSpotMaps=A,F.numLightProbes=N,r.version=o_e++)}function c(u,f){let m=0,g=0,y=0,_=0,v=0;const x=f.matrixWorldInverse;for(let M=0,w=u.length;M<w;M++){const C=u[M];if(C.isDirectionalLight){const T=r.directional[m];T.direction.setFromMatrixPosition(C.matrixWorld),a.setFromMatrixPosition(C.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),m++}else if(C.isSpotLight){const T=r.spot[y];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(x),T.direction.setFromMatrixPosition(C.matrixWorld),a.setFromMatrixPosition(C.target.matrixWorld),T.direction.sub(a),T.direction.transformDirection(x),y++}else if(C.isRectAreaLight){const T=r.rectArea[_];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(x),o.identity(),s.copy(C.matrixWorld),s.premultiply(x),o.extractRotation(s),T.halfWidth.set(C.width*.5,0,0),T.halfHeight.set(0,C.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),_++}else if(C.isPointLight){const T=r.point[g];T.position.setFromMatrixPosition(C.matrixWorld),T.position.applyMatrix4(x),g++}else if(C.isHemisphereLight){const T=r.hemi[v];T.direction.setFromMatrixPosition(C.matrixWorld),T.direction.transformDirection(x),v++}}}return{setup:l,setupView:c,state:r}}function T5(t,e){const n=new c_e(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 u_e(t,e){let n=new WeakMap;function i(a,s=0){const o=n.get(a);let l;return o===void 0?(l=new T5(t,e),n.set(a,[l])):s>=o.length?(l=new T5(t,e),o.push(l)):l=o[s],l}function r(){n=new WeakMap}return{get:i,dispose:r}}class d_e extends Am{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Yge,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 f_e extends Am{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 h_e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,p_e=`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 m_e(t,e,n){let i=new sw;const r=new Xt,a=new Xt,s=new Gn,o=new d_e({depthPacking:Zge}),l=new f_e,c={},u=n.maxTextureSize,f={[Ku]:Ua,[Ua]:Ku,[Xl]:Xl},m=new Yu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Xt},radius:{value:4}},vertexShader:h_e,fragmentShader:p_e}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const y=new aa;y.setAttribute("position",new ds(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new xo(y,m),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=e7;let x=this.type;this.render=function(T,P,A){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||T.length===0)return;const j=t.getRenderTarget(),N=t.getActiveCubeFace(),k=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Fu),F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const I=x!==$l&&this.type===$l,W=x===$l&&this.type!==$l;for(let D=0,B=T.length;D<B;D++){const $=T[D],K=$.shadow;if(K===void 0){console.warn("THREE.WebGLShadowMap:",$,"has no shadow.");continue}if(K.autoUpdate===!1&&K.needsUpdate===!1)continue;r.copy(K.mapSize);const X=K.getFrameExtents();if(r.multiply(X),a.copy(K.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/X.x),r.x=a.x*X.x,K.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/X.y),r.y=a.y*X.y,K.mapSize.y=a.y)),K.map===null||I===!0||W===!0){const ee=this.type!==$l?{minFilter:Hr,magFilter:Hr}:{};K.map!==null&&K.map.dispose(),K.map=new Tf(r.x,r.y,ee),K.map.texture.name=$.name+".shadowMap",K.camera.updateProjectionMatrix()}t.setRenderTarget(K.map),t.clear();const Y=K.getViewportCount();for(let ee=0;ee<Y;ee++){const z=K.getViewport(ee);s.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),F.viewport(s),K.updateMatrices($,ee),i=K.getFrustum(),C(P,A,K.camera,$,this.type)}K.isPointLightShadow!==!0&&this.type===$l&&M(K,A),K.needsUpdate=!1}x=this.type,v.needsUpdate=!1,t.setRenderTarget(j,N,k)};function M(T,P){const A=e.update(_);m.defines.VSM_SAMPLES!==T.blurSamples&&(m.defines.VSM_SAMPLES=T.blurSamples,g.defines.VSM_SAMPLES=T.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Tf(r.x,r.y)),m.uniforms.shadow_pass.value=T.map.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,t.setRenderTarget(T.mapPass),t.clear(),t.renderBufferDirect(P,null,A,m,_,null),g.uniforms.shadow_pass.value=T.mapPass.texture,g.uniforms.resolution.value=T.mapSize,g.uniforms.radius.value=T.radius,t.setRenderTarget(T.map),t.clear(),t.renderBufferDirect(P,null,A,g,_,null)}function w(T,P,A,j){let N=null;const k=A.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(k!==void 0)N=k;else if(N=A.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 F=N.uuid,I=P.uuid;let W=c[F];W===void 0&&(W={},c[F]=W);let D=W[I];D===void 0&&(D=N.clone(),W[I]=D),N=D}if(N.visible=P.visible,N.wireframe=P.wireframe,j===$l?N.side=P.shadowSide!==null?P.shadowSide:P.side:N.side=P.shadowSide!==null?P.shadowSide:f[P.side],N.alphaMap=P.alphaMap,N.alphaTest=P.alphaTest,N.map=P.map,N.clipShadows=P.clipShadows,N.clippingPlanes=P.clippingPlanes,N.clipIntersection=P.clipIntersection,N.displacementMap=P.displacementMap,N.displacementScale=P.displacementScale,N.displacementBias=P.displacementBias,N.wireframeLinewidth=P.wireframeLinewidth,N.linewidth=P.linewidth,A.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const F=t.properties.get(N);F.light=A}return N}function C(T,P,A,j,N){if(T.visible===!1)return;if(T.layers.test(P.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&N===$l)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,T.matrixWorld);const I=e.update(T),W=T.material;if(Array.isArray(W)){const D=I.groups;for(let B=0,$=D.length;B<$;B++){const K=D[B],X=W[K.materialIndex];if(X&&X.visible){const Y=w(T,X,j,N);T.onBeforeShadow(t,T,P,A,I,Y,K),t.renderBufferDirect(A,null,I,Y,T,K),T.onAfterShadow(t,T,P,A,I,Y,K)}}}else if(W.visible){const D=w(T,W,j,N);T.onBeforeShadow(t,T,P,A,I,D,null),t.renderBufferDirect(A,null,I,D,T,null),T.onAfterShadow(t,T,P,A,I,D,null)}}const F=T.children;for(let I=0,W=F.length;I<W;I++)C(F[I],P,A,j,N)}}function g_e(t,e,n){const i=n.isWebGL2;function r(){let fe=!1;const Oe=new Gn;let Me=null;const ve=new Gn(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,ct,bt,Rt,ln){ln===!0&&(Be*=Rt,ct*=Rt,bt*=Rt),Oe.set(Be,ct,bt,Rt),ve.equals(Oe)===!1&&(t.clearColor(Be,ct,bt,Rt),ve.copy(Oe))},reset:function(){fe=!1,Me=null,ve.set(-1,0,0,0)}}}function a(){let fe=!1,Oe=null,Me=null,ve=null;return{setTest:function(Be){Be?he(t.DEPTH_TEST):we(t.DEPTH_TEST)},setMask:function(Be){Oe!==Be&&!fe&&(t.depthMask(Be),Oe=Be)},setFunc:function(Be){if(Me!==Be){switch(Be){case Tge:t.depthFunc(t.NEVER);break;case Cge:t.depthFunc(t.ALWAYS);break;case Nge:t.depthFunc(t.LESS);break;case Z_:t.depthFunc(t.LEQUAL);break;case Rge:t.depthFunc(t.EQUAL);break;case Pge:t.depthFunc(t.GEQUAL);break;case kge:t.depthFunc(t.GREATER);break;case Dge:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Me=Be}},setLocked:function(Be){fe=Be},setClear:function(Be){ve!==Be&&(t.clearDepth(Be),ve=Be)},reset:function(){fe=!1,Oe=null,Me=null,ve=null}}}function s(){let fe=!1,Oe=null,Me=null,ve=null,Be=null,ct=null,bt=null,Rt=null,ln=null;return{setTest:function(Ot){fe||(Ot?he(t.STENCIL_TEST):we(t.STENCIL_TEST))},setMask:function(Ot){Oe!==Ot&&!fe&&(t.stencilMask(Ot),Oe=Ot)},setFunc:function(Ot,Rn,qn){(Me!==Ot||ve!==Rn||Be!==qn)&&(t.stencilFunc(Ot,Rn,qn),Me=Ot,ve=Rn,Be=qn)},setOp:function(Ot,Rn,qn){(ct!==Ot||bt!==Rn||Rt!==qn)&&(t.stencilOp(Ot,Rn,qn),ct=Ot,bt=Rn,Rt=qn)},setLocked:function(Ot){fe=Ot},setClear:function(Ot){ln!==Ot&&(t.clearStencil(Ot),ln=Ot)},reset:function(){fe=!1,Oe=null,Me=null,ve=null,Be=null,ct=null,bt=null,Rt=null,ln=null}}}const o=new r,l=new a,c=new s,u=new WeakMap,f=new WeakMap;let m={},g={},y=new WeakMap,_=[],v=null,x=!1,M=null,w=null,C=null,T=null,P=null,A=null,j=null,N=new zt(0,0,0),k=0,F=!1,I=null,W=null,D=null,B=null,$=null;const K=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,Y=0;const ee=t.getParameter(t.VERSION);ee.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(ee)[1]),X=Y>=1):ee.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),X=Y>=2);let z=null,V={};const re=t.getParameter(t.SCISSOR_BOX),le=t.getParameter(t.VIEWPORT),ge=new Gn().fromArray(re),ie=new Gn().fromArray(le);function xe(fe,Oe,Me,ve){const Be=new Uint8Array(4),ct=t.createTexture();t.bindTexture(fe,ct),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(Oe,0,t.RGBA,1,1,ve,0,t.RGBA,t.UNSIGNED_BYTE,Be):t.texImage2D(Oe+bt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Be);return ct}const ke={};ke[t.TEXTURE_2D]=xe(t.TEXTURE_2D,t.TEXTURE_2D,1),ke[t.TEXTURE_CUBE_MAP]=xe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(ke[t.TEXTURE_2D_ARRAY]=xe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),ke[t.TEXTURE_3D]=xe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),he(t.DEPTH_TEST),l.setFunc(Z_),Q(!1),se(cz),he(t.CULL_FACE),oe(Fu);function he(fe){m[fe]!==!0&&(t.enable(fe),m[fe]=!0)}function we(fe){m[fe]!==!1&&(t.disable(fe),m[fe]=!1)}function Ue(fe,Oe){return g[fe]!==Oe?(t.bindFramebuffer(fe,Oe),g[fe]=Oe,i&&(fe===t.DRAW_FRAMEBUFFER&&(g[t.FRAMEBUFFER]=Oe),fe===t.FRAMEBUFFER&&(g[t.DRAW_FRAMEBUFFER]=Oe)),!0):!1}function ue(fe,Oe){let Me=_,ve=!1;if(fe)if(Me=y.get(Oe),Me===void 0&&(Me=[],y.set(Oe,Me)),fe.isWebGLMultipleRenderTargets){const Be=fe.texture;if(Me.length!==Be.length||Me[0]!==t.COLOR_ATTACHMENT0){for(let ct=0,bt=Be.length;ct<bt;ct++)Me[ct]=t.COLOR_ATTACHMENT0+ct;Me.length=Be.length,ve=!0}}else Me[0]!==t.COLOR_ATTACHMENT0&&(Me[0]=t.COLOR_ATTACHMENT0,ve=!0);else Me[0]!==t.BACK&&(Me[0]=t.BACK,ve=!0);ve&&(n.isWebGL2?t.drawBuffers(Me):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Me))}function lt(fe){return v!==fe?(t.useProgram(fe),v=fe,!0):!1}const H={[Gd]:t.FUNC_ADD,[fge]:t.FUNC_SUBTRACT,[hge]:t.FUNC_REVERSE_SUBTRACT};if(i)H[hz]=t.MIN,H[pz]=t.MAX;else{const fe=e.get("EXT_blend_minmax");fe!==null&&(H[hz]=fe.MIN_EXT,H[pz]=fe.MAX_EXT)}const q={[pge]:t.ZERO,[mge]:t.ONE,[gge]:t.SRC_COLOR,[S3]:t.SRC_ALPHA,[Sge]:t.SRC_ALPHA_SATURATE,[bge]:t.DST_COLOR,[vge]:t.DST_ALPHA,[xge]:t.ONE_MINUS_SRC_COLOR,[w3]:t.ONE_MINUS_SRC_ALPHA,[_ge]:t.ONE_MINUS_DST_COLOR,[yge]:t.ONE_MINUS_DST_ALPHA,[wge]:t.CONSTANT_COLOR,[Mge]:t.ONE_MINUS_CONSTANT_COLOR,[Ege]:t.CONSTANT_ALPHA,[Age]:t.ONE_MINUS_CONSTANT_ALPHA};function oe(fe,Oe,Me,ve,Be,ct,bt,Rt,ln,Ot){if(fe===Fu){x===!0&&(we(t.BLEND),x=!1);return}if(x===!1&&(he(t.BLEND),x=!0),fe!==dge){if(fe!==M||Ot!==F){if((w!==Gd||P!==Gd)&&(t.blendEquation(t.FUNC_ADD),w=Gd,P=Gd),Ot)switch(fe){case Cp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case uz:t.blendFunc(t.ONE,t.ONE);break;case dz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case fz: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 Cp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case uz:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case dz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case fz:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",fe);break}C=null,T=null,A=null,j=null,N.set(0,0,0),k=0,M=fe,F=Ot}return}Be=Be||Oe,ct=ct||Me,bt=bt||ve,(Oe!==w||Be!==P)&&(t.blendEquationSeparate(H[Oe],H[Be]),w=Oe,P=Be),(Me!==C||ve!==T||ct!==A||bt!==j)&&(t.blendFuncSeparate(q[Me],q[ve],q[ct],q[bt]),C=Me,T=ve,A=ct,j=bt),(Rt.equals(N)===!1||ln!==k)&&(t.blendColor(Rt.r,Rt.g,Rt.b,ln),N.copy(Rt),k=ln),M=fe,F=!1}function Z(fe,Oe){fe.side===Xl?we(t.CULL_FACE):he(t.CULL_FACE);let Me=fe.side===Ua;Oe&&(Me=!Me),Q(Me),fe.blending===Cp&&fe.transparent===!1?oe(Fu):oe(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 ve=fe.stencilWrite;c.setTest(ve),ve&&(c.setMask(fe.stencilWriteMask),c.setFunc(fe.stencilFunc,fe.stencilRef,fe.stencilFuncMask),c.setOp(fe.stencilFail,fe.stencilZFail,fe.stencilZPass)),Ee(fe.polygonOffset,fe.polygonOffsetFactor,fe.polygonOffsetUnits),fe.alphaToCoverage===!0?he(t.SAMPLE_ALPHA_TO_COVERAGE):we(t.SAMPLE_ALPHA_TO_COVERAGE)}function Q(fe){I!==fe&&(fe?t.frontFace(t.CW):t.frontFace(t.CCW),I=fe)}function se(fe){fe!==lge?(he(t.CULL_FACE),fe!==W&&(fe===cz?t.cullFace(t.BACK):fe===cge?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):we(t.CULL_FACE),W=fe}function Ce(fe){fe!==D&&(X&&t.lineWidth(fe),D=fe)}function Ee(fe,Oe,Me){fe?(he(t.POLYGON_OFFSET_FILL),(B!==Oe||$!==Me)&&(t.polygonOffset(Oe,Me),B=Oe,$=Me)):we(t.POLYGON_OFFSET_FILL)}function ne(fe){fe?he(t.SCISSOR_TEST):we(t.SCISSOR_TEST)}function U(fe){fe===void 0&&(fe=t.TEXTURE0+K-1),z!==fe&&(t.activeTexture(fe),z=fe)}function L(fe,Oe,Me){Me===void 0&&(z===null?Me=t.TEXTURE0+K-1:Me=z);let ve=V[Me];ve===void 0&&(ve={type:void 0,texture:void 0},V[Me]=ve),(ve.type!==fe||ve.texture!==Oe)&&(z!==Me&&(t.activeTexture(Me),z=Me),t.bindTexture(fe,Oe||ke[fe]),ve.type=fe,ve.texture=Oe)}function J(){const fe=V[z];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 pe(){try{t.texSubImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function Qe(){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 Xe(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function st(){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 Pe(){try{t.texImage2D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function pt(){try{t.texImage3D.apply(t,arguments)}catch(fe){console.error("THREE.WebGLState:",fe)}}function it(fe){ge.equals(fe)===!1&&(t.scissor(fe.x,fe.y,fe.z,fe.w),ge.copy(fe))}function nt(fe){ie.equals(fe)===!1&&(t.viewport(fe.x,fe.y,fe.z,fe.w),ie.copy(fe))}function dt(fe,Oe){let Me=f.get(Oe);Me===void 0&&(Me=new WeakMap,f.set(Oe,Me));let ve=Me.get(fe);ve===void 0&&(ve=t.getUniformBlockIndex(Oe,fe.name),Me.set(fe,ve))}function de(fe,Oe){const ve=f.get(Oe).get(fe);u.get(Oe)!==ve&&(t.uniformBlockBinding(Oe,ve,fe.__bindingPointIndex),u.set(Oe,ve))}function rt(){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),m={},z=null,V={},g={},y=new WeakMap,_=[],v=null,x=!1,M=null,w=null,C=null,T=null,P=null,A=null,j=null,N=new zt(0,0,0),k=0,F=!1,I=null,W=null,D=null,B=null,$=null,ge.set(0,0,t.canvas.width,t.canvas.height),ie.set(0,0,t.canvas.width,t.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:he,disable:we,bindFramebuffer:Ue,drawBuffers:ue,useProgram:lt,setBlending:oe,setMaterial:Z,setFlipSided:Q,setCullFace:se,setLineWidth:Ce,setPolygonOffset:Ee,setScissorTest:ne,activeTexture:U,bindTexture:L,unbindTexture:J,compressedTexImage2D:me,compressedTexImage3D:ye,texImage2D:Pe,texImage3D:pt,updateUBOMapping:dt,uniformBlockBinding:de,texStorage2D:st,texStorage3D:Ie,texSubImage2D:pe,texSubImage3D:Qe,compressedTexSubImage2D:Le,compressedTexSubImage3D:Xe,scissor:it,viewport:nt,reset:rt}}function x_e(t,e,n,i,r,a,s){const o=r.isWebGL2,l=r.maxTextures,c=r.maxCubemapSize,u=r.maxTextureSize,f=r.maxSamples,m=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,g=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),y=new WeakMap;let _;const v=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(U,L){return x?new OffscreenCanvas(U,L):n1("canvas")}function w(U,L,J,me){let ye=1;if((U.width>me||U.height>me)&&(ye=me/Math.max(U.width,U.height)),ye<1||L===!0)if(typeof HTMLImageElement<"u"&&U instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&U instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&U instanceof ImageBitmap){const pe=L?t1:Math.floor,Qe=pe(ye*U.width),Le=pe(ye*U.height);_===void 0&&(_=M(Qe,Le));const Xe=J?M(Qe,Le):_;return Xe.width=Qe,Xe.height=Le,Xe.getContext("2d").drawImage(U,0,0,Qe,Le),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+U.width+"x"+U.height+") to ("+Qe+"x"+Le+")."),Xe}else return"data"in U&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+U.width+"x"+U.height+")."),U;return U}function C(U){return R3(U.width)&&R3(U.height)}function T(U){return o?!1:U.wrapS!==uo||U.wrapT!==uo||U.minFilter!==Hr&&U.minFilter!==js}function P(U,L){return U.generateMipmaps&&L&&U.minFilter!==Hr&&U.minFilter!==js}function A(U){t.generateMipmap(U)}function j(U,L,J,me,ye=!1){if(o===!1)return L;if(U!==null){if(t[U]!==void 0)return t[U];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+U+"'")}let pe=L;if(L===t.RED&&(J===t.FLOAT&&(pe=t.R32F),J===t.HALF_FLOAT&&(pe=t.R16F),J===t.UNSIGNED_BYTE&&(pe=t.R8)),L===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(pe=t.R8UI),J===t.UNSIGNED_SHORT&&(pe=t.R16UI),J===t.UNSIGNED_INT&&(pe=t.R32UI),J===t.BYTE&&(pe=t.R8I),J===t.SHORT&&(pe=t.R16I),J===t.INT&&(pe=t.R32I)),L===t.RG&&(J===t.FLOAT&&(pe=t.RG32F),J===t.HALF_FLOAT&&(pe=t.RG16F),J===t.UNSIGNED_BYTE&&(pe=t.RG8)),L===t.RGBA){const Qe=ye?Q_:$n.getTransfer(me);J===t.FLOAT&&(pe=t.RGBA32F),J===t.HALF_FLOAT&&(pe=t.RGBA16F),J===t.UNSIGNED_BYTE&&(pe=Qe===ii?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(pe=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(pe=t.RGB5_A1)}return(pe===t.R16F||pe===t.R32F||pe===t.RG16F||pe===t.RG32F||pe===t.RGBA16F||pe===t.RGBA32F)&&e.get("EXT_color_buffer_float"),pe}function N(U,L,J){return P(U,J)===!0||U.isFramebufferTexture&&U.minFilter!==Hr&&U.minFilter!==js?Math.log2(Math.max(L.width,L.height))+1:U.mipmaps!==void 0&&U.mipmaps.length>0?U.mipmaps.length:U.isCompressedTexture&&Array.isArray(U.image)?L.mipmaps.length:1}function k(U){return U===Hr||U===mz||U===gT?t.NEAREST:t.LINEAR}function F(U){const L=U.target;L.removeEventListener("dispose",F),W(L),L.isVideoTexture&&y.delete(L)}function I(U){const L=U.target;L.removeEventListener("dispose",I),B(L)}function W(U){const L=i.get(U);if(L.__webglInit===void 0)return;const J=U.source,me=v.get(J);if(me){const ye=me[L.__cacheKey];ye.usedTimes--,ye.usedTimes===0&&D(U),Object.keys(me).length===0&&v.delete(J)}i.remove(U)}function D(U){const L=i.get(U);t.deleteTexture(L.__webglTexture);const J=U.source,me=v.get(J);delete me[L.__cacheKey],s.memory.textures--}function B(U){const L=U.texture,J=i.get(U),me=i.get(L);if(me.__webglTexture!==void 0&&(t.deleteTexture(me.__webglTexture),s.memory.textures--),U.depthTexture&&U.depthTexture.dispose(),U.isWebGLCubeRenderTarget)for(let ye=0;ye<6;ye++){if(Array.isArray(J.__webglFramebuffer[ye]))for(let pe=0;pe<J.__webglFramebuffer[ye].length;pe++)t.deleteFramebuffer(J.__webglFramebuffer[ye][pe]);else t.deleteFramebuffer(J.__webglFramebuffer[ye]);J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer[ye])}else{if(Array.isArray(J.__webglFramebuffer))for(let ye=0;ye<J.__webglFramebuffer.length;ye++)t.deleteFramebuffer(J.__webglFramebuffer[ye]);else t.deleteFramebuffer(J.__webglFramebuffer);if(J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&t.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let ye=0;ye<J.__webglColorRenderbuffer.length;ye++)J.__webglColorRenderbuffer[ye]&&t.deleteRenderbuffer(J.__webglColorRenderbuffer[ye]);J.__webglDepthRenderbuffer&&t.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(U.isWebGLMultipleRenderTargets)for(let ye=0,pe=L.length;ye<pe;ye++){const Qe=i.get(L[ye]);Qe.__webglTexture&&(t.deleteTexture(Qe.__webglTexture),s.memory.textures--),i.remove(L[ye])}i.remove(L),i.remove(U)}let $=0;function K(){$=0}function X(){const U=$;return U>=l&&console.warn("THREE.WebGLTextures: Trying to use "+U+" texture units while this GPU supports only "+l),$+=1,U}function Y(U){const L=[];return L.push(U.wrapS),L.push(U.wrapT),L.push(U.wrapR||0),L.push(U.magFilter),L.push(U.minFilter),L.push(U.anisotropy),L.push(U.internalFormat),L.push(U.format),L.push(U.type),L.push(U.generateMipmaps),L.push(U.premultiplyAlpha),L.push(U.flipY),L.push(U.unpackAlignment),L.push(U.colorSpace),L.join()}function ee(U,L){const J=i.get(U);if(U.isVideoTexture&&Ee(U),U.isRenderTargetTexture===!1&&U.version>0&&J.__version!==U.version){const me=U.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{he(J,U,L);return}}n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+L)}function z(U,L){const J=i.get(U);if(U.version>0&&J.__version!==U.version){he(J,U,L);return}n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+L)}function V(U,L){const J=i.get(U);if(U.version>0&&J.__version!==U.version){he(J,U,L);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+L)}function re(U,L){const J=i.get(U);if(U.version>0&&J.__version!==U.version){we(J,U,L);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+L)}const le={[A3]:t.REPEAT,[uo]:t.CLAMP_TO_EDGE,[T3]:t.MIRRORED_REPEAT},ge={[Hr]:t.NEAREST,[mz]:t.NEAREST_MIPMAP_NEAREST,[gT]:t.NEAREST_MIPMAP_LINEAR,[js]:t.LINEAR,[Bge]:t.LINEAR_MIPMAP_NEAREST,[e0]:t.LINEAR_MIPMAP_LINEAR},ie={[Jge]:t.NEVER,[axe]:t.ALWAYS,[exe]:t.LESS,[d7]:t.LEQUAL,[txe]:t.EQUAL,[rxe]:t.GEQUAL,[nxe]:t.GREATER,[ixe]:t.NOTEQUAL};function xe(U,L,J){if(J?(t.texParameteri(U,t.TEXTURE_WRAP_S,le[L.wrapS]),t.texParameteri(U,t.TEXTURE_WRAP_T,le[L.wrapT]),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,le[L.wrapR]),t.texParameteri(U,t.TEXTURE_MAG_FILTER,ge[L.magFilter]),t.texParameteri(U,t.TEXTURE_MIN_FILTER,ge[L.minFilter])):(t.texParameteri(U,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(U,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(U===t.TEXTURE_3D||U===t.TEXTURE_2D_ARRAY)&&t.texParameteri(U,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(L.wrapS!==uo||L.wrapT!==uo)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(U,t.TEXTURE_MAG_FILTER,k(L.magFilter)),t.texParameteri(U,t.TEXTURE_MIN_FILTER,k(L.minFilter)),L.minFilter!==Hr&&L.minFilter!==js&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(t.texParameteri(U,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(U,t.TEXTURE_COMPARE_FUNC,ie[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const me=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===Hr||L.minFilter!==gT&&L.minFilter!==e0||L.type===ec&&e.has("OES_texture_float_linear")===!1||o===!1&&L.type===t0&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||i.get(L).__currentAnisotropy)&&(t.texParameterf(U,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,r.getMaxAnisotropy())),i.get(L).__currentAnisotropy=L.anisotropy)}}function ke(U,L){let J=!1;U.__webglInit===void 0&&(U.__webglInit=!0,L.addEventListener("dispose",F));const me=L.source;let ye=v.get(me);ye===void 0&&(ye={},v.set(me,ye));const pe=Y(L);if(pe!==U.__cacheKey){ye[pe]===void 0&&(ye[pe]={texture:t.createTexture(),usedTimes:0},s.memory.textures++,J=!0),ye[pe].usedTimes++;const Qe=ye[U.__cacheKey];Qe!==void 0&&(ye[U.__cacheKey].usedTimes--,Qe.usedTimes===0&&D(L)),U.__cacheKey=pe,U.__webglTexture=ye[pe].texture}return J}function he(U,L,J){let me=t.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(me=t.TEXTURE_2D_ARRAY),L.isData3DTexture&&(me=t.TEXTURE_3D);const ye=ke(U,L),pe=L.source;n.bindTexture(me,U.__webglTexture,t.TEXTURE0+J);const Qe=i.get(pe);if(pe.version!==Qe.__version||ye===!0){n.activeTexture(t.TEXTURE0+J);const Le=$n.getPrimaries($n.workingColorSpace),Xe=L.colorSpace===Fs?null:$n.getPrimaries(L.colorSpace),st=L.colorSpace===Fs||Le===Xe?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,st);const Ie=T(L)&&C(L.image)===!1;let Pe=w(L.image,Ie,!1,u);Pe=ne(L,Pe);const pt=C(Pe)||o,it=a.convert(L.format,L.colorSpace);let nt=a.convert(L.type),dt=j(L.internalFormat,it,nt,L.colorSpace,L.isVideoTexture);xe(me,L,pt);let de;const rt=L.mipmaps,fe=o&&L.isVideoTexture!==!0&&dt!==l7,Oe=Qe.__version===void 0||ye===!0,Me=N(L,Pe,pt);if(L.isDepthTexture)dt=t.DEPTH_COMPONENT,o?L.type===ec?dt=t.DEPTH_COMPONENT32F:L.type===ku?dt=t.DEPTH_COMPONENT24:L.type===af?dt=t.DEPTH24_STENCIL8:dt=t.DEPTH_COMPONENT16:L.type===ec&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===sf&&dt===t.DEPTH_COMPONENT&&L.type!==ak&&L.type!==ku&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=ku,nt=a.convert(L.type)),L.format===Qp&&dt===t.DEPTH_COMPONENT&&(dt=t.DEPTH_STENCIL,L.type!==af&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=af,nt=a.convert(L.type))),Oe&&(fe?n.texStorage2D(t.TEXTURE_2D,1,dt,Pe.width,Pe.height):n.texImage2D(t.TEXTURE_2D,0,dt,Pe.width,Pe.height,0,it,nt,null));else if(L.isDataTexture)if(rt.length>0&&pt){fe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Me,dt,rt[0].width,rt[0].height);for(let ve=0,Be=rt.length;ve<Be;ve++)de=rt[ve],fe?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,de.width,de.height,it,nt,de.data):n.texImage2D(t.TEXTURE_2D,ve,dt,de.width,de.height,0,it,nt,de.data);L.generateMipmaps=!1}else fe?(Oe&&n.texStorage2D(t.TEXTURE_2D,Me,dt,Pe.width,Pe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Pe.width,Pe.height,it,nt,Pe.data)):n.texImage2D(t.TEXTURE_2D,0,dt,Pe.width,Pe.height,0,it,nt,Pe.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){fe&&Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Me,dt,rt[0].width,rt[0].height,Pe.depth);for(let ve=0,Be=rt.length;ve<Be;ve++)de=rt[ve],L.format!==Us?it!==null?fe?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ve,0,0,0,de.width,de.height,Pe.depth,it,de.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ve,dt,de.width,de.height,Pe.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,ve,0,0,0,de.width,de.height,Pe.depth,it,nt,de.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ve,dt,de.width,de.height,Pe.depth,0,it,nt,de.data)}else{fe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Me,dt,rt[0].width,rt[0].height);for(let ve=0,Be=rt.length;ve<Be;ve++)de=rt[ve],L.format!==Us?it!==null?fe?n.compressedTexSubImage2D(t.TEXTURE_2D,ve,0,0,de.width,de.height,it,de.data):n.compressedTexImage2D(t.TEXTURE_2D,ve,dt,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,ve,0,0,de.width,de.height,it,nt,de.data):n.texImage2D(t.TEXTURE_2D,ve,dt,de.width,de.height,0,it,nt,de.data)}else if(L.isDataArrayTexture)fe?(Oe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Me,dt,Pe.width,Pe.height,Pe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Pe.width,Pe.height,Pe.depth,it,nt,Pe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,dt,Pe.width,Pe.height,Pe.depth,0,it,nt,Pe.data);else if(L.isData3DTexture)fe?(Oe&&n.texStorage3D(t.TEXTURE_3D,Me,dt,Pe.width,Pe.height,Pe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Pe.width,Pe.height,Pe.depth,it,nt,Pe.data)):n.texImage3D(t.TEXTURE_3D,0,dt,Pe.width,Pe.height,Pe.depth,0,it,nt,Pe.data);else if(L.isFramebufferTexture){if(Oe)if(fe)n.texStorage2D(t.TEXTURE_2D,Me,dt,Pe.width,Pe.height);else{let ve=Pe.width,Be=Pe.height;for(let ct=0;ct<Me;ct++)n.texImage2D(t.TEXTURE_2D,ct,dt,ve,Be,0,it,nt,null),ve>>=1,Be>>=1}}else if(rt.length>0&&pt){fe&&Oe&&n.texStorage2D(t.TEXTURE_2D,Me,dt,rt[0].width,rt[0].height);for(let ve=0,Be=rt.length;ve<Be;ve++)de=rt[ve],fe?n.texSubImage2D(t.TEXTURE_2D,ve,0,0,it,nt,de):n.texImage2D(t.TEXTURE_2D,ve,dt,it,nt,de);L.generateMipmaps=!1}else fe?(Oe&&n.texStorage2D(t.TEXTURE_2D,Me,dt,Pe.width,Pe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,it,nt,Pe)):n.texImage2D(t.TEXTURE_2D,0,dt,it,nt,Pe);P(L,pt)&&A(me),Qe.__version=pe.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function we(U,L,J){if(L.image.length!==6)return;const me=ke(U,L),ye=L.source;n.bindTexture(t.TEXTURE_CUBE_MAP,U.__webglTexture,t.TEXTURE0+J);const pe=i.get(ye);if(ye.version!==pe.__version||me===!0){n.activeTexture(t.TEXTURE0+J);const Qe=$n.getPrimaries($n.workingColorSpace),Le=L.colorSpace===Fs?null:$n.getPrimaries(L.colorSpace),Xe=L.colorSpace===Fs||Qe===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,L.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,L.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Xe);const st=L.isCompressedTexture||L.image[0].isCompressedTexture,Ie=L.image[0]&&L.image[0].isDataTexture,Pe=[];for(let ve=0;ve<6;ve++)!st&&!Ie?Pe[ve]=w(L.image[ve],!1,!0,c):Pe[ve]=Ie?L.image[ve].image:L.image[ve],Pe[ve]=ne(L,Pe[ve]);const pt=Pe[0],it=C(pt)||o,nt=a.convert(L.format,L.colorSpace),dt=a.convert(L.type),de=j(L.internalFormat,nt,dt,L.colorSpace),rt=o&&L.isVideoTexture!==!0,fe=pe.__version===void 0||me===!0;let Oe=N(L,pt,it);xe(t.TEXTURE_CUBE_MAP,L,it);let Me;if(st){rt&&fe&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,de,pt.width,pt.height);for(let ve=0;ve<6;ve++){Me=Pe[ve].mipmaps;for(let Be=0;Be<Me.length;Be++){const ct=Me[Be];L.format!==Us?nt!==null?rt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,0,0,ct.width,ct.height,nt,ct.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,de,ct.width,ct.height,0,ct.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,0,0,ct.width,ct.height,nt,dt,ct.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be,de,ct.width,ct.height,0,nt,dt,ct.data)}}}else{Me=L.mipmaps,rt&&fe&&(Me.length>0&&Oe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Oe,de,Pe[0].width,Pe[0].height));for(let ve=0;ve<6;ve++)if(Ie){rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,Pe[ve].width,Pe[ve].height,nt,dt,Pe[ve].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,de,Pe[ve].width,Pe[ve].height,0,nt,dt,Pe[ve].data);for(let Be=0;Be<Me.length;Be++){const bt=Me[Be].image[ve].image;rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,0,0,bt.width,bt.height,nt,dt,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,de,bt.width,bt.height,0,nt,dt,bt.data)}}else{rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,nt,dt,Pe[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,de,nt,dt,Pe[ve]);for(let Be=0;Be<Me.length;Be++){const ct=Me[Be];rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,0,0,nt,dt,ct.image[ve]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Be+1,de,nt,dt,ct.image[ve])}}}P(L,it)&&A(t.TEXTURE_CUBE_MAP),pe.__version=ye.version,L.onUpdate&&L.onUpdate(L)}U.__version=L.version}function Ue(U,L,J,me,ye,pe){const Qe=a.convert(J.format,J.colorSpace),Le=a.convert(J.type),Xe=j(J.internalFormat,Qe,Le,J.colorSpace);if(!i.get(L).__hasExternalTextures){const Ie=Math.max(1,L.width>>pe),Pe=Math.max(1,L.height>>pe);ye===t.TEXTURE_3D||ye===t.TEXTURE_2D_ARRAY?n.texImage3D(ye,pe,Xe,Ie,Pe,L.depth,0,Qe,Le,null):n.texImage2D(ye,pe,Xe,Ie,Pe,0,Qe,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,U),Ce(L)?m.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,me,ye,i.get(J).__webglTexture,0,se(L)):(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(J).__webglTexture,pe),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(U,L,J){if(t.bindRenderbuffer(t.RENDERBUFFER,U),L.depthBuffer&&!L.stencilBuffer){let me=o===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(J||Ce(L)){const ye=L.depthTexture;ye&&ye.isDepthTexture&&(ye.type===ec?me=t.DEPTH_COMPONENT32F:ye.type===ku&&(me=t.DEPTH_COMPONENT24));const pe=se(L);Ce(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,pe,me,L.width,L.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,pe,me,L.width,L.height)}else t.renderbufferStorage(t.RENDERBUFFER,me,L.width,L.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,U)}else if(L.depthBuffer&&L.stencilBuffer){const me=se(L);J&&Ce(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,me,t.DEPTH24_STENCIL8,L.width,L.height):Ce(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,me,t.DEPTH24_STENCIL8,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,L.width,L.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,U)}else{const me=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let ye=0;ye<me.length;ye++){const pe=me[ye],Qe=a.convert(pe.format,pe.colorSpace),Le=a.convert(pe.type),Xe=j(pe.internalFormat,Qe,Le,pe.colorSpace),st=se(L);J&&Ce(L)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,st,Xe,L.width,L.height):Ce(L)?m.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,st,Xe,L.width,L.height):t.renderbufferStorage(t.RENDERBUFFER,Xe,L.width,L.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function lt(U,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,U),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),ee(L.depthTexture,0);const me=i.get(L.depthTexture).__webglTexture,ye=se(L);if(L.depthTexture.format===sf)Ce(L)?m.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(L.depthTexture.format===Qp)Ce(L)?m.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 H(U){const L=i.get(U),J=U.isWebGLCubeRenderTarget===!0;if(U.depthTexture&&!L.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");lt(L.__webglFramebuffer,U)}else if(J){L.__webglDepthbuffer=[];for(let me=0;me<6;me++)n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer[me]),L.__webglDepthbuffer[me]=t.createRenderbuffer(),ue(L.__webglDepthbuffer[me],U,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=t.createRenderbuffer(),ue(L.__webglDepthbuffer,U,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function q(U,L,J){const me=i.get(U);L!==void 0&&Ue(me.__webglFramebuffer,U,U.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&H(U)}function oe(U){const L=U.texture,J=i.get(U),me=i.get(L);U.addEventListener("dispose",I),U.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=t.createTexture()),me.__version=L.version,s.memory.textures++);const ye=U.isWebGLCubeRenderTarget===!0,pe=U.isWebGLMultipleRenderTargets===!0,Qe=C(U)||o;if(ye){J.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(o&&L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer[Le]=[];for(let Xe=0;Xe<L.mipmaps.length;Xe++)J.__webglFramebuffer[Le][Xe]=t.createFramebuffer()}else J.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(o&&L.mipmaps&&L.mipmaps.length>0){J.__webglFramebuffer=[];for(let Le=0;Le<L.mipmaps.length;Le++)J.__webglFramebuffer[Le]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(pe)if(r.drawBuffers){const Le=U.texture;for(let Xe=0,st=Le.length;Xe<st;Xe++){const Ie=i.get(Le[Xe]);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&&U.samples>0&&Ce(U)===!1){const Le=pe?L:[L];J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Xe=0;Xe<Le.length;Xe++){const st=Le[Xe];J.__webglColorRenderbuffer[Xe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Xe]);const Ie=a.convert(st.format,st.colorSpace),Pe=a.convert(st.type),pt=j(st.internalFormat,Ie,Pe,st.colorSpace,U.isXRRenderTarget===!0),it=se(U);t.renderbufferStorageMultisample(t.RENDERBUFFER,it,pt,U.width,U.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Xe,t.RENDERBUFFER,J.__webglColorRenderbuffer[Xe])}t.bindRenderbuffer(t.RENDERBUFFER,null),U.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),ue(J.__webglDepthRenderbuffer,U,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ye){n.bindTexture(t.TEXTURE_CUBE_MAP,me.__webglTexture),xe(t.TEXTURE_CUBE_MAP,L,Qe);for(let Le=0;Le<6;Le++)if(o&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ue(J.__webglFramebuffer[Le][Xe],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,Xe);else Ue(J.__webglFramebuffer[Le],U,L,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);P(L,Qe)&&A(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(pe){const Le=U.texture;for(let Xe=0,st=Le.length;Xe<st;Xe++){const Ie=Le[Xe],Pe=i.get(Ie);n.bindTexture(t.TEXTURE_2D,Pe.__webglTexture),xe(t.TEXTURE_2D,Ie,Qe),Ue(J.__webglFramebuffer,U,Ie,t.COLOR_ATTACHMENT0+Xe,t.TEXTURE_2D,0),P(Ie,Qe)&&A(t.TEXTURE_2D)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((U.isWebGL3DRenderTarget||U.isWebGLArrayRenderTarget)&&(o?Le=U.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),xe(Le,L,Qe),o&&L.mipmaps&&L.mipmaps.length>0)for(let Xe=0;Xe<L.mipmaps.length;Xe++)Ue(J.__webglFramebuffer[Xe],U,L,t.COLOR_ATTACHMENT0,Le,Xe);else Ue(J.__webglFramebuffer,U,L,t.COLOR_ATTACHMENT0,Le,0);P(L,Qe)&&A(Le),n.unbindTexture()}U.depthBuffer&&H(U)}function Z(U){const L=C(U)||o,J=U.isWebGLMultipleRenderTargets===!0?U.texture:[U.texture];for(let me=0,ye=J.length;me<ye;me++){const pe=J[me];if(P(pe,L)){const Qe=U.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Le=i.get(pe).__webglTexture;n.bindTexture(Qe,Le),A(Qe),n.unbindTexture()}}}function Q(U){if(o&&U.samples>0&&Ce(U)===!1){const L=U.isWebGLMultipleRenderTargets?U.texture:[U.texture],J=U.width,me=U.height;let ye=t.COLOR_BUFFER_BIT;const pe=[],Qe=U.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=i.get(U),Xe=U.isWebGLMultipleRenderTargets===!0;if(Xe)for(let st=0;st<L.length;st++)n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Le.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglFramebuffer);for(let st=0;st<L.length;st++){pe.push(t.COLOR_ATTACHMENT0+st),U.depthBuffer&&pe.push(Qe);const Ie=Le.__ignoreDepthValues!==void 0?Le.__ignoreDepthValues:!1;if(Ie===!1&&(U.depthBuffer&&(ye|=t.DEPTH_BUFFER_BIT),U.stencilBuffer&&(ye|=t.STENCIL_BUFFER_BIT)),Xe&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Le.__webglColorRenderbuffer[st]),Ie===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[Qe]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[Qe])),Xe){const Pe=i.get(L[st]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Pe,0)}t.blitFramebuffer(0,0,J,me,0,0,J,me,ye,t.NEAREST),g&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,pe)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Xe)for(let st=0;st<L.length;st++){n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.RENDERBUFFER,Le.__webglColorRenderbuffer[st]);const Ie=i.get(L[st]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+st,t.TEXTURE_2D,Ie,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglMultisampledFramebuffer)}}function se(U){return Math.min(f,U.samples)}function Ce(U){const L=i.get(U);return o&&U.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Ee(U){const L=s.render.frame;y.get(U)!==L&&(y.set(U,L),U.update())}function ne(U,L){const J=U.colorSpace,me=U.format,ye=U.type;return U.isCompressedTexture===!0||U.isVideoTexture===!0||U.format===N3||J!==xc&&J!==Fs&&($n.getTransfer(J)===ii?o===!1?e.has("EXT_sRGB")===!0&&me===Us?(U.format=N3,U.minFilter=js,U.generateMipmaps=!1):L=p7.sRGBToLinear(L):(me!==Us||ye!==Bu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",J)),L}this.allocateTextureUnit=X,this.resetTextureUnits=K,this.setTexture2D=ee,this.setTexture2DArray=z,this.setTexture3D=V,this.setTextureCube=re,this.rebindTextures=q,this.setupRenderTarget=oe,this.updateRenderTargetMipmap=Z,this.updateMultisampleRenderTarget=Q,this.setupDepthRenderbuffer=H,this.setupFrameBufferTexture=Ue,this.useMultisampledRTT=Ce}function v_e(t,e,n){const i=n.isWebGL2;function r(a,s=Fs){let o;const l=$n.getTransfer(s);if(a===Bu)return t.UNSIGNED_BYTE;if(a===i7)return t.UNSIGNED_SHORT_4_4_4_4;if(a===r7)return t.UNSIGNED_SHORT_5_5_5_1;if(a===Hge)return t.BYTE;if(a===$ge)return t.SHORT;if(a===ak)return t.UNSIGNED_SHORT;if(a===n7)return t.INT;if(a===ku)return t.UNSIGNED_INT;if(a===ec)return t.FLOAT;if(a===t0)return i?t.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===Vge)return t.ALPHA;if(a===Us)return t.RGBA;if(a===Gge)return t.LUMINANCE;if(a===Wge)return t.LUMINANCE_ALPHA;if(a===sf)return t.DEPTH_COMPONENT;if(a===Qp)return t.DEPTH_STENCIL;if(a===N3)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===qge)return t.RED;if(a===a7)return t.RED_INTEGER;if(a===Xge)return t.RG;if(a===s7)return t.RG_INTEGER;if(a===o7)return t.RGBA_INTEGER;if(a===xT||a===vT||a===yT||a===bT)if(l===ii)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===xT)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===vT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===yT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===bT)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===xT)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===vT)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===yT)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===bT)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===gz||a===xz||a===vz||a===yz)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===gz)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===xz)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===vz)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===yz)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===l7)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===bz||a===_z)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(a===bz)return l===ii?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===_z)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===Sz||a===wz||a===Mz||a===Ez||a===Az||a===Tz||a===Cz||a===Nz||a===Rz||a===Pz||a===kz||a===Dz||a===Oz||a===Lz)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(a===Sz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===wz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Mz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===Ez)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===Az)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===Tz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Cz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===Nz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===Rz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===Pz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===kz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===Dz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===Oz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===Lz)return l===ii?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===_T||a===Iz||a===jz)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(a===_T)return l===ii?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===Iz)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===jz)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===Kge||a===Uz||a===Fz||a===zz)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(a===_T)return o.COMPRESSED_RED_RGTC1_EXT;if(a===Uz)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===Fz)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===zz)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===af?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 y_e extends as{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class ux extends ga{constructor(){super(),this.isGroup=!0,this.type="Group"}}const b_e={type:"move"};class VT{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ux,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 ux,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Te,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Te),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ux,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Te,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Te),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 _ of e.hand.values()){const v=n.getJointPose(_,i),x=this._getHandJoint(c,_);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 u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],m=u.position.distanceTo(f.position),g=.02,y=.005;c.inputState.pinching&&m>g+y?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&m<=g-y&&(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(b_e)))}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 ux;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[n.jointName]=i,e.add(i)}return e.joints[n.jointName]}}class __e extends $f{constructor(e,n){super();const i=this;let r=null,a=1,s=null,o="local-floor",l=1,c=null,u=null,f=null,m=null,g=null,y=null;const _=n.getContextAttributes();let v=null,x=null;const M=[],w=[],C=new Xt;let T=null;const P=new as;P.layers.enable(1),P.viewport=new Gn;const A=new as;A.layers.enable(2),A.viewport=new Gn;const j=[P,A],N=new y_e;N.layers.enable(1),N.layers.enable(2);let k=null,F=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(re){let le=M[re];return le===void 0&&(le=new VT,M[re]=le),le.getTargetRaySpace()},this.getControllerGrip=function(re){let le=M[re];return le===void 0&&(le=new VT,M[re]=le),le.getGripSpace()},this.getHand=function(re){let le=M[re];return le===void 0&&(le=new VT,M[re]=le),le.getHandSpace()};function I(re){const le=w.indexOf(re.inputSource);if(le===-1)return;const ge=M[le];ge!==void 0&&(ge.update(re.inputSource,re.frame,c||s),ge.dispatchEvent({type:re.type,data:re.inputSource}))}function W(){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",W),r.removeEventListener("inputsourceschange",D);for(let re=0;re<M.length;re++){const le=w[re];le!==null&&(w[re]=null,M[re].disconnect(le))}k=null,F=null,e.setRenderTarget(v),g=null,m=null,f=null,r=null,x=null,V.stop(),i.isPresenting=!1,e.setPixelRatio(T),e.setSize(C.width,C.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){a=re,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){o=re,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(re){c=re},this.getBaseLayer=function(){return m!==null?m:g},this.getBinding=function(){return f},this.getFrame=function(){return y},this.getSession=function(){return r},this.setSession=async function(re){if(r=re,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",W),r.addEventListener("inputsourceschange",D),_.xrCompatible!==!0&&await n.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(C),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const le={antialias:r.renderState.layers===void 0?_.antialias:!0,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(r,n,le),r.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),x=new Tf(g.framebufferWidth,g.framebufferHeight,{format:Us,type:Bu,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil})}else{let le=null,ge=null,ie=null;_.depth&&(ie=_.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,le=_.stencil?Qp:sf,ge=_.stencil?af:ku);const xe={colorFormat:n.RGBA8,depthFormat:ie,scaleFactor:a};f=new XRWebGLBinding(r,n),m=f.createProjectionLayer(xe),r.updateRenderState({layers:[m]}),e.setPixelRatio(1),e.setSize(m.textureWidth,m.textureHeight,!1),x=new Tf(m.textureWidth,m.textureHeight,{format:Us,type:Bu,depthTexture:new A7(m.textureWidth,m.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,le),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0});const ke=e.properties.get(x);ke.__ignoreDepthValues=m.ignoreDepthValues}x.isXRRenderTarget=!0,this.setFoveation(l),c=null,s=await r.requestReferenceSpace(o),V.setContext(r),V.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function D(re){for(let le=0;le<re.removed.length;le++){const ge=re.removed[le],ie=w.indexOf(ge);ie>=0&&(w[ie]=null,M[ie].disconnect(ge))}for(let le=0;le<re.added.length;le++){const ge=re.added[le];let ie=w.indexOf(ge);if(ie===-1){for(let ke=0;ke<M.length;ke++)if(ke>=w.length){w.push(ge),ie=ke;break}else if(w[ke]===null){w[ke]=ge,ie=ke;break}if(ie===-1)break}const xe=M[ie];xe&&xe.connect(ge)}}const B=new Te,$=new Te;function K(re,le,ge){B.setFromMatrixPosition(le.matrixWorld),$.setFromMatrixPosition(ge.matrixWorld);const ie=B.distanceTo($),xe=le.projectionMatrix.elements,ke=ge.projectionMatrix.elements,he=xe[14]/(xe[10]-1),we=xe[14]/(xe[10]+1),Ue=(xe[9]+1)/xe[5],ue=(xe[9]-1)/xe[5],lt=(xe[8]-1)/xe[0],H=(ke[8]+1)/ke[0],q=he*lt,oe=he*H,Z=ie/(-lt+H),Q=Z*-lt;le.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(Q),re.translateZ(Z),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert();const se=he+Z,Ce=we+Z,Ee=q-Q,ne=oe+(ie-Q),U=Ue*we/Ce*se,L=ue*we/Ce*se;re.projectionMatrix.makePerspective(Ee,ne,U,L,se,Ce),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}function X(re,le){le===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(le.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(r===null)return;N.near=A.near=P.near=re.near,N.far=A.far=P.far=re.far,(k!==N.near||F!==N.far)&&(r.updateRenderState({depthNear:N.near,depthFar:N.far}),k=N.near,F=N.far);const le=re.parent,ge=N.cameras;X(N,le);for(let ie=0;ie<ge.length;ie++)X(ge[ie],le);ge.length===2?K(N,P,A):N.projectionMatrix.copy(P.projectionMatrix),Y(re,N,le)};function Y(re,le,ge){ge===null?re.matrix.copy(le.matrixWorld):(re.matrix.copy(ge.matrixWorld),re.matrix.invert(),re.matrix.multiply(le.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(le.projectionMatrix),re.projectionMatrixInverse.copy(le.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=i0*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(m===null&&g===null))return l},this.setFoveation=function(re){l=re,m!==null&&(m.fixedFoveation=re),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=re)};let ee=null;function z(re,le){if(u=le.getViewerPose(c||s),y=le,u!==null){const ge=u.views;g!==null&&(e.setRenderTargetFramebuffer(x,g.framebuffer),e.setRenderTarget(x));let ie=!1;ge.length!==N.cameras.length&&(N.cameras.length=0,ie=!0);for(let xe=0;xe<ge.length;xe++){const ke=ge[xe];let he=null;if(g!==null)he=g.getViewport(ke);else{const Ue=f.getViewSubImage(m,ke);he=Ue.viewport,xe===0&&(e.setRenderTargetTextures(x,Ue.colorTexture,m.ignoreDepthValues?void 0:Ue.depthStencilTexture),e.setRenderTarget(x))}let we=j[xe];we===void 0&&(we=new as,we.layers.enable(xe),we.viewport=new Gn,j[xe]=we),we.matrix.fromArray(ke.transform.matrix),we.matrix.decompose(we.position,we.quaternion,we.scale),we.projectionMatrix.fromArray(ke.projectionMatrix),we.projectionMatrixInverse.copy(we.projectionMatrix).invert(),we.viewport.set(he.x,he.y,he.width,he.height),xe===0&&(N.matrix.copy(we.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),ie===!0&&N.cameras.push(we)}}for(let ge=0;ge<M.length;ge++){const ie=w[ge],xe=M[ge];ie!==null&&xe!==void 0&&xe.update(ie,le,c||s)}ee&&ee(re,le),le.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:le}),y=null}const V=new E7;V.setAnimationLoop(z),this.setAnimationLoop=function(re){ee=re},this.dispose=function(){}}}function S_e(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,S7(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,C){x.isMeshBasicMaterial||x.isMeshLambertMaterial?a(v,x):x.isMeshToonMaterial?(a(v,x),f(v,x)):x.isMeshPhongMaterial?(a(v,x),u(v,x)):x.isMeshStandardMaterial?(a(v,x),m(v,x),x.isMeshPhysicalMaterial&&g(v,x,C)):x.isMeshMatcapMaterial?(a(v,x),y(v,x)):x.isMeshDepthMaterial?a(v,x):x.isMeshDistanceMaterial?(a(v,x),_(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===Ua&&(v.bumpScale.value*=-1)),x.normalMap&&(v.normalMap.value=x.normalMap,n(x.normalMap,v.normalMapTransform),v.normalScale.value.copy(x.normalScale),x.side===Ua&&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 u(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 m(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 g(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===Ua&&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 y(v,x){x.matcap&&(v.matcap.value=x.matcap)}function _(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 w_e(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 C=w.program;i.uniformBlockBinding(M,C)}function c(M,w){let C=r[M.id];C===void 0&&(y(M),C=u(M),r[M.id]=C,M.addEventListener("dispose",v));const T=w.program;i.updateUBOMapping(M,T);const P=e.render.frame;a[M.id]!==P&&(m(M),a[M.id]=P)}function u(M){const w=f();M.__bindingPointIndex=w;const C=t.createBuffer(),T=M.__size,P=M.usage;return t.bindBuffer(t.UNIFORM_BUFFER,C),t.bufferData(t.UNIFORM_BUFFER,T,P),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,C),C}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 m(M){const w=r[M.id],C=M.uniforms,T=M.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let P=0,A=C.length;P<A;P++){const j=C[P];if(g(j,P,T)===!0){const N=j.__offset,k=Array.isArray(j.value)?j.value:[j.value];let F=0;for(let I=0;I<k.length;I++){const W=k[I],D=_(W);typeof W=="number"?(j.__data[0]=W,t.bufferSubData(t.UNIFORM_BUFFER,N+F,j.__data)):W.isMatrix3?(j.__data[0]=W.elements[0],j.__data[1]=W.elements[1],j.__data[2]=W.elements[2],j.__data[3]=W.elements[0],j.__data[4]=W.elements[3],j.__data[5]=W.elements[4],j.__data[6]=W.elements[5],j.__data[7]=W.elements[0],j.__data[8]=W.elements[6],j.__data[9]=W.elements[7],j.__data[10]=W.elements[8],j.__data[11]=W.elements[0]):(W.toArray(j.__data,F),F+=D.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,N,j.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(M,w,C){const T=M.value;if(C[w]===void 0){if(typeof T=="number")C[w]=T;else{const P=Array.isArray(T)?T:[T],A=[];for(let j=0;j<P.length;j++)A.push(P[j].clone());C[w]=A}return!0}else if(typeof T=="number"){if(C[w]!==T)return C[w]=T,!0}else{const P=Array.isArray(C[w])?C[w]:[C[w]],A=Array.isArray(T)?T:[T];for(let j=0;j<P.length;j++){const N=P[j];if(N.equals(A[j])===!1)return N.copy(A[j]),!0}}return!1}function y(M){const w=M.uniforms;let C=0;const T=16;let P=0;for(let A=0,j=w.length;A<j;A++){const N=w[A],k={boundary:0,storage:0},F=Array.isArray(N.value)?N.value:[N.value];for(let I=0,W=F.length;I<W;I++){const D=F[I],B=_(D);k.boundary+=B.boundary,k.storage+=B.storage}if(N.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=C,A>0){P=C%T;const I=T-P;P!==0&&I-k.boundary<0&&(C+=T-P,N.__offset=C)}C+=k.storage}return P=C%T,P>0&&(C+=T-P),M.__size=C,M.__cache={},this}function _(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 C=s.indexOf(w.__bindingPointIndex);s.splice(C,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 k3{constructor(e={}){const{canvas:n=bxe(),context:i=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let m;i!==null?m=i.getContextAttributes().alpha:m=s;const g=new Uint32Array(4),y=new Int32Array(4);let _=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=$r,this._useLegacyLights=!1,this.toneMapping=zu,this.toneMappingExposure=1;const w=this;let C=!1,T=0,P=0,A=null,j=-1,N=null;const k=new Gn,F=new Gn;let I=null;const W=new zt(0);let D=0,B=n.width,$=n.height,K=1,X=null,Y=null;const ee=new Gn(0,0,B,$),z=new Gn(0,0,B,$);let V=!1;const re=new sw;let le=!1,ge=!1,ie=null;const xe=new Jn,ke=new Xt,he=new Te,we={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ue(){return A===null?K:1}let ue=i;function lt(ce,je){for(let qe=0;qe<ce.length;qe++){const Ke=ce[qe],We=n.getContext(Ke,je);if(We!==null)return We}return null}try{const ce={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${iw}`),n.addEventListener("webglcontextlost",rt,!1),n.addEventListener("webglcontextrestored",fe,!1),n.addEventListener("webglcontextcreationerror",Oe,!1),ue===null){const je=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&je.shift(),ue=lt(je,ce),ue===null)throw lt(je)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&ue instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ue.getShaderPrecisionFormat===void 0&&(ue.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ce){throw console.error("THREE.WebGLRenderer: "+ce.message),ce}let H,q,oe,Z,Q,se,Ce,Ee,ne,U,L,J,me,ye,pe,Qe,Le,Xe,st,Ie,Pe,pt,it,nt;function dt(){H=new Oye(ue),q=new Tye(ue,H,e),H.init(q),pt=new v_e(ue,H,q),oe=new g_e(ue,H,q),Z=new jye(ue),Q=new n_e,se=new x_e(ue,H,oe,Q,q,pt,Z),Ce=new Nye(w),Ee=new Dye(w),ne=new Vxe(ue,q),it=new Eye(ue,H,ne,q),U=new Lye(ue,ne,Z,it),L=new Bye(ue,U,ne,Z),st=new zye(ue,q,se),Qe=new Cye(Q),J=new t_e(w,Ce,Ee,H,q,it,Qe),me=new S_e(w,Q),ye=new r_e,pe=new u_e(H,q),Xe=new Mye(w,Ce,Ee,oe,L,m,l),Le=new m_e(w,L,q),nt=new w_e(ue,Z,q,oe),Ie=new Aye(ue,H,Z,q),Pe=new Iye(ue,H,Z,q),Z.programs=J.programs,w.capabilities=q,w.extensions=H,w.properties=Q,w.renderLists=ye,w.shadowMap=Le,w.state=oe,w.info=Z}dt();const de=new __e(w,ue);this.xr=de,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){const ce=H.get("WEBGL_lose_context");ce&&ce.loseContext()},this.forceContextRestore=function(){const ce=H.get("WEBGL_lose_context");ce&&ce.restoreContext()},this.getPixelRatio=function(){return K},this.setPixelRatio=function(ce){ce!==void 0&&(K=ce,this.setSize(B,$,!1))},this.getSize=function(ce){return ce.set(B,$)},this.setSize=function(ce,je,qe=!0){if(de.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}B=ce,$=je,n.width=Math.floor(ce*K),n.height=Math.floor(je*K),qe===!0&&(n.style.width=ce+"px",n.style.height=je+"px"),this.setViewport(0,0,ce,je)},this.getDrawingBufferSize=function(ce){return ce.set(B*K,$*K).floor()},this.setDrawingBufferSize=function(ce,je,qe){B=ce,$=je,K=qe,n.width=Math.floor(ce*qe),n.height=Math.floor(je*qe),this.setViewport(0,0,ce,je)},this.getCurrentViewport=function(ce){return ce.copy(k)},this.getViewport=function(ce){return ce.copy(ee)},this.setViewport=function(ce,je,qe,Ke){ce.isVector4?ee.set(ce.x,ce.y,ce.z,ce.w):ee.set(ce,je,qe,Ke),oe.viewport(k.copy(ee).multiplyScalar(K).floor())},this.getScissor=function(ce){return ce.copy(z)},this.setScissor=function(ce,je,qe,Ke){ce.isVector4?z.set(ce.x,ce.y,ce.z,ce.w):z.set(ce,je,qe,Ke),oe.scissor(F.copy(z).multiplyScalar(K).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(ce){oe.setScissorTest(V=ce)},this.setOpaqueSort=function(ce){X=ce},this.setTransparentSort=function(ce){Y=ce},this.getClearColor=function(ce){return ce.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor.apply(Xe,arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha.apply(Xe,arguments)},this.clear=function(ce=!0,je=!0,qe=!0){let Ke=0;if(ce){let We=!1;if(A!==null){const _t=A.texture.format;We=_t===o7||_t===s7||_t===a7}if(We){const _t=A.texture.type,te=_t===Bu||_t===ku||_t===ak||_t===af||_t===i7||_t===r7,be=Xe.getClearColor(),Re=Xe.getClearAlpha(),Ne=be.r,Se=be.g,Je=be.b;te?(g[0]=Ne,g[1]=Se,g[2]=Je,g[3]=Re,ue.clearBufferuiv(ue.COLOR,0,g)):(y[0]=Ne,y[1]=Se,y[2]=Je,y[3]=Re,ue.clearBufferiv(ue.COLOR,0,y))}else Ke|=ue.COLOR_BUFFER_BIT}je&&(Ke|=ue.DEPTH_BUFFER_BIT),qe&&(Ke|=ue.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ue.clear(Ke)},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",rt,!1),n.removeEventListener("webglcontextrestored",fe,!1),n.removeEventListener("webglcontextcreationerror",Oe,!1),ye.dispose(),pe.dispose(),Q.dispose(),Ce.dispose(),Ee.dispose(),L.dispose(),it.dispose(),nt.dispose(),J.dispose(),de.dispose(),de.removeEventListener("sessionstart",ln),de.removeEventListener("sessionend",Ot),ie&&(ie.dispose(),ie=null),Rn.stop()};function rt(ce){ce.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),C=!0}function fe(){console.log("THREE.WebGLRenderer: Context Restored."),C=!1;const ce=Z.autoReset,je=Le.enabled,qe=Le.autoUpdate,Ke=Le.needsUpdate,We=Le.type;dt(),Z.autoReset=ce,Le.enabled=je,Le.autoUpdate=qe,Le.needsUpdate=Ke,Le.type=We}function Oe(ce){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ce.statusMessage)}function Me(ce){const je=ce.target;je.removeEventListener("dispose",Me),ve(je)}function ve(ce){Be(ce),Q.remove(ce)}function Be(ce){const je=Q.get(ce).programs;je!==void 0&&(je.forEach(function(qe){J.releaseProgram(qe)}),ce.isShaderMaterial&&J.releaseShaderCache(ce))}this.renderBufferDirect=function(ce,je,qe,Ke,We,_t){je===null&&(je=we);const te=We.isMesh&&We.matrixWorld.determinant()<0,be=Ti(ce,je,qe,Ke,We);oe.setMaterial(Ke,te);let Re=qe.index,Ne=1;if(Ke.wireframe===!0){if(Re=U.getWireframeAttribute(qe),Re===void 0)return;Ne=2}const Se=qe.drawRange,Je=qe.attributes.position;let ft=Se.start*Ne,vt=(Se.start+Se.count)*Ne;_t!==null&&(ft=Math.max(ft,_t.start*Ne),vt=Math.min(vt,(_t.start+_t.count)*Ne)),Re!==null?(ft=Math.max(ft,0),vt=Math.min(vt,Re.count)):Je!=null&&(ft=Math.max(ft,0),vt=Math.min(vt,Je.count));const xt=vt-ft;if(xt<0||xt===1/0)return;it.setup(We,Ke,be,qe,Re);let Pt,wt=Ie;if(Re!==null&&(Pt=ne.get(Re),wt=Pe,wt.setIndex(Pt)),We.isMesh)Ke.wireframe===!0?(oe.setLineWidth(Ke.wireframeLinewidth*Ue()),wt.setMode(ue.LINES)):wt.setMode(ue.TRIANGLES);else if(We.isLine){let mt=Ke.linewidth;mt===void 0&&(mt=1),oe.setLineWidth(mt*Ue()),We.isLineSegments?wt.setMode(ue.LINES):We.isLineLoop?wt.setMode(ue.LINE_LOOP):wt.setMode(ue.LINE_STRIP)}else We.isPoints?wt.setMode(ue.POINTS):We.isSprite&&wt.setMode(ue.TRIANGLES);if(We.isBatchedMesh)wt.renderMultiDraw(We._multiDrawStarts,We._multiDrawCounts,We._multiDrawCount);else if(We.isInstancedMesh)wt.renderInstances(ft,xt,We.count);else if(qe.isInstancedBufferGeometry){const mt=qe._maxInstanceCount!==void 0?qe._maxInstanceCount:1/0,Wt=Math.min(qe.instanceCount,mt);wt.renderInstances(ft,xt,Wt)}else wt.render(ft,xt)};function ct(ce,je,qe){ce.transparent===!0&&ce.side===Xl&&ce.forceSinglePass===!1?(ce.side=Ua,ce.needsUpdate=!0,qr(ce,je,qe),ce.side=Ku,ce.needsUpdate=!0,qr(ce,je,qe),ce.side=Xl):qr(ce,je,qe)}this.compile=function(ce,je,qe=null){qe===null&&(qe=ce),v=pe.get(qe),v.init(),M.push(v),qe.traverseVisible(function(We){We.isLight&&We.layers.test(je.layers)&&(v.pushLight(We),We.castShadow&&v.pushShadow(We))}),ce!==qe&&ce.traverseVisible(function(We){We.isLight&&We.layers.test(je.layers)&&(v.pushLight(We),We.castShadow&&v.pushShadow(We))}),v.setupLights(w._useLegacyLights);const Ke=new Set;return ce.traverse(function(We){const _t=We.material;if(_t)if(Array.isArray(_t))for(let te=0;te<_t.length;te++){const be=_t[te];ct(be,qe,We),Ke.add(be)}else ct(_t,qe,We),Ke.add(_t)}),M.pop(),v=null,Ke},this.compileAsync=function(ce,je,qe=null){const Ke=this.compile(ce,je,qe);return new Promise(We=>{function _t(){if(Ke.forEach(function(te){Q.get(te).currentProgram.isReady()&&Ke.delete(te)}),Ke.size===0){We(ce);return}setTimeout(_t,10)}H.get("KHR_parallel_shader_compile")!==null?_t():setTimeout(_t,10)})};let bt=null;function Rt(ce){bt&&bt(ce)}function ln(){Rn.stop()}function Ot(){Rn.start()}const Rn=new E7;Rn.setAnimationLoop(Rt),typeof self<"u"&&Rn.setContext(self),this.setAnimationLoop=function(ce){bt=ce,de.setAnimationLoop(ce),ce===null?Rn.stop():Rn.start()},de.addEventListener("sessionstart",ln),de.addEventListener("sessionend",Ot),this.render=function(ce,je){if(je!==void 0&&je.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;ce.matrixWorldAutoUpdate===!0&&ce.updateMatrixWorld(),je.parent===null&&je.matrixWorldAutoUpdate===!0&&je.updateMatrixWorld(),de.enabled===!0&&de.isPresenting===!0&&(de.cameraAutoUpdate===!0&&de.updateCamera(je),je=de.getCamera()),ce.isScene===!0&&ce.onBeforeRender(w,ce,je,A),v=pe.get(ce,M.length),v.init(),M.push(v),xe.multiplyMatrices(je.projectionMatrix,je.matrixWorldInverse),re.setFromProjectionMatrix(xe),ge=this.localClippingEnabled,le=Qe.init(this.clippingPlanes,ge),_=ye.get(ce,x.length),_.init(),x.push(_),qn(ce,je,0,w.sortObjects),_.finish(),w.sortObjects===!0&&_.sort(X,Y),this.info.render.frame++,le===!0&&Qe.beginShadows();const qe=v.state.shadowsArray;if(Le.render(qe,ce,je),le===!0&&Qe.endShadows(),this.info.autoReset===!0&&this.info.reset(),Xe.render(_,ce),v.setupLights(w._useLegacyLights),je.isArrayCamera){const Ke=je.cameras;for(let We=0,_t=Ke.length;We<_t;We++){const te=Ke[We];mr(_,ce,te,te.viewport)}}else mr(_,ce,je);A!==null&&(se.updateMultisampleRenderTarget(A),se.updateRenderTargetMipmap(A)),ce.isScene===!0&&ce.onAfterRender(w,ce,je),it.resetDefaultState(),j=-1,N=null,M.pop(),M.length>0?v=M[M.length-1]:v=null,x.pop(),x.length>0?_=x[x.length-1]:_=null};function qn(ce,je,qe,Ke){if(ce.visible===!1)return;if(ce.layers.test(je.layers)){if(ce.isGroup)qe=ce.renderOrder;else if(ce.isLOD)ce.autoUpdate===!0&&ce.update(je);else if(ce.isLight)v.pushLight(ce),ce.castShadow&&v.pushShadow(ce);else if(ce.isSprite){if(!ce.frustumCulled||re.intersectsSprite(ce)){Ke&&he.setFromMatrixPosition(ce.matrixWorld).applyMatrix4(xe);const te=L.update(ce),be=ce.material;be.visible&&_.push(ce,te,be,qe,he.z,null)}}else if((ce.isMesh||ce.isLine||ce.isPoints)&&(!ce.frustumCulled||re.intersectsObject(ce))){const te=L.update(ce),be=ce.material;if(Ke&&(ce.boundingSphere!==void 0?(ce.boundingSphere===null&&ce.computeBoundingSphere(),he.copy(ce.boundingSphere.center)):(te.boundingSphere===null&&te.computeBoundingSphere(),he.copy(te.boundingSphere.center)),he.applyMatrix4(ce.matrixWorld).applyMatrix4(xe)),Array.isArray(be)){const Re=te.groups;for(let Ne=0,Se=Re.length;Ne<Se;Ne++){const Je=Re[Ne],ft=be[Je.materialIndex];ft&&ft.visible&&_.push(ce,te,ft,qe,he.z,Je)}}else be.visible&&_.push(ce,te,be,qe,he.z,null)}}const _t=ce.children;for(let te=0,be=_t.length;te<be;te++)qn(_t[te],je,qe,Ke)}function mr(ce,je,qe,Ke){const We=ce.opaque,_t=ce.transmissive,te=ce.transparent;v.setupLightsView(qe),le===!0&&Qe.setGlobalState(w.clippingPlanes,qe),_t.length>0&&Qi(We,_t,je,qe),Ke&&oe.viewport(k.copy(Ke)),We.length>0&&gr(We,je,qe),_t.length>0&&gr(_t,je,qe),te.length>0&&gr(te,je,qe),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function Qi(ce,je,qe,Ke){if((qe.isScene===!0?qe.overrideMaterial:null)!==null)return;const _t=q.isWebGL2;ie===null&&(ie=new Tf(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?t0:Bu,minFilter:e0,samples:_t?4:0})),w.getDrawingBufferSize(ke),_t?ie.setSize(ke.x,ke.y):ie.setSize(t1(ke.x),t1(ke.y));const te=w.getRenderTarget();w.setRenderTarget(ie),w.getClearColor(W),D=w.getClearAlpha(),D<1&&w.setClearColor(16777215,.5),w.clear();const be=w.toneMapping;w.toneMapping=zu,gr(ce,qe,Ke),se.updateMultisampleRenderTarget(ie),se.updateRenderTargetMipmap(ie);let Re=!1;for(let Ne=0,Se=je.length;Ne<Se;Ne++){const Je=je[Ne],ft=Je.object,vt=Je.geometry,xt=Je.material,Pt=Je.group;if(xt.side===Xl&&ft.layers.test(Ke.layers)){const wt=xt.side;xt.side=Ua,xt.needsUpdate=!0,Pr(ft,qe,Ke,vt,xt,Pt),xt.side=wt,xt.needsUpdate=!0,Re=!0}}Re===!0&&(se.updateMultisampleRenderTarget(ie),se.updateRenderTargetMipmap(ie)),w.setRenderTarget(te),w.setClearColor(W,D),w.toneMapping=be}function gr(ce,je,qe){const Ke=je.isScene===!0?je.overrideMaterial:null;for(let We=0,_t=ce.length;We<_t;We++){const te=ce[We],be=te.object,Re=te.geometry,Ne=Ke===null?te.material:Ke,Se=te.group;be.layers.test(qe.layers)&&Pr(be,je,qe,Re,Ne,Se)}}function Pr(ce,je,qe,Ke,We,_t){ce.onBeforeRender(w,je,qe,Ke,We,_t),ce.modelViewMatrix.multiplyMatrices(qe.matrixWorldInverse,ce.matrixWorld),ce.normalMatrix.getNormalMatrix(ce.modelViewMatrix),We.onBeforeRender(w,je,qe,Ke,ce,_t),We.transparent===!0&&We.side===Xl&&We.forceSinglePass===!1?(We.side=Ua,We.needsUpdate=!0,w.renderBufferDirect(qe,je,Ke,We,ce,_t),We.side=Ku,We.needsUpdate=!0,w.renderBufferDirect(qe,je,Ke,We,ce,_t),We.side=Xl):w.renderBufferDirect(qe,je,Ke,We,ce,_t),ce.onAfterRender(w,je,qe,Ke,We,_t)}function qr(ce,je,qe){je.isScene!==!0&&(je=we);const Ke=Q.get(ce),We=v.state.lights,_t=v.state.shadowsArray,te=We.state.version,be=J.getParameters(ce,We.state,_t,je,qe),Re=J.getProgramCacheKey(be);let Ne=Ke.programs;Ke.environment=ce.isMeshStandardMaterial?je.environment:null,Ke.fog=je.fog,Ke.envMap=(ce.isMeshStandardMaterial?Ee:Ce).get(ce.envMap||Ke.environment),Ne===void 0&&(ce.addEventListener("dispose",Me),Ne=new Map,Ke.programs=Ne);let Se=Ne.get(Re);if(Se!==void 0){if(Ke.currentProgram===Se&&Ke.lightsStateVersion===te)return hi(ce,be),Se}else be.uniforms=J.getUniforms(ce),ce.onBuild(qe,be,w),ce.onBeforeCompile(be,w),Se=J.acquireProgram(be,Re),Ne.set(Re,Se),Ke.uniforms=be.uniforms;const Je=Ke.uniforms;return(!ce.isShaderMaterial&&!ce.isRawShaderMaterial||ce.clipping===!0)&&(Je.clippingPlanes=Qe.uniform),hi(ce,be),Ke.needsLights=Oc(ce),Ke.lightsStateVersion=te,Ke.needsLights&&(Je.ambientLightColor.value=We.state.ambient,Je.lightProbe.value=We.state.probe,Je.directionalLights.value=We.state.directional,Je.directionalLightShadows.value=We.state.directionalShadow,Je.spotLights.value=We.state.spot,Je.spotLightShadows.value=We.state.spotShadow,Je.rectAreaLights.value=We.state.rectArea,Je.ltc_1.value=We.state.rectAreaLTC1,Je.ltc_2.value=We.state.rectAreaLTC2,Je.pointLights.value=We.state.point,Je.pointLightShadows.value=We.state.pointShadow,Je.hemisphereLights.value=We.state.hemi,Je.directionalShadowMap.value=We.state.directionalShadowMap,Je.directionalShadowMatrix.value=We.state.directionalShadowMatrix,Je.spotShadowMap.value=We.state.spotShadowMap,Je.spotLightMatrix.value=We.state.spotLightMatrix,Je.spotLightMap.value=We.state.spotLightMap,Je.pointShadowMap.value=We.state.pointShadowMap,Je.pointShadowMatrix.value=We.state.pointShadowMatrix),Ke.currentProgram=Se,Ke.uniformsList=null,Se}function Ii(ce){if(ce.uniformsList===null){const je=ce.currentProgram.getUniforms();ce.uniformsList=w_.seqWithValue(je.seq,ce.uniforms)}return ce.uniformsList}function hi(ce,je){const qe=Q.get(ce);qe.outputColorSpace=je.outputColorSpace,qe.batching=je.batching,qe.instancing=je.instancing,qe.instancingColor=je.instancingColor,qe.skinning=je.skinning,qe.morphTargets=je.morphTargets,qe.morphNormals=je.morphNormals,qe.morphColors=je.morphColors,qe.morphTargetsCount=je.morphTargetsCount,qe.numClippingPlanes=je.numClippingPlanes,qe.numIntersection=je.numClipIntersection,qe.vertexAlphas=je.vertexAlphas,qe.vertexTangents=je.vertexTangents,qe.toneMapping=je.toneMapping}function Ti(ce,je,qe,Ke,We){je.isScene!==!0&&(je=we),se.resetTextureUnits();const _t=je.fog,te=Ke.isMeshStandardMaterial?je.environment:null,be=A===null?w.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:xc,Re=(Ke.isMeshStandardMaterial?Ee:Ce).get(Ke.envMap||te),Ne=Ke.vertexColors===!0&&!!qe.attributes.color&&qe.attributes.color.itemSize===4,Se=!!qe.attributes.tangent&&(!!Ke.normalMap||Ke.anisotropy>0),Je=!!qe.morphAttributes.position,ft=!!qe.morphAttributes.normal,vt=!!qe.morphAttributes.color;let xt=zu;Ke.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(xt=w.toneMapping);const Pt=qe.morphAttributes.position||qe.morphAttributes.normal||qe.morphAttributes.color,wt=Pt!==void 0?Pt.length:0,mt=Q.get(Ke),Wt=v.state.lights;if(le===!0&&(ge===!0||ce!==N)){const Ci=ce===N&&Ke.id===j;Qe.setState(Ke,ce,Ci)}let It=!1;Ke.version===mt.__version?(mt.needsLights&&mt.lightsStateVersion!==Wt.state.version||mt.outputColorSpace!==be||We.isBatchedMesh&&mt.batching===!1||!We.isBatchedMesh&&mt.batching===!0||We.isInstancedMesh&&mt.instancing===!1||!We.isInstancedMesh&&mt.instancing===!0||We.isSkinnedMesh&&mt.skinning===!1||!We.isSkinnedMesh&&mt.skinning===!0||We.isInstancedMesh&&mt.instancingColor===!0&&We.instanceColor===null||We.isInstancedMesh&&mt.instancingColor===!1&&We.instanceColor!==null||mt.envMap!==Re||Ke.fog===!0&&mt.fog!==_t||mt.numClippingPlanes!==void 0&&(mt.numClippingPlanes!==Qe.numPlanes||mt.numIntersection!==Qe.numIntersection)||mt.vertexAlphas!==Ne||mt.vertexTangents!==Se||mt.morphTargets!==Je||mt.morphNormals!==ft||mt.morphColors!==vt||mt.toneMapping!==xt||q.isWebGL2===!0&&mt.morphTargetsCount!==wt)&&(It=!0):(It=!0,mt.__version=Ke.version);let tn=mt.currentProgram;It===!0&&(tn=qr(Ke,je,We));let un=!1,mn=!1,Lt=!1;const Kt=tn.getUniforms(),Zt=mt.uniforms;if(oe.useProgram(tn.program)&&(un=!0,mn=!0,Lt=!0),Ke.id!==j&&(j=Ke.id,mn=!0),un||N!==ce){Kt.setValue(ue,"projectionMatrix",ce.projectionMatrix),Kt.setValue(ue,"viewMatrix",ce.matrixWorldInverse);const Ci=Kt.map.cameraPosition;Ci!==void 0&&Ci.setValue(ue,he.setFromMatrixPosition(ce.matrixWorld)),q.logarithmicDepthBuffer&&Kt.setValue(ue,"logDepthBufFC",2/(Math.log(ce.far+1)/Math.LN2)),(Ke.isMeshPhongMaterial||Ke.isMeshToonMaterial||Ke.isMeshLambertMaterial||Ke.isMeshBasicMaterial||Ke.isMeshStandardMaterial||Ke.isShaderMaterial)&&Kt.setValue(ue,"isOrthographic",ce.isOrthographicCamera===!0),N!==ce&&(N=ce,mn=!0,Lt=!0)}if(We.isSkinnedMesh){Kt.setOptional(ue,We,"bindMatrix"),Kt.setOptional(ue,We,"bindMatrixInverse");const Ci=We.skeleton;Ci&&(q.floatVertexTextures?(Ci.boneTexture===null&&Ci.computeBoneTexture(),Kt.setValue(ue,"boneTexture",Ci.boneTexture,se)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}We.isBatchedMesh&&(Kt.setOptional(ue,We,"batchingTexture"),Kt.setValue(ue,"batchingTexture",We._matricesTexture,se));const yi=qe.morphAttributes;if((yi.position!==void 0||yi.normal!==void 0||yi.color!==void 0&&q.isWebGL2===!0)&&st.update(We,qe,tn),(mn||mt.receiveShadow!==We.receiveShadow)&&(mt.receiveShadow=We.receiveShadow,Kt.setValue(ue,"receiveShadow",We.receiveShadow)),Ke.isMeshGouraudMaterial&&Ke.envMap!==null&&(Zt.envMap.value=Re,Zt.flipEnvMap.value=Re.isCubeTexture&&Re.isRenderTargetTexture===!1?-1:1),mn&&(Kt.setValue(ue,"toneMappingExposure",w.toneMappingExposure),mt.needsLights&&Qs(Zt,Lt),_t&&Ke.fog===!0&&me.refreshFogUniforms(Zt,_t),me.refreshMaterialUniforms(Zt,Ke,K,$,ie),w_.upload(ue,Ii(mt),Zt,se)),Ke.isShaderMaterial&&Ke.uniformsNeedUpdate===!0&&(w_.upload(ue,Ii(mt),Zt,se),Ke.uniformsNeedUpdate=!1),Ke.isSpriteMaterial&&Kt.setValue(ue,"center",We.center),Kt.setValue(ue,"modelViewMatrix",We.modelViewMatrix),Kt.setValue(ue,"normalMatrix",We.normalMatrix),Kt.setValue(ue,"modelMatrix",We.matrixWorld),Ke.isShaderMaterial||Ke.isRawShaderMaterial){const Ci=Ke.uniformsGroups;for(let Nn=0,Js=Ci.length;Nn<Js;Nn++)if(q.isWebGL2){const Pn=Ci[Nn];nt.update(Pn,tn),nt.bind(Pn,tn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return tn}function Qs(ce,je){ce.ambientLightColor.needsUpdate=je,ce.lightProbe.needsUpdate=je,ce.directionalLights.needsUpdate=je,ce.directionalLightShadows.needsUpdate=je,ce.pointLights.needsUpdate=je,ce.pointLightShadows.needsUpdate=je,ce.spotLights.needsUpdate=je,ce.spotLightShadows.needsUpdate=je,ce.rectAreaLights.needsUpdate=je,ce.hemisphereLights.needsUpdate=je}function Oc(ce){return ce.isMeshLambertMaterial||ce.isMeshToonMaterial||ce.isMeshPhongMaterial||ce.isMeshStandardMaterial||ce.isShadowMaterial||ce.isShaderMaterial&&ce.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return P},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(ce,je,qe){Q.get(ce.texture).__webglTexture=je,Q.get(ce.depthTexture).__webglTexture=qe;const Ke=Q.get(ce);Ke.__hasExternalTextures=!0,Ke.__hasExternalTextures&&(Ke.__autoAllocateDepthBuffer=qe===void 0,Ke.__autoAllocateDepthBuffer||H.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Ke.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ce,je){const qe=Q.get(ce);qe.__webglFramebuffer=je,qe.__useDefaultFramebuffer=je===void 0},this.setRenderTarget=function(ce,je=0,qe=0){A=ce,T=je,P=qe;let Ke=!0,We=null,_t=!1,te=!1;if(ce){const Re=Q.get(ce);Re.__useDefaultFramebuffer!==void 0?(oe.bindFramebuffer(ue.FRAMEBUFFER,null),Ke=!1):Re.__webglFramebuffer===void 0?se.setupRenderTarget(ce):Re.__hasExternalTextures&&se.rebindTextures(ce,Q.get(ce.texture).__webglTexture,Q.get(ce.depthTexture).__webglTexture);const Ne=ce.texture;(Ne.isData3DTexture||Ne.isDataArrayTexture||Ne.isCompressedArrayTexture)&&(te=!0);const Se=Q.get(ce).__webglFramebuffer;ce.isWebGLCubeRenderTarget?(Array.isArray(Se[je])?We=Se[je][qe]:We=Se[je],_t=!0):q.isWebGL2&&ce.samples>0&&se.useMultisampledRTT(ce)===!1?We=Q.get(ce).__webglMultisampledFramebuffer:Array.isArray(Se)?We=Se[qe]:We=Se,k.copy(ce.viewport),F.copy(ce.scissor),I=ce.scissorTest}else k.copy(ee).multiplyScalar(K).floor(),F.copy(z).multiplyScalar(K).floor(),I=V;if(oe.bindFramebuffer(ue.FRAMEBUFFER,We)&&q.drawBuffers&&Ke&&oe.drawBuffers(ce,We),oe.viewport(k),oe.scissor(F),oe.setScissorTest(I),_t){const Re=Q.get(ce.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+je,Re.__webglTexture,qe)}else if(te){const Re=Q.get(ce.texture),Ne=je||0;ue.framebufferTextureLayer(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,Re.__webglTexture,qe||0,Ne)}j=-1},this.readRenderTargetPixels=function(ce,je,qe,Ke,We,_t,te){if(!(ce&&ce.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=Q.get(ce).__webglFramebuffer;if(ce.isWebGLCubeRenderTarget&&te!==void 0&&(be=be[te]),be){oe.bindFramebuffer(ue.FRAMEBUFFER,be);try{const Re=ce.texture,Ne=Re.format,Se=Re.type;if(Ne!==Us&&pt.convert(Ne)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Je=Se===t0&&(H.has("EXT_color_buffer_half_float")||q.isWebGL2&&H.has("EXT_color_buffer_float"));if(Se!==Bu&&pt.convert(Se)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Se===ec&&(q.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!Je){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}je>=0&&je<=ce.width-Ke&&qe>=0&&qe<=ce.height-We&&ue.readPixels(je,qe,Ke,We,pt.convert(Ne),pt.convert(Se),_t)}finally{const Re=A!==null?Q.get(A).__webglFramebuffer:null;oe.bindFramebuffer(ue.FRAMEBUFFER,Re)}}},this.copyFramebufferToTexture=function(ce,je,qe=0){const Ke=Math.pow(2,-qe),We=Math.floor(je.image.width*Ke),_t=Math.floor(je.image.height*Ke);se.setTexture2D(je,0),ue.copyTexSubImage2D(ue.TEXTURE_2D,qe,0,0,ce.x,ce.y,We,_t),oe.unbindTexture()},this.copyTextureToTexture=function(ce,je,qe,Ke=0){const We=je.image.width,_t=je.image.height,te=pt.convert(qe.format),be=pt.convert(qe.type);se.setTexture2D(qe,0),ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,qe.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,qe.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,qe.unpackAlignment),je.isDataTexture?ue.texSubImage2D(ue.TEXTURE_2D,Ke,ce.x,ce.y,We,_t,te,be,je.image.data):je.isCompressedTexture?ue.compressedTexSubImage2D(ue.TEXTURE_2D,Ke,ce.x,ce.y,je.mipmaps[0].width,je.mipmaps[0].height,te,je.mipmaps[0].data):ue.texSubImage2D(ue.TEXTURE_2D,Ke,ce.x,ce.y,te,be,je.image),Ke===0&&qe.generateMipmaps&&ue.generateMipmap(ue.TEXTURE_2D),oe.unbindTexture()},this.copyTextureToTexture3D=function(ce,je,qe,Ke,We=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const _t=ce.max.x-ce.min.x+1,te=ce.max.y-ce.min.y+1,be=ce.max.z-ce.min.z+1,Re=pt.convert(Ke.format),Ne=pt.convert(Ke.type);let Se;if(Ke.isData3DTexture)se.setTexture3D(Ke,0),Se=ue.TEXTURE_3D;else if(Ke.isDataArrayTexture)se.setTexture2DArray(Ke,0),Se=ue.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,Ke.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ke.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,Ke.unpackAlignment);const Je=ue.getParameter(ue.UNPACK_ROW_LENGTH),ft=ue.getParameter(ue.UNPACK_IMAGE_HEIGHT),vt=ue.getParameter(ue.UNPACK_SKIP_PIXELS),xt=ue.getParameter(ue.UNPACK_SKIP_ROWS),Pt=ue.getParameter(ue.UNPACK_SKIP_IMAGES),wt=qe.isCompressedTexture?qe.mipmaps[0]:qe.image;ue.pixelStorei(ue.UNPACK_ROW_LENGTH,wt.width),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,wt.height),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,ce.min.x),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,ce.min.y),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,ce.min.z),qe.isDataTexture||qe.isData3DTexture?ue.texSubImage3D(Se,We,je.x,je.y,je.z,_t,te,be,Re,Ne,wt.data):qe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ue.compressedTexSubImage3D(Se,We,je.x,je.y,je.z,_t,te,be,Re,wt.data)):ue.texSubImage3D(Se,We,je.x,je.y,je.z,_t,te,be,Re,Ne,wt),ue.pixelStorei(ue.UNPACK_ROW_LENGTH,Je),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,ft),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,vt),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,xt),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,Pt),We===0&&Ke.generateMipmaps&&ue.generateMipmap(Se),oe.unbindTexture()},this.initTexture=function(ce){ce.isCubeTexture?se.setTextureCube(ce,0):ce.isData3DTexture?se.setTexture3D(ce,0):ce.isDataArrayTexture||ce.isCompressedArrayTexture?se.setTexture2DArray(ce,0):se.setTexture2D(ce,0),oe.unbindTexture()},this.resetState=function(){T=0,P=0,A=null,oe.reset(),it.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wo}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===sk?"display-p3":"srgb",n.unpackColorSpace=$n.workingColorSpace===aw?"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===$r?of:c7}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===of?$r:xc}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 M_e extends k3{}M_e.prototype.isWebGL1Renderer=!0;class fk{constructor(e,n=1,i=1e3){this.isFog=!0,this.name="",this.color=new zt(e),this.near=n,this.far=i}clone(){return new fk(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class E_e extends ga{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 A_e{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=C3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=oc()}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=oc()),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=oc()),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 ca=new Te;class Du{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++)ca.fromBufferAttribute(this,n),ca.applyMatrix4(e),this.setXYZ(n,ca.x,ca.y,ca.z);return this}applyNormalMatrix(e){for(let n=0,i=this.count;n<i;n++)ca.fromBufferAttribute(this,n),ca.applyNormalMatrix(e),this.setXYZ(n,ca.x,ca.y,ca.z);return this}transformDirection(e){for(let n=0,i=this.count;n<i;n++)ca.fromBufferAttribute(this,n),ca.transformDirection(e),this.setXYZ(n,ca.x,ca.y,ca.z);return this}setX(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=Hn(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=Hn(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=$o(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=$o(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=$o(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=$o(n,this.array)),n}setXY(e,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=Hn(n,this.array),i=Hn(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=Hn(n,this.array),i=Hn(i,this.array),r=Hn(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=Hn(n,this.array),i=Hn(i,this.array),r=Hn(r,this.array),a=Hn(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 ds(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 Du(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 T_e extends Fa{constructor(e=null,n=1,i=1,r,a,s,o,l,c=Hr,u=Hr,f,m){super(null,s,o,l,c,u,r,a,f,m),this.isDataTexture=!0,this.image={data:e,width:n,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function C_e(t,e){return t.z-e.z}function N_e(t,e){return e.z-t.z}class R_e{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 ap="batchId",mu=new Jn,C5=new Jn,P_e=new Jn,N5=new Jn,GT=new sw,Ab=new Vs,jd=new Xo,qg=new Te,WT=new R_e,Jr=new xo,Tb=[];function k_e(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 D_e extends xo{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,i=n*2,r){super(new aa,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 T_e(n,e,e,Us,ec);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:u,normalized:f}=l,m=new c.constructor(i*u),g=new l.constructor(m,u,f);g.setUsage(l.usage),n.setAttribute(o,g)}if(e.getIndex()!==null){const o=i>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new ds(o,1))}const s=r>65536?new Uint32Array(i):new Uint16Array(i);n.setAttribute(ap,new ds(s,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(ap))throw new Error(`BatchedMesh: Geometry cannot use attribute "${ap}"`);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===ap)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 Vs);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,mu),this.getBoundingBoxAt(r,Ab).applyMatrix4(mu),n.union(Ab))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xo);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,mu),this.getBoundingSphereAt(r,jd).applyMatrix4(mu),n.union(jd))}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(),u=c!==null;if(u&&(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,m=this._active,g=this._matricesTexture,y=this._matricesTexture.image.data;f.push(!0),m.push(!0);const _=this._geometryCount;this._geometryCount++,P_e.toArray(y,_*16),g.needsUpdate=!0,s.push(r),o.push({start:u?r.indexStart:r.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Vs,sphereInitialized:!1,sphere:new Xo});const v=this.geometry.getAttribute(ap);for(let x=0;x<r.vertexCount;x++)v.setX(r.vertexStart+x,_);return v.needsUpdate=!0,this.setGeometryAt(_,e),_}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 g in i.attributes){if(g===ap)continue;const y=n.getAttribute(g),_=i.getAttribute(g);k_e(y,_,l);const v=y.itemSize;for(let x=y.count,M=c;x<M;x++){const w=l+x;for(let C=0;C<v;C++)_.setComponent(w,C,0)}_.needsUpdate=!0}if(r){const g=o.indexStart;for(let y=0;y<s.count;y++)a.setX(g+y,l+s.getX(y));for(let y=s.count,_=o.indexCount;y<_;y++)a.setX(g+y,l);a.needsUpdate=!0}const u=this._bounds[e];n.boundingBox!==null?(u.box.copy(n.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,n.boundingSphere!==null?(u.sphere.copy(n.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const f=this._drawRanges[e],m=n.getAttribute("position");return f.count=r?s.count:m.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 u=c.start,f=c.start+c.count;u<f;u++){let m=u;o&&(m=o.getX(m)),a.expandByPoint(qg.fromBufferAttribute(l,m))}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,Ab),Ab.getCenter(a.center);const o=s.index,l=s.attributes.position,c=this._drawRanges[e];let u=0;for(let f=c.start,m=c.start+c.count;f<m;f++){let g=f;o&&(g=o.getX(g)),qg.fromBufferAttribute(l,g),u=Math.max(u,a.center.distanceToSquared(qg))}a.radius=Math.sqrt(u),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;Jr.material=this.material,Jr.geometry.index=l.index,Jr.geometry.attributes=l.attributes,Jr.geometry.boundingBox===null&&(Jr.geometry.boundingBox=new Vs),Jr.geometry.boundingSphere===null&&(Jr.geometry.boundingSphere=new Xo);for(let c=0;c<s;c++){if(!i[c]||!r[c])continue;const u=a[c];Jr.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(c,Jr.matrixWorld).premultiply(o),this.getBoundingBoxAt(c,Jr.geometry.boundingBox),this.getBoundingSphereAt(c,Jr.geometry.boundingSphere),Jr.raycast(e,Tb);for(let f=0,m=Tb.length;f<m;f++){const g=Tb[f];g.object=this,g.batchId=c,n.push(g)}Tb.length=0}Jr.material=null,Jr.geometry.index=null,Jr.geometry.attributes={},Jr.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,u=this._multiDrawCounts,f=this._drawRanges,m=this.perObjectFrustumCulled;m&&(N5.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),GT.setFromProjectionMatrix(N5,e.isWebGPURenderer?n0:Wo));let g=0;if(this.sortObjects){C5.copy(this.matrixWorld).invert(),qg.setFromMatrixPosition(i.matrixWorld).applyMatrix4(C5);for(let v=0,x=l.length;v<x;v++)if(l[v]){this.getMatrixAt(v,mu),this.getBoundingSphereAt(v,jd).applyMatrix4(mu);let M=!1;if(m&&(M=!GT.intersectsSphere(jd)),!M){const w=qg.distanceTo(jd.center);WT.push(f[v],w)}}const y=WT.list,_=this.customSort;_===null?y.sort(a.transparent?N_e:C_e):_.call(this,y,i);for(let v=0,x=y.length;v<x;v++){const M=y[v];c[g]=M.start*o,u[g]=M.count,g++}WT.reset()}else for(let y=0,_=l.length;y<_;y++)if(l[y]){let v=!1;if(m&&(this.getMatrixAt(y,mu),this.getBoundingSphereAt(y,jd).applyMatrix4(mu),v=!GT.intersectsSphere(jd)),!v){const x=f[y];c[g]=x.start*o,u[g]=x.count,g++}}this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,n,i,r,a,s){this.onBeforeRender(e,null,r,a,s)}}class B0 extends Am{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new zt(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 R5=new Te,P5=new Te,k5=new Jn,qT=new lk,Cb=new Xo;class O_e extends ga{constructor(e=new aa,n=new B0){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++)R5.fromBufferAttribute(n,r-1),P5.fromBufferAttribute(n,r),i[r]=i[r-1],i[r]+=R5.distanceTo(P5);e.setAttribute("lineDistance",new Oi(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(),Cb.copy(i.boundingSphere),Cb.applyMatrix4(r),Cb.radius+=a,e.ray.intersectsSphere(Cb)===!1)return;k5.copy(r).invert(),qT.copy(e.ray).applyMatrix4(k5);const o=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new Te,u=new Te,f=new Te,m=new Te,g=this.isLineSegments?2:1,y=i.index,v=i.attributes.position;if(y!==null){const x=Math.max(0,s.start),M=Math.min(y.count,s.start+s.count);for(let w=x,C=M-1;w<C;w+=g){const T=y.getX(w),P=y.getX(w+1);if(c.fromBufferAttribute(v,T),u.fromBufferAttribute(v,P),qT.distanceSqToSegment(c,u,m,f)>l)continue;m.applyMatrix4(this.matrixWorld);const j=e.ray.origin.distanceTo(m);j<e.near||j>e.far||n.push({distance:j,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,C=M-1;w<C;w+=g){if(c.fromBufferAttribute(v,w),u.fromBufferAttribute(v,w+1),qT.distanceSqToSegment(c,u,m,f)>l)continue;m.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(m);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 D5=new Te,O5=new Te;class lw extends O_e{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)D5.fromBufferAttribute(n,r),O5.fromBufferAttribute(n,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+D5.distanceTo(O5);e.setAttribute("lineDistance",new Oi(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class L_e extends aa{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],i=new Set,r=new Te,a=new Te;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,u=l.length;c<u;++c){const f=l[c],m=f.start,g=f.count;for(let y=m,_=m+g;y<_;y+=3)for(let v=0;v<3;v++){const x=o.getX(y+v),M=o.getX(y+(v+1)%3);r.fromBufferAttribute(s,x),a.fromBufferAttribute(s,M),L5(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 u=3*o+c,f=3*o+(c+1)%3;r.fromBufferAttribute(s,u),a.fromBufferAttribute(s,f),L5(r,a,i)===!0&&(n.push(r.x,r.y,r.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Oi(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function L5(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 I_e extends Am{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=u7,this.normalScale=new Xt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rk,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 j_e extends B0{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 k7 extends ga{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new zt(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 XT=new Jn,I5=new Te,j5=new Te;class U_e{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Xt(512,512),this.map=null,this.mapPass=null,this.matrix=new Jn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new sw,this._frameExtents=new Xt(1,1),this._viewportCount=1,this._viewports=[new Gn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,i=this.matrix;I5.setFromMatrixPosition(e.matrixWorld),n.position.copy(I5),j5.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(j5),n.updateMatrixWorld(),XT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(XT),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(XT)}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 U5=new Jn,Xg=new Te,KT=new Te;class F_e extends U_e{constructor(){super(new as(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Xt(4,2),this._viewportCount=6,this._viewports=[new Gn(2,1,1,1),new Gn(0,1,1,1),new Gn(3,1,1,1),new Gn(1,1,1,1),new Gn(3,0,1,1),new Gn(1,0,1,1)],this._cubeDirections=[new Te(1,0,0),new Te(-1,0,0),new Te(0,0,1),new Te(0,0,-1),new Te(0,1,0),new Te(0,-1,0)],this._cubeUps=[new Te(0,1,0),new Te(0,1,0),new Te(0,1,0),new Te(0,1,0),new Te(0,0,1),new Te(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()),Xg.setFromMatrixPosition(e.matrixWorld),i.position.copy(Xg),KT.copy(i.position),KT.add(this._cubeDirections[n]),i.up.copy(this._cubeUps[n]),i.lookAt(KT),i.updateMatrixWorld(),r.makeTranslation(-Xg.x,-Xg.y,-Xg.z),U5.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(U5)}}class z_e extends k7{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 F_e}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 B_e extends k7{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class H_e extends aa{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 D3 extends A_e{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 F5{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(Vr(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const z5=new Te,Nb=new Te;class $_e{constructor(e=new Te,n=new Te){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){z5.subVectors(e,this.start),Nb.subVectors(this.end,this.start);const i=Nb.dot(Nb);let a=Nb.dot(z5)/i;return n&&(a=Vr(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 V_e extends lw{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 aa;r.setAttribute("position",new Oi(n,3)),r.setAttribute("color",new Oi(i,3));const a=new B0({vertexColors:!0,toneMapped:!1});super(r,a),this.type="AxesHelper"}setColors(e,n,i){const r=new zt,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:iw}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=iw);class Ko{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"),Ko.nextNameID=Ko.nextNameID||0,this.$name.id=`lil-gui-name-${++Ko.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 G_e extends Ko{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 O3(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 W_e={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:O3,toHexString:O3},r0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},q_e={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const i=r0.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 r0.toHexString(r)}},X_e={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const i=r0.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 r0.toHexString(r)}},K_e=[W_e,r0,q_e,X_e];function Y_e(t){return K_e.find(e=>e.match(t))}class Z_e extends Ko{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=Y_e(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=O3(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 YT extends Ko{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 Q_e extends Ko{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,u,f;const m=5,g=M=>{o=M.clientX,l=c=M.clientY,s=!0,u=this.getValue(),f=0,window.addEventListener("mousemove",y),window.addEventListener("mouseup",_)},y=M=>{if(s){const w=M.clientX-o,C=M.clientY-l;Math.abs(C)>m?(M.preventDefault(),this.$input.blur(),s=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>m&&_()}if(!s){const w=M.clientY-c;f-=w*this._step*this._arrowKeyMultiplier(M),u+f>this._max?f=this._max-u:u+f<this._min&&(f=this._min-u),this._snapClampSetValue(u+f)}c=M.clientY},_=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",_)},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",g),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,C,T)=>(x-M)/(w-M)*(T-C)+C,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},u=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",m))},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",m))}else x.preventDefault(),n(x.touches[0].clientX)},m=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",m)},g=this._callOnFinishChange.bind(this),y=400;let _;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(_),_=setTimeout(g,y)};this.$slider.addEventListener("mousedown",i),this.$slider.addEventListener("touchstart",u,{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 J_e extends Ko{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 e1e extends Ko{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 t1e=`.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 n1e(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 B5=!1;class i1{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"),!B5&&o&&(n1e(t1e),B5=!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 J_e(this,e,n,i);const s=e[n];switch(typeof s){case"number":return new Q_e(this,e,n,i,r,a);case"boolean":return new G_e(this,e,n);case"string":return new e1e(this,e,n);case"function":return new YT(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,s)}addColor(e,n,i=1){return new Z_e(this,e,n,i)}addFolder(e){const n=new i1({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(i=>{i instanceof YT||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 YT)){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 ZT(t,e,n,i){return new(n||(n=Promise))((function(r,a){function s(c){try{l(i.next(c))}catch(u){a(u)}}function o(c){try{l(i.throw(c))}catch(u){a(u)}}function l(c){var u;c.done?r(c.value):(u=c.value,u instanceof n?u:new n((function(f){f(u)}))).then(s,o)}l((i=i.apply(t,[])).next())}))}class hk{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 hk(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 pk{constructor(e,n,i,r){this.src=e,this.gcode=n,this.params=i,this.comment=r}}class H5 extends pk{constructor(e,n,i,r){super(e,n,i,r),this.params=i}}class gu extends pk{constructor(e,n,i,r){super(e,n,void 0,i),this.toolIndex=r}}class $5{constructor(e,n,i,r=0){this.layer=e,this.commands=n,this.lineNumber=i,this.height=r}}class r1{constructor(e){this.lines=[],this.preamble=new $5(-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((u=>u.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 H5(e,l,c,s);case"t0":return new gu(e,l,s,0);case"t1":return new gu(e,l,s,1);case"t2":return new gu(e,l,s,2);case"t3":return new gu(e,l,s,3);case"t4":return new gu(e,l,s,4);case"t5":return new gu(e,l,s,5);case"t6":return new gu(e,l,s,6);case"t7":return new gu(e,l,s,7);default:return new pk(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 H5){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 $5(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=hk.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}}}r1.prototype.parseGcode=r1.prototype.parseGCode;const V5={type:"change"},QT={type:"start"},G5={type:"end"},Rb=new lk,W5=new bu,i1e=Math.cos(70*f7.DEG2RAD);class r1e extends $f{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new Te,this.cursor=new Te,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:Bh.ROTATE,MIDDLE:Bh.DOLLY,RIGHT:Bh.PAN},this.touches={ONE:Hh.ROTATE,TWO:Hh.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(q){q.addEventListener("keydown",Ue),this._domElementKeyEvents=q},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Ue),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(V5),i.update(),a=r.NONE},this.update=(function(){const q=new Te,oe=new Cf().setFromUnitVectors(e.up,new Te(0,1,0)),Z=oe.clone().invert(),Q=new Te,se=new Cf,Ce=new Te,Ee=2*Math.PI;return function(ne=null){const U=i.object.position;q.copy(U).sub(i.target),q.applyQuaternion(oe),o.setFromVector3(q),i.autoRotate&&a===r.NONE&&k((function(ye){return ye!==null?2*Math.PI/60*i.autoRotateSpeed*ye:2*Math.PI/60/60*i.autoRotateSpeed})(ne)),i.enableDamping?(o.theta+=l.theta*i.dampingFactor,o.phi+=l.phi*i.dampingFactor):(o.theta+=l.theta,o.phi+=l.phi);let L=i.minAzimuthAngle,J=i.maxAzimuthAngle;isFinite(L)&&isFinite(J)&&(L<-Math.PI?L+=Ee:L>Math.PI&&(L-=Ee),J<-Math.PI?J+=Ee:J>Math.PI&&(J-=Ee),o.theta=L<=J?Math.max(L,Math.min(J,o.theta)):o.theta>(L+J)/2?Math.max(L,o.theta):Math.min(J,o.theta)),o.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,o.phi)),o.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(u,i.dampingFactor):i.target.add(u),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),q.setFromSpherical(o),q.applyQuaternion(Z),U.copy(i.target).add(q),i.object.lookAt(i.target),i.enableDamping===!0?(l.theta*=1-i.dampingFactor,l.phi*=1-i.dampingFactor,u.multiplyScalar(1-i.dampingFactor)):(l.set(0,0,0),u.set(0,0,0));let me=!1;if(i.zoomToCursor&&P){let ye=null;if(i.object.isPerspectiveCamera){const pe=q.length();ye=X(pe*c);const Qe=pe-ye;i.object.position.addScaledVector(C,Qe),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const pe=new Te(T.x,T.y,0);pe.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),me=!0;const Qe=new Te(T.x,T.y,0);Qe.unproject(i.object),i.object.position.sub(Qe).add(pe),i.object.updateMatrixWorld(),ye=q.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):(Rb.origin.copy(i.object.position),Rb.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(Rb.direction))<i1e?e.lookAt(i.target):(W5.setFromNormalAndCoplanarPoint(i.object.up,i.target),Rb.intersectPlane(W5,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||Q.distanceToSquared(i.object.position)>s||8*(1-se.dot(i.object.quaternion))>s||Ce.distanceToSquared(i.target)>0)&&(i.dispatchEvent(V5),Q.copy(i.object.position),se.copy(i.object.quaternion),Ce.copy(i.target),!0)}})(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",ue),i.domElement.removeEventListener("pointerdown",xe),i.domElement.removeEventListener("pointercancel",he),i.domElement.removeEventListener("wheel",we),i.domElement.removeEventListener("pointermove",ke),i.domElement.removeEventListener("pointerup",he),i._domElementKeyEvents!==null&&(i._domElementKeyEvents.removeEventListener("keydown",Ue),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 F5,l=new F5;let c=1;const u=new Te,f=new Xt,m=new Xt,g=new Xt,y=new Xt,_=new Xt,v=new Xt,x=new Xt,M=new Xt,w=new Xt,C=new Te,T=new Xt;let P=!1;const A=[],j={};function N(){return Math.pow(.95,i.zoomSpeed)}function k(q){l.theta-=q}function F(q){l.phi-=q}const I=(function(){const q=new Te;return function(oe,Z){q.setFromMatrixColumn(Z,0),q.multiplyScalar(-oe),u.add(q)}})(),W=(function(){const q=new Te;return function(oe,Z){i.screenSpacePanning===!0?q.setFromMatrixColumn(Z,1):(q.setFromMatrixColumn(Z,0),q.crossVectors(i.object.up,q)),q.multiplyScalar(oe),u.add(q)}})(),D=(function(){const q=new Te;return function(oe,Z){const Q=i.domElement;if(i.object.isPerspectiveCamera){const se=i.object.position;q.copy(se).sub(i.target);let Ce=q.length();Ce*=Math.tan(i.object.fov/2*Math.PI/180),I(2*oe*Ce/Q.clientHeight,i.object.matrix),W(2*Z*Ce/Q.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(I(oe*(i.object.right-i.object.left)/i.object.zoom/Q.clientWidth,i.object.matrix),W(Z*(i.object.top-i.object.bottom)/i.object.zoom/Q.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}})();function B(q){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c/=q:(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*=q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function K(q){if(!i.zoomToCursor)return;P=!0;const oe=i.domElement.getBoundingClientRect(),Z=q.clientX-oe.left,Q=q.clientY-oe.top,se=oe.width,Ce=oe.height;T.x=Z/se*2-1,T.y=-Q/Ce*2+1,C.set(T.x,T.y,1).unproject(i.object).sub(i.object.position).normalize()}function X(q){return Math.max(i.minDistance,Math.min(i.maxDistance,q))}function Y(q){f.set(q.clientX,q.clientY)}function ee(q){y.set(q.clientX,q.clientY)}function z(){if(A.length===1)f.set(A[0].pageX,A[0].pageY);else{const q=.5*(A[0].pageX+A[1].pageX),oe=.5*(A[0].pageY+A[1].pageY);f.set(q,oe)}}function V(){if(A.length===1)y.set(A[0].pageX,A[0].pageY);else{const q=.5*(A[0].pageX+A[1].pageX),oe=.5*(A[0].pageY+A[1].pageY);y.set(q,oe)}}function re(){const q=A[0].pageX-A[1].pageX,oe=A[0].pageY-A[1].pageY,Z=Math.sqrt(q*q+oe*oe);x.set(0,Z)}function le(q){if(A.length==1)m.set(q.pageX,q.pageY);else{const Z=H(q),Q=.5*(q.pageX+Z.x),se=.5*(q.pageY+Z.y);m.set(Q,se)}g.subVectors(m,f).multiplyScalar(i.rotateSpeed);const oe=i.domElement;k(2*Math.PI*g.x/oe.clientHeight),F(2*Math.PI*g.y/oe.clientHeight),f.copy(m)}function ge(q){if(A.length===1)_.set(q.pageX,q.pageY);else{const oe=H(q),Z=.5*(q.pageX+oe.x),Q=.5*(q.pageY+oe.y);_.set(Z,Q)}v.subVectors(_,y).multiplyScalar(i.panSpeed),D(v.x,v.y),y.copy(_)}function ie(q){const oe=H(q),Z=q.pageX-oe.x,Q=q.pageY-oe.y,se=Math.sqrt(Z*Z+Q*Q);M.set(0,se),w.set(0,Math.pow(M.y/x.y,i.zoomSpeed)),B(w.y),x.copy(M)}function xe(q){i.enabled!==!1&&(A.length===0&&(i.domElement.setPointerCapture(q.pointerId),i.domElement.addEventListener("pointermove",ke),i.domElement.addEventListener("pointerup",he)),(function(oe){A.push(oe)})(q),q.pointerType==="touch"?(function(oe){switch(lt(oe),A.length){case 1:switch(i.touches.ONE){case Hh.ROTATE:if(i.enableRotate===!1)return;z(),a=r.TOUCH_ROTATE;break;case Hh.PAN:if(i.enablePan===!1)return;V(),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(i.touches.TWO){case Hh.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;i.enableZoom&&re(),i.enablePan&&V(),a=r.TOUCH_DOLLY_PAN;break;case Hh.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;i.enableZoom&&re(),i.enableRotate&&z(),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&i.dispatchEvent(QT)})(q):(function(oe){let Z;switch(oe.button){case 0:Z=i.mouseButtons.LEFT;break;case 1:Z=i.mouseButtons.MIDDLE;break;case 2:Z=i.mouseButtons.RIGHT;break;default:Z=-1}switch(Z){case Bh.DOLLY:if(i.enableZoom===!1)return;(function(Q){K(Q),x.set(Q.clientX,Q.clientY)})(oe),a=r.DOLLY;break;case Bh.ROTATE:if(oe.ctrlKey||oe.metaKey||oe.shiftKey){if(i.enablePan===!1)return;ee(oe),a=r.PAN}else{if(i.enableRotate===!1)return;Y(oe),a=r.ROTATE}break;case Bh.PAN:if(oe.ctrlKey||oe.metaKey||oe.shiftKey){if(i.enableRotate===!1)return;Y(oe),a=r.ROTATE}else{if(i.enablePan===!1)return;ee(oe),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&i.dispatchEvent(QT)})(q))}function ke(q){i.enabled!==!1&&(q.pointerType==="touch"?(function(oe){switch(lt(oe),a){case r.TOUCH_ROTATE:if(i.enableRotate===!1)return;le(oe),i.update();break;case r.TOUCH_PAN:if(i.enablePan===!1)return;ge(oe),i.update();break;case r.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;(function(Z){i.enableZoom&&ie(Z),i.enablePan&&ge(Z)})(oe),i.update();break;case r.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;(function(Z){i.enableZoom&&ie(Z),i.enableRotate&&le(Z)})(oe),i.update();break;default:a=r.NONE}})(q):(function(oe){switch(a){case r.ROTATE:if(i.enableRotate===!1)return;(function(Z){m.set(Z.clientX,Z.clientY),g.subVectors(m,f).multiplyScalar(i.rotateSpeed);const Q=i.domElement;k(2*Math.PI*g.x/Q.clientHeight),F(2*Math.PI*g.y/Q.clientHeight),f.copy(m),i.update()})(oe);break;case r.DOLLY:if(i.enableZoom===!1)return;(function(Z){M.set(Z.clientX,Z.clientY),w.subVectors(M,x),w.y>0?B(N()):w.y<0&&$(N()),x.copy(M),i.update()})(oe);break;case r.PAN:if(i.enablePan===!1)return;(function(Z){_.set(Z.clientX,Z.clientY),v.subVectors(_,y).multiplyScalar(i.panSpeed),D(v.x,v.y),y.copy(_),i.update()})(oe)}})(q))}function he(q){(function(oe){delete j[oe.pointerId];for(let Z=0;Z<A.length;Z++)if(A[Z].pointerId==oe.pointerId)return void A.splice(Z,1)})(q),A.length===0&&(i.domElement.releasePointerCapture(q.pointerId),i.domElement.removeEventListener("pointermove",ke),i.domElement.removeEventListener("pointerup",he)),i.dispatchEvent(G5),a=r.NONE}function we(q){i.enabled!==!1&&i.enableZoom!==!1&&a===r.NONE&&(q.preventDefault(),i.dispatchEvent(QT),(function(oe){K(oe),oe.deltaY<0?$(N()):oe.deltaY>0&&B(N()),i.update()})(q),i.dispatchEvent(G5))}function Ue(q){i.enabled!==!1&&i.enablePan!==!1&&(function(oe){let Z=!1;switch(oe.code){case i.keys.UP:oe.ctrlKey||oe.metaKey||oe.shiftKey?F(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(0,i.keyPanSpeed),Z=!0;break;case i.keys.BOTTOM:oe.ctrlKey||oe.metaKey||oe.shiftKey?F(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(0,-i.keyPanSpeed),Z=!0;break;case i.keys.LEFT:oe.ctrlKey||oe.metaKey||oe.shiftKey?k(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(i.keyPanSpeed,0),Z=!0;break;case i.keys.RIGHT:oe.ctrlKey||oe.metaKey||oe.shiftKey?k(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(-i.keyPanSpeed,0),Z=!0}Z&&(oe.preventDefault(),i.update())})(q)}function ue(q){i.enabled!==!1&&q.preventDefault()}function lt(q){let oe=j[q.pointerId];oe===void 0&&(oe=new Xt,j[q.pointerId]=oe),oe.set(q.pageX,q.pageY)}function H(q){const oe=q.pointerId===A[0].pointerId?A[1]:A[0];return j[oe.pointerId]}i.domElement.addEventListener("contextmenu",ue),i.domElement.addEventListener("pointerdown",xe),i.domElement.addEventListener("pointercancel",he),i.domElement.addEventListener("wheel",we,{passive:!1}),this.update()}}yt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Xt(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Da.line={uniforms:ck.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 D7 extends Yu{constructor(e){super({type:"LineMaterial",uniforms:ck.clone(Da.line.uniforms),vertexShader:Da.line.vertexShader,fragmentShader:Da.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 q5=new Vs,Pb=new Te;class O7 extends H_e{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 Oi([-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 Oi([-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 D3(n,6,1);return this.setAttribute("instanceStart",new Du(i,3,0)),this.setAttribute("instanceEnd",new Du(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 D3(n,6,1);return this.setAttribute("instanceColorStart",new Du(i,3,0)),this.setAttribute("instanceColorEnd",new Du(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 L_e(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Vs);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),q5.setFromBufferAttribute(n),this.boundingBox.union(q5))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Xo),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++)Pb.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(Pb)),Pb.fromBufferAttribute(n,a),r=Math.max(r,i.distanceToSquared(Pb));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 X5=new Te,K5=new Te,jr=new Gn,Ur=new Gn,Oo=new Gn,JT=new Te,e2=new Jn,Fr=new $_e,Y5=new Te,kb=new Vs,Db=new Xo,Lo=new Gn;let Io,qd;function Z5(t,e,n){return Lo.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Lo.multiplyScalar(1/Lo.w),Lo.x=qd/n.width,Lo.y=qd/n.height,Lo.applyMatrix4(t.projectionMatrixInverse),Lo.multiplyScalar(1/Lo.w),Math.abs(Math.max(Lo.x,Lo.y))}class a1e extends xo{constructor(e=new O7,n=new D7({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)X5.fromBufferAttribute(n,s),K5.fromBufferAttribute(i,s),r[o]=o===0?0:r[o-1],r[o+1]=r[o]+X5.distanceTo(K5);const a=new D3(r,2,1);return e.setAttribute("instanceDistanceStart",new Du(a,1,0)),e.setAttribute("instanceDistanceEnd",new Du(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;Io=e.ray;const s=this.matrixWorld,o=this.geometry,l=this.material;let c,u;qd=l.linewidth+a,o.boundingSphere===null&&o.computeBoundingSphere(),Db.copy(o.boundingSphere).applyMatrix4(s),i?c=.5*qd:c=Z5(r,Math.max(r.near,Db.distanceToPoint(Io.origin)),l.resolution),Db.radius+=c,Io.intersectsSphere(Db)!==!1&&(o.boundingBox===null&&o.computeBoundingBox(),kb.copy(o.boundingBox).applyMatrix4(s),i?u=.5*qd:u=Z5(r,Math.max(r.near,kb.distanceToPoint(Io.origin)),l.resolution),kb.expandByScalar(u),Io.intersectsBox(kb)!==!1&&(i?(function(f,m){const g=f.matrixWorld,y=f.geometry,_=y.attributes.instanceStart,v=y.attributes.instanceEnd;for(let x=0,M=Math.min(y.instanceCount,_.count);x<M;x++){Fr.start.fromBufferAttribute(_,x),Fr.end.fromBufferAttribute(v,x),Fr.applyMatrix4(g);const w=new Te,C=new Te;Io.distanceSqToSegment(Fr.start,Fr.end,C,w),C.distanceTo(w)<.5*qd&&m.push({point:C,pointOnLine:w,distance:Io.origin.distanceTo(C),object:f,face:null,faceIndex:x,uv:null,uv1:null})}})(this,n):(function(f,m,g){const y=m.projectionMatrix,_=f.material.resolution,v=f.matrixWorld,x=f.geometry,M=x.attributes.instanceStart,w=x.attributes.instanceEnd,C=Math.min(x.instanceCount,M.count),T=-m.near;Io.at(1,Oo),Oo.w=1,Oo.applyMatrix4(m.matrixWorldInverse),Oo.applyMatrix4(y),Oo.multiplyScalar(1/Oo.w),Oo.x*=_.x/2,Oo.y*=_.y/2,Oo.z=0,JT.copy(Oo),e2.multiplyMatrices(m.matrixWorldInverse,v);for(let P=0,A=C;P<A;P++){if(jr.fromBufferAttribute(M,P),Ur.fromBufferAttribute(w,P),jr.w=1,Ur.w=1,jr.applyMatrix4(e2),Ur.applyMatrix4(e2),jr.z>T&&Ur.z>T)continue;if(jr.z>T){const I=jr.z-Ur.z,W=(jr.z-T)/I;jr.lerp(Ur,W)}else if(Ur.z>T){const I=Ur.z-jr.z,W=(Ur.z-T)/I;Ur.lerp(jr,W)}jr.applyMatrix4(y),Ur.applyMatrix4(y),jr.multiplyScalar(1/jr.w),Ur.multiplyScalar(1/Ur.w),jr.x*=_.x/2,jr.y*=_.y/2,Ur.x*=_.x/2,Ur.y*=_.y/2,Fr.start.copy(jr),Fr.start.z=0,Fr.end.copy(Ur),Fr.end.z=0;const j=Fr.closestPointToPointParameter(JT,!0);Fr.at(j,Y5);const N=f7.lerp(jr.z,Ur.z,j),k=N>=-1&&N<=1,F=JT.distanceTo(Y5)<.5*qd;if(k&&F){Fr.start.fromBufferAttribute(M,P),Fr.end.fromBufferAttribute(w,P),Fr.start.applyMatrix4(v),Fr.end.applyMatrix4(v);const I=new Te,W=new Te;Io.distanceSqToSegment(Fr.start,Fr.end,W,I),g.push({point:W,pointOnLine:I,distance:Io.origin.distanceTo(W),object:f,face:null,faceIndex:P,uv:null,uv1:null})}}})(this,r,n)))}}class s1e extends lw{constructor(e,n,i,r,a=4473924,s=8947848){a=new zt(a),s=new zt(s);const o=Math.round(e/n);i=Math.round(i/r)*r/2;const l=[],c=[];let u=0;for(let m=-1*(e=o*n/2);m<=e;m+=n){l.push(m,0,-1*i,m,0,i);const g=m===0?a:s;g.toArray(c,u),u+=3,g.toArray(c,u),u+=3,g.toArray(c,u),u+=3,g.toArray(c,u),u+=3}for(let m=-1*i;m<=i;m+=r){l.push(-1*e,0,m,e,0,m);const g=m===0?a:s;g.toArray(c,u),u+=3,g.toArray(c,u),u+=3,g.toArray(c,u),u+=3,g.toArray(c,u),u+=3}const f=new aa;f.setAttribute("position",new Oi(l,3)),f.setAttribute("color",new Oi(c,3)),super(f,new B0({vertexColors:!0,toneMapped:!1}))}}function o1e(t,e,n,i){const r=(function(s,o,l){s*=.5,o*=.5,l*=.5;const c=new aa,u=[];return u.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 Oi(u,3)),c})(t,e,n),a=new lw(r,new j_e({color:new zt(i),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var wx=function(){var t=0,e=document.createElement("div");function n(u){return e.appendChild(u.dom),u}function i(u){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===u?"block":"none";t=u}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(u){u.preventDefault(),i(++t%e.children.length)}),!1);var r=(performance||Date).now(),a=r,s=0,o=n(new wx.Panel("FPS","#0ff","#002")),l=n(new wx.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new wx.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 u=(performance||Date).now();if(l.update(u-r,200),u>=a+1e3&&(o.update(1e3*s/(u-a),100),a=u,s=0,c)){var f=performance.memory;c.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return u},update:function(){r=this.end()},domElement:e,setMode:i}};wx.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,u=2*s,f=3*s,m=15*s,g=74*s,y=30*s,_=document.createElement("canvas");_.width=o,_.height=l,_.style.cssText="width:80px;height:48px";var v=_.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,u),v.fillRect(f,m,g,y),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f,m,g,y),{dom:_,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,m),v.fillStyle=e,v.fillText(a(x)+" "+t+" ("+a(i)+"-"+a(r)+")",c,u),v.drawImage(_,f+s,m,g-s,y,f,m,g-s,y),v.fillRect(f+g-s,m,s,y),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f+g-s,m,s,a((1-x/M)*y))}}};var l1e=wx;class Q5{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new i1,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 i1,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 c1e extends aa{constructor(e=[new Te],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 Te,s=new Te,o=new Xt,l=[],c=[],u=[],f=[];function m(g){const[y,_,v]=(function(x){const M=e[x],w=new Te,C=new Te,T=new Te,P=new Te;w.copy(M).sub(e[x-1]||M).normalize().add((e[x+1]||M).clone().sub(M).normalize()).normalize();let A=Number.MAX_VALUE;const j=Math.abs(w.x),N=Math.abs(w.y),k=Math.abs(w.z);return j<=A&&(A=j,C.set(1,0,0)),N<=A&&(A=N,C.set(0,1,0)),k<=A&&C.set(0,0,1),P.crossVectors(w,C).normalize(),C.crossVectors(w,P),T.crossVectors(w,C),[M,C,T]})(g);for(let x=0;x<=r;x++){const M=x/r*Math.PI*2,w=Math.sin(M),C=-Math.cos(M);s.x=C*_.x+w*v.x,s.y=C*_.y+w*v.y,s.z=C*_.z+w*v.z,s.normalize(),c.push(s.x,s.y,s.z),a.x=y.x+n*s.x*.5,a.y=y.y+n*s.y*.5,a.z=y.z+i*s.z*.5,l.push(a.x,a.y,a.z)}}(function(){for(let g=0;g<e.length;g++)m(g);m(closed===!1?e.length-1:0),(function(){for(let g=0;g<e.length;g++)for(let y=0;y<=r;y++)o.x=g/e.length,o.y=y/r,u.push(o.x,o.y)})(),(function(){for(let g=1;g<e.length;g++)for(let y=1;y<=r;y++){const _=(r+1)*(g-1)+(y-1),v=(r+1)*g+(y-1),x=(r+1)*g+y,M=(r+1)*(g-1)+y;f.push(_,v,M),f.push(v,x,M)}})()})(),this.setIndex(f),this.setAttribute("position",new Oi(l,3)),this.setAttribute("normal",new Oi(c,3)),this.setAttribute("uv",new Oi(u,2))}}class Mx{static get initial(){const e=new Mx;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const t2={h:0,s:0,l:0};class Rp{constructor(e){var n,i,r,a,s,o,l,c,u;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=Mx.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Rp.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new zt(14737632),this._travelColor=new zt(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 r1(this.minLayerThreshold),this.scene=new E_e,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new zt(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=(u=e.devMode)!==null&&u!==void 0?u:this.devMode,this.stats=this.devMode?new l1e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new zt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new zt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new zt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[g,y]of Object.entries(e.toolColors))this._toolColors[parseInt(g)]=new zt(y)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+iw),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 k3({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const g=document.getElementById(this.targetId);if(!g)throw new Error("Unable to find element "+this.targetId);this.renderer=new k3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,g.appendChild(this.canvas)}this.camera=new as(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,m=.8*f;this.scene.fog=new fk(this._backgroundColor,m,f),this.resize(),this.controls=new r1e(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 zt(i)}else this._extrusionColor=new zt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Rp.defaultExtrusionColor:this._extrusionColor instanceof zt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Rp.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new zt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new zt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new zt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new zt(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 V_e(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 B_e(13421772,.3*Math.PI),n=new z_e(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 ux;return n.name=e,n.quaternion.setFromEuler(new F0(-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=Mx.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 ZT(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 u=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:u.height};for(const m of u.commands)if(m.gcode!="g20"){if(m.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const g=m;this.state.t=g.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(m.gcode)>-1){const g=m,y={x:(n=g.params.x)!==null&&n!==void 0?n:this.state.x,y:(i=g.params.y)!==null&&i!==void 0?i:this.state.y,z:(r=g.params.z)!==null&&r!==void 0?r:this.state.z,r:(a=g.params.r)!==null&&a!==void 0?a:this.state.r,e:(s=g.params.e)!==null&&s!==void 0?s:this.state.e,i:(o=g.params.i)!==null&&o!==void 0?o:this.state.i,j:(l=g.params.j)!==null&&l!==void 0?l:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const _=((c=g.params.e)!==null&&c!==void 0?c:0)>0||this.nonTravelmoves.indexOf(m.gcode)>-1;(y.x!=this.state.x||y.y!=this.state.y||y.z!=this.state.z)&&(_&&this.renderExtrusion||!_&&this.renderTravel)&&(m.gcode=="g2"||m.gcode=="g3"||m.gcode=="g02"||m.gcode=="g03"?this.addArcSegment(f,this.state,y,_,m.gcode=="g2"||m.gcode=="g02"):this.addLineSegment(f,this.state,y,_))}this.state.x=y.x,this.state.y=y.y,this.state.z=y.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(t2),a=new zt().setHSL(t2.h,t2.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 s1e(this.buildVolume.x,10,this.buildVolume.y,10));const e=o1e(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 r1(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Mx.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,u=i.x,f=i.y,m=i.z;let g=i.r,y=i.i,_=i.j;if(g){const B=u-o,$=f-l,K=Math.sqrt(Math.pow(B/2,2)+Math.pow($/2,2));g=Math.max(g,K);const X=Math.pow(B,2)+Math.pow($,2),Y=Math.pow(g,2)-X/4;let ee=Math.sqrt(Y/X);(a&&g<0||!a&&g>0)&&(ee=-ee),y=B/2+$*ee,_=$/2-B*ee}const v=o==u&&l==f,x=o+y,M=l+_,w=Math.sqrt(y*y+_*_),C=Math.atan2(-_,-y),T=Math.atan2(f-M,u-x);let P;v?P=2*Math.PI:(P=a?C-T:T-C,P<0&&(P+=2*Math.PI));let A=w*P/1.8;this.inches&&(A*=25),A<1&&(A=1);let j=P/A;j*=a?-1:1;const N=[];N.push({x:o,y:l,z:c});const k=(c-m)/A;let F=o,I=l,W=c,D=C;for(let B=0;B<A-1;B++)D+=j,F=x+w*Math.cos(D),I=M+w*Math.sin(D),W+=k,N.push({x:F,y:I,z:W});N.push({x:i.x,y:i.y,z:i.z});for(let B=0;B<N.length-1;B++)s.push(N[B].x,N[B].y,N[B].z,N[B+1].x,N[B+1].y,N[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 aa;r.setAttribute("position",new Oi(e,3)),this.disposables.push(r);const a=new B0({color:n});this.disposables.push(a);const s=new lw(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 Te(o[0],o[1],o[2]),c=new Te(o[3],o[4],o[5]),u=new Te(o[6],o[7],o[8]);r.push(l),c.equals(u)||(r.push(c),a.push(r),r=[])}a.forEach((s=>{var o;const l=new c1e(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 O7;this.disposables.push(r);const a=new D7({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),r.setPositions(e);const s=new a1e(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=>ZT(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 I_e({color:e,wireframe:this._wireframe});this.disposables.push(r);const a=i.reduce(((o,l)=>3*l.attributes.position.count+o),0),s=new D_e(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 ZT(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)),u=c.lastIndexOf(`
- `),f=c.slice(0,u);this.parser.parseGCode(s+f),s=c.slice(u)}while(!a.done);var l;console.debug("read from stream",o)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new Q5(this):typeof this.devMode=="object"&&(this.devGui=new Q5(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())}}Rp.defaultExtrusionColor=new zt("hotpink");const u1e=function(t){return new Rp(t)};function d1e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},className:n=""}){const i=E.useRef(null),r=E.useRef(null),[a,s]=E.useState(!0),[o,l]=E.useState(null),[c,u]=E.useState(!1),[f,m]=E.useState(0),[g,y]=E.useState(0);E.useEffect(()=>{if(!i.current)return;const x=i.current,M=u1e({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),u(!1),fetch(t).then(async C=>{if(!C.ok)throw C.status===404&&(await C.json().catch(()=>({}))).detail?.includes("sliced")?(u(!0),new Error("not_sliced")):new Error("Failed to load G-code");return C.text()}).then(C=>{M.processGCode(C);const T=M.layers?.length||0;y(T),m(T),M.render(),s(!1)}).catch(C=>{l(C.message),s(!1)});const w=()=>{if(x.parentElement){const C=x.parentElement.getBoundingClientRect();x.width=C.width,x.height=C.height,M.resize()}};return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),M.dispose()}},[t,e]);const _=x=>{if(!r.current)return;const M=Math.max(1,Math.min(x,g));m(M),r.current.render()},v=x=>{_(parseInt(x.target.value,10))};return h.jsxs("div",{className:`relative flex flex-col h-full ${n}`,children:[h.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[h.jsx("canvas",{ref:i,className:"w-full h-full"}),a&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsxs("div",{className:"text-center",children:[h.jsx(Ht,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),h.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),c&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsxs("div",{className:"text-center max-w-sm px-4",children:[h.jsx(Nse,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),h.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),h.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&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:h.jsx("div",{className:"text-center text-red-400",children:h.jsx("p",{className:"text-sm",children:o})})})]}),!a&&!o&&!c&&g>0&&h.jsx("div",{className:"mt-4 px-2",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(Fp,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),h.jsx("button",{onClick:()=>_(f-1),disabled:f<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:h.jsx(_f,{className:"w-4 h-4"})}),h.jsx("input",{type:"range",min:1,max:g,value:f,onChange:v,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),h.jsx("button",{onClick:()=>_(f+1),disabled:f>=g,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:h.jsx(_m,{className:"w-4 h-4"})}),h.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[f," / ",g]})]})})]})}function f1e({archiveId:t,title:e,onClose:n}){const[i,r]=E.useState(null),[a,s]=E.useState(null),[o,l]=E.useState(!0);E.useEffect(()=>{const u=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]),E.useEffect(()=>{$e.getArchiveCapabilities(t).then(u=>{s(u),u.has_model?r("3d"):u.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 u=e||"model",f=`${window.location.origin}${$e.getArchiveForSlicer(t,u)}`;window.location.href=`bambustudioopen://${encodeURIComponent(f)}`};return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:h.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:u=>u.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:c,children:[h.jsx(mc,{className:"w-4 h-4"}),"Open in Slicer"]}),h.jsx(Ye,{variant:"ghost",size:"sm",onClick:n,children:h.jsx(Sn,{className:"w-5 h-5"})})]})]}),a&&h.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[h.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:[h.jsx(Gx,{className:"w-4 h-4"}),"3D Model",!a.has_model&&h.jsx("span",{className:"text-xs",children:"(not available)"})]}),h.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:[h.jsx(dse,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&h.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),h.jsx("div",{className:"flex-1 overflow-hidden p-4",children:o?h.jsx("div",{className:"w-full h-full flex items-center justify-center",children:h.jsx(Ht,{className:"w-8 h-8 animate-spin text-bambu-green"})}):i==="3d"&&a?h.jsx(oge,{url:$e.getArchiveDownload(t),buildVolume:a.build_volume,className:"w-full h-full"}):i==="gcode"&&a?h.jsx(d1e,{gcodeUrl:$e.getArchiveGcode(t),buildVolume:a.build_volume,className:"w-full h-full"}):h.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}function h1e({archiveId:t,archiveName:e,onClose:n,onSuccess:i}){const[r,a]=E.useState(null);E.useEffect(()=>{const u=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]);const{data:s,isLoading:o}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),l=Nt({mutationFn:()=>{if(!r)throw new Error("No printer selected");return $e.reprintArchive(t,r)},onSuccess:()=>{i(),n()}}),c=s?.filter(u=>u.is_active)||[];return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:h.jsx($t,{className:"w-full max-w-md",children:h.jsxs(Qt,{children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),h.jsx(Ye,{variant:"ghost",size:"sm",onClick:n,children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",h.jsx("span",{className:"text-white",children:e})," to a printer"]}),o?h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):c.length===0?h.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):h.jsx("div",{className:"space-y-2 mb-6",children:c.map(u=>h.jsxs("button",{onClick:()=>a(u.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${r===u.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[h.jsx("div",{className:`p-2 rounded-lg ${r===u.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:h.jsx(Qo,{className:`w-5 h-5 ${r===u.id?"text-bambu-green":"text-bambu-gray"}`})}),h.jsxs("div",{className:"text-left",children:[h.jsx("p",{className:"text-white font-medium",children:u.name}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.model||"Unknown model"," • ",u.ip_address]})]})]},u.id))}),l.isError&&h.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"}),h.jsxs("div",{className:"flex gap-3",children:[h.jsx(Ye,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),h.jsx(Ye,{onClick:()=>l.mutate(),disabled:!r||l.isPending,className:"flex-1",children:l.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Ht,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Qo,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function p1e({onClose:t,initialFiles:e}){const n=In(),{showToast:i}=wa(),r=E.useRef(null),[a,s]=E.useState(()=>e?.filter(A=>A.name.endsWith(".3mf")).map(A=>({file:A,status:"pending"}))||[]),[o,l]=E.useState(!1),[c,u]=E.useState(),[f,m]=E.useState(null);E.useEffect(()=>{const A=j=>{j.key==="Escape"&&t()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t]);const{data:g}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),y=Nt({mutationFn:A=>$e.uploadArchivesBulk(A,c),onSuccess:A=>{m(A),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),s(j=>j.map(N=>{const k=A.results.find(I=>I.filename===N.file.name),F=A.errors.find(I=>I.filename===N.file.name);return k?{...N,status:"success",archiveId:k.id}:F?{...N,status:"error",error:F.error}:N})),A.failed===0?i(`${A.uploaded} file${A.uploaded!==1?"s":""} uploaded`):A.uploaded===0?i(`Failed to upload ${A.failed} file${A.failed!==1?"s":""}`,"error"):i(`${A.uploaded} uploaded, ${A.failed} failed`,"warning")},onError:()=>{s(A=>A.map(j=>({...j,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),_=E.useCallback(A=>{A.preventDefault(),l(!0)},[]),v=E.useCallback(A=>{A.preventDefault(),l(!1)},[]),x=E.useCallback(A=>{A.preventDefault(),l(!1);const j=Array.from(A.dataTransfer.files).filter(N=>N.name.endsWith(".3mf"));j.length>0&&s(N=>[...N,...j.map(k=>({file:k,status:"pending"}))])},[]),M=E.useCallback(A=>{const j=Array.from(A.target.files||[]).filter(N=>N.name.endsWith(".3mf"));j.length>0&&s(N=>[...N,...j.map(k=>({file:k,status:"pending"}))]),r.current&&(r.current.value="")},[]),w=E.useCallback(A=>{s(j=>j.filter((N,k)=>k!==A))},[]),C=()=>{if(a.length===0)return;const A=a.filter(j=>j.status==="pending");A.length!==0&&(s(j=>j.map(N=>N.status==="pending"?{...N,status:"uploading"}:N)),y.mutate(A.map(j=>j.file)))},T=a.filter(A=>A.status==="pending").length,P=y.isPending;return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx($t,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:h.jsxs(Qt,{className:"p-0 flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),h.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"p-4",children:h.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:_,onDragLeave:v,onDrop:x,children:[h.jsx($p,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),h.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),h.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),h.jsx(Ye,{variant:"secondary",onClick:()=>r.current?.click(),disabled:P,children:"Browse Files"}),h.jsx("input",{ref:r,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:M})]})}),h.jsxs("div",{className:"px-4 pb-4",children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),h.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:A=>u(A.target.value?Number(A.target.value):void 0),disabled:P,children:[h.jsx("option",{value:"",children:"No printer"}),g?.map(A=>h.jsx("option",{value:A.id,children:A.name},A.id))]})]}),a.length>0&&h.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:h.jsx("div",{className:"space-y-2",children:a.map((A,j)=>h.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[h.jsx(qG,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),h.jsx("span",{className:"flex-1 text-white text-sm truncate",children:A.file.name}),h.jsxs("span",{className:"text-xs text-bambu-gray",children:[(A.file.size/(1024*1024)).toFixed(1)," MB"]}),A.status==="pending"&&h.jsx("button",{onClick:()=>w(j),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:P,children:h.jsx(Sn,{className:"w-4 h-4"})}),A.status==="uploading"&&h.jsx(Ht,{className:"w-4 h-4 text-bambu-green animate-spin"}),A.status==="success"&&h.jsx(hc,{className:"w-4 h-4 text-bambu-green"}),A.status==="error"&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-red-400",children:A.error}),h.jsx(Ec,{className:"w-4 h-4 text-red-400"})]})]},`${A.file.name}-${j}`))})}),f&&h.jsx("div",{className:"px-4 pb-4",children:h.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:h.jsxs("p",{className:"text-sm text-white",children:[h.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&h.jsxs(h.Fragment,{children:[", ",h.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),h.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[h.jsx(Ye,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&h.jsx(Ye,{onClick:C,disabled:T===0||P,className:"flex-1",children:P?h.jsxs(h.Fragment,{children:[h.jsx(Ht,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):h.jsxs(h.Fragment,{children:[h.jsx($p,{className:"w-4 h-4"}),"Upload ",T>0&&`(${T})`]})})]})]})})})}const m1e=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"];function g1e({archive:t,onClose:e,existingTags:n=[]}){E.useEffect(()=>{const X=Y=>{Y.key==="Escape"&&e()};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e]);const i=In(),[r,a]=E.useState(t.print_name||""),[s,o]=E.useState(t.printer_id),[l,c]=E.useState(t.notes||""),[u,f]=E.useState(t.tags||""),[m,g]=E.useState(t.failure_reason||""),[y,_]=E.useState(t.photos||[]),[v,x]=E.useState(!1),[M,w]=E.useState(!1),C=E.useRef(null),T=E.useRef(null),P=E.useRef(null),{data:A}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),{data:j}=Dt({queryKey:["archives"],queryFn:()=>$e.getArchives(void 0,1e3,0),enabled:n.length===0}),N=n.length>0?n:[...new Set(j?.flatMap(X=>X.tags?.split(",").map(Y=>Y.trim())||[]).filter(Boolean)||[])].sort(),k=u.split(",").map(X=>X.trim()).filter(Boolean),F=N.filter(X=>!k.includes(X)),I=X=>{if(!k.includes(X)){const Y=[...k,X].join(", ");f(Y)}P.current!==null&&clearTimeout(P.current),C.current?.focus()},W=X=>{const Y=k.filter(ee=>ee!==X).join(", ");f(Y)},D=Nt({mutationFn:X=>$e.updateArchive(t.id,X),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),e()}}),B=async X=>{const Y=X.target.files?.[0];if(Y){x(!0);try{const ee=await $e.uploadArchivePhoto(t.id,Y);_(ee.photos),i.invalidateQueries({queryKey:["archives"]})}catch(ee){console.error("Failed to upload photo:",ee)}finally{x(!1),T.current&&(T.current.value="")}}},$=async X=>{try{const Y=await $e.deleteArchivePhoto(t.id,X);_(Y.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(Y){console.error("Failed to delete photo:",Y)}},K=X=>{X.preventDefault(),D.mutate({print_name:r||void 0,printer_id:s,notes:l||void 0,tags:u||void 0,failure_reason:t.status==="failed"&&m||void 0})};return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:h.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:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:K,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),h.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),h.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:[h.jsx("option",{value:"",children:"No printer"}),A?.map(X=>h.jsx("option",{value:X.id,children:X.name},X.id))]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),h.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..."})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),k.length>0&&h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:k.map(X=>h.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[h.jsx(Xx,{className:"w-3 h-3"}),X,h.jsx("button",{type:"button",onClick:()=>W(X),className:"ml-0.5 text-bambu-gray hover:text-white",children:h.jsx(Sn,{className:"w-3 h-3"})})]},X))}),h.jsxs("div",{className:"relative",children:[h.jsx("input",{ref:C,type:"text",value:u,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:k.length>0?"Add more tags...":"Add tags..."}),M&&F.length>0&&h.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:[h.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),h.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:F.map(X=>h.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"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),h.jsxs("select",{value:m,onChange:X=>g(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:[h.jsx("option",{value:"",children:"Select reason..."}),m1e.map(X=>h.jsx("option",{value:X,children:X},X))]})]}),h.jsxs("div",{children:[h.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[h.jsx(H_,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),h.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[y.map(X=>h.jsxs("div",{className:"relative group",children:[h.jsx("img",{src:$e.getArchivePhotoUrl(t.id,X),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),h.jsx("button",{type:"button",onClick:()=>$(X),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:h.jsx(Ei,{className:"w-3 h-3 text-white"})})]},X)),h.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:[h.jsx("input",{ref:T,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:B,className:"hidden",disabled:v}),v?h.jsx(Ht,{className:"w-6 h-6 text-bambu-gray animate-spin"}):h.jsx(So,{className:"w-6 h-6 text-bambu-gray"})]})]}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(Ye,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{type:"submit",disabled:D.isPending,className:"flex-1",children:[h.jsx(Sm,{className:"w-4 h-4"}),D.isPending?"Saving...":"Save"]})]})]})]})})}function x1e({x:t,y:e,items:n,onClose:i}){const r=E.useRef(null);return E.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]),E.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]),h.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?h.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},s):h.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&&h.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:a.icon}),a.label]},s))})}function v1e({selectedIds:t,existingTags:e,onClose:n}){const i=In(),{showToast:r}=wa(),[a,s]=E.useState(""),[o,l]=E.useState(new Set),[c,u]=E.useState("add");E.useEffect(()=>{const _=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[n]);const f=Nt({mutationFn:async()=>{const _=Array.from(o);let v=0;for(const x of t)try{const M=await $e.getArchive(x),w=M.tags?M.tags.split(",").map(T=>T.trim()).filter(Boolean):[];let C;c==="add"?C=[...new Set([...w,..._])]:C=w.filter(T=>!o.has(T)),await $e.updateArchive(x,{tags:C.join(", ")}),v++}catch(M){throw console.error(`Failed to update archive ${x}:`,M),new Error(`Failed on archive ${x}: ${M instanceof Error?M.message:"Unknown error"}`)}return{count:v,mode:c,tags:_}},onSuccess:({count:_,mode:v,tags:x})=>{i.invalidateQueries({queryKey:["archives"]}),r(`${v==="add"?"Added":"Removed"} ${x.length} tag${x.length!==1?"s":""} ${v==="add"?"to":"from"} ${_} archive${_!==1?"s":""}`),n()},onError:_=>{r(_.message||"Failed to update tags","error")}}),m=_=>{l(v=>{const x=new Set(v);return x.has(_)?x.delete(_):x.add(_),x})},g=()=>{a.trim()&&!o.has(a.trim())&&(l(_=>new Set([..._,a.trim()])),s(""))},y=_=>{_.key==="Enter"&&(_.preventDefault(),g())};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx($t,{className:"w-full max-w-md",children:h.jsxs(Qt,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Xx,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:c==="add"?"Add Tags":"Remove Tags"})]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"p-4 space-y-4",children:[h.jsxs("p",{className:"text-sm text-bambu-gray",children:[c==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Ye,{size:"sm",variant:c==="add"?"primary":"secondary",onClick:()=>u("add"),children:"Add Tags"}),h.jsx(Ye,{size:"sm",variant:c==="remove"?"primary":"secondary",onClick:()=>u("remove"),children:"Remove Tags"})]}),c==="add"&&h.jsxs("div",{className:"flex gap-2",children:[h.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:_=>s(_.target.value),onKeyDown:y}),h.jsx(Ye,{size:"sm",variant:"secondary",onClick:g,disabled:!a.trim(),children:h.jsx(So,{className:"w-4 h-4"})})]}),e.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),h.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(_=>h.jsx("button",{onClick:()=>m(_),className:`px-2 py-1 rounded text-sm transition-colors ${o.has(_)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:_},_))})]}),o.size>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",c==="add"?"add":"remove",":"]}),h.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(o).map(_=>h.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:[_,h.jsx("button",{onClick:()=>m(_),className:"hover:opacity-70",children:h.jsx(Sn,{className:"w-3 h-3"})})]},_))})]})]}),h.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[h.jsx(Ye,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),h.jsx(Ye,{onClick:()=>f.mutate(),disabled:o.size===0||f.isPending,className:"flex-1",children:f.isPending?h.jsxs(h.Fragment,{children:[h.jsx(Ht,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Xx,{className:"w-4 h-4"}),c==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function y1e(t,e){return new Date(t,e+1,0).getDate()}function b1e(t,e){return new Date(t,e,1).getDay()}const _1e=["January","February","March","April","May","June","July","August","September","October","November","December"],S1e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function w1e({archives:t,onArchiveClick:e}){const n=new Date,[i,r]=E.useState(n.getMonth()),[a,s]=E.useState(n.getFullYear()),[o,l]=E.useState(null),c=E.useMemo(()=>{const x=new Map;return t.forEach(M=>{const w=new Date(M.completed_at||M.created_at),C=`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}-${String(w.getDate()).padStart(2,"0")}`,T=x.get(C)||[];T.push(M),x.set(C,T)}),x},[t]),u=y1e(a,i),f=b1e(a,i),m=()=>{i===0?(r(11),s(a-1)):r(i-1)},g=()=>{i===11?(r(0),s(a+1)):r(i+1)},y=()=>{r(n.getMonth()),s(n.getFullYear())},_=[];for(let x=0;x<f;x++)_.push(null);for(let x=1;x<=u;x++)_.push(x);const v=o?c.get(o)||[]:[];return h.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[h.jsxs("div",{className:"flex-1",children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsx("button",{onClick:m,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(_f,{className:"w-5 h-5 text-bambu-gray"})}),h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsxs("h2",{className:"text-lg font-semibold text-white",children:[_1e[i]," ",a]}),h.jsx("button",{onClick:y,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"})]}),h.jsx("button",{onClick:g,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(_m,{className:"w-5 h-5 text-bambu-gray"})})]}),h.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:S1e.map(x=>h.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:x},x))}),h.jsx("div",{className:"grid grid-cols-7 gap-1",children:_.map((x,M)=>{if(x===null)return h.jsx("div",{className:"aspect-square"},`empty-${M}`);const w=`${a}-${String(i+1).padStart(2,"0")}-${String(x).padStart(2,"0")}`,C=c.get(w)||[],T=C.length>0,P=x===n.getDate()&&i===n.getMonth()&&a===n.getFullYear(),A=w===o,j=C.filter(k=>k.status==="completed").length,N=C.filter(k=>k.status==="failed").length;return h.jsxs("button",{onClick:()=>l(A?null:w),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${A?"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:[h.jsx("span",{className:`text-sm font-medium ${P&&!A?"text-bambu-green":""}`,children:x}),T&&h.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[h.jsx("div",{className:`w-2 h-2 rounded-full ${N>0&&j===0?"bg-red-400":N>0?"bg-yellow-400":"bg-green-400"}`}),h.jsx("span",{className:"text-xs font-medium",children:C.length})]})]},x)})}),h.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[h.jsxs("div",{children:[h.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}),h.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),h.jsxs("div",{children:[h.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}),h.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),h.jsxs("div",{children:[h.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}),h.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),h.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:o?h.jsxs(h.Fragment,{children:[h.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?h.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:v.map(x=>h.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?h.jsx("img",{src:$e.getArchiveThumbnail(x.id),alt:"",className:"w-12 h-12 rounded object-cover"}):h.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:h.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-sm text-white truncate",children:x.print_name||x.filename}),h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:x.status==="failed"?"text-red-400":"text-green-400",children:x.status==="failed"?"Failed":"Completed"}),x.filament_color&&h.jsx("div",{className:"flex gap-0.5",children:x.filament_color.split(",").map((M,w)=>h.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:M}},w))})]})]})]},x.id))}):h.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):h.jsx("div",{className:"text-center py-8",children:h.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function M1e({archiveId:t,archiveName:e,onClose:n}){const i=$e.getArchiveQRCodeUrl(t,300);E.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 h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"p-6 flex flex-col items-center",children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),h.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:h.jsx("img",{src:i,alt:"QR Code",className:"w-64 h-64"})}),h.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),h.jsxs(Ye,{onClick:r,className:"w-full",children:[h.jsx(pc,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function E1e({archiveId:t,archiveName:e,photos:n,onClose:i,onDelete:r}){const[a,s]=E.useState(0),[o,l]=E.useState(!1);if(E.useEffect(()=>{const g=y=>{y.key==="Escape"&&i(),y.key==="ArrowLeft"&&s(_=>Math.max(0,_-1)),y.key==="ArrowRight"&&s(_=>Math.min(n.length-1,_+1))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[i,n.length]),E.useEffect(()=>{a>=n.length&&s(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return i(),null;const c=n[a],u=$e.getArchivePhotoUrl(t,c),f=()=>{const g=document.createElement("a");g.href=u,g.download=`${e}_photo_${a+1}.jpg`,g.click()},m=()=>{r&&l(!0)};return h.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:i,children:[h.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:g=>g.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),h.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:f,children:[h.jsx(pc,{className:"w-4 h-4"}),"Download"]}),r&&h.jsx(Ye,{variant:"secondary",size:"sm",onClick:m,className:"text-red-400 hover:text-red-300",children:h.jsx(Ei,{className:"w-4 h-4"})}),h.jsx("button",{onClick:i,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-6 h-6"})})]})]}),h.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&h.jsx("button",{onClick:()=>s(g=>g-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:h.jsx(_f,{className:"w-8 h-8 text-white"})}),h.jsx("img",{src:u,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&h.jsx("button",{onClick:()=>s(g=>g+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:h.jsx(_m,{className:"w-8 h-8 text-white"})})]}),n.length>1&&h.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((g,y)=>h.jsx("button",{onClick:()=>s(y),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${y===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:h.jsx("img",{src:$e.getArchivePhotoUrl(t,g),alt:`Thumbnail ${y+1}`,className:"w-full h-full object-cover"})},g))})]}),o&&h.jsx(Ia,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{r?.(c),l(!1)},onCancel:()=>l(!1)})]})}function Br(t){this.content=t}Br.prototype={constructor:Br,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 Br(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 Br(n)},addToStart:function(t,e){return new Br([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Br(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 Br(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=Br.from(t),t.size?new Br(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Br.from(t),t.size?new Br(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Br.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}};Br.from=function(t){if(t instanceof Br)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Br(e)};function L7(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=L7(r.content,a.content,n+1);if(s!=null)return s}n+=r.nodeSize}}function I7(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,u=Math.min(s.text.length,o.text.length);for(;c<u&&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=I7(s.content,o.content,n-1,i-1);if(c)return c}n-=l,i-=l}}class ht{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 u=o+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),i,r+u)}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 ht(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 ht(i,r)}cutByIndex(e,n){return e==n?ht.empty:e==0&&n==this.content.length?this:new ht(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 ht(r,a)}addToStart(e){return new ht([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ht(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 L7(this,e,n)}findDiffEnd(e,n=this.size,i=e.size){return I7(this,e,n,i)}findIndex(e){if(e==0)return Ob(0,e);if(e==this.size)return Ob(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?Ob(n+1,a):Ob(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 ht.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ht(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ht.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 ht(n||e,i)}static from(e){if(!e)return ht.empty;if(e instanceof ht)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ht([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ht.empty=new ht([],0);const n2={index:0,offset:0};function Ob(t,e){return n2.index=t,n2.offset=e,n2}function a1(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(!a1(t[i],e[i]))return!1}else{for(let i in t)if(!(i in e)||!a1(t[i],e[i]))return!1;for(let i in e)if(!(i in t))return!1}return!0}let Kn=class L3{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&&a1(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 L3.none;if(e instanceof L3)return[e];let n=e.slice();return n.sort((i,r)=>i.type.rank-r.type.rank),n}};Kn.none=[];class s1 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=U7(this.content,e+this.openStart,n);return i&&new Mt(i,this.openStart,this.openEnd)}removeBetween(e,n){return new Mt(j7(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(ht.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(ht.empty,0,0);function j7(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(j7(a.content,e-r-1,n-r-1)))}function U7(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=U7(s.content,e-a-1,n,s);return o&&t.replaceChild(r,s.copy(o))}function A1e(t,e,n){if(n.openStart>t.depth)throw new s1("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new s1("Inconsistent open depths");return F7(t,e,n,0)}function F7(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=F7(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 cf(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=T1e(n,t);return cf(a,B7(t,s,o,e,i))}else return cf(a,o1(t,e,i))}function z7(t,e){if(!e.type.compatibleContent(t.type))throw new s1("Cannot join "+e.type.name+" onto "+t.type.name)}function I3(t,e,n){let i=t.node(n);return z7(i,e.node(n)),i}function lf(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 Ex(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&&(lf(t.nodeAfter,i),a++));for(let o=a;o<s;o++)lf(r.child(o),i);e&&e.depth==n&&e.textOffset&&lf(e.nodeBefore,i)}function cf(t,e){return t.type.checkContent(e),t.copy(e)}function B7(t,e,n,i,r){let a=t.depth>r&&I3(t,e,r+1),s=i.depth>r&&I3(n,i,r+1),o=[];return Ex(null,t,r,o),a&&s&&e.index(r)==n.index(r)?(z7(a,s),lf(cf(a,B7(t,e,n,i,r+1)),o)):(a&&lf(cf(a,o1(t,e,r+1)),o),Ex(e,n,r,o),s&&lf(cf(s,o1(n,i,r+1)),o)),Ex(i,null,r,o),new ht(o)}function o1(t,e,n){let i=[];if(Ex(null,t,n,i),t.depth>n){let r=I3(t,e,n+1);lf(cf(r,o1(t,e,n+1)),i)}return Ex(e,null,n,i),new ht(i)}function T1e(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(ht.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}class a0{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 Kn.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 l1(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 a0(n,i,a)}static resolveCached(e,n){let i=J5.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 J5.set(e,i=new C1e);let r=i.elts[i.i]=a0.resolve(e,n);return i.i=(i.i+1)%N1e,r}}class C1e{constructor(){this.elts=[],this.i=0}}const N1e=12,J5=new WeakMap;class l1{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 R1e=Object.create(null);let Hu=class j3{constructor(e,n,i,r=Kn.none){this.type=e,this.attrs=n,this.marks=r,this.content=i||ht.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&&a1(this.attrs,n||e.defaultAttrs||R1e)&&Kn.sameSet(this.marks,i||Kn.none)}copy(e=null){return e==this.content?this:new j3(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new j3(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 A1e(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 a0.resolveCached(this,e)}resolveNoCache(e){return a0.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()+")"),H7(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=ht.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=Kn.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(!Kn.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=ht.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,r,i);return a.type.checkAttrs(a.attrs),a}};Hu.prototype.text=void 0;class c1 extends Hu{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):H7(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 c1(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new c1(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 H7(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Nf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let i=new P1e(e,n);if(i.next==null)return Nf.empty;let r=$7(i);i.next&&i.err("Unexpected trailing text");let a=U1e(j1e(r));return F1e(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 ht.from(o.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let m=a(f,o.concat(u));if(m)return m}}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(`
- `)}}Nf.empty=new Nf(!0);class P1e{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 $7(t){let e=[];do e.push(k1e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function k1e(t){let e=[];do e.push(D1e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function D1e(t){let e=I1e(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=O1e(t,e);else break;return e}function eB(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function O1e(t,e){let n=eB(t),i=n;return t.eat(",")&&(t.next!="}"?i=eB(t):i=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:e}}function L1e(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 I1e(t){if(t.eat("(")){let e=$7(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=L1e(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 j1e(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 u=n();r(a(s.expr,l),u),l=u}if(s.max==-1)r(a(s.expr,l),l);else for(let c=s.min;c<s.max;c++){let u=n();i(l,u),r(a(s.expr,l),u),l=u}return[i(l)]}else{if(s.type=="name")return[i(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function V7(t,e){return e-t}function tB(t,e){let n=[];return i(e),n.sort(V7);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 U1e(t){let e=Object.create(null);return n(tB(t,0));function n(i){let r=[];i.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let c;for(let u=0;u<r.length;u++)r[u][0]==o&&(c=r[u][1]);tB(t,l).forEach(u=>{c||r.push([o,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let a=e[i.join(",")]=new Nf(i.indexOf(t.length-1)>-1);for(let s=0;s<r.length;s++){let o=r[s][1].sort(V7);a.next.push({type:r[s][0],next:e[o.join(",")]||n(o)})}return a}}function F1e(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 G7(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 W7(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 q7(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 X7(t,e){let n=Object.create(null);if(e)for(let i in e)n[i]=new B1e(t,i,e[i]);return n}let nB=class K7{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=X7(e,i.attrs),this.defaultAttrs=G7(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==Nf.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:W7(this.attrs,e)}create(e=null,n,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Hu(this,this.computeAttrs(e),ht.from(n),Kn.setFrom(i))}createChecked(e=null,n,i){return n=ht.from(n),this.checkContent(n),new Hu(this,this.computeAttrs(e),n,Kn.setFrom(i))}createAndFill(e=null,n,i){if(e=this.computeAttrs(e),n=ht.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(ht.empty,!0);return a?new Hu(this,e,n.append(a),Kn.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){q7(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:Kn.none:e}static compile(e,n){let i=Object.create(null);e.forEach((a,s)=>i[a]=new K7(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 z1e(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 B1e{constructor(e,n,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?z1e(e,n,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class cw{constructor(e,n,i,r){this.name=e,this.rank=n,this.schema=i,this.spec=r,this.attrs=X7(e,r.attrs),this.excluded=null;let a=G7(this.attrs);this.instance=a?new Kn(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Kn(this,W7(this.attrs,e))}static compile(e,n){let i=Object.create(null),r=0;return e.forEach((a,s)=>i[a]=new cw(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){q7(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Y7{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=Br.from(e.nodes),n.marks=Br.from(e.marks||{}),this.nodes=nB.compile(this.spec.nodes,this),this.marks=cw.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]=Nf.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?iB(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==""?[]:iB(this,s.split(" "))}this.nodeFromJSON=r=>Hu.fromJSON(this,r),this.markFromJSON=r=>Kn.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 nB){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 c1(i,i.defaultAttrs,e,Kn.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 iB(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 H1e(t){return t.tag!=null}function $1e(t){return t.style!=null}let Ax=class U3{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let i=this.matchedStyles=[];n.forEach(r=>{if(H1e(r))this.tags.push(r);else if($1e(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 aB(this,n,!1);return i.addAll(e,Kn.none,n.from,n.to),i.finish()}parseSlice(e,n={}){let i=new aB(this,n,!0);return i.addAll(e,Kn.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(W1e(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=sB(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=sB(s)),s.node||s.ignore||s.mark||(s.node=r)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new U3(e,U3.schemaRules(e)))}};const Z7={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},V1e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Q7={ol:!0,ul:!0},s0=1,F3=2,Tx=4;function rB(t,e,n){return e!=null?(e?s0:0)|(e==="full"?F3:0):t&&t.whitespace=="pre"?s0|F3:n&~Tx}class Lb{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=Kn.none,this.match=a||(s&Tx?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ht.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&s0)){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=ht.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ht.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&&!Z7.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class aB{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=rB(null,n.preserveWhitespace,0)|(i?Tx:0);r?a=new Lb(r.type,r.attrs,Kn.none,!0,n.topMatch||r.type.contentMatch,s):i?a=new Lb(null,null,Kn.none,!0,null,s):a=new Lb(e.schema.topNodeType,null,Kn.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&F3?"full":this.localPreserveWS||(r.options&s0)>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;Q7.hasOwnProperty(s)&&this.parser.normalizeLists&&G1e(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,i));e:if(l?l.ignore:V1e.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,u=this.needsBlock;if(Z7.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=u}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=Kn.none;for(let o of r.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):oB(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=rB(e,a,s.options);s.options&Tx&&s.content.length==0&&(o|=Tx);let l=Kn.none;return i=i.filter(c=>(s.type?s.type.allowsMarkType(c.type):oB(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Lb(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|=s0)}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 u=l>0||l==0&&r?this.nodes[l].type:i&&l>=a?i.node(l-a).type:null;if(!u||u.name!=c&&!u.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 G1e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Q7.hasOwnProperty(i)&&n?(n.appendChild(e),e=n):i=="li"?n=e:i&&(n=null)}}function W1e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function sB(t){let e={};for(let n in t)e[n]=t[n];return e}function oB(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:u}=o.edge(l);if(c==e||a.indexOf(u)<0&&s(u))return!0}};if(s(r.contentMatch))return!0}}class Vf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},i){i||(i=i2(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++],u=this.serializeMark(c,s.isInline,n);u&&(a.push([c,r]),r.appendChild(u.dom),r=u.contentDOM||u.dom)}}r.appendChild(this.serializeNodeInner(s,n))}),i}serializeNodeInner(e,n){let{dom:i,contentDOM:r}=M_(i2(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&&M_(i2(i),r(e,n),null,e.attrs)}static renderSpec(e,n,i=null,r){return M_(e,n,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Vf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=lB(e.nodes);return n.text||(n.text=i=>i.text),n}static marksFromSchema(e){return lB(e.marks)}}function lB(t){let e={};for(let n in t){let i=t[n].spec.toDOM;i&&(e[n]=i)}return e}function i2(t){return t.document||window.document}const cB=new WeakMap;function q1e(t){let e=cB.get(t);return e===void 0&&cB.set(t,e=X1e(t)),e}function X1e(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 M_(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=q1e(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],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let m=f.indexOf(" ");m>0?l.setAttributeNS(f.slice(0,m),f.slice(m+1),c[f]):f=="style"&&l.style?l.style.cssText=c[f]:l.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let m=e[f];if(m===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:g,contentDOM:y}=M_(t,m,n,i);if(l.appendChild(g),y){if(o)throw new RangeError("Multiple content holes");o=y}}}return{dom:l,contentDOM:o}}const J7=65535,eW=Math.pow(2,16);function K1e(t,e){return t+e*eW}function uB(t){return t&J7}function Y1e(t){return(t-(t&J7))/eW}const tW=1,nW=2,E_=4,iW=8;class z3{constructor(e,n,i){this.pos=e,this.delInfo=n,this.recover=i}get deleted(){return(this.delInfo&iW)>0}get deletedBefore(){return(this.delInfo&(tW|E_))>0}get deletedAfter(){return(this.delInfo&(nW|E_))>0}get deletedAcross(){return(this.delInfo&E_)>0}}class ss{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ss.empty)return ss.empty}recover(e){let n=0,i=uB(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+Y1e(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],u=this.ranges[o+s],f=l+c;if(e<=f){let m=c?e==l?-1:e==f?1:n:n,g=l+r+(m<0?0:u);if(i)return g;let y=e==(n<0?l:f)?null:K1e(o/3,e-l),_=e==l?nW:e==f?tW:E_;return(n<0?e!=l:e!=f)&&(_|=iW),new z3(g,_,y)}r+=u-c}return i?e+r:new z3(e+r,0,null)}touches(e,n){let i=0,r=uB(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],u=l+c;if(e<=u&&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],u=this.ranges[r+i];e(o,o+c,l,l+u),a+=u-c}}invert(){return new ss(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ss.empty:new ss(e<0?[0,-e,0]:[0,0,e])}}ss.empty=new ss([]);class o0{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 o0(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 o0;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 z3(e,r,null)}}const r2=Object.create(null);let sa=class{getMap(){return ss.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=r2[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 r2)throw new RangeError("Duplicate use of step JSON ID "+e);return r2[e]=n,n.prototype.jsonID=e,n}};class Gi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Gi(e,null)}static fail(e){return new Gi(null,e)}static fromReplace(e,n,i,r){try{return Gi.ok(e.replace(n,i,r))}catch(a){if(a instanceof s1)return Gi.fail(a.message);throw a}}}function mk(t,e,n){let i=[];for(let r=0;r<t.childCount;r++){let a=t.child(r);a.content.size&&(a=a.copy(mk(a.content,e,a))),a.isInline&&(a=e(a,n,r)),i.push(a)}return ht.fromArray(i)}class Ou extends sa{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(mk(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 Gi.fromReplace(e,this.from,this.to,a)}invert(){return new vo(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 Ou(n.pos,i.pos,this.mark)}merge(e){return e instanceof Ou&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ou(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 Ou(n.from,n.to,e.markFromJSON(n.mark))}}sa.jsonID("addMark",Ou);class vo extends sa{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(mk(n.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),n.openStart,n.openEnd);return Gi.fromReplace(e,this.from,this.to,i)}invert(){return new Ou(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 vo(n.pos,i.pos,this.mark)}merge(e){return e instanceof vo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new vo(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 vo(n.from,n.to,e.markFromJSON(n.mark))}}sa.jsonID("removeMark",vo);class Lu extends sa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gi.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Gi.fromReplace(e,this.pos,this.pos+1,new Mt(ht.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 Lu(this.pos,n.marks[r]);return new Lu(this.pos,this.mark)}}return new Rf(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Lu(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 Lu(n.pos,e.markFromJSON(n.mark))}}sa.jsonID("addNodeMark",Lu);class Rf extends sa{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gi.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Gi.fromReplace(e,this.pos,this.pos+1,new Mt(ht.from(i),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Lu(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Rf(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 Rf(n.pos,e.markFromJSON(n.mark))}}sa.jsonID("removeNodeMark",Rf);class Ar extends sa{constructor(e,n,i,r=!1){super(),this.from=e,this.to=n,this.slice=i,this.structure=r}apply(e){return this.structure&&B3(e,this.from,this.to)?Gi.fail("Structure replace would overwrite content"):Gi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ss([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ar(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 Ar(n.pos,Math.max(n.pos,i.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ar)||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 Ar(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 Ar(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 Ar(n.from,n.to,Mt.fromJSON(e,n.slice),!!n.structure)}}sa.jsonID("replace",Ar);class Cr extends sa{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&&(B3(e,this.from,this.gapFrom)||B3(e,this.gapTo,this.to)))return Gi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Gi.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,n.content);return i?Gi.fromReplace(e,this.from,this.to,i):Gi.fail("Content does not fit in gap")}getMap(){return new ss([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 Cr(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 Cr(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 Cr(n.from,n.to,n.gapFrom,n.gapTo,Mt.fromJSON(e,n.slice),n.insert,!!n.structure)}}sa.jsonID("replaceAround",Cr);function B3(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 Z1e(t,e,n,i){let r=[],a=[],s,o;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let f=l.marks;if(!i.isInSet(f)&&u.type.allowsMarkType(i.type)){let m=Math.max(c,e),g=Math.min(c+l.nodeSize,n),y=i.addToSet(f);for(let _=0;_<f.length;_++)f[_].isInSet(y)||(s&&s.to==m&&s.mark.eq(f[_])?s.to=g:r.push(s=new vo(m,g,f[_])));o&&o.to==m?o.to=g:a.push(o=new Ou(m,g,i))}}),r.forEach(l=>t.step(l)),a.forEach(l=>t.step(l))}function Q1e(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 cw){let c=s.marks,u;for(;u=i.isInSet(c);)(l||(l=[])).push(u),c=u.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 u=0;u<l.length;u++){let f=l[u],m;for(let g=0;g<r.length;g++){let y=r[g];y.step==a-1&&f.eq(r[g].style)&&(m=y)}m?(m.to=c,m.step=a):r.push({style:f,from:Math.max(o,e),to:c,step:a})}}}),r.forEach(s=>t.step(new vo(s.from,s.to,s.style)))}function gk(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),u=o+c.nodeSize,f=i.matchType(c.type);if(!f)s.push(new Ar(o,u,Mt.empty));else{i=f;for(let m=0;m<c.marks.length;m++)n.allowsMarkType(c.marks[m].type)||t.step(new vo(o,u,c.marks[m]));if(r&&c.isText&&n.whitespace!="pre"){let m,g=/\r?\n|\r/g,y;for(;m=g.exec(c.text);)y||(y=new Mt(ht.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new Ar(o+m.index,o+m.index+m[0].length,y))}}o=u}if(!i.validEnd){let l=i.fillBefore(ht.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 J1e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Cm(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||!J1e(s,o,l))break;o&&(r=1),l<s.childCount&&(a=1)}return null}function eSe(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,u=ht.empty,f=0;for(let y=a,_=!1;y>n;y--)_||i.index(y)>0?(_=!0,u=ht.from(i.node(y).copy(u)),f++):l--;let m=ht.empty,g=0;for(let y=a,_=!1;y>n;y--)_||r.after(y+1)<r.end(y)?(_=!0,m=ht.from(r.node(y).copy(m)),g++):c++;t.step(new Cr(l,c,s,o,new Mt(u.append(m),f,g),u.size-f,!0))}function xk(t,e,n=null,i=t){let r=tSe(t,e),a=r&&nSe(i,e);return a?r.map(dB).concat({type:e,attrs:n}).concat(a.map(dB)):null}function dB(t){return{type:t,attrs:null}}function tSe(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 nSe(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 iSe(t,e,n){let i=ht.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=ht.from(n[s].type.create(n[s].attrs,i))}let r=e.start,a=e.end;t.step(new Cr(r,a,r,a,new Mt(i,0,0),n.length,!0))}function rSe(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)&&aSe(t.doc,t.mapping.slice(a).map(o),i)){let c=null;if(i.schema.linebreakReplacement){let g=i.whitespace=="pre",y=!!i.contentMatch.matchType(i.schema.linebreakReplacement);g&&!y?c=!1:!g&&y&&(c=!0)}c===!1&&aW(t,s,o,a),gk(t,t.mapping.slice(a).map(o,1),i,void 0,c===null);let u=t.mapping.slice(a),f=u.map(o,1),m=u.map(o+s.nodeSize,1);return t.step(new Cr(f,m,f+1,m-1,new Mt(ht.from(i.create(l,null,s.marks)),0,0),1,!0)),c===!0&&rW(t,s,o,a),!1}})}function rW(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 aW(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 aSe(t,e,n){let i=t.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}function sSe(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 Cr(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Mt(ht.from(s),0,0),1,!0))}function lc(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,u=n-2;c>a;c--,u--){let f=r.node(c),m=r.index(c);if(f.type.spec.isolating)return!1;let g=f.content.cutByIndex(m,f.childCount),y=i&&i[u+1];y&&(g=g.replaceChild(0,y.type.create(y.attrs)));let _=i&&i[u]||f;if(!f.canReplace(m+1,f.childCount)||!_.type.validContent(g))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 oSe(t,e,n=1,i){let r=t.doc.resolve(e),a=ht.empty,s=ht.empty;for(let o=r.depth,l=r.depth-n,c=n-1;o>l;o--,c--){a=ht.from(r.node(o).copy(a));let u=i&&i[c];s=ht.from(u?u.type.create(u.attrs,s):r.node(o).copy(s))}t.step(new Ar(e,e,new Mt(a.append(s),n,n),!0))}function ad(t,e){let n=t.resolve(e),i=n.index();return sW(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function lSe(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 sW(t,e){return!!(t&&e&&!t.isLeaf&&lSe(t,e))}function uw(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&&sW(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 cSe(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 u=s.whitespace=="pre",f=!!s.contentMatch.matchType(r);u&&!f?i=!1:!u&&f&&(i=!0)}let o=t.steps.length;if(i===!1){let u=t.doc.resolve(e+n);aW(t,u.node(),u.before(),o)}s.inlineContent&&gk(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 Ar(c,l.map(e+n,-1),Mt.empty,!0)),i===!0){let u=t.doc.resolve(c);rW(t,u.node(),u.before(),t.steps.length)}return t}function uSe(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 oW(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),u=!1;if(a==1)u=c.canReplace(l,l,r);else{let f=c.contentMatchAt(l).findWrapping(r.firstChild.type);u=f&&c.canReplaceWith(l,l,f[0])}if(u)return o==0?i.pos:o<0?i.before(s+1):i.after(s+1)}return null}function dw(t,e,n=e,i=Mt.empty){if(e==n&&!i.size)return null;let r=t.resolve(e),a=t.resolve(n);return lW(r,a,i)?new Ar(e,n,i):new dSe(r,a,i).fit()}function lW(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class dSe{constructor(e,n,i){this.$from=e,this.$to=n,this.unplaced=i,this.frontier=[],this.placed=ht.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=ht.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 Cr(i.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||i.pos!=this.$to.pos?new Ar(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=a2(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],u,f=null;if(n==1&&(s?c.matchType(s.type)||(f=c.fillBefore(ht.from(s),!1)):a&&l.compatibleContent(a.type)))return{sliceDepth:i,frontierDepth:o,parent:a,inject:f};if(n==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:i,frontierDepth:o,parent:a,wrap:u};if(a&&c.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:i}=this.unplaced,r=a2(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=a2(e,n);if(r.childCount<=1&&n>0){let a=e.size-n<=n+r.size;this.unplaced=new Mt(dx(e,n-1,1),n-1,a?n-1:i)}else this.unplaced=new Mt(dx(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 _=0;_<a.length;_++)this.openFrontierNode(a[_]);let s=this.unplaced,o=i?i.content:s.content,l=s.openStart-e,c=0,u=[],{match:f,type:m}=this.frontier[n];if(r){for(let _=0;_<r.childCount;_++)u.push(r.child(_));f=f.matchFragment(r)}let g=o.size+e-(s.content.size-s.openEnd);for(;c<o.childCount;){let _=o.child(c),v=f.matchType(_.type);if(!v)break;c++,(c>1||l==0||_.content.size)&&(f=v,u.push(cW(_.mark(m.allowedMarks(_.marks)),c==1?l:0,c==o.childCount?g:-1)))}let y=c==o.childCount;y||(g=-1),this.placed=fx(this.placed,n,ht.from(u)),this.frontier[n].match=f,y&&g<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let _=0,v=o;_<g;_++){let x=v.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),v=x.content}this.unplaced=y?e==0?Mt.empty:new Mt(dx(s.content,e-1,1),e-1,g<0?s.openEnd:e-1):new Mt(dx(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||!s2(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=s2(e,n,r,i,a);if(s){for(let o=n-1;o>=0;o--){let{match:l,type:c}=this.frontier[o],u=s2(e,o,c,l,!0);if(!u||u.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=fx(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=fx(this.placed,this.depth,ht.from(e.create(n,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ht.empty,!0);n.childCount&&(this.placed=fx(this.placed,this.frontier.length,n))}}function dx(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(dx(t.firstChild.content,e-1,n)))}function fx(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(fx(t.lastChild.content,e-1,n)))}function a2(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function cW(t,e,n){if(e<=0)return t;let i=t.content;return e>1&&(i=i.replaceChild(0,cW(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(ht.empty,!0)))),t.copy(i)}function s2(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&&!fSe(n,a.content,s)?o:null}function fSe(t,e,n){for(let i=n;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return!0;return!1}function hSe(t){return t.spec.defining||t.spec.definingForContent}function pSe(t,e,n,i){if(!i.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),a=t.doc.resolve(n);if(lW(r,a,i))return t.step(new Ar(e,n,i));let s=dW(r,a);s[s.length-1]==0&&s.pop();let o=-(r.depth+1);s.unshift(o);for(let m=r.depth,g=r.pos-1;m>0;m--,g--){let y=r.node(m).type.spec;if(y.defining||y.definingAsContext||y.isolating)break;s.indexOf(m)>-1?o=m:r.before(m)==g&&s.splice(1,0,-m)}let l=s.indexOf(o),c=[],u=i.openStart;for(let m=i.content,g=0;;g++){let y=m.firstChild;if(c.push(y),g==i.openStart)break;m=y.content}for(let m=u-1;m>=0;m--){let g=c[m],y=hSe(g.type);if(y&&!g.sameMarkup(r.node(Math.abs(o)-1)))u=m;else if(y||!g.type.isTextblock)break}for(let m=i.openStart;m>=0;m--){let g=(m+u+1)%(i.openStart+1),y=c[g];if(y)for(let _=0;_<s.length;_++){let v=s[(_+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,y.type,y.marks))return t.replace(r.before(v),x?a.after(v):n,new Mt(uW(i.content,0,i.openStart,g),g,i.openEnd))}}let f=t.steps.length;for(let m=s.length-1;m>=0&&(t.replace(e,n,i),!(t.steps.length>f));m--){let g=s[m];g<0||(e=r.before(g),n=a.after(g))}}function uW(t,e,n,i,r){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(uW(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(ht.empty,!0))}return t}function mSe(t,e,n,i){if(!i.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=uSe(t.doc,e,i.type);r!=null&&(e=n=r)}t.replaceRange(e,n,new Mt(ht.from(i),0,0))}function gSe(t,e,n){let i=t.doc.resolve(e),r=t.doc.resolve(n),a=dW(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 dW(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 Pp extends sa{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 Gi.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 Gi.fromReplace(e,this.pos,this.pos+1,new Mt(ht.from(r),0,n.isLeaf?0:1))}getMap(){return ss.empty}invert(e){return new Pp(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 Pp(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 Pp(n.pos,n.attr,n.value)}}sa.jsonID("attr",Pp);class l0 extends sa{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 Gi.ok(i)}getMap(){return ss.empty}invert(e){return new l0(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 l0(n.attr,n.value)}}sa.jsonID("docAttr",l0);let em=class extends Error{};em=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};em.prototype=Object.create(Error.prototype);em.prototype.constructor=em;em.prototype.name="TransformError";class fW{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new o0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new em(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=dw(this.doc,e,n,i);return r&&this.step(r),this}replaceWith(e,n,i){return this.replace(e,n,new Mt(ht.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 pSe(this,e,n,i),this}replaceRangeWith(e,n,i){return mSe(this,e,n,i),this}deleteRange(e,n){return gSe(this,e,n),this}lift(e,n){return eSe(this,e,n),this}join(e,n=1){return cSe(this,e,n),this}wrap(e,n){return iSe(this,e,n),this}setBlockType(e,n=e,i,r=null){return rSe(this,e,n,i,r),this}setNodeMarkup(e,n,i=null,r){return sSe(this,e,n,i,r),this}setNodeAttribute(e,n,i){return this.step(new Pp(e,n,i)),this}setDocAttribute(e,n){return this.step(new l0(e,n)),this}addNodeMark(e,n){return this.step(new Lu(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 Kn)n.isInSet(i.marks)&&this.step(new Rf(e,n));else{let r=i.marks,a,s=[];for(;a=n.isInSet(r);)s.push(new Rf(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 oSe(this,e,n,i),this}addMark(e,n,i){return Z1e(this,e,n,i),this}removeMark(e,n,i){return Q1e(this,e,n,i),this}clearIncompatible(e,n,i){return gk(this,e,n,i),this}}const o2=Object.create(null);class on{constructor(e,n,i){this.$anchor=e,this.$head=n,this.ranges=i||[new xSe(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],u=e.mapping.slice(a);e.replaceRange(u.map(l.pos),u.map(c.pos),o?Mt.empty:n),o==0&&pB(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),u=l.map(o.pos);a?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),pB(e,i,n.isInline?-1:1))}}static findFrom(e,n,i=!1){let r=e.parent.inlineContent?new Gt(e):fp(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?fp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,i):fp(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 fs(e.node(0))}static atStart(e){return fp(e,e,0,0,1)||new fs(e)}static atEnd(e){return fp(e,e,e.content.size,e.childCount,-1)||new fs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=o2[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 o2)throw new RangeError("Duplicate use of selection JSON ID "+e);return o2[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Gt.between(this.$anchor,this.$head).getBookmark()}}on.prototype.visible=!0;class xSe{constructor(e,n){this.$from=e,this.$to=n}}let fB=!1;function hB(t){!fB&&!t.parent.inlineContent&&(fB=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Gt extends on{constructor(e,n=e){hB(e),hB(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 on.near(i);let r=e.resolve(n.map(this.anchor));return new Gt(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 Gt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fw(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 Gt(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=on.findFrom(n,i,!0)||on.findFrom(n,-i,!0);if(a)n=a.$head;else return on.near(n,i)}return e.parent.inlineContent||(r==0?e=n:(e=(on.findFrom(e,-i,!0)||on.findFrom(e,i,!0)).$anchor,e.pos<n.pos!=r<0&&(e=n))),new Gt(e,n)}}on.jsonID("text",Gt);class fw{constructor(e,n){this.anchor=e,this.head=n}map(e){return new fw(e.map(this.anchor),e.map(this.head))}resolve(e){return Gt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ft extends on{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?on.near(a):new Ft(a)}content(){return new Mt(ht.from(this.node),0,0)}eq(e){return e instanceof Ft&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new vk(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ft(e.resolve(n.anchor))}static create(e,n){return new Ft(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ft.prototype.visible=!1;on.jsonID("node",Ft);class vk{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:i}=e.mapResult(this.anchor);return n?new fw(i,i):new vk(i)}resolve(e){let n=e.resolve(this.anchor),i=n.nodeAfter;return i&&Ft.isSelectable(i)?new Ft(n):on.near(n)}}class fs extends on{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=on.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new fs(e)}map(e){return new fs(e)}eq(e){return e instanceof fs}getBookmark(){return vSe}}on.jsonID("all",fs);const vSe={map(){return this},resolve(t){return new fs(t)}};function fp(t,e,n,i,r,a=!1){if(e.inlineContent)return Gt.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&&Ft.isSelectable(o))return Ft.create(t,n-(r<0?o.nodeSize:0))}else{let l=fp(t,o,n+r,r<0?o.childCount:0,r,a);if(l)return l}n+=o.nodeSize*r}return null}function pB(t,e,n){let i=t.steps.length-1;if(i<e)return;let r=t.steps[i];if(!(r instanceof Ar||r instanceof Cr))return;let a=t.mapping.maps[i],s;a.forEach((o,l,c,u)=>{s==null&&(s=u)}),t.setSelection(on.near(t.doc.resolve(s),n))}const mB=1,Ib=2,gB=4;class ySe extends fW{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|mB)&~Ib,this.storedMarks=null,this}get selectionSet(){return(this.updated&mB)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ib,this}ensureMarks(e){return Kn.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&Ib)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ib,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)||Kn.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(on.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|=gB,this}get scrolledIntoView(){return(this.updated&gB)>0}}function xB(t,e){return!e||!t?t:t.bind(e)}class hx{constructor(e,n,i){this.name=e,this.init=xB(n.init,i),this.apply=xB(n.apply,i)}}const bSe=[new hx("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new hx("selection",{init(t,e){return t.selection||on.atStart(e.doc)},apply(t){return t.selection}}),new hx("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,i){return i.selection.$cursor?t.storedMarks:null}}),new hx("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class l2{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bSe.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 hx(i.key,i.spec.state,i))})}}class bp{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,u=l<n.length&&o.spec.appendTransaction.call(o,l?n.slice(l):n,c,i);if(u&&i.filterTransaction(u,s)){if(u.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(u),i=i.applyInner(u),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 bp(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 ySe(this)}static create(e){let n=new l2(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new bp(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 l2(this.schema,e.plugins),i=n.fields,r=new bp(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 l2(e.schema,e.plugins),a=new bp(r);return r.fields.forEach(s=>{if(s.name=="doc")a.doc=Hu.fromJSON(e.schema,n.doc);else if(s.name=="selection")a.selection=on.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 hW(t,e,n){for(let i in t){let r=t[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=hW(r,e,{})),n[i]=r}return n}class xi{constructor(e){this.spec=e,this.props={},e.props&&hW(e.props,this,this.props),this.key=e.key?e.key.key:pW("plugin")}getState(e){return e[this.key]}}const c2=Object.create(null);function pW(t){return t in c2?t+"$"+ ++c2[t]:(c2[t]=0,t+"$")}class ur{constructor(e="key"){this.key=pW(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const yk=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function mW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const gW=(t,e,n)=>{let i=mW(t,n);if(!i)return!1;let r=bk(i);if(!r){let s=i.blockRange(),o=s&&Cm(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)}let a=r.nodeBefore;if(EW(t,r,e,-1))return!0;if(i.parent.content.size==0&&(tm(a,"end")||Ft.isSelectable(a)))for(let s=i.depth;;s--){let o=dw(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(tm(a,"end")?on.findFrom(l.doc.resolve(l.mapping.map(r.pos,-1)),-1):Ft.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},_Se=(t,e,n)=>{let i=mW(t,n);if(!i)return!1;let r=bk(i);return r?xW(t,r,e):!1},SSe=(t,e,n)=>{let i=yW(t,n);if(!i)return!1;let r=_k(i);return r?xW(t,r,e):!1};function xW(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 u=r.lastChild;if(!u)return!1;r=u}let s=e.nodeAfter,o=s,l=e.pos+1;for(;!o.isTextblock;l++){if(o.type.spec.isolating)return!1;let u=o.firstChild;if(!u)return!1;o=u}let c=dw(t.doc,a,l,Mt.empty);if(!c||c.from!=a||c instanceof Ar&&c.slice.size>=l-a)return!1;if(n){let u=t.tr.step(c);u.setSelection(Gt.create(u.doc,a)),n(u.scrollIntoView())}return!0}function tm(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 vW=(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=bk(i)}let s=a&&a.nodeBefore;return!s||!Ft.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ft.create(t.doc,a.pos-s.nodeSize)).scrollIntoView()),!0)};function bk(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 yW(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const bW=(t,e,n)=>{let i=yW(t,n);if(!i)return!1;let r=_k(i);if(!r)return!1;let a=r.nodeAfter;if(EW(t,r,e,1))return!0;if(i.parent.content.size==0&&(tm(a,"start")||Ft.isSelectable(a))){let s=dw(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(tm(a,"start")?on.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):Ft.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},_W=(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=_k(i)}let s=a&&a.nodeAfter;return!s||!Ft.isSelectable(s)?!1:(e&&e(t.tr.setSelection(Ft.create(t.doc,a.pos)).scrollIntoView()),!0)};function _k(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 wSe=(t,e)=>{let n=t.selection,i=n instanceof Ft,r;if(i){if(n.node.isTextblock||!ad(t.doc,n.from))return!1;r=n.from}else if(r=uw(t.doc,n.from,-1),r==null)return!1;if(e){let a=t.tr.join(r);i&&a.setSelection(Ft.create(a.doc,r-t.doc.resolve(r).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},MSe=(t,e)=>{let n=t.selection,i;if(n instanceof Ft){if(n.node.isTextblock||!ad(t.doc,n.to))return!1;i=n.to}else if(i=uw(t.doc,n.to,1),i==null)return!1;return e&&e(t.tr.join(i).scrollIntoView()),!0},ESe=(t,e)=>{let{$from:n,$to:i}=t.selection,r=n.blockRange(i),a=r&&Cm(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)},SW=(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 Sk(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 ASe=(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=Sk(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(on.near(l.doc.resolve(o),1)),e(l.scrollIntoView())}return!0},wW=(t,e)=>{let n=t.selection,{$from:i,$to:r}=n;if(n instanceof fs||i.parent.inlineContent||r.parent.inlineContent)return!1;let a=Sk(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(Gt.create(o.doc,s+1)),e(o.scrollIntoView())}return!0},MW=(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(lc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let i=n.blockRange(),r=i&&Cm(i);return r==null?!1:(e&&e(t.tr.lift(i,r).scrollIntoView()),!0)};function TSe(t){return(e,n)=>{let{$from:i,$to:r}=e.selection;if(e.selection instanceof Ft&&e.selection.node.isBlock)return!i.parentOffset||!lc(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 g=i.depth;;g--)if(i.node(g).isBlock){l=i.end(g)==i.pos+(i.depth-g),c=i.start(g)==i.pos-(i.depth-g),o=Sk(i.node(g-1).contentMatchAt(i.indexAfter(g-1))),a.unshift(l&&o?{type:o}:null),s=g;break}else{if(g==1)return!1;a.unshift(null)}let u=e.tr;(e.selection instanceof Gt||e.selection instanceof fs)&&u.deleteSelection();let f=u.mapping.map(i.pos),m=lc(u.doc,f,a.length,a);if(m||(a[0]=o?{type:o}:null,m=lc(u.doc,f,a.length,a)),!m)return!1;if(u.split(f,a.length,a),!l&&c&&i.node(s).type!=o){let g=u.mapping.map(i.before(s)),y=u.doc.resolve(g);o&&i.node(s-1).canReplaceWith(y.index(),y.index()+1,o)&&u.setNodeMarkup(u.mapping.map(i.before(s)),o)}return n&&n(u.scrollIntoView()),!0}}const CSe=TSe(),NSe=(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(Ft.create(t.doc,r))),!0)};function RSe(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||ad(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function EW(t,e,n,i){let r=e.nodeBefore,a=e.nodeAfter,s,o,l=r.type.spec.isolating||a.type.spec.isolating;if(!l&&RSe(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 g=e.pos+a.nodeSize,y=ht.empty;for(let x=s.length-1;x>=0;x--)y=ht.from(s[x].create(null,y));y=ht.from(r.copy(y));let _=t.tr.step(new Cr(e.pos-1,g,e.pos,g,new Mt(y,1,0),s.length,!0)),v=_.doc.resolve(g+2*s.length);v.nodeAfter&&v.nodeAfter.type==r.type&&ad(_.doc,v.pos)&&_.join(v.pos),n(_.scrollIntoView())}return!0}let u=a.type.spec.isolating||i>0&&l?null:on.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),m=f&&Cm(f);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(f,m).scrollIntoView()),!0;if(c&&tm(a,"start",!0)&&tm(r,"end")){let g=r,y=[];for(;y.push(g),!g.isTextblock;)g=g.lastChild;let _=a,v=1;for(;!_.isTextblock;_=_.firstChild)v++;if(g.canReplace(g.childCount,g.childCount,_.content)){if(n){let x=ht.empty;for(let w=y.length-1;w>=0;w--)x=ht.from(y[w].copy(x));let M=t.tr.step(new Cr(e.pos-y.length,e.pos+a.nodeSize,e.pos+v,e.pos+a.nodeSize-v,new Mt(x,y.length,0),0,!0));n(M.scrollIntoView())}return!0}}return!1}function AW(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(Gt.create(e.doc,t<0?r.start(a):r.end(a)))),!0):!1}}const PSe=AW(-1),kSe=AW(1);function DSe(t,e=null){return function(n,i){let{$from:r,$to:a}=n.selection,s=r.blockRange(a),o=s&&xk(s,t,e);return o?(i&&i(n.tr.wrap(s,o).scrollIntoView()),!0):!1}}function vB(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 u=n.doc.resolve(c),f=u.index();r=u.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 wk(...t){return function(e,n,i){for(let r=0;r<t.length;r++)if(t[r](e,n,i))return!0;return!1}}wk(yk,gW,vW);wk(yk,bW,_W);wk(SW,wW,MW,CSe);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function OSe(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 LSe(o,s,t,e)?(i&&i(o.scrollIntoView()),!0):!1}}function LSe(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 l1(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new l1(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let o=xk(a,n,i,e);return o?(t&&ISe(t,e,o,r,n),!0):!1}function ISe(t,e,n,i,r){let a=ht.empty;for(let u=n.length-1;u>=0;u--)a=ht.from(n[u].type.create(n[u].attrs,a));t.step(new Cr(e.start-(i?2:0),e.end,e.start,e.end,new Mt(a,0,0),n.length,!0));let s=0;for(let u=0;u<n.length;u++)n[u].type==r&&(s=u+1);let o=n.length-s,l=e.start+n.length-(i?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,m=!0;u<f;u++,m=!1)!m&&lc(t.doc,l,o)&&(t.split(l,o),l+=2*o),l+=c.child(u).nodeSize;return t}function jSe(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?USe(e,n,t,a):FSe(e,n,a):!0:!1}}function USe(t,e,n,i){let r=t.tr,a=i.end,s=i.$to.end(i.depth);a<s&&(r.step(new Cr(a-1,s,a,s,new Mt(ht.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new l1(r.doc.resolve(i.$from.pos),r.doc.resolve(s),i.depth));const o=Cm(i);if(o==null)return!1;r.lift(i,o);let l=r.doc.resolve(r.mapping.map(a,-1)-1);return ad(r.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&r.join(l.pos),e(r.scrollIntoView()),!0}function FSe(t,e,n){let i=t.tr,r=n.parent;for(let g=n.end,y=n.endIndex-1,_=n.startIndex;y>_;y--)g-=r.child(y).nodeSize,i.delete(g-1,g+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),u=a.index(-1);if(!c.canReplace(u+(o?0:1),u+1,s.content.append(l?ht.empty:ht.from(r))))return!1;let f=a.pos,m=f+s.nodeSize;return i.step(new Cr(f-(o?1:0),m+(l?1:0),f+1,m-1,new Mt((o?ht.empty:ht.from(r.copy(ht.empty))).append(l?ht.empty:ht.from(r.copy(ht.empty))),o?0:1,l?0:1),o?0:1)),e(i.scrollIntoView()),!0}function zSe(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,u=ht.from(c?t.create():null),f=new Mt(ht.from(t.create(null,ht.from(o.type.create(null,u)))),c?3:1,0),m=a.start,g=a.end;n(e.tr.step(new Cr(m-(c?3:1),g,m,g,f,1,!0)).scrollIntoView())}return!0}}const Gr=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},nm=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let H3=null;const Wl=function(t,e,n){let i=H3||(H3=document.createRange());return i.setEnd(t,n??t.nodeValue.length),i.setStart(t,e||0),i},BSe=function(){H3=null},Pf=function(t,e,n,i){return n&&(yB(t,e,n,i,-1)||yB(t,e,n,i,1))},HSe=/^(img|br|input|textarea|hr)$/i;function yB(t,e,n,i,r){for(var a;;){if(t==n&&e==i)return!0;if(e==(r<0?0:zs(t))){let s=t.parentNode;if(!s||s.nodeType!=1||H0(t)||HSe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Gr(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?zs(t):0}else return!1}}function zs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function $Se(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=zs(t)}else if(t.parentNode&&!H0(t))e=Gr(t),t=t.parentNode;else return null}}function VSe(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&&!H0(t))e=Gr(t)+1,t=t.parentNode;else return null}}function GSe(t,e,n){for(let i=e==0,r=e==zs(t);i||r;){if(t==n)return!0;let a=Gr(t);if(t=t.parentNode,!t)return!1;i=i&&a==0,r=r&&a==zs(t)}}function H0(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 hw=function(t){return t.focusNode&&Pf(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Xd(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function WSe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function qSe(t,e,n){if(t.caretPositionFromPoint)try{let i=t.caretPositionFromPoint(e,n);if(i)return{node:i.offsetNode,offset:Math.min(zs(i.offsetNode),i.offset)}}catch{}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,n);if(i)return{node:i.startContainer,offset:Math.min(zs(i.startContainer),i.startOffset)}}}const nl=typeof navigator<"u"?navigator:null,bB=typeof document<"u"?document:null,sd=nl&&nl.userAgent||"",$3=/Edge\/(\d+)/.exec(sd),TW=/MSIE \d/.exec(sd),V3=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(sd),za=!!(TW||V3||$3),$u=TW?document.documentMode:V3?+V3[1]:$3?+$3[1]:0,Gs=!za&&/gecko\/(\d+)/i.test(sd);Gs&&+(/Firefox\/(\d+)/.exec(sd)||[0,0])[1];const G3=!za&&/Chrome\/(\d+)/.exec(sd),ia=!!G3,CW=G3?+G3[1]:0,xa=!za&&!!nl&&/Apple Computer/.test(nl.vendor),im=xa&&(/Mobile\/\w+/.test(sd)||!!nl&&nl.maxTouchPoints>2),Os=im||(nl?/Mac/.test(nl.platform):!1),XSe=nl?/Win/.test(nl.platform):!1,tc=/Android \d/.test(sd),$0=!!bB&&"webkitFontSmoothing"in bB.documentElement.style,KSe=$0?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function YSe(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 Fl(t,e){return typeof t=="number"?t:t[e]}function ZSe(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 _B(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=nm(s);continue}let o=s,l=o==a.body,c=l?YSe(a):ZSe(o),u=0,f=0;if(e.top<c.top+Fl(i,"top")?f=-(c.top-e.top+Fl(r,"top")):e.bottom>c.bottom-Fl(i,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Fl(r,"top")-c.top:e.bottom-c.bottom+Fl(r,"bottom")),e.left<c.left+Fl(i,"left")?u=-(c.left-e.left+Fl(r,"left")):e.right>c.right-Fl(i,"right")&&(u=e.right-c.right+Fl(r,"right")),u||f)if(l)a.defaultView.scrollBy(u,f);else{let g=o.scrollLeft,y=o.scrollTop;f&&(o.scrollTop+=f),u&&(o.scrollLeft+=u);let _=o.scrollLeft-g,v=o.scrollTop-y;e={left:e.left-_,top:e.top-v,right:e.right-_,bottom:e.bottom-v}}let m=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(m))break;s=m=="absolute"?s.offsetParent:nm(s)}}function QSe(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:NW(t.dom)}}function NW(t){let e=[],n=t.ownerDocument;for(let i=t;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),t!=n);i=nm(i));return e}function JSe({refDOM:t,refTop:e,stack:n}){let i=t?t.getBoundingClientRect().top:0;RW(n,i==0?0:i-e)}function RW(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 sp=null;function ewe(t){if(t.setActive)return t.setActive();if(sp)return t.focus(sp);let e=NW(t);t.focus(sp==null?{get preventScroll(){return sp={preventScroll:!0},!0}}:void 0),sp||(sp=!1,RW(e,0))}function PW(t,e){let n,i=2e8,r,a=0,s=e.top,o=e.top,l,c;for(let u=t.firstChild,f=0;u;u=u.nextSibling,f++){let m;if(u.nodeType==1)m=u.getClientRects();else if(u.nodeType==3)m=Wl(u).getClientRects();else continue;for(let g=0;g<m.length;g++){let y=m[g];if(y.top<=s&&y.bottom>=o){s=Math.max(y.bottom,s),o=Math.min(y.top,o);let _=y.left>e.left?y.left-e.left:y.right<e.left?e.left-y.right:0;if(_<i){n=u,i=_,r=_&&n.nodeType==3?{left:y.right<e.left?y.right:y.left,top:e.top}:e,u.nodeType==1&&_&&(a=f+(e.left>=(y.left+y.right)/2?1:0));continue}}else y.top>e.top&&!l&&y.left<=e.left&&y.right>=e.left&&(l=u,c={left:Math.max(y.left,Math.min(y.right,e.left)),top:y.top});!n&&(e.left>=y.right&&e.top>=y.top||e.left>=y.left&&e.top>=y.bottom)&&(a=f+1)}}return!n&&l&&(n=l,r=c,i=0),n&&n.nodeType==3?twe(n,r):!n||i&&n.nodeType==1?{node:t,offset:a}:PW(n,r)}function twe(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=vu(i,1);if(a.top!=a.bottom&&Mk(e,a))return{node:t,offset:r+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function Mk(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function nwe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function iwe(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 rwe(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 kW(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(Mk(e,c))return kW(s,e,c)}}if((a=(a+1)%i)==r)break}return t}function awe(t,e){let n=t.dom.ownerDocument,i,r=0,a=qSe(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(!Mk(e,c)||(s=kW(t.dom,e,c),!s))return null}if(xa)for(let c=s;i&&c;c=nm(c))c.draggable&&(i=void 0);if(s=nwe(s,e),i){if(Gs&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let u=i.childNodes[r],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&r++}let c;$0&&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=rwe(t,i,r,e))}o==null&&(o=iwe(t,s,e));let l=t.docView.nearestDesc(s,!0);return{pos:o,inside:l?l.posAtStart-l.border:-1}}function SB(t){return t.top<t.bottom||t.left<t.right}function vu(t,e){let n=t.getClientRects();if(n.length){let i=n[e<0?0:n.length-1];if(SB(i))return i}return Array.prototype.find.call(n,SB)||t.getBoundingClientRect()}const swe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function DW(t,e,n){let{node:i,offset:r,atom:a}=t.docView.domFromPos(e,n<0?-1:1),s=$0||Gs;if(i.nodeType==3)if(s&&(swe.test(i.nodeValue)||(n<0?!r:r==i.nodeValue.length))){let l=vu(Wl(i,r,r),n);if(Gs&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let c=vu(Wl(i,r-1,r-1),-1);if(c.top==l.top){let u=vu(Wl(i,r,r+1),-1);if(u.top!=l.top)return Kg(u,u.left<c.left)}}return l}else{let l=r,c=r,u=n<0?1:-1;return n<0&&!r?(c++,u=-1):n>=0&&r==i.nodeValue.length?(l--,u=1):n<0?l--:c++,Kg(vu(Wl(i,l,c),u),u<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&r&&(n<0||r==zs(i))){let l=i.childNodes[r-1];if(l.nodeType==1)return u2(l.getBoundingClientRect(),!1)}if(a==null&&r<zs(i)){let l=i.childNodes[r];if(l.nodeType==1)return u2(l.getBoundingClientRect(),!0)}return u2(i.getBoundingClientRect(),n>=0)}if(a==null&&r&&(n<0||r==zs(i))){let l=i.childNodes[r-1],c=l.nodeType==3?Wl(l,zs(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Kg(vu(c,1),!1)}if(a==null&&r<zs(i)){let l=i.childNodes[r];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?Wl(l,0,s?0:1):l.nodeType==1?l:null:null;if(c)return Kg(vu(c,-1),!0)}return Kg(vu(i.nodeType==3?Wl(i):i,-n),n>=0)}function Kg(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 u2(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 OW(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 owe(t,e,n){let i=e.selection,r=n=="up"?i.$from:i.$to;return OW(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=DW(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=Wl(o,0,o.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const lwe=/[\u0590-\u08ac]/;function cwe(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?!lwe.test(i.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:s:OW(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:f}=t.domSelectionRange(),m=o.caretBidiLevel;o.modify("move",n,"character");let g=i.depth?t.docView.domAfterPos(i.before()):t.dom,{focusNode:y,focusOffset:_}=t.domSelectionRange(),v=y&&!g.contains(y.nodeType==1?y:y.parentNode)||l==y&&c==_;try{o.collapse(u,f),l&&(l!=u||c!=f)&&o.extend&&o.extend(l,c)}catch{}return m!=null&&(o.caretBidiLevel=m),v}):i.pos==i.start()||i.pos==i.end()}let wB=null,MB=null,EB=!1;function uwe(t,e,n){return wB==e&&MB==n?EB:(wB=e,MB=n,EB=n=="up"||n=="down"?owe(t,e,n):cwe(t,e,n))}const Ws=0,AB=1,Zd=2,il=3;class V0{constructor(e,n,i,r){this.parent=e,this.children=n,this.dom=i,this.contentDOM=r,this.dirty=Ws,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>Gr(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 IW){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 LW&&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?Gr(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?Gr(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 u=s+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=s;for(let f=o;f>0;f--){let m=this.children[f-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){r=Gr(m.dom)+1;break}e-=m.size}r==-1&&(r=0)}if(r>-1&&(c>n||o==this.children.length-1)){n=c;for(let u=o+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=Gr(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 g=0,y=0;g<this.children.length;g++){let _=this.children[g],v=y+_.size;if(a>y&&s<v)return _.setSelection(e-y-_.border,n-y-_.border,i,r);y=v}let o=this.domFromPos(e,e?-1:1),l=n==e?o:this.domFromPos(n,n?-1:1),c=i.root.getSelection(),u=i.domSelectionRange(),f=!1;if((Gs||xa)&&e==n){let{node:g,offset:y}=o;if(g.nodeType==3){if(f=!!(y&&g.nodeValue[y-1]==`
- `),f&&y==g.nodeValue.length)for(let _=g,v;_;_=_.parentNode){if(v=_.nextSibling){v.nodeName=="BR"&&(o=l={node:v.parentNode,offset:Gr(v)+1});break}let x=_.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let _=g.childNodes[y-1];f=_&&(_.nodeName=="BR"||_.contentEditable=="false")}}if(Gs&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let g=u.focusNode.childNodes[u.focusOffset];g&&g.contentEditable=="false"&&(r=!0)}if(!(r||f&&xa)&&Pf(o.node,o.offset,u.anchorNode,u.anchorOffset)&&Pf(l.node,l.offset,u.focusNode,u.focusOffset))return;let m=!1;if((c.extend||e==n)&&!(f&&Gs)){c.collapse(o.node,o.offset);try{e!=n&&c.extend(l.node,l.offset),m=!0}catch{}}if(!m){if(e>n){let y=o;o=l,l=y}let g=document.createRange();g.setEnd(l.node,l.offset),g.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(g)}}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?Zd:AB,e==o&&n==l&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=il:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Zd:il}i=s}this.dirty=Zd}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let i=e==1?Zd:AB;n.dirty<i&&(n.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class LW extends V0{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==Ws&&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 dwe extends V0{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 kf extends V0{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=Vf.renderSpec(document,n.type.spec.toDOM(n,i),null,n.attrs)),new kf(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&il||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=il&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ws){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=Ws}}slice(e,n,i){let r=kf.create(this.parent,this.mark,!0,i),a=this.children,s=this.size;n<s&&(a=q3(a,n,s,i)),e>0&&(a=q3(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 Vu extends V0{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),u=c&&c.dom,f=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=Vf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let m=u;return u=FW(u,i,n),c?l=new fwe(e,n,i,r,u,f||null,m,c,a,s+1):n.isText?new pw(e,n,i,r,u,m,a):new Vu(e,n,i,r,u,f||null,m,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=()=>ht.empty)}return e}matchesNode(e,n,i){return this.dirty==Ws&&e.eq(this.node)&&u1(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 pwe(this,s&&s.node,e);xwe(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?l.syncToMarks(c.spec.marks,i,e):c.type.side>=0&&!f&&l.syncToMarks(u==this.node.childCount?Kn.none:this.node.child(u).marks,i,e),l.placeWidget(c,e,r)},(c,u,f,m)=>{l.syncToMarks(c.marks,i,e);let g;l.findNodeMatch(c,u,f,m)||o&&e.state.selection.from>r&&e.state.selection.to<r+c.nodeSize&&(g=l.findIndexWithChild(a.node))>-1&&l.updateNodeAt(c,u,f,g,e)||l.updateNextNode(c,u,f,e,m,r)||l.addNode(c,u,f,e,r),r+=c.nodeSize}),l.syncToMarks([],i,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Zd)&&(s&&this.protectLocalComposition(e,s),jW(this.contentDOM,this.children,e),im&&vwe(this.dom))}localCompositionInfo(e,n){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof Gt)||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=ywe(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 dwe(this,a,n,r);e.input.compositionNodes.push(s),this.children=q3(this.children,i,i+r.length,e,s)}update(e,n,i,r){return this.dirty==il||!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=Ws}updateOuterDeco(e){if(u1(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=UW(this.dom,this.nodeDOM,W3(this.outerDeco,this.node,n),W3(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 TB(t,e,n,i,r){FW(i,e,t);let a=new Vu(void 0,t,e,n,i,i,i,r,0);return a.contentDOM&&a.updateChildren(r,0),a}class pw extends Vu{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==il||this.dirty!=Ws&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ws||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=Ws,!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 pw(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=il)}get domAtom(){return!1}isText(e){return this.node.text==e}}class IW extends V0{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ws&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class fwe extends Vu{constructor(e,n,i,r,a,s,o,l,c,u){super(e,n,i,r,a,s,o,c,u),this.spec=l}update(e,n,i,r){if(this.dirty==il)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 jW(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=CB(i),r=!0;i=i.nextSibling}else r=!0,t.insertBefore(o,i);if(s instanceof kf){let l=i?i.previousSibling:t.lastChild;jW(s.contentDOM,s.children,n),i=l?l.nextSibling:t.firstChild}}for(;i;)i=CB(i),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const Cx=function(t){t&&(this.nodeName=t)};Cx.prototype=Object.create(null);const Qd=[new Cx];function W3(t,e,n){if(t.length==0)return Qd;let i=n?Qd[0]:new Cx,r=[i];for(let a=0;a<t.length;a++){let s=t[a].type.attrs;if(s){s.nodeName&&r.push(i=new Cx(s.nodeName));for(let o in s){let l=s[o];l!=null&&(n&&r.length==1&&r.push(i=new Cx(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 UW(t,e,n,i){if(n==Qd&&i==Qd)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=Qd[0]),r=l}hwe(r,o||Qd[0],s)}return r}function hwe(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 FW(t,e,n){return UW(t,t,Qd,W3(e,n,t.nodeType!=1))}function u1(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 CB(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class pwe{constructor(e,n,i){this.lock=n,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=mwe(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=Ws,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=kf.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==il&&s.dom==s.contentDOM&&(s.dirty=Zd),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 Vu){let c=this.preMatch.matched.get(l);if(c!=null&&c!=a)return!1;let u=l.dom,f,m=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=il&&u1(n,l.outerDeco));if(!m&&l.update(e,n,i,r))return this.destroyBetween(this.index,o),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!m&&(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=Zd,f.updateChildren(r,s+1),f.dirty=Ws),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)||!u1(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Vu.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=Vu.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 LW(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 kf;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof pw)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((xa||ia)&&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 IW(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 mwe(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 kf)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 gwe(t,e){return t.type.side-e.type.side}function xwe(t,e,n,i){let r=e.locals(t),a=0;if(r.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);i(u,r,e.forChild(a,u),c),a+=u.nodeSize}return}let s=0,o=[],l=null;for(let c=0;;){let u,f;for(;s<r.length&&r[s].to==a;){let v=r[s++];v.widget&&(u?(f||(f=[u])).push(v):u=v)}if(u)if(f){f.sort(gwe);for(let v=0;v<f.length;v++)n(f[v],c,!!l)}else n(u,c,!!l);let m,g;if(l)g=-1,m=l,l=null;else if(c<t.childCount)g=c,m=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 y=a+m.nodeSize;if(m.isText){let v=y;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<y&&(l=m.cut(v-a),m=m.cut(0,v-a),y=v,g=-1)}else for(;s<r.length&&r[s].to<y;)s++;let _=m.isInline&&!m.isLeaf?o.filter(v=>!v.inline):o.slice();i(m,_,e.forChild(a,m),g),a=y}}function vwe(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 ywe(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 q3(t,e,n,i,r){let a=[];for(let s=0,o=0;s<t.length;s++){let l=t[s],c=o,u=o+=l.size;c>=n||u<=e?a.push(l):(c<e&&a.push(l.slice(0,e-c,i)),r&&(a.push(r),r=void 0),u>n&&a.push(l.slice(n-c,l.size,i)))}return a}function Ek(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(hw(n)){for(l=s;r&&!r.node;)r=r.parent;let f=r.node;if(r&&f.isAtom&&Ft.isSelectable(f)&&r.parent&&!(f.isInline&&GSe(n.focusNode,n.focusOffset,r.dom))){let m=r.posBefore;c=new Ft(s==m?o:i.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=s,m=s;for(let g=0;g<n.rangeCount;g++){let y=n.getRangeAt(g);f=Math.min(f,t.docView.posFromDOM(y.startContainer,y.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(y.endContainer,y.endOffset,-1))}if(f<0)return null;[l,s]=m==t.state.selection.anchor?[m,f]:[f,m],o=i.resolve(s)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=i.resolve(l);if(!c){let f=e=="pointer"||t.state.selection.head<o.pos&&!a?1:-1;c=Ak(t,u,o,f)}return c}function zW(t){return t.editable?t.hasFocus():HW(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function cc(t,e=!1){let n=t.state.selection;if(BW(t,n),!!zW(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ia){let i=t.domSelectionRange(),r=t.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&Pf(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)_we(t);else{let{anchor:i,head:r}=n,a,s;NB&&!(n instanceof Gt)&&(n.$from.parent.inlineContent||(a=RB(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(s=RB(t,n.to))),t.docView.setSelection(i,r,t,e),NB&&(a&&PB(a),s&&PB(s)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&bwe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const NB=xa||ia&&CW<63;function RB(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(xa&&r&&r.contentEditable=="false")return d2(r);if((!r||r.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(r)return d2(r);if(a)return d2(a)}}function d2(t){return t.contentEditable="true",xa&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function PB(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function bwe(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(()=>{(!zW(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function _we(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,i=n.nodeName=="IMG";i?e.collapse(n.parentNode,Gr(n)+1):e.collapse(n,0),!i&&!t.state.selection.visible&&za&&$u<=11&&(n.disabled=!0,n.disabled=!1)}function BW(t,e){if(e instanceof Ft){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(kB(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else kB(t)}function kB(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ak(t,e,n,i){return t.someProp("createSelectionBetween",r=>r(t,e,n))||Gt.between(e,n,i)}function DB(t){return t.editable&&!t.hasFocus()?!1:HW(t)}function HW(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 Swe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Pf(e.node,e.offset,n.anchorNode,n.anchorOffset)}function X3(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&&on.findFrom(a,e)}function _u(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function OB(t,e,n){let i=t.state.selection;if(i instanceof Gt)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 _u(t,new Gt(i.$anchor,s))}else if(i.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let r=X3(t.state,e);return r&&r instanceof Ft?_u(t,r):!1}else if(!(Os&&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?Ft.isSelectable(a)?_u(t,new Ft(e<0?t.state.doc.resolve(r.pos-a.nodeSize):r)):$0?_u(t,new Gt(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(i instanceof Ft&&i.node.isInline)return _u(t,new Gt(e>0?i.$to:i.$from));{let r=X3(t.state,e);return r?_u(t,r):!1}}}function d1(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nx(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function op(t,e){return e<0?wwe(t):Mwe(t)}function wwe(t){let e=t.domSelectionRange(),n=e.focusNode,i=e.focusOffset;if(!n)return;let r,a,s=!1;for(Gs&&n.nodeType==1&&i<d1(n)&&Nx(n.childNodes[i],-1)&&(s=!0);;)if(i>0){if(n.nodeType!=1)break;{let o=n.childNodes[i-1];if(Nx(o,-1))r=n,a=--i;else if(o.nodeType==3)n=o,i=n.nodeValue.length;else break}}else{if($W(n))break;{let o=n.previousSibling;for(;o&&Nx(o,-1);)r=n.parentNode,a=Gr(o),o=o.previousSibling;if(o)n=o,i=d1(n);else{if(n=n.parentNode,n==t.dom)break;i=0}}}s?K3(t,n,i):r&&K3(t,r,a)}function Mwe(t){let e=t.domSelectionRange(),n=e.focusNode,i=e.focusOffset;if(!n)return;let r=d1(n),a,s;for(;;)if(i<r){if(n.nodeType!=1)break;let o=n.childNodes[i];if(Nx(o,1))a=n,s=++i;else break}else{if($W(n))break;{let o=n.nextSibling;for(;o&&Nx(o,1);)a=o.parentNode,s=Gr(o)+1,o=o.nextSibling;if(o)n=o,i=0,r=d1(n);else{if(n=n.parentNode,n==t.dom)break;i=r=0}}}a&&K3(t,a,s)}function $W(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ewe(t,e){for(;t&&e==t.childNodes.length&&!H0(t);)e=Gr(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 Awe(t,e){for(;t&&!e&&!H0(t);)e=Gr(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 K3(t,e,n){if(e.nodeType!=3){let a,s;(s=Ewe(e,n))?(e=s,n=0):(a=Awe(e,n))&&(e=a,n=a.nodeValue.length)}let i=t.domSelection();if(!i)return;if(hw(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&&cc(t)},50)}function LB(t,e){let n=t.state.doc.resolve(e);if(!(ia||XSe)&&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 IB(t,e,n){let i=t.state.selection;if(i instanceof Gt&&!i.empty||n.indexOf("s")>-1||Os&&n.indexOf("m")>-1)return!1;let{$from:r,$to:a}=i;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=X3(t.state,e);if(s&&s instanceof Ft)return _u(t,s)}if(!r.parent.inlineContent){let s=e<0?r:a,o=i instanceof fs?on.near(s,e):on.findFrom(s,e);return o?_u(t,o):!1}return!1}function jB(t,e){if(!(t.state.selection instanceof Gt))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 UB(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Twe(t){if(!xa||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;UB(t,i,"true"),setTimeout(()=>UB(t,i,"false"),20)}return!1}function Cwe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Nwe(t,e){let n=e.keyCode,i=Cwe(e);if(n==8||Os&&n==72&&i=="c")return jB(t,-1)||op(t,-1);if(n==46&&!e.shiftKey||Os&&n==68&&i=="c")return jB(t,1)||op(t,1);if(n==13||n==27)return!0;if(n==37||Os&&n==66&&i=="c"){let r=n==37?LB(t,t.state.selection.from)=="ltr"?-1:1:-1;return OB(t,r,i)||op(t,r)}else if(n==39||Os&&n==70&&i=="c"){let r=n==39?LB(t,t.state.selection.from)=="ltr"?1:-1:1;return OB(t,r,i)||op(t,r)}else{if(n==38||Os&&n==80&&i=="c")return IB(t,-1,i)||op(t,-1);if(n==40||Os&&n==78&&i=="c")return Twe(t)||IB(t,1,i)||op(t,1);if(i==(Os?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Tk(t,e){t.someProp("transformCopied",g=>{e=g(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 g=i.firstChild;n.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),i=g.content}let s=t.someProp("clipboardSerializer")||Vf.fromSchema(t.state.schema),o=KW(),l=o.createElement("div");l.appendChild(s.serializeFragment(i,{document:o}));let c=l.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=XW[c.nodeName.toLowerCase()]);){for(let g=u.length-1;g>=0;g--){let y=o.createElement(u[g]);for(;l.firstChild;)y.appendChild(l.firstChild);l.appendChild(y),f++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${r} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",g=>g(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:l,text:m,slice:e}}function VW(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",m=>{e=m(e,a||i,t)}),a)return o=new Mt(ht.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",m=>{o=m(o,t,!0)}),o;let f=t.someProp("clipboardTextParser",m=>m(e,r,i,t));if(f)o=f;else{let m=r.marks(),{schema:g}=t.state,y=Vf.fromSchema(g);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(_=>{let v=s.appendChild(document.createElement("p"));_&&v.appendChild(y.serializeNode(g.text(_,m)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=Dwe(n),$0&&Owe(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let m=s.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;s=m}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||Ax.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:r,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!Rwe.test(m.parentNode.nodeName)?{ignore:!0}:null}})),u)o=Lwe(FB(o,+u[1],+u[2]),u[4]);else if(o=Mt.maxOpen(Pwe(o.content,r),!0),o.openStart||o.openEnd){let f=0,m=0;for(let g=o.content.firstChild;f<o.openStart&&!g.type.spec.isolating;f++,g=g.firstChild);for(let g=o.content.lastChild;m<o.openEnd&&!g.type.spec.isolating;m++,g=g.lastChild);o=FB(o,f,m)}return t.someProp("transformPasted",f=>{o=f(o,t,l)}),o}const Rwe=/^(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 Pwe(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&&WW(l,a,o,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=qW(s[s.length-1],a.length));let u=GW(o,l);s.push(u),r=r.matchType(u.type),a=l}}),s)return ht.from(s)}return t}function GW(t,e,n=0){for(let i=e.length-1;i>=n;i--)t=e[i].create(null,ht.from(t));return t}function WW(t,e,n,i,r){if(r<t.length&&r<e.length&&t[r]==e[r]){let a=WW(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(ht.from(GW(n,t,r+1))))}}function qW(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,qW(t.lastChild,e-1)),i=t.contentMatchAt(t.childCount).fillBefore(ht.empty,!0);return t.copy(n.append(i))}function Y3(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=Y3(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(ht.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(o))}function FB(t,e,n){return e<t.openStart&&(t=new Mt(Y3(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Mt(Y3(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const XW={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 zB=null;function KW(){return zB||(zB=document.implementation.createHTMLDocument("title"))}let f2=null;function kwe(t){let e=window.trustedTypes;return e?(f2||(f2=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),f2.createHTML(t)):t}function Dwe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=KW().createElement("div"),i=/<([a-z][^>\s]+)/i.exec(t),r;if((r=i&&XW[i[1].toLowerCase()])&&(t=r.map(a=>"<"+a+">").join("")+t+r.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=kwe(t),r)for(let a=0;a<r.length;a++)n=n.querySelector(r[a])||n;return n}function Owe(t){let e=t.querySelectorAll(ia?"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 Lwe(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=ht.from(l.create(i[o+1],r)),a++,s++}return new Mt(r,a,s)}const va={},ya={},Iwe={touchstart:!0,touchmove:!0};class jwe{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 Uwe(t){for(let e in va){let n=va[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=i=>{zwe(t,i)&&!Ck(t,i)&&(t.editable||!(i.type in ya))&&n(t,i)},Iwe[e]?{passive:!0}:void 0)}xa&&t.dom.addEventListener("input",()=>null),Z3(t)}function Iu(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Fwe(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 Z3(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=i=>Ck(t,i))})}function Ck(t,e){return t.someProp("handleDOMEvents",n=>{let i=n[e.type];return i?i(t,e)||e.defaultPrevented:!1})}function zwe(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 Bwe(t,e){!Ck(t,e)&&va[e.type]&&(t.editable||!(e.type in ya))&&va[e.type](t,e)}ya.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!ZW(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(tc&&ia&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),im&&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,Xd(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",i=>i(t,n))||Nwe(t,n)?n.preventDefault():Iu(t,"key")};ya.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ya.keypress=(t,e)=>{let n=e;if(ZW(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Os&&n.metaKey)return;if(t.someProp("handleKeyPress",r=>r(t,n))){n.preventDefault();return}let i=t.state.selection;if(!(i instanceof Gt)||!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 mw(t){return{left:t.clientX,top:t.clientY}}function Hwe(t,e){let n=e.x-t.clientX,i=e.y-t.clientY;return n*n+i*i<100}function Nk(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 kp(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 $we(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),i=n.nodeAfter;return i&&i.isAtom&&Ft.isSelectable(i)?(kp(t,new Ft(n)),!0):!1}function Vwe(t,e){if(e==-1)return!1;let n=t.state.selection,i,r;n instanceof Ft&&(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(Ft.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?(kp(t,Ft.create(t.state.doc,r)),!0):!1}function Gwe(t,e,n,i,r){return Nk(t,"handleClickOn",e,n,i)||t.someProp("handleClick",a=>a(t,e,i))||(r?Vwe(t,n):$we(t,n))}function Wwe(t,e,n,i){return Nk(t,"handleDoubleClickOn",e,n,i)||t.someProp("handleDoubleClick",r=>r(t,e,i))}function qwe(t,e,n,i){return Nk(t,"handleTripleClickOn",e,n,i)||t.someProp("handleTripleClick",r=>r(t,e,i))||Xwe(t,n,i)}function Xwe(t,e,n){if(n.button!=0)return!1;let i=t.state.doc;if(e==-1)return i.inlineContent?(kp(t,Gt.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)kp(t,Gt.create(i,o+1,o+1+s.content.size));else if(Ft.isSelectable(s))kp(t,Ft.create(i,o));else continue;return!0}}function Rk(t){return f1(t)}const YW=Os?"metaKey":"ctrlKey";va.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let i=Rk(t),r=Date.now(),a="singleClick";r-t.input.lastClick.time<500&&Hwe(n,t.input.lastClick)&&!n[YW]&&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(mw(n));s&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Kwe(t,s,n,!!i)):(a=="doubleClick"?Wwe:qwe)(t,s.pos,s.inside,n)?n.preventDefault():Iu(t,"pointer"))};class Kwe{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[YW],this.allowDefault=i.shiftKey;let a,s;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),s=n.inside;else{let u=e.state.doc.resolve(n.pos);a=u.parent,s=u.depth?u.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 Ft&&c.from<=s&&c.to>s)&&(this.mightDrag={node:a,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Gs&&!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)),Iu(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(()=>cc(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(mw(e))),this.updateAllowDefault(e),this.allowDefault||!n?Iu(this.view,"pointer"):Gwe(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||xa&&this.mightDrag&&!this.mightDrag.node.isAtom||ia&&!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)?(kp(this.view,on.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Iu(this.view,"pointer")}move(e){this.updateAllowDefault(e),Iu(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)}}va.touchstart=t=>{t.input.lastTouch=Date.now(),Rk(t),Iu(t,"pointer")};va.touchmove=t=>{t.input.lastTouch=Date.now(),Iu(t,"pointer")};va.contextmenu=t=>Rk(t);function ZW(t,e){return t.composing?!0:xa&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Ywe=tc?5e3:-1;ya.compositionstart=ya.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Gt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(i=>i.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),f1(t,!0),t.markCursor=null;else if(f1(t,!e.selection.empty),Gs&&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}QW(t,Ywe)};ya.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++,QW(t,20))};function QW(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>f1(t),e))}function JW(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Qwe());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Zwe(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=$Se(e.focusNode,e.focusOffset),i=VSe(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 Qwe(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function f1(t,e=!1){if(!(tc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),JW(t),e||t.docView&&t.docView.dirty){let n=Ek(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 Jwe(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 c0=za&&$u<15||im&&KSe<604;va.copy=ya.cut=(t,e)=>{let n=e,i=t.state.selection,r=n.type=="cut";if(i.empty)return;let a=c0?null:n.clipboardData,s=i.content(),{dom:o,text:l}=Tk(t,s);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",l)):Jwe(t,o),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function eMe(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function tMe(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?u0(t,i.value,null,r,e):u0(t,i.textContent,i.innerHTML,r,e)},50)}function u0(t,e,n,i,r){let a=VW(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=eMe(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 eq(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," "):""}ya.paste=(t,e)=>{let n=e;if(t.composing&&!tc)return;let i=c0?null:n.clipboardData,r=t.input.shiftKey&&t.input.lastKeyCode!=45;i&&u0(t,eq(i),i.getData("text/html"),r,n)?n.preventDefault():tMe(t,n)};class tq{constructor(e,n,i){this.slice=e,this.move=n,this.node=i}}const nMe=Os?"altKey":"ctrlKey";function nq(t,e){let n=t.someProp("dragCopies",i=>!i(e));return n??!e[nMe]}va.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(mw(n)),s;if(!(a&&a.pos>=r.from&&a.pos<=(r instanceof Ft?r.to-1:r.to))){if(i&&i.mightDrag)s=Ft.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=Ft.create(t.state.doc,f.posBefore))}}let o=(s||t.state.selection).content(),{dom:l,text:c,slice:u}=Tk(t,o);(!n.dataTransfer.files.length||!ia||CW>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(c0?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",c0||n.dataTransfer.setData("text/plain",c),t.dragging=new tq(u,nq(t,n),s)};va.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ya.dragover=ya.dragenter=(t,e)=>e.preventDefault();ya.drop=(t,e)=>{let n=e,i=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let r=t.posAtCoords(mw(n));if(!r)return;let a=t.state.doc.resolve(r.pos),s=i&&i.slice;s?t.someProp("transformPasted",y=>{s=y(s,t,!1)}):s=VW(t,eq(n.dataTransfer),c0?null:n.dataTransfer.getData("text/html"),!1,a);let o=!!(i&&nq(t,n));if(t.someProp("handleDrop",y=>y(t,n,s||Mt.empty,o))){n.preventDefault();return}if(!s)return;n.preventDefault();let l=s?oW(t.state.doc,a.pos,s):a.pos;l==null&&(l=a.pos);let c=t.state.tr;if(o){let{node:y}=i;y?y.replace(c):c.deleteSelection()}let u=c.mapping.map(l),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,m=c.doc;if(f?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(m))return;let g=c.doc.resolve(u);if(f&&Ft.isSelectable(s.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Ft(g));else{let y=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((_,v,x,M)=>y=M),c.setSelection(Ak(t,g,c.doc.resolve(y)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};va.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())&&cc(t)},20))};va.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)};va.beforeinput=(t,e)=>{if(ia&&tc&&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,Xd(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 ya)va[t]=ya[t];function d0(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 h1{constructor(e,n){this.toDOM=e,this.spec=n||uf,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 pa(a-i,a-i,this)}valid(){return!0}eq(e){return this==e||e instanceof h1&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&d0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Gu{constructor(e,n){this.attrs=e,this.spec=n||uf}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 pa(a,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Gu&&d0(this.attrs,e.attrs)&&d0(this.spec,e.spec)}static is(e){return e.type instanceof Gu}destroy(){}}class Pk{constructor(e,n){this.attrs=e,this.spec=n||uf}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 pa(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 Pk&&d0(this.attrs,e.attrs)&&d0(this.spec,e.spec)}destroy(){}}class pa{constructor(e,n,i){this.from=e,this.to=n,this.type=i}copy(e,n){return new pa(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 pa(e,e,new h1(n,i))}static inline(e,n,i,r){return new pa(e,n,new Gu(i,r))}static node(e,n,i,r){return new pa(e,n,new Pk(i,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Gu}get widget(){return this.type instanceof h1}}const hp=[],uf={};class pi{constructor(e,n){this.local=e.length?e:hp,this.children=n.length?n:hp}static create(e,n){return n.length?p1(n,e,0,uf):ea}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==ea||e.maps.length==0?this:this.mapInner(e,n,0,0,i||uf)}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?iMe(this.children,s||[],e,n,i,r,a):s?new pi(s.sort(df),hp):ea}add(e,n){return n.length?this==ea?pi.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,u;if(u=rq(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,u,c+1):r.splice(a,0,l,l+o.nodeSize,p1(u,o,c+1,uf)),a+=3}});let s=iq(a?aq(n):n,-i);for(let o=0;o<s.length;o++)s[o].type.valid(e,s[o])||s.splice(o--,1);return new pi(s.length?this.local.concat(s).sort(df):this.local,r||this.children)}remove(e){return e.length==0||this==ea?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 u=0,f;u<e.length;u++)(f=e[u])&&f.from>o&&f.to<l&&(e[u]=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!=ea?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 pi(r,i):ea}forChild(e,n){if(this==ea)return this;if(n.isLeaf)return pi.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 Gu){let c=Math.max(a,l.from)-a,u=Math.min(s,l.to)-a;c<u&&(r||(r=[])).push(l.copy(c,u))}}if(r){let o=new pi(r.sort(df),hp);return i?new Cu([o,i]):o}return i||ea}eq(e){if(this==e)return!0;if(!(e instanceof pi)||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 kk(this.localsInner(e))}localsInner(e){if(this==ea)return hp;if(e.inlineContent||!this.local.some(Gu.is))return this.local;let n=[];for(let i=0;i<this.local.length;i++)this.local[i].type instanceof Gu||n.push(this.local[i]);return n}forEachSet(e){e(this)}}pi.empty=new pi([],[]);pi.removeOverlap=kk;const ea=pi.empty;class Cu{constructor(e){this.members=e}map(e,n){const i=this.members.map(r=>r.map(e,n,uf));return Cu.from(i)}forChild(e,n){if(n.isLeaf)return pi.empty;let i=[];for(let r=0;r<this.members.length;r++){let a=this.members[r].forChild(e,n);a!=ea&&(a instanceof Cu?i=i.concat(a.members):i.push(a))}return Cu.from(i)}eq(e){if(!(e instanceof Cu)||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?kk(i?n:n.sort(df)):hp}static from(e){switch(e.length){case 0:return ea;case 1:return e[0];default:return new Cu(e.every(n=>n instanceof pi)?e:e.reduce((n,i)=>n.concat(i instanceof pi?i:i.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function iMe(t,e,n,i,r,a,s){let o=t.slice();for(let c=0,u=a;c<n.maps.length;c++){let f=0;n.maps[c].forEach((m,g,y,_)=>{let v=_-y-(g-m);for(let x=0;x<o.length;x+=3){let M=o[x+1];if(M<0||m>M+u-f)continue;let w=o[x]+u-f;g>=w?o[x+1]=m<=w?-2:-1:m>=u&&v&&(o[x]+=v,o[x+1]+=v)}f+=v}),u=n.maps[c].map(u,-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 u=n.map(t[c]+a),f=u-r;if(f<0||f>=i.content.size){l=!0;continue}let m=n.map(t[c+1]+a,-1),g=m-r,{index:y,offset:_}=i.content.findIndex(f),v=i.maybeChild(y);if(v&&_==f&&_+v.nodeSize==g){let x=o[c+2].mapInner(n,v,u+1,t[c]+a+1,s);x!=ea?(o[c]=f,o[c+1]=g,o[c+2]=x):(o[c+1]=-2,l=!0)}else l=!0}if(l){let c=rMe(o,t,e,n,r,a,s),u=p1(c,i,0,s);e=u.local;for(let f=0;f<o.length;f+=3)o[f+1]<0&&(o.splice(f,3),f-=3);for(let f=0,m=0;f<u.children.length;f+=3){let g=u.children[f];for(;m<o.length&&o[m]<g;)m+=3;o.splice(m,0,u.children[f],u.children[f+1],u.children[f+2])}}return new pi(e.sort(df),o)}function iq(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 pa(r.from+e,r.to+e,r.type))}return n}function rMe(t,e,n,i,r,a,s){function o(l,c){for(let u=0;u<l.local.length;u++){let f=l.local[u].map(i,r,c);f?n.push(f):s.onRemove&&s.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)o(l.children[u+2],l.children[u]+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 rq(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 aq(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function p1(t,e,n,i){let r=[],a=!1;e.forEach((o,l)=>{let c=rq(t,o,l+n);if(c){a=!0;let u=p1(c,o,n+l+1,i);u!=ea&&r.push(l,l+o.nodeSize,u)}});let s=iq(a?aq(t):t,-n).sort(df);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 pi(s,r):ea}function df(t,e){return t.from-e.from||t.to-e.to}function kk(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),BB(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),BB(e,r,i.copy(a.from,i.to)));break}}}return e}function BB(t,e,n){for(;e<t.length&&df(n,t[e])>0;)e++;t.splice(e,0,n)}function h2(t){let e=[];return t.someProp("decorations",n=>{let i=n(t.state);i&&i!=ea&&e.push(i)}),t.cursorWrapper&&e.push(pi.create(t.state.doc,[t.cursorWrapper.deco])),Cu.from(e)}const aMe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},sMe=za&&$u<=11;class oMe{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 lMe{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new oMe,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]);za&&$u<=11&&i.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),sMe&&(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,aMe)),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(DB(this.view)){if(this.suppressingSelectionUpdates)return cc(this.view);if(za&&$u<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pf(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=nm(a))n.add(a);for(let a=e.anchorNode;a;a=nm(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)&&DB(e)&&!this.ignoreSelectionChange(i),a=-1,s=-1,o=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let f=this.registerMutation(n[u],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(Gs&&l.length){let u=l.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,m]=u;f.parentNode&&f.parentNode.parentNode==m.parentNode?m.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let m of u){let g=m.parentNode;g&&g.nodeName=="LI"&&(!f||dMe(e,f)!=g)&&m.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&&hw(i)&&(c=Ek(e))&&c.eq(on.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,cc(e),this.currentSelection.set(i),e.scrollToSelection()):(a>-1||r)&&(a>-1&&(e.docView.markDirty(a,s),cMe(e)),this.handleDOMChange(a,s,o,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(i)||cc(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 u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];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(za&&$u<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:m}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(r=f),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(a=m)}let s=r&&r.parentNode==e.target?Gr(r)+1:0,o=i.localPosFromDOM(e.target,s,-1),l=a&&a.parentNode==e.target?Gr(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 HB=new WeakMap,$B=!1;function cMe(t){if(!HB.has(t)&&(HB.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Gs,$B)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."),$B=!0}}function VB(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,a=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return Pf(s.node,s.offset,r,a)&&([n,i,r,a]=[r,a,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:a}}function uMe(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return VB(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?VB(t,n):null}function dMe(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 fMe(t,e,n){let{node:i,fromOffset:r,toOffset:a,from:s,to:o}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],hw(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ia&&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,m=t.someProp("domParser")||Ax.fromSchema(t.state.schema),g=f.resolve(s),y=null,_=m.parse(i,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:r,to:a,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:hMe,context:g});if(c&&c[0].pos!=null){let v=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=v),y={anchor:v+s,head:x+s}}return{doc:_,sel:y,from:s,to:o}}function hMe(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(xa&&/^(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||xa&&/^(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 pMe=/^(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 mMe(t,e,n,i,r){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let A=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,j=Ek(t,A);if(j&&!t.state.selection.eq(j)){if(ia&&tc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",k=>k(t,Xd(13,"Enter"))))return;let N=t.state.tr.setSelection(j);A=="pointer"?N.setMeta("pointer",!0):A=="key"&&N.scrollIntoView(),a&&N.setMeta("composition",a),t.dispatch(N)}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=fMe(t,e,n),u=t.state.doc,f=u.slice(c.from,c.to),m,g;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,g="end"):(m=t.state.selection.from,g="start"),t.input.lastKeyCode=null;let y=vMe(f.content,c.doc.content,c.from,m,g);if(y&&t.input.domChangeCount++,(im&&t.input.lastIOSEnter>Date.now()-225||tc)&&r.some(A=>A.nodeType==1&&!pMe.test(A.nodeName))&&(!y||y.endA>=y.endB)&&t.someProp("handleKeyDown",A=>A(t,Xd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!y)if(i&&l instanceof Gt&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))y={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let A=GB(t,t.state.doc,c.sel);if(A&&!A.eq(t.state.selection)){let j=t.state.tr.setSelection(A);a&&j.setMeta("composition",a),t.dispatch(j)}}return}t.state.selection.from<t.state.selection.to&&y.start==y.endB&&t.state.selection instanceof Gt&&(y.start>t.state.selection.from&&y.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?y.start=t.state.selection.from:y.endA<t.state.selection.to&&y.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(y.endB+=t.state.selection.to-y.endA,y.endA=t.state.selection.to)),za&&$u<=11&&y.endB==y.start+1&&y.endA==y.start&&y.start>c.from&&c.doc.textBetween(y.start-c.from-1,y.start-c.from+1)==" "&&(y.start--,y.endA--,y.endB--);let _=c.doc.resolveNoCache(y.start-c.from),v=c.doc.resolveNoCache(y.endB-c.from),x=u.resolve(y.start),M=_.sameParent(v)&&_.parent.inlineContent&&x.end()>=y.endA;if((im&&t.input.lastIOSEnter>Date.now()-225&&(!M||r.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!M&&_.pos<c.doc.content.size&&(!_.sameParent(v)||!_.parent.inlineContent)&&_.pos<v.pos&&!/\S/.test(c.doc.textBetween(_.pos,v.pos,"","")))&&t.someProp("handleKeyDown",A=>A(t,Xd(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>y.start&&xMe(u,y.start,y.endA,_,v)&&t.someProp("handleKeyDown",A=>A(t,Xd(8,"Backspace")))){tc&&ia&&t.domObserver.suppressSelectionUpdates();return}ia&&y.endB==y.start&&(t.input.lastChromeDelete=Date.now()),tc&&!M&&_.start()!=v.start()&&v.parentOffset==0&&_.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==y.endA&&(y.endB-=2,v=c.doc.resolveNoCache(y.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(A){return A(t,Xd(13,"Enter"))})},20));let w=y.start,C=y.endA,T=A=>{let j=A||t.state.tr.replace(w,C,c.doc.slice(y.start-c.from,y.endB-c.from));if(c.sel){let N=GB(t,j.doc,c.sel);N&&!(ia&&t.composing&&N.empty&&(y.start!=y.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==w||N.head==j.mapping.map(C)-1)||za&&N.empty&&N.head==w)&&j.setSelection(N)}return a&&j.setMeta("composition",a),j.scrollIntoView()},P;if(M)if(_.pos==v.pos){za&&$u<=11&&_.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>cc(t),20));let A=T(t.state.tr.delete(w,C)),j=u.resolve(y.start).marksAcross(u.resolve(y.endA));j&&A.ensureMarks(j),t.dispatch(A)}else if(y.endA==y.endB&&(P=gMe(_.parent.content.cut(_.parentOffset,v.parentOffset),x.parent.content.cut(x.parentOffset,y.endA-x.start())))){let A=T(t.state.tr);P.type=="add"?A.addMark(w,C,P.mark):A.removeMark(w,C,P.mark),t.dispatch(A)}else if(_.parent.child(_.index()).isText&&_.index()==v.index()-(v.textOffset?0:1)){let A=_.parent.textBetween(_.parentOffset,v.parentOffset),j=()=>T(t.state.tr.insertText(A,w,C));t.someProp("handleTextInput",N=>N(t,w,C,A,j))||t.dispatch(j())}else t.dispatch(T());else t.dispatch(T())}function GB(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ak(t,e.resolve(n.anchor),e.resolve(n.head))}function gMe(t,e){let n=t.firstChild.marks,i=e.firstChild.marks,r=n,a=i,s,o,l;for(let u=0;u<i.length;u++)r=i[u].removeFromSet(r);for(let u=0;u<n.length;u++)a=n[u].removeFromSet(a);if(r.length==1&&a.length==0)o=r[0],s="add",l=u=>u.mark(o.addToSet(u.marks));else if(r.length==0&&a.length==1)o=a[0],s="remove",l=u=>u.mark(o.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(ht.from(c).eq(t))return{mark:o,type:s}}function xMe(t,e,n,i,r){if(n-e<=r.pos-i.pos||p2(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(p2(a,!0,!0));return!s.parent.isTextblock||s.pos>n||p2(s,!0,!1)<n?!1:i.parent.content.cut(i.parentOffset).eq(s.parent.content)}function p2(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 vMe(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&&WB(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&&WB(t.textBetween(a-1,a+1))&&(a+=l?1:-1),s=a+(s-o),o=a}return{start:a,endA:s,endB:o}}function WB(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 sq{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 jwe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(ZB),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=KB(this),XB(this),this.nodeViews=YB(this),this.docView=TB(this.state.doc,qB(this),h2(this),this.dom,this),this.domObserver=new lMe(this,(i,r,a,s)=>mMe(this,i,r,a,s)),this.domObserver.start(),Uwe(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&&Z3(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ZB),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&&(JW(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 g=YB(this);bMe(g,this.nodeViews)&&(this.nodeViews=g,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&Z3(this),this.editable=KB(this),XB(this);let l=h2(this),c=qB(this),u=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 m=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&QSe(this);if(s){this.domObserver.stop();let g=f&&(za||ia)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&yMe(r.selection,e.selection);if(f){let y=ia?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Zwe(this)),(a||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=TB(e.doc,c,l,this.dom,this)),y&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Swe(this))?cc(this,g):(BW(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),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():m&&JSe(m)}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 Ft){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&_B(this,n.getBoundingClientRect(),e)}else _B(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 tq(e.slice,e.move,r<0?void 0:Ft.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(za){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&&ewe(this.dom),cc(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 awe(this,e)}coordsAtPos(e,n=1){return DW(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 uwe(this,n||this.state,e)}pasteHTML(e,n){return u0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return u0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Tk(this,e)}destroy(){this.docView&&(Fwe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],h2(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,BSe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Bwe(this,e)}domSelectionRange(){let e=this.domSelection();return e?xa&&this.root.nodeType===11&&WSe(this.dom.ownerDocument)==this.dom&&uMe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}sq.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function qB(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"),[pa.node(0,t.state.doc.content.size,e)]}function XB(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:pa.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function KB(t){return!t.someProp("editable",e=>e(t.state)===!1)}function yMe(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 YB(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 bMe(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 ZB(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 Zu={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:"'"},m1={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},_Me=typeof navigator<"u"&&/Mac/.test(navigator.platform),SMe=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Wr=0;Wr<10;Wr++)Zu[48+Wr]=Zu[96+Wr]=String(Wr);for(var Wr=1;Wr<=24;Wr++)Zu[Wr+111]="F"+Wr;for(var Wr=65;Wr<=90;Wr++)Zu[Wr]=String.fromCharCode(Wr+32),m1[Wr]=String.fromCharCode(Wr);for(var m2 in Zu)m1.hasOwnProperty(m2)||(m1[m2]=Zu[m2]);function wMe(t){var e=_Me&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||SMe&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?m1:Zu)[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 MMe=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),EMe=typeof navigator<"u"&&/Win/.test(navigator.platform);function AMe(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))MMe?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 TMe(t){let e=Object.create(null);for(let n in t)e[AMe(n)]=t[n];return e}function g2(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 CMe(t){return new xi({props:{handleKeyDown:oq(t)}})}function oq(t){let e=TMe(t);return function(n,i){let r=wMe(i),a,s=e[g2(r,i)];if(s&&s(n.state,n.dispatch,n))return!0;if(r.length==1&&r!=" "){if(i.shiftKey){let o=e[g2(r,i,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((i.altKey||i.metaKey||i.ctrlKey)&&!(EMe&&i.ctrlKey&&i.altKey)&&(a=Zu[i.keyCode])&&a!=r){let o=e[g2(a,i)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var NMe=Object.defineProperty,Dk=(t,e)=>{for(var n in e)NMe(t,n,{get:e[n],enumerable:!0})};function gw(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 xw=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 u=o(...c)(a);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),u}]))}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)),u={...Object.fromEntries(Object.entries(n).map(([f,m])=>[f,(...y)=>{const _=this.buildProps(l,e),v=m(...y)(_);return s.push(v),u}])),run:c};return u}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:gw({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}},lq={};Dk(lq,{blur:()=>RMe,clearContent:()=>PMe,clearNodes:()=>kMe,command:()=>DMe,createParagraphNear:()=>OMe,cut:()=>LMe,deleteCurrentNode:()=>IMe,deleteNode:()=>jMe,deleteRange:()=>UMe,deleteSelection:()=>FMe,enter:()=>zMe,exitCode:()=>BMe,extendMarkRange:()=>HMe,first:()=>$Me,focus:()=>GMe,forEach:()=>WMe,insertContent:()=>qMe,insertContentAt:()=>YMe,joinBackward:()=>JMe,joinDown:()=>QMe,joinForward:()=>eEe,joinItemBackward:()=>tEe,joinItemForward:()=>nEe,joinTextblockBackward:()=>iEe,joinTextblockForward:()=>rEe,joinUp:()=>ZMe,keyboardShortcut:()=>sEe,lift:()=>oEe,liftEmptyBlock:()=>lEe,liftListItem:()=>cEe,newlineInCode:()=>uEe,resetAttributes:()=>dEe,scrollIntoView:()=>fEe,selectAll:()=>hEe,selectNodeBackward:()=>pEe,selectNodeForward:()=>mEe,selectParentNode:()=>gEe,selectTextblockEnd:()=>xEe,selectTextblockStart:()=>vEe,setContent:()=>yEe,setMark:()=>jEe,setMeta:()=>UEe,setNode:()=>FEe,setNodeSelection:()=>zEe,setTextDirection:()=>BEe,setTextSelection:()=>HEe,sinkListItem:()=>$Ee,splitBlock:()=>VEe,splitListItem:()=>GEe,toggleList:()=>WEe,toggleMark:()=>qEe,toggleNode:()=>XEe,toggleWrap:()=>KEe,undoInputRule:()=>YEe,unsetAllMarks:()=>ZEe,unsetMark:()=>QEe,unsetTextDirection:()=>JEe,updateAttributes:()=>eAe,wrapIn:()=>tAe,wrapInList:()=>nAe});var RMe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),PMe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),kMe=()=>({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:u}=e,f=c.resolve(u.map(l)),m=c.resolve(u.map(l+o.nodeSize)),g=f.blockRange(m);if(!g)return;const y=Cm(g);if(o.type.isTextblock){const{defaultType:_}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(g.start,_)}(y||y===0)&&e.lift(g,y)})}),!0},DMe=t=>e=>t(e),OMe=()=>({state:t,dispatch:e})=>wW(t,e),LMe=(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 Gt(i.doc.resolve(Math.max(s-1,0)))),!0},IMe=()=>({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 Yi(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 jMe=t=>({tr:e,state:n,dispatch:i})=>{const r=Yi(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},UMe=t=>({tr:e,dispatch:n})=>{const{from:i,to:r}=t;return n&&e.delete(i,r),!0},FMe=()=>({state:t,dispatch:e})=>yk(t,e),zMe=()=>({commands:t})=>t.keyboardShortcut("Enter"),BMe=()=>({state:t,dispatch:e})=>ASe(t,e);function Ok(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function g1(t,e,n={strict:!0}){const i=Object.keys(e);return i.length?i.every(r=>n.strict?e[r]===t[r]:Ok(e[r])?e[r].test(t[r]):e[r]===t[r]):!0}function cq(t,e,n={}){return t.find(i=>i.type===e&&g1(Object.fromEntries(Object.keys(n).map(r=>[r,i.attrs[r]])),n))}function QB(t,e,n={}){return!!cq(t,e,n)}function Lk(t,e,n){var i;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(u=>u.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(u=>u.type===e)||(n=n||((i=r.node.marks[0])==null?void 0:i.attrs),!cq([...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&&QB([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&QB([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:c}}function Ac(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 HMe=(t,e={})=>({tr:n,state:i,dispatch:r})=>{const a=Ac(t,i.schema),{doc:s,selection:o}=n,{$from:l,from:c,to:u}=o;if(r){const f=Lk(l,a,e);if(f&&f.from<=c&&f.to>=u){const m=Gt.create(s,f.from,f.to);n.setSelection(m)}}return!0},$Me=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 uq(t){return t instanceof Gt}function Jd(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function dq(t,e=null){if(!e)return null;const n=on.atStart(t),i=on.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return i;const r=n.from,a=i.to;return e==="all"?Gt.create(t,Jd(0,r,a),Jd(t.content.size,r,a)):Gt.create(t,Jd(e,r,a),Jd(e,r,a))}function VMe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ik(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var GMe=(t=null,e={})=>({editor:n,view:i,tr:r,dispatch:a})=>{e={scrollIntoView:!0,...e};const s=()=>{(Ik()||VMe())&&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&&!uq(n.state.selection))return s(),!0;const o=dq(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},WMe=(t,e)=>n=>t.every((i,r)=>e(i,{...n,index:r})),qMe=(t,e)=>({tr:n,commands:i})=>i.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),fq=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&&fq(i)}return t};function jb(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 fq(n)}function f0(t,e,n){if(t instanceof Hu||t instanceof ht)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 ht.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),f0("",e,n)}if(r){if(n.errorOnInvalidContent){let s=!1,o="";const l=new Y7({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?Ax.fromSchema(l).parseSlice(jb(t),n.parseOptions):Ax.fromSchema(l).parse(jb(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=Ax.fromSchema(e);return n.slice?a.parseSlice(jb(t),n.parseOptions).content:a.parse(jb(t),n.parseOptions)}return f0("",e,n)}function XMe(t,e,n){const i=t.steps.length-1;if(i<e)return;const r=t.steps[i];if(!(r instanceof Ar||r instanceof Cr))return;const a=t.mapping.maps[i];let s=0;a.forEach((o,l,c,u)=>{s===0&&(s=u)}),t.setSelection(on.near(t.doc.resolve(s),n))}var KMe=t=>!("type"in t),YMe=(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{f0(e,a.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(v){l(v)}try{o=f0(e,a.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:a.options.enableContentCheck})}catch(v){return l(v),!1}let{from:u,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,g=!0;if((KMe(o)?o:[o]).forEach(v=>{v.check(),m=m?v.isText&&v.marks.length===0:!1,g=g?v.isBlock:!1}),u===f&&g){const{parent:v}=i.doc.resolve(u);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(u-=1,f+=1)}let _;if(m){if(Array.isArray(e))_=e.map(v=>v.text||"").join("");else if(e instanceof ht){let v="";e.forEach(x=>{x.text&&(v+=x.text)}),_=v}else typeof e=="object"&&e&&e.text?_=e.text:_=e;i.insertText(_,u,f)}else{_=o;const v=i.doc.resolve(u),x=v.node(),M=v.parentOffset===0,w=x.isText||x.isTextblock,C=x.content.size>0;M&&w&&C&&(u=Math.max(0,u-1)),i.replaceWith(u,f,_)}n.updateSelection&&XMe(i,i.steps.length-1,-1),n.applyInputRules&&i.setMeta("applyInputRules",{from:u,text:_}),n.applyPasteRules&&i.setMeta("applyPasteRules",{from:u,text:_})}return!0},ZMe=()=>({state:t,dispatch:e})=>wSe(t,e),QMe=()=>({state:t,dispatch:e})=>MSe(t,e),JMe=()=>({state:t,dispatch:e})=>gW(t,e),eEe=()=>({state:t,dispatch:e})=>bW(t,e),tEe=()=>({state:t,dispatch:e,tr:n})=>{try{const i=uw(t.doc,t.selection.$from.pos,-1);return i==null?!1:(n.join(i,2),e&&e(n),!0)}catch{return!1}},nEe=()=>({state:t,dispatch:e,tr:n})=>{try{const i=uw(t.doc,t.selection.$from.pos,1);return i==null?!1:(n.join(i,2),e&&e(n),!0)}catch{return!1}},iEe=()=>({state:t,dispatch:e})=>_Se(t,e),rEe=()=>({state:t,dispatch:e})=>SSe(t,e);function hq(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function aEe(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))Ik()||hq()?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 sEe=t=>({editor:e,view:n,tr:i,dispatch:r})=>{const a=aEe(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 u=c.map(i.mapping);u&&r&&i.maybeStep(u)}),!0};function Qu(t,e,n={}){const{from:i,to:r,empty:a}=t.selection,s=e?Yi(e,t.schema):null,o=[];t.doc.nodesBetween(i,r,(f,m)=>{if(f.isText)return;const g=Math.max(i,m),y=Math.min(r,m+f.nodeSize);o.push({node:f,from:g,to:y})});const l=r-i,c=o.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>g1(f.node.attrs,n,{strict:!1}));return a?!!c.length:c.reduce((f,m)=>f+m.to-m.from,0)>=l}var oEe=(t,e={})=>({state:n,dispatch:i})=>{const r=Yi(t,n.schema);return Qu(n,r,e)?ESe(n,i):!1},lEe=()=>({state:t,dispatch:e})=>MW(t,e),cEe=t=>({state:e,dispatch:n})=>{const i=Yi(t,e.schema);return jSe(i)(e,n)},uEe=()=>({state:t,dispatch:e})=>SW(t,e);function vw(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function JB(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 dEe=(t,e)=>({tr:n,state:i,dispatch:r})=>{let a=null,s=null;const o=vw(typeof t=="string"?t:t.name,i.schema);if(!o)return!1;o==="node"&&(a=Yi(t,i.schema)),o==="mark"&&(s=Ac(t,i.schema));let l=!1;return n.selection.ranges.forEach(c=>{i.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,f)=>{a&&a===u.type&&(l=!0,r&&n.setNodeMarkup(f,void 0,JB(u.attrs,e))),s&&u.marks.length&&u.marks.forEach(m=>{s===m.type&&(l=!0,r&&n.addMark(f,f+u.nodeSize,s.create(JB(m.attrs,e))))})})}),l},fEe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),hEe=()=>({tr:t,dispatch:e})=>{if(e){const n=new fs(t.doc);t.setSelection(n)}return!0},pEe=()=>({state:t,dispatch:e})=>vW(t,e),mEe=()=>({state:t,dispatch:e})=>_W(t,e),gEe=()=>({state:t,dispatch:e})=>NSe(t,e),xEe=()=>({state:t,dispatch:e})=>kSe(t,e),vEe=()=>({state:t,dispatch:e})=>PSe(t,e);function Q3(t,e,n={},i={}){return f0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:i.errorOnInvalidContent})}var yEe=(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=Q3(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 pq(t,e){const n=Ac(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 mq(t,e){const n=new fW(t);return e.forEach(i=>{i.steps.forEach(r=>{n.step(r)})}),n}function bEe(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 _Ee(t,e,n){const i=[];return t.nodesBetween(e.from,e.to,(r,a)=>{n(r)&&i.push({node:r,pos:a})}),i}function SEe(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 yw(t){return e=>SEe(e.$from,t)}function Ut(t,e,n){return t.config[e]===void 0&&t.parent?Ut(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ut(t.parent,e,n):null}):t.config[e]}function jk(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},i=Ut(e,"addExtensions",n);return i?[e,...jk(i())]:e}).flat(10)}function Uk(t,e){const n=Vf.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function gq(t){return typeof t=="function"}function On(t,e=void 0,...n){return gq(t)?e?t.bind(e)(...n):t(...n):t}function wEe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function rm(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 xq(t){const e=[],{nodeExtensions:n,markExtensions:i}=rm(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=Ut(s,"addGlobalAttributes",o);if(!l)return;l().forEach(u=>{u.types.forEach(f=>{Object.entries(u.attributes).forEach(([m,g])=>{e.push({type:f,name:m,attribute:{...a,...g}})})})})}),r.forEach(s=>{const o={name:s.name,options:s.options,storage:s.storage},l=Ut(s,"addAttributes",o);if(!l)return;const c=l();Object.entries(c).forEach(([u,f])=>{const m={...a,...f};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:s.name,name:u,attribute:m})})}),e}function Ai(...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(u=>!l.includes(u));i[r]=[...l,...c].join(" ")}else if(r==="style"){const o=a?a.split(";").map(u=>u.trim()).filter(Boolean):[],l=i[r]?i[r].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[f,m]=u.split(":").map(g=>g.trim());c.set(f,m)}),o.forEach(u=>{const[f,m]=u.split(":").map(g=>g.trim());c.set(f,m)}),i[r]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else i[r]=a}),i},{})}function x1(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)=>Ai(n,i),{})}function MEe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function e8(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):MEe(n.getAttribute(s.name));return o==null?a:{...a,[s.name]:o}},{});return{...i,...r}}}}function t8(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&wEe(n)?!1:n!=null))}function n8(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 EEe(t,e){var n;const i=xq(t),{nodeExtensions:r,markExtensions:a}=rm(t),s=(n=r.find(c=>Ut(c,"topNode")))==null?void 0:n.name,o=Object.fromEntries(r.map(c=>{const u=i.filter(x=>x.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},m=t.reduce((x,M)=>{const w=Ut(M,"extendNodeSchema",f);return{...x,...w?w(c):{}}},{}),g=t8({...m,content:On(Ut(c,"content",f)),marks:On(Ut(c,"marks",f)),group:On(Ut(c,"group",f)),inline:On(Ut(c,"inline",f)),atom:On(Ut(c,"atom",f)),selectable:On(Ut(c,"selectable",f)),draggable:On(Ut(c,"draggable",f)),code:On(Ut(c,"code",f)),whitespace:On(Ut(c,"whitespace",f)),linebreakReplacement:On(Ut(c,"linebreakReplacement",f)),defining:On(Ut(c,"defining",f)),isolating:On(Ut(c,"isolating",f)),attrs:Object.fromEntries(u.map(n8))}),y=On(Ut(c,"parseHTML",f));y&&(g.parseDOM=y.map(x=>e8(x,u)));const _=Ut(c,"renderHTML",f);_&&(g.toDOM=x=>_({node:x,HTMLAttributes:x1(x,u)}));const v=Ut(c,"renderText",f);return v&&(g.toText=v),[c.name,g]})),l=Object.fromEntries(a.map(c=>{const u=i.filter(v=>v.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},m=t.reduce((v,x)=>{const M=Ut(x,"extendMarkSchema",f);return{...v,...M?M(c):{}}},{}),g=t8({...m,inclusive:On(Ut(c,"inclusive",f)),excludes:On(Ut(c,"excludes",f)),group:On(Ut(c,"group",f)),spanning:On(Ut(c,"spanning",f)),code:On(Ut(c,"code",f)),attrs:Object.fromEntries(u.map(n8))}),y=On(Ut(c,"parseHTML",f));y&&(g.parseDOM=y.map(v=>e8(v,u)));const _=Ut(c,"renderHTML",f);return _&&(g.toDOM=v=>_({mark:v,HTMLAttributes:x1(v,u)})),[c.name,g]}));return new Y7({topNode:s,nodes:o,marks:l})}function AEe(t){const e=t.filter((n,i)=>t.indexOf(n)!==i);return Array.from(new Set(e))}function Fk(t){return t.sort((n,i)=>{const r=Ut(n,"priority")||100,a=Ut(i,"priority")||100;return r>a?-1:r<a?1:0})}function vq(t){const e=Fk(jk(t)),n=AEe(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 yq(t,e,n){const{from:i,to:r}=e,{blockSeparator:a=`
- `,textSerializers:s={}}=n||{};let o="";return t.nodesBetween(i,r,(l,c,u,f)=>{var m;l.isBlock&&c>i&&(o+=a);const g=s?.[l.type.name];if(g)return u&&(o+=g({node:l,pos:c,parent:u,index:f,range:e})),!1;l.isText&&(o+=(m=l?.text)==null?void 0:m.slice(Math.max(i,c)-c,r-c))}),o}function TEe(t,e){const n={from:0,to:t.content.size};return yq(t,n,e)}function bq(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function CEe(t,e){const n=Yi(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 _q(t,e){const n=vw(typeof e=="string"?e:e.name,t.schema);return n==="node"?CEe(t,e):n==="mark"?pq(t,e):{}}function NEe(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 REe(t){const e=NEe(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 Sq(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),u=e.slice(a).map(l),f=e.invert().map(c,-1),m=e.invert().map(u);i.push({oldRange:{from:f,to:m},newRange:{from:c,to:u}})})}),REe(i)}function zk(t,e,n){const i=[];return t===e?n.resolve(t).marks().forEach(r=>{const a=n.resolve(t),s=Lk(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 PEe=(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 x2(t,e){return e.nodes[t]||e.marks[t]||null}function A_(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 kEe=(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 u=((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?u:u.slice(0,Math.max(0,i-a))}),n};function J3(t,e,n={}){const{empty:i,ranges:r}=t.selection,a=e?Ac(e,t.schema):null;if(i)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>g1(f.attrs,n,{strict:!1}));let s=0;const o=[];if(r.forEach(({$from:f,$to:m})=>{const g=f.pos,y=m.pos;t.doc.nodesBetween(g,y,(_,v)=>{if(!_.isText&&!_.marks.length)return;const x=Math.max(g,v),M=Math.min(y,v+_.nodeSize),w=M-x;s+=w,o.push(..._.marks.map(C=>({mark:C,from:x,to:M})))})}),s===0)return!1;const l=o.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>g1(f.mark.attrs,n,{strict:!1})).reduce((f,m)=>f+m.to-m.from,0),c=o.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,m)=>f+m.to-m.from,0);return(l>0?l+c:l)>=s}function DEe(t,e,n={}){if(!e)return Qu(t,null,n)||J3(t,null,n);const i=vw(e,t.schema);return i==="node"?Qu(t,e,n):i==="mark"?J3(t,e,n):!1}var OEe=(t,e)=>{const{$from:n,$to:i,$anchor:r}=t.selection;if(e){const a=yw(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)},LEe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function i8(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function r8(t,e){const{nodeExtensions:n}=rm(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(Ut(i,"group",r));return typeof a!="string"?!1:a.split(" ").includes("list")}function bw(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&&(bw(a,{ignoreWhitespace:n,checkChildren:e})||(r=!1))}),r}return!1}function wq(t){return t instanceof Ft}function IEe(t,e,n){var i;const{selection:r}=e;let a=null;if(uq(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,(u,f,m)=>{if(c)return!1;if(u.isInline){const g=!m||m.type.allowsMarkType(n),y=!!n.isInSet(u.marks)||!u.marks.some(_=>_.type.excludes(n));c=g&&y}return!c}),c})}var jEe=(t,e={})=>({tr:n,state:i,dispatch:r})=>{const{selection:a}=n,{empty:s,ranges:o}=a,l=Ac(t,i.schema);if(r)if(s){const c=pq(i,l);n.addStoredMark(l.create({...c,...e}))}else o.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;i.doc.nodesBetween(u,f,(m,g)=>{const y=Math.max(g,u),_=Math.min(g+m.nodeSize,f);m.marks.find(x=>x.type===l)?m.marks.forEach(x=>{l===x.type&&n.addMark(y,_,l.create({...x.attrs,...e}))}):n.addMark(y,_,l.create(e))})});return IEe(i,n,l)},UEe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),FEe=(t,e={})=>({state:n,dispatch:i,chain:r})=>{const a=Yi(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})=>vB(a,{...s,...e})(n)?!0:o.clearNodes()).command(({state:o})=>vB(a,{...s,...e})(o,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},zEe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:i}=e,r=Jd(t,0,i.content.size),a=Ft.create(i,r);e.setSelection(a)}return!0},BEe=(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},HEe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:i}=e,{from:r,to:a}=typeof t=="number"?{from:t,to:t}:t,s=Gt.atStart(i).from,o=Gt.atEnd(i).to,l=Jd(r,s,o),c=Jd(a,s,o),u=Gt.create(i,l,c);e.setSelection(u)}return!0},$Ee=t=>({state:e,dispatch:n})=>{const i=Yi(t,e.schema);return zSe(i)(e,n)};function a8(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 VEe=({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,u=A_(c,o.node().type.name,o.node().attrs);if(a instanceof Ft&&a.node.isBlock)return!o.parentOffset||!lc(s,o.pos)?!1:(i&&(t&&a8(n,r.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const f=l.parentOffset===l.parent.content.size,m=o.depth===0?void 0:bEe(o.node(-1).contentMatchAt(o.indexAfter(-1)));let g=f&&m?[{type:m,attrs:u}]:void 0,y=lc(e.doc,e.mapping.map(o.pos),1,g);if(!g&&!y&&lc(e.doc,e.mapping.map(o.pos),1,m?[{type:m}]:void 0)&&(y=!0,g=m?[{type:m,attrs:u}]:void 0),i){if(y&&(a instanceof Gt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,g),m&&!f&&!o.parentOffset&&o.parent.type!==m)){const _=e.mapping.map(o.before()),v=e.doc.resolve(_);o.node(-1).canReplaceWith(v.index(),v.index()+1,m)&&e.setNodeMarkup(e.mapping.map(o.before()),m)}t&&a8(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return y},GEe=(t,e={})=>({tr:n,state:i,dispatch:r,editor:a})=>{var s;const o=Yi(t,i.schema),{$from:l,$to:c}=i.selection,u=i.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const f=l.node(-1);if(f.type!==o)return!1;const m=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=ht.empty;const M=l.index(-1)?1:l.index(-2)?2:3;for(let j=l.depth-M;j>=l.depth-3;j-=1)x=ht.from(l.node(j).copy(x));const w=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,C={...A_(m,l.node().type.name,l.node().attrs),...e},T=((s=o.contentMatch.defaultType)==null?void 0:s.createAndFill(C))||void 0;x=x.append(ht.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 A=-1;n.doc.nodesBetween(P,n.doc.content.size,(j,N)=>{if(A>-1)return!1;j.isTextblock&&j.content.size===0&&(A=N+1)}),A>-1&&n.setSelection(Gt.near(n.doc.resolve(A))),n.scrollIntoView()}return!0}const g=c.pos===l.end()?f.contentMatchAt(0).defaultType:null,y={...A_(m,f.type.name,f.attrs),...e},_={...A_(m,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const v=g?[{type:o,attrs:y},{type:g,attrs:_}]:[{type:o,attrs:y}];if(!lc(n.doc,l.pos,2))return!1;if(r){const{selection:x,storedMarks:M}=i,{splittableMarks:w}=a.extensionManager,C=M||x.$to.parentOffset&&x.$from.marks();if(n.split(l.pos,2,v).scrollIntoView(),!C||!r)return!0;const T=C.filter(P=>w.includes(P.type.name));n.ensureMarks(T)}return!0},v2=(t,e)=>{const n=yw(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&&ad(t.doc,n.pos)&&t.join(n.pos),!0},y2=(t,e)=>{const n=yw(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&&ad(t.doc,i)&&t.join(i),!0},WEe=(t,e,n,i={})=>({editor:r,tr:a,state:s,dispatch:o,chain:l,commands:c,can:u})=>{const{extensions:f,splittableMarks:m}=r.extensionManager,g=Yi(t,s.schema),y=Yi(e,s.schema),{selection:_,storedMarks:v}=s,{$from:x,$to:M}=_,w=x.blockRange(M),C=v||_.$to.parentOffset&&_.$from.marks();if(!w)return!1;const T=yw(P=>r8(P.type.name,f))(_);if(w.depth>=1&&T&&w.depth-T.depth<=1){if(T.node.type===g)return c.liftListItem(y);if(r8(T.node.type.name,f)&&g.validContent(T.node.content)&&o)return l().command(()=>(a.setNodeMarkup(T.pos,g),!0)).command(()=>v2(a,g)).command(()=>y2(a,g)).run()}return!n||!C||!o?l().command(()=>u().wrapInList(g,i)?!0:c.clearNodes()).wrapInList(g,i).command(()=>v2(a,g)).command(()=>y2(a,g)).run():l().command(()=>{const P=u().wrapInList(g,i),A=C.filter(j=>m.includes(j.type.name));return a.ensureMarks(A),P?!0:c.clearNodes()}).wrapInList(g,i).command(()=>v2(a,g)).command(()=>y2(a,g)).run()},qEe=(t,e={},n={})=>({state:i,commands:r})=>{const{extendEmptyMarkRange:a=!1}=n,s=Ac(t,i.schema);return J3(i,s,e)?r.unsetMark(s,{extendEmptyMarkRange:a}):r.setMark(s,e)},XEe=(t,e,n={})=>({state:i,commands:r})=>{const a=Yi(t,i.schema),s=Yi(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})},KEe=(t,e={})=>({state:n,commands:i})=>{const r=Yi(t,n.schema);return Qu(n,r,e)?i.lift(r):i.wrapIn(r,e)},YEe=()=>({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},ZEe=()=>({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},QEe=(t,e={})=>({tr:n,state:i,dispatch:r})=>{var a;const{extendEmptyMarkRange:s=!1}=e,{selection:o}=n,l=Ac(t,i.schema),{$from:c,empty:u,ranges:f}=o;if(!r)return!0;if(u&&s){let{from:m,to:g}=o;const y=(a=c.marks().find(v=>v.type===l))==null?void 0:a.attrs,_=Lk(c,l,y);_&&(m=_.from,g=_.to),n.removeMark(m,g,l)}else f.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,l)});return n.removeStoredMark(l),!0},JEe=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},eAe=(t,e={})=>({tr:n,state:i,dispatch:r})=>{let a=null,s=null;const o=vw(typeof t=="string"?t:t.name,i.schema);if(!o)return!1;o==="node"&&(a=Yi(t,i.schema)),o==="mark"&&(s=Ac(t,i.schema));let l=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;let m,g,y,_;n.selection.empty?i.doc.nodesBetween(u,f,(v,x)=>{a&&a===v.type&&(l=!0,y=Math.max(x,u),_=Math.min(x+v.nodeSize,f),m=x,g=v)}):i.doc.nodesBetween(u,f,(v,x)=>{x<u&&a&&a===v.type&&(l=!0,y=Math.max(x,u),_=Math.min(x+v.nodeSize,f),m=x,g=v),x>=u&&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,u),C=Math.min(x+v.nodeSize,f);n.addMark(w,C,s.create({...M.attrs,...e}))}}))}),g&&(m!==void 0&&r&&n.setNodeMarkup(m,void 0,{...g.attrs,...e}),s&&g.marks.length&&g.marks.forEach(v=>{s===v.type&&r&&n.addMark(y,_,s.create({...v.attrs,...e}))}))}),l},tAe=(t,e={})=>({state:n,dispatch:i})=>{const r=Yi(t,n.schema);return DSe(r,e)(n,i)},nAe=(t,e={})=>({state:n,dispatch:i})=>{const r=Yi(t,n.schema);return OSe(r,e)(n,i)},iAe=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={}}},_w=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},rAe=(t,e)=>{if(Ok(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 Ub(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(m=>m.type.spec.code))return!1;let u=!1;const f=kEe(c)+a;return s.forEach(m=>{if(u)return;const g=rAe(f,m.find);if(!g)return;const y=l.state.tr,_=gw({state:l.state,transaction:y}),v={from:i-(g[0].length-a.length),to:r},{commands:x,chain:M,can:w}=new xw({editor:n,state:_});m.handler({state:_,range:v,match:g,commands:x,chain:M,can:w})===null||!y.steps.length||(m.undoable&&y.setMeta(o,{transform:y,from:i,to:r,text:a}),l.dispatch(y),u=!0)}),u}function aAe(t){const{editor:e,rules:n}=t,i=new xi({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:u}=l;typeof u=="string"?u=u:u=Uk(ht.from(u),s.schema);const{from:f}=l,m=f+u.length;Ub({editor:e,from:f,to:m,text:u,rules:n,plugin:i})}),r.selectionSet||r.docChanged?null:a}},props:{handleTextInput(r,a,s,o){return Ub({editor:e,from:a,to:s,text:o,rules:n,plugin:i})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{const{$cursor:a}=r.state.selection;a&&Ub({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?Ub({editor:e,from:s.pos,to:s.pos,text:`
- `,rules:n,plugin:i}):!1}},isInputRules:!0});return i}function sAe(t){return Object.prototype.toString.call(t).slice(8,-1)}function Fb(t){return sAe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Mq(t,e){const n={...t};return Fb(t)&&Fb(e)&&Object.keys(e).forEach(i=>{Fb(e[i])&&Fb(t[i])?n[i]=Mq(t[i],e[i]):n[i]=e[i]}),n}var Bk=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(Ut(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...On(Ut(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Mq(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}},od=class Eq extends Bk{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Eq(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 oAe(t){return typeof t=="number"}var lAe=class{constructor(t){this.find=t.find,this.handler=t.handler}},cAe=(t,e,n)=>{if(Ok(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 uAe(t){const{editor:e,state:n,from:i,to:r,rule:a,pasteEvent:s,dropEvent:o}=t,{commands:l,chain:c,can:u}=new xw({editor:e,state:n}),f=[];return n.doc.nodesBetween(i,r,(g,y)=>{var _,v,x,M,w;if((v=(_=g.type)==null?void 0:_.spec)!=null&&v.code||!(g.isText||g.isTextblock||g.isInline))return;const C=(w=(M=(x=g.content)==null?void 0:x.size)!=null?M:g.nodeSize)!=null?w:0,T=Math.max(i,y),P=Math.min(r,y+C);if(T>=P)return;const A=g.isText?g.text||"":g.textBetween(T-y,P-y,void 0,"");cAe(A,a.find,s).forEach(N=>{if(N.index===void 0)return;const k=T+N.index+1,F=k+N[0].length,I={from:n.tr.mapping.map(k),to:n.tr.mapping.map(F)},W=a.handler({state:n,range:I,match:N,commands:l,chain:c,can:u,pasteEvent:s,dropEvent:o});f.push(W)})}),f.every(g=>g!==null)}var zb=null,dAe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function fAe(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:u,from:f,to:m,rule:g,pasteEvt:y})=>{const _=u.tr,v=gw({state:u,transaction:_});if(!(!uAe({editor:e,state:v,from:Math.max(f-1,0),to:m.b-1,rule:g,pasteEvent:y,dropEvent:o})||!_.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,_}};return n.map(u=>new xi({view(f){const m=y=>{var _;i=(_=f.dom.parentElement)!=null&&_.contains(y.target)?f.dom.parentElement:null,i&&(zb=e)},g=()=>{zb&&(zb=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(f,m)=>{if(a=i===f.dom.parentElement,o=m,!a){const g=zb;g?.isEditable&&setTimeout(()=>{const y=g.state.selection;y&&g.commands.deleteRange({from:y.from,to:y.to})},10)}return!1},paste:(f,m)=>{var g;const y=(g=m.clipboardData)==null?void 0:g.getData("text/html");return s=m,r=!!y?.includes("data-pm-slice"),!1}}},appendTransaction:(f,m,g)=>{const y=f[0],_=y.getMeta("uiEvent")==="paste"&&!r,v=y.getMeta("uiEvent")==="drop"&&!a,x=y.getMeta("applyPasteRules"),M=!!x;if(!_&&!v&&!M)return;if(M){let{text:T}=x;typeof T=="string"?T=T:T=Uk(ht.from(T),g.schema);const{from:P}=x,A=P+T.length,j=dAe(T);return l({rule:u,state:g,from:P,to:{b:A},pasteEvt:j})}const w=m.doc.content.findDiffStart(g.doc.content),C=m.doc.content.findDiffEnd(g.doc.content);if(!(!oAe(w)||!C||w===C.b))return l({rule:u,state:g,from:w,to:C,pasteEvt:s})}}))}var Sw=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=vq(t),this.schema=EEe(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:x2(e.name,this.schema)},i=Ut(e,"addCommands",n);return i?{...t,...i()}:t},{})}get plugins(){const{editor:t}=this;return Fk([...this.extensions].reverse()).flatMap(i=>{const r={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:t,type:x2(i.name,this.schema)},a=[],s=Ut(i,"addKeyboardShortcuts",r);let o={};if(i.type==="mark"&&Ut(i,"exitable",r)&&(o.ArrowRight=()=>od.handleExit({editor:t,mark:i})),s){const m=Object.fromEntries(Object.entries(s()).map(([g,y])=>[g,()=>y({editor:t})]));o={...o,...m}}const l=CMe(o);a.push(l);const c=Ut(i,"addInputRules",r);if(i8(i,t.options.enableInputRules)&&c){const m=c();if(m&&m.length){const g=aAe({editor:t,rules:m}),y=Array.isArray(g)?g:[g];a.push(...y)}}const u=Ut(i,"addPasteRules",r);if(i8(i,t.options.enablePasteRules)&&u){const m=u();if(m&&m.length){const g=fAe({editor:t,rules:m});a.push(...g)}}const f=Ut(i,"addProseMirrorPlugins",r);if(f){const m=f();a.push(...m)}return a})}get attributes(){return xq(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=rm(this.extensions);return Object.fromEntries(e.filter(n=>!!Ut(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:Yi(n.name,this.schema)},a=Ut(n,"addNodeView",r);if(!a)return[];const s=a();if(!s)return[];const o=(l,c,u,f,m)=>{const g=x1(l,i);return s({node:l,view:c,getPos:u,decorations:f,innerDecorations:m,editor:t,extension:n,HTMLAttributes:g})};return[n.name,o]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=rm(this.extensions);return Object.fromEntries(e.filter(n=>!!Ut(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:Ac(n.name,this.schema)},a=Ut(n,"addMarkView",r);if(!a)return[];const s=(o,l,c)=>{const u=x1(o,i);return a()({mark:o,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:f=>{TAe(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:x2(e.name,this.schema)};e.type==="mark"&&((n=On(Ut(e,"keepOnSplit",i)))==null||n)&&this.splittableMarks.push(e.name);const r=Ut(e,"onBeforeCreate",i),a=Ut(e,"onCreate",i),s=Ut(e,"onUpdate",i),o=Ut(e,"onSelectionUpdate",i),l=Ut(e,"onTransaction",i),c=Ut(e,"onFocus",i),u=Ut(e,"onBlur",i),f=Ut(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),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};Sw.resolve=vq;Sw.sort=Fk;Sw.flatten=jk;var hAe={};Dk(hAe,{ClipboardTextSerializer:()=>Tq,Commands:()=>Cq,Delete:()=>Nq,Drop:()=>Rq,Editable:()=>Pq,FocusEvents:()=>Dq,Keymap:()=>Oq,Paste:()=>Lq,Tabindex:()=>Iq,TextDirection:()=>jq,focusEventsPluginKey:()=>kq});var Wn=class Aq extends Bk{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Aq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Tq=Wn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new xi({key:new ur("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(u=>u.$from.pos)),o=Math.max(...a.map(u=>u.$to.pos)),l=bq(n);return yq(i,{from:s,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Cq=Wn.create({name:"commands",addCommands(){return{...lq}}}),Nq=Wn.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 u=mq(t.before,[t,...e]);Sq(u).forEach(g=>{u.mapping.mapResult(g.oldRange.from).deletedAfter&&u.mapping.mapResult(g.oldRange.to).deletedBefore&&u.before.nodesBetween(g.oldRange.from,g.oldRange.to,(y,_)=>{const v=_+y.nodeSize-2,x=g.oldRange.from<=_&&v<=g.oldRange.to;this.editor.emit("delete",{type:"node",node:y,from:_,to:v,newFrom:u.mapping.map(_),newTo:u.mapping.map(v),deletedRange:g.oldRange,newRange:g.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:u})})});const m=u.mapping;u.steps.forEach((g,y)=>{var _,v;if(g instanceof vo){const x=m.slice(y).map(g.from,-1),M=m.slice(y).map(g.to),w=m.invert().map(x,-1),C=m.invert().map(M),T=(_=u.doc.nodeAt(x-1))==null?void 0:_.marks.some(A=>A.eq(g.mark)),P=(v=u.doc.nodeAt(M))==null?void 0:v.marks.some(A=>A.eq(g.mark));this.editor.emit("delete",{type:"mark",mark:g.mark,from:g.from,to:g.to,deletedRange:{from:w,to:C},newRange:{from:x,to:M},partial:!!(P||T),editor:this.editor,transaction:t,combinedTransform:u})}})};(r=(i=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:i.async)==null||r?setTimeout(a,0):a()}}),Rq=Wn.create({name:"drop",addProseMirrorPlugins(){return[new xi({key:new ur("tiptapDrop"),props:{handleDrop:(t,e,n,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:i})}}})]}}),Pq=Wn.create({name:"editable",addProseMirrorPlugins(){return[new xi({key:new ur("editable"),props:{editable:()=>this.editor.options.editable}})]}}),kq=new ur("focusEvents"),Dq=Wn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new xi({key:kq,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}}}})]}}),Oq=Wn.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:u,$anchor:f}=l,{pos:m,parent:g}=f,y=f.parent.isTextblock&&m>0?o.doc.resolve(m-1):f,_=y.parent.type.spec.isolating,v=f.pos-f.parentOffset,x=_&&y.parent.childCount===1?v===f.pos:on.atStart(c).from===m;return!u||!g.type.isTextblock||g.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 Ik()||hq()?a:r},addProseMirrorPlugins(){return[new xi({key:new ur("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(_=>_.getMeta("composition")))return;const i=t.some(_=>_.docChanged)&&!e.doc.eq(n.doc),r=t.some(_=>_.getMeta("preventClearDocument"));if(!i||r)return;const{empty:a,from:s,to:o}=e.selection,l=on.atStart(e.doc).from,c=on.atEnd(e.doc).to;if(a||!(s===l&&o===c)||!bw(n.doc))return;const m=n.tr,g=gw({state:n,transaction:m}),{commands:y}=new xw({editor:this.editor,state:g});if(y.clearNodes(),!!m.steps.length)return m}})]}}),Lq=Wn.create({name:"paste",addProseMirrorPlugins(){return[new xi({key:new ur("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Iq=Wn.create({name:"tabindex",addProseMirrorPlugins(){return[new xi({key:new ur("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),jq=Wn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=rm(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 xi({key:new ur("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),pAe=class pp{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 pp(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 pp(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 pp(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 pp(o,this.editor,r,r?n:null);r&&(l.actualDepth=this.depth+1),e.push(new pp(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)}},mAe=`.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 gAe(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 xAe=class extends iAe{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=dq(e,this.options.autofocus);this.editorState=bp.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=gAe(mAe,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=gq(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?[Pq,Tq.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Cq,Dq,Oq,Iq,Rq,Lq,Nq,jq.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 Sw(i,this)}createCommandManager(){this.commandManager=new xw({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Q3(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=Q3(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new sq(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 u;return(u=this.capturedTransaction)==null?void 0:u.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 _q(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,i=typeof t=="string"?e:t;return DEe(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Uk(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return TEe(this.state.doc,{blockSeparator:e,textSerializers:{...bq(this.schema),...n}})}get isEmpty(){return bw(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 pAe(e,this)}get $doc(){return this.$pos(0)}};function am(t){return new _w({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),u=c+s.length;if(zk(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(_=>_===t.type&&_!==g.mark.type)).filter(g=>g.to>c).length)return null;u<n.to&&a.delete(u,n.to),c>n.from&&a.delete(n.from+l,c);const m=n.from+l+s.length;a.addMark(n.from+l,m,t.type.create(r||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function Uq(t){return new _w({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 u=s+c;u>o?u=o:o=u+i[1].length;const f=i[0][i[0].length-1];a.insertText(f,s+i[0].length-1),a.replaceWith(u,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 eR(t){return new _w({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 sm(t){return new _w({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&&xk(l,t.type,a);if(!c)return null;if(s.wrap(l,c),t.keepMarks&&t.editor){const{selection:f,storedMarks:m}=e,{splittableMarks:g}=t.editor.extensionManager,y=m||f.$to.parentOffset&&f.$from.marks();if(y){const _=y.filter(v=>g.includes(v.type.name));s.ensureMarks(_)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";r().updateAttributes(f,a).run()}const u=s.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&ad(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(i,u))&&s.join(n.from-1)},undoable:t.undoable})}var vAe=t=>"touches"in t,yAe=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,vAe(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),u=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&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}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 bAe(t,e){const{selection:n}=t,{$from:i}=n;if(n instanceof Ft){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 _Ae={};Dk(_Ae,{createAtomBlockMarkdownSpec:()=>SAe,createBlockMarkdownSpec:()=>wAe,createInlineMarkdownSpec:()=>AAe,parseAttributes:()=>Hk,parseIndentedBlocks:()=>tR,renderNestedMarkdownContent:()=>Vk,serializeAttributes:()=>$k});function Hk(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(u=>u.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,u])=>{var f;const m=parseInt(((f=u.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),g=n[m];g&&(e[c]=g.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(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function $k(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 SAe(t){const{nodeName:e,name:n,parseAttributes:i=Hk,serializeAttributes:r=$k,defaultAttributes:a={},requiredAttributes:s=[],allowedAttributes:o}=t,l=n||e,c=u=>{if(!o)return u;const f={};return o.forEach(m=>{m in u&&(f[m]=u[m])}),f};return{parseMarkdown:(u,f)=>{const m={...a,...u.attributes};return f.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(u){var f;const m=new RegExp(`^:::${l}(?:\\s|$)`,"m"),g=(f=u.match(m))==null?void 0:f.index;return g!==void 0?g:-1},tokenize(u,f,m){const g=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),y=u.match(g);if(!y)return;const _=y[1]||"",v=i(_);if(!s.find(M=>!(M in v)))return{type:e,raw:y[0],attributes:v}}},renderMarkdown:u=>{const f=c(u.attrs||{}),m=r(f),g=m?` {${m}}`:"";return`:::${l}${g} :::`}}}function wAe(t){const{nodeName:e,name:n,getContent:i,parseAttributes:r=Hk,serializeAttributes:a=$k,defaultAttributes:s={},content:o="block",allowedAttributes:l}=t,c=n||e,u=f=>{if(!l)return f;const m={};return l.forEach(g=>{g in f&&(m[g]=f[g])}),m};return{parseMarkdown:(f,m)=>{let g;if(i){const _=i(f);g=typeof _=="string"?[{type:"text",text:_}]:_}else o==="block"?g=m.parseChildren(f.tokens||[]):g=m.parseInline(f.tokens||[]);const y={...s,...f.attributes};return m.createNode(e,y,g)},markdownTokenizer:{name:e,level:"block",start(f){var m;const g=new RegExp(`^:::${c}`,"m"),y=(m=f.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(f,m,g){var y;const _=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=f.match(_);if(!v)return;const[x,M=""]=v,w=r(M);let C=1;const T=x.length;let P="";const A=/^:::([\w-]*)(\s.*)?/gm,j=f.slice(T);for(A.lastIndex=0;;){const N=A.exec(j);if(N===null)break;const k=N.index,F=N[1];if(!((y=N[2])!=null&&y.endsWith(":::"))){if(F)C+=1;else if(C-=1,C===0){const I=j.slice(0,k);P=I.trim();const W=f.slice(0,T+k+N[0].length);let D=[];if(P)if(o==="block")for(D=g.blockTokens(I),D.forEach(B=>{B.text&&(!B.tokens||B.tokens.length===0)&&(B.tokens=g.inlineTokens(B.text))});D.length>0;){const B=D[D.length-1];if(B.type==="paragraph"&&(!B.text||B.text.trim()===""))D.pop();else break}else D=g.inlineTokens(P);return{type:e,raw:W,attributes:w,content:P,tokens:D}}}}}},renderMarkdown:(f,m)=>{const g=u(f.attrs||{}),y=a(g),_=y?` {${y}}`:"",v=m.renderChildren(f.content||[],`
- `);return`:::${c}${_}
- ${v}
- :::`}}}function MAe(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 EAe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function AAe(t){const{nodeName:e,name:n,getContent:i,parseAttributes:r=MAe,serializeAttributes:a=EAe,defaultAttributes:s={},selfClosing:o=!1,allowedAttributes:l}=t,c=n||e,u=m=>{if(!l)return m;const g={};return l.forEach(y=>{y in m&&(g[y]=m[y])}),g},f=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,g)=>{const y={...s,...m.attributes};if(o)return g.createNode(e,y);const _=i?i(m):m.content||"";return _?g.createNode(e,y,[g.createTextNode(_)]):g.createNode(e,y,[])},markdownTokenizer:{name:e,level:"inline",start(m){const g=o?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),y=m.match(g),_=y?.index;return _!==void 0?_:-1},tokenize(m,g,y){const _=o?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),v=m.match(_);if(!v)return;let x="",M="";if(o){const[,C]=v;M=C}else{const[,C,T]=v;M=C,x=T||""}const w=r(M.trim());return{type:e,raw:v[0],content:x.trim(),attributes:w}}},renderMarkdown:m=>{let g="";i?g=i(m):m.content&&m.content.length>0&&(g=m.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const y=u(m.attrs||{}),_=a(y),v=_?` ${_}`:"";return o?`[${c}${v}]`:`[${c}${v}]${g}[/${c}]`}}}function tR(t,e,n){var i,r,a,s;const o=t.split(`
- `),l=[];let c="",u=0;const f=e.baseIndentSize||2;for(;u<o.length;){const m=o[u],g=m.match(e.itemPattern);if(!g){if(l.length>0)break;if(m.trim()===""){u+=1,c=`${c}${m}
- `;continue}else return}const y=e.extractItemData(g),{indentLevel:_,mainContent:v}=y;c=`${c}${m}
- `;const x=[v];for(u+=1;u<o.length;){const T=o[u];if(T.trim()===""){const A=o.slice(u+1).findIndex(k=>k.trim()!=="");if(A===-1)break;if((((r=(i=o[u+1+A].match(/^(\s*)/))==null?void 0:i[1])==null?void 0:r.length)||0)>_){x.push(T),c=`${c}${T}
- `,u+=1;continue}else break}if((((s=(a=T.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:s.length)||0)>_)x.push(T),c=`${c}${T}
- `,u+=1;else break}let M;const w=x.slice(1);if(w.length>0){const T=w.map(P=>P.slice(_+f)).join(`
- `);T.trim()&&(e.customNestedParser?M=e.customNestedParser(T):M=n.blockTokens(T))}const C=e.createToken(y,M);l.push(C)}if(l.length!==0)return{items:l,raw:c}}function Vk(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 u=e.renderChildren([c]);if(u){const f=u.split(`
- `).map(m=>m?e.indent(m):"").join(`
- `);l.push(f)}}),l.join(`
- `)}function TAe(t,e,n={}){const{state:i}=e,{doc:r,tr:a}=i,s=t;r.descendants((o,l)=>{const c=a.mapping.map(l),u=a.mapping.map(l)+o.nodeSize;let f=null;if(o.marks.forEach(g=>{if(g!==s)return!1;f=g}),!f)return;let m=!1;if(Object.keys(n).forEach(g=>{n[g]!==f.attrs[g]&&(m=!0)}),m){const g=t.type.create({...t.attrs,...n});a.removeMark(c,u,t.type),a.addMark(c,u,g)}}),a.docChanged&&e.view.dispatch(a)}var Ha=class Fq extends Bk{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Fq(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Df(t){return new lAe({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 u=l.search(/\S/),f=n.from+l.indexOf(o),m=f+o.length;if(zk(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(v=>v===t.type&&v!==y.mark.type)).filter(y=>y.to>f).length)return null;m<n.to&&s.delete(m,n.to),f>n.from&&s.delete(n.from+u,f),c=n.from+u+o.length,s.addMark(n.from+u,c,t.type.create(a||{})),s.removeStoredMark(t.type)}}})}var b2,s8;function CAe(){return s8||(s8=1,b2=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}),b2}var NAe=CAe();const RAe=Ys(NAe);var _2={exports:{}},S2={};var o8;function PAe(){if(o8)return S2;o8=1;var t=xm(),e=hG();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}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 S2.useSyncExternalStoreWithSelector=function(c,u,f,m,g){var y=a(null);if(y.current===null){var _={hasValue:!1,value:null};y.current=_}else _=y.current;y=o(function(){function x(P){if(!M){if(M=!0,w=P,P=m(P),g!==void 0&&_.hasValue){var A=_.value;if(g(A,P))return C=A}return C=P}if(A=C,i(w,P))return A;var j=m(P);return g!==void 0&&g(A,j)?(w=P,A):(w=P,C=j)}var M=!1,w,C,T=f===void 0?null:f;return[function(){return x(u())},T===null?void 0:function(){return x(T())}]},[u,f,m,g]);var v=r(c,y[0],y[1]);return s(function(){_.hasValue=!0,_.value=v},[v]),l(v),v},S2}var l8;function kAe(){return l8||(l8=1,_2.exports=PAe()),_2.exports}var zq=kAe(),DAe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},OAe=({contentComponent:t})=>{const e=MP.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return h.jsx(h.Fragment,{children:Object.values(e)})};function LAe(){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]:Vre.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 IAe=class extends ui.Component{constructor(t){var e;super(t),this.editorContentRef=ui.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=LAe(),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 h.jsxs(h.Fragment,{children:[h.jsx("div",{ref:DAe(e,this.editorContentRef),...n}),t?.contentComponent&&h.jsx(OAe,{contentComponent:t.contentComponent})]})}},jAe=E.forwardRef((t,e)=>{const n=ui.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ui.createElement(IAe,{key:n,innerRef:e,...t})}),UAe=ui.memo(jAe),FAe=typeof window<"u"?E.useLayoutEffect:E.useEffect,zAe=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 BAe(t){var e;const[n]=E.useState(()=>new zAe(t.editor)),i=zq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:RAe);return FAe(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(i),i}var HAe=!1,nR=typeof window>"u",$Ae=nR||!!(typeof window<"u"&&window.next),VAe=class Bq{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?nR||$Ae?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 xAe(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?Bq.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 GAe(t={},e=[]){const n=E.useRef(t);n.current=t;const[i]=E.useState(()=>new VAe(n)),r=MP.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return E.useDebugValue(r),E.useEffect(i.onRender(e)),BAe({editor:r,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),r}var WAe=E.createContext({editor:null});WAe.Consumer;var qAe=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),XAe=()=>E.useContext(qAe);ui.forwardRef((t,e)=>{const{onDragStart:n}=XAe(),i=t.as||"div";return h.jsx(i,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ui.createContext({markViewContentRef:()=>{}});var v1=(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]},KAe=/^\s*>\s$/,YAe=Ha.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return v1("blockquote",{...Ai(this.options.HTMLAttributes,t),children:v1("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[sm({find:KAe,type:this.type})]}}),ZAe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,QAe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,JAe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,eTe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,tTe=od.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 v1("strong",{...Ai(this.options.HTMLAttributes,t),children:v1("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[am({find:ZAe,type:this.type}),am({find:JAe,type:this.type})]},addPasteRules(){return[Df({find:QAe,type:this.type}),Df({find:eTe,type:this.type})]}}),nTe=/(^|[^`])`([^`]+)`(?!`)$/,iTe=/(^|[^`])`([^`]+)`(?!`)/g,rTe=od.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ai(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[am({find:nTe,type:this.type})]},addPasteRules(){return[Df({find:iTe,type:this.type})]}}),w2=4,aTe=/^```([a-z]+)?[\s\n]$/,sTe=/^~~~([a-z]+)?[\s\n]$/,oTe=Ha.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:w2,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",Ai(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:w2,{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:u}=r,g=i.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(y=>o+y).join(`
- `);return l.replaceWith(c,u,i.schema.text(g)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:w2,{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,u=a.start(),f=a.end(),g=i.doc.textBetween(u,f,`
- `,`
- `).split(`
- `);let y=0,_=0;const v=c-u;for(let P=0;P<g.length;P+=1){if(_+g[P].length>=v){y=P;break}_+=g[P].length+1}const M=((l=g[y].match(/^ */))==null?void 0:l[0])||"",w=Math.min(M.length,n);if(w===0)return!0;let C=u;for(let P=0;P<y;P+=1)C+=g[P].length+1;return o.delete(C,C+w),c-C<=w&&o.setSelection(Gt.create(o.doc,C)),!0}):t.commands.command(({tr:o})=>{const{from:l,to:c}=r,m=i.doc.textBetween(l,c,`
- `,`
- `).split(`
- `).map(g=>{var y;const _=((y=g.match(/^ */))==null?void 0:y[0])||"",v=Math.min(_.length,n);return g.slice(v)}).join(`
- `);return o.replaceWith(l,c,i.schema.text(m)),!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(on.near(i.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[eR({find:aTe,type:this.type,getAttributes:t=>({language:t[1]})}),eR({find:sTe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new xi({key:new ur("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(Gt.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),t.dispatch(s),!0}}})]}}),lTe=Ha.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),cTe=Ha.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",Ai(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:u})=>{if(u&&l&&s){const f=l.filter(m=>o.includes(m.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),uTe=Ha.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]}`,Ai(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=>eR({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),dTe=Ha.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ai(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!bAe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:i}=n,r=t();return wq(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(Gt.create(s.doc,l.pos+1)):l.nodeAfter.isBlock?s.setSelection(Ft.create(s.doc,l.pos)):s.setSelection(Gt.create(s.doc,l.pos));else{const u=a.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,f=u?.create();f&&(s.insert(c,f),s.setSelection(Gt.create(s.doc,c+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Uq({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),fTe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,hTe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,pTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,mTe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,gTe=od.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",Ai(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[am({find:fTe,type:this.type}),am({find:pTe,type:this.type})]},addPasteRules(){return[Df({find:hTe,type:this.type}),Df({find:mTe,type:this.type})]}});const xTe="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",vTe="ελ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",iR="numeric",rR="ascii",aR="alpha",Rx="asciinumeric",px="alphanumeric",sR="domain",Hq="emoji",yTe="scheme",bTe="slashscheme",M2="whitespace";function _Te(t,e){return t in e||(e[t]=[]),e[t]}function ef(t,e,n){e[iR]&&(e[Rx]=!0,e[px]=!0),e[rR]&&(e[Rx]=!0,e[aR]=!0),e[Rx]&&(e[px]=!0),e[aR]&&(e[px]=!0),e[px]&&(e[sR]=!0),e[Hq]&&(e[sR]=!0);for(const i in e){const r=_Te(i,n);r.indexOf(t)<0&&r.push(t)}}function STe(t,e){const n={};for(const i in e)e[i].indexOf(t)>=0&&(n[i]=!0);return n}function Oa(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Oa.groups={};Oa.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||Oa.groups;let r;return e&&e.j?r=e:(r=new Oa(e),n&&i&&ef(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||Oa.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 Oa,Object.assign(s.j,o.j),s.jr.push.apply(s.jr,o.jr),s.jd=o.jd,s.t=o.t):s=new Oa,a){if(i)if(s.t&&typeof s.t=="string"){const l=Object.assign(STe(s.t,i),n);ef(a,l,i)}else n&&ef(a,n,i);s.t=a}return r.j[t]=s,s}};const nn=(t,e,n,i,r)=>t.ta(e,n,i,r),Si=(t,e,n,i,r)=>t.tr(e,n,i,r),c8=(t,e,n,i,r)=>t.ts(e,n,i,r),gt=(t,e,n,i,r)=>t.tt(e,n,i,r),Vl="WORD",oR="UWORD",$q="ASCIINUMERICAL",Vq="ALPHANUMERICAL",h0="LOCALHOST",lR="TLD",cR="UTLD",T_="SCHEME",mp="SLASH_SCHEME",Gk="NUM",uR="WS",Wk="NL",Px="OPENBRACE",kx="CLOSEBRACE",y1="OPENBRACKET",b1="CLOSEBRACKET",_1="OPENPAREN",S1="CLOSEPAREN",w1="OPENANGLEBRACKET",M1="CLOSEANGLEBRACKET",E1="FULLWIDTHLEFTPAREN",A1="FULLWIDTHRIGHTPAREN",T1="LEFTCORNERBRACKET",C1="RIGHTCORNERBRACKET",N1="LEFTWHITECORNERBRACKET",R1="RIGHTWHITECORNERBRACKET",P1="FULLWIDTHLESSTHAN",k1="FULLWIDTHGREATERTHAN",D1="AMPERSAND",O1="APOSTROPHE",L1="ASTERISK",Su="AT",I1="BACKSLASH",j1="BACKTICK",U1="CARET",Nu="COLON",qk="COMMA",F1="DOLLAR",Uo="DOT",z1="EQUALS",Xk="EXCLAMATION",Rs="HYPHEN",Dx="PERCENT",B1="PIPE",H1="PLUS",$1="POUND",Ox="QUERY",Kk="QUOTE",Gq="FULLWIDTHMIDDLEDOT",Yk="SEMI",Fo="SLASH",Lx="TILDE",V1="UNDERSCORE",Wq="EMOJI",G1="SYM";var qq=Object.freeze({__proto__:null,ALPHANUMERICAL:Vq,AMPERSAND:D1,APOSTROPHE:O1,ASCIINUMERICAL:$q,ASTERISK:L1,AT:Su,BACKSLASH:I1,BACKTICK:j1,CARET:U1,CLOSEANGLEBRACKET:M1,CLOSEBRACE:kx,CLOSEBRACKET:b1,CLOSEPAREN:S1,COLON:Nu,COMMA:qk,DOLLAR:F1,DOT:Uo,EMOJI:Wq,EQUALS:z1,EXCLAMATION:Xk,FULLWIDTHGREATERTHAN:k1,FULLWIDTHLEFTPAREN:E1,FULLWIDTHLESSTHAN:P1,FULLWIDTHMIDDLEDOT:Gq,FULLWIDTHRIGHTPAREN:A1,HYPHEN:Rs,LEFTCORNERBRACKET:T1,LEFTWHITECORNERBRACKET:N1,LOCALHOST:h0,NL:Wk,NUM:Gk,OPENANGLEBRACKET:w1,OPENBRACE:Px,OPENBRACKET:y1,OPENPAREN:_1,PERCENT:Dx,PIPE:B1,PLUS:H1,POUND:$1,QUERY:Ox,QUOTE:Kk,RIGHTCORNERBRACKET:C1,RIGHTWHITECORNERBRACKET:R1,SCHEME:T_,SEMI:Yk,SLASH:Fo,SLASH_SCHEME:mp,SYM:G1,TILDE:Lx,TLD:lR,UNDERSCORE:V1,UTLD:cR,UWORD:oR,WORD:Vl,WS:uR});const zl=/[a-z]/,Yg=new RegExp("\\p{L}","u"),E2=new RegExp("\\p{Emoji}","u"),Bl=/\d/,A2=/\s/,u8="\r",T2=`
- `,wTe="️",MTe="",C2="";let Bb=null,Hb=null;function ETe(t=[]){const e={};Oa.groups=e;const n=new Oa;Bb==null&&(Bb=d8(xTe)),Hb==null&&(Hb=d8(vTe)),gt(n,"'",O1),gt(n,"{",Px),gt(n,"}",kx),gt(n,"[",y1),gt(n,"]",b1),gt(n,"(",_1),gt(n,")",S1),gt(n,"<",w1),gt(n,">",M1),gt(n,"(",E1),gt(n,")",A1),gt(n,"「",T1),gt(n,"」",C1),gt(n,"『",N1),gt(n,"』",R1),gt(n,"<",P1),gt(n,">",k1),gt(n,"&",D1),gt(n,"*",L1),gt(n,"@",Su),gt(n,"`",j1),gt(n,"^",U1),gt(n,":",Nu),gt(n,",",qk),gt(n,"$",F1),gt(n,".",Uo),gt(n,"=",z1),gt(n,"!",Xk),gt(n,"-",Rs),gt(n,"%",Dx),gt(n,"|",B1),gt(n,"+",H1),gt(n,"#",$1),gt(n,"?",Ox),gt(n,'"',Kk),gt(n,"/",Fo),gt(n,";",Yk),gt(n,"~",Lx),gt(n,"_",V1),gt(n,"\\",I1),gt(n,"・",Gq);const i=Si(n,Bl,Gk,{[iR]:!0});Si(i,Bl,i);const r=Si(i,zl,$q,{[Rx]:!0}),a=Si(i,Yg,Vq,{[px]:!0}),s=Si(n,zl,Vl,{[rR]:!0});Si(s,Bl,r),Si(s,zl,s),Si(r,Bl,r),Si(r,zl,r);const o=Si(n,Yg,oR,{[aR]:!0});Si(o,zl),Si(o,Bl,a),Si(o,Yg,o),Si(a,Bl,a),Si(a,zl),Si(a,Yg,a);const l=gt(n,T2,Wk,{[M2]:!0}),c=gt(n,u8,uR,{[M2]:!0}),u=Si(n,A2,uR,{[M2]:!0});gt(n,C2,u),gt(c,T2,l),gt(c,C2,u),Si(c,A2,u),gt(u,u8),gt(u,T2),Si(u,A2,u),gt(u,C2,u);const f=Si(n,E2,Wq,{[Hq]:!0});gt(f,"#"),Si(f,E2,f),gt(f,wTe,f);const m=gt(f,MTe);gt(m,"#"),Si(m,E2,f);const g=[[zl,s],[Bl,r]],y=[[zl,null],[Yg,o],[Bl,a]];for(let _=0;_<Bb.length;_++)xu(n,Bb[_],lR,Vl,g);for(let _=0;_<Hb.length;_++)xu(n,Hb[_],cR,oR,y);ef(lR,{tld:!0,ascii:!0},e),ef(cR,{utld:!0,alpha:!0},e),xu(n,"file",T_,Vl,g),xu(n,"mailto",T_,Vl,g),xu(n,"http",mp,Vl,g),xu(n,"https",mp,Vl,g),xu(n,"ftp",mp,Vl,g),xu(n,"ftps",mp,Vl,g),ef(T_,{scheme:!0,ascii:!0},e),ef(mp,{slashscheme:!0,ascii:!0},e),t=t.sort((_,v)=>_[0]>v[0]?1:-1);for(let _=0;_<t.length;_++){const v=t[_][0],M=t[_][1]?{[yTe]:!0}:{[bTe]:!0};v.indexOf("-")>=0?M[sR]=!0:zl.test(v)?Bl.test(v)?M[Rx]=!0:M[rR]=!0:M[iR]=!0,c8(n,v,v,M)}return c8(n,"localhost",h0,{ascii:!0}),n.jd=new Oa(G1),{start:n,tokens:Object.assign({groups:e},qq)}}function Xq(t,e){const n=ATe(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,u=null,f=-1,m=-1;for(;s<i&&(l=o.go(n[s]));)o=l,o.accepts()?(f=0,m=0,u=o):f>=0&&(f+=n[s].length,m++),c+=n[s].length,a+=n[s].length,s++;a-=f,s-=m,c-=f,r.push({t:u.t,v:e.slice(a-c,a),s:a-c,e:a})}return r}function ATe(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 xu(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 Oa(i),a.jr=r.slice(),t.j[l]=a),t=a}return a=new Oa(n),a.jr=r.slice(),t.j[e[s-1]]=a,a}function d8(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 p0={defaultProtocol:"http",events:null,format:f8,formatHref:f8,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Zk(t,e=null){let n=Object.assign({},p0);t&&(n=Object.assign(n,t instanceof Zk?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}Zk.prototype={o:p0,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]:p0[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 f8(t){return t}function Kq(t,e){this.t="token",this.v=t,this.tk=e}Kq.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=p0.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),u=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),u&&Object.assign(s,u),{tagName:r,attributes:s,content:a,eventListeners:f}}};function ww(t,e){class n extends Kq{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 h8=ww("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),p8=ww("text"),TTe=ww("nl"),$b=ww("url",{isLink:!0,toHref(t=p0.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==h0&&t[1].t===Nu}}),As=t=>new Oa(t);function CTe({groups:t}){const e=t.domain.concat([D1,L1,Su,I1,j1,U1,F1,z1,Rs,Gk,Dx,B1,H1,$1,Fo,G1,Lx,V1]),n=[O1,Nu,qk,Uo,Xk,Dx,Ox,Kk,Yk,w1,M1,Px,kx,b1,y1,_1,S1,E1,A1,T1,C1,N1,R1,P1,k1],i=[D1,O1,L1,I1,j1,U1,F1,z1,Rs,Px,kx,Dx,B1,H1,$1,Ox,Fo,G1,Lx,V1],r=As(),a=gt(r,Lx);nn(a,i,a),nn(a,t.domain,a);const s=As(),o=As(),l=As();nn(r,t.domain,s),nn(r,t.scheme,o),nn(r,t.slashscheme,l),nn(s,i,a),nn(s,t.domain,s);const c=gt(s,Su);gt(a,Su,c),gt(o,Su,c),gt(l,Su,c);const u=gt(a,Uo);nn(u,i,a),nn(u,t.domain,a);const f=As();nn(c,t.domain,f),nn(f,t.domain,f);const m=gt(f,Uo);nn(m,t.domain,f);const g=As(h8);nn(m,t.tld,g),nn(m,t.utld,g),gt(c,h0,g);const y=gt(f,Rs);gt(y,Rs,y),nn(y,t.domain,f),nn(g,t.domain,f),gt(g,Uo,m),gt(g,Rs,y);const _=gt(g,Nu);nn(_,t.numeric,h8);const v=gt(s,Rs),x=gt(s,Uo);gt(v,Rs,v),nn(v,t.domain,s),nn(x,i,a),nn(x,t.domain,s);const M=As($b);nn(x,t.tld,M),nn(x,t.utld,M),nn(M,t.domain,s),nn(M,i,a),gt(M,Uo,x),gt(M,Rs,v),gt(M,Su,c);const w=gt(M,Nu),C=As($b);nn(w,t.numeric,C);const T=As($b),P=As();nn(T,e,T),nn(T,n,P),nn(P,e,T),nn(P,n,P),gt(M,Fo,T),gt(C,Fo,T);const A=gt(o,Nu),j=gt(l,Nu),N=gt(j,Fo),k=gt(N,Fo);nn(o,t.domain,s),gt(o,Uo,x),gt(o,Rs,v),nn(l,t.domain,s),gt(l,Uo,x),gt(l,Rs,v),nn(A,t.domain,T),gt(A,Fo,T),gt(A,Ox,T),nn(k,t.domain,T),nn(k,e,T),gt(k,Fo,T);const F=[[Px,kx],[y1,b1],[_1,S1],[w1,M1],[E1,A1],[T1,C1],[N1,R1],[P1,k1]];for(let I=0;I<F.length;I++){const[W,D]=F[I],B=gt(T,W);gt(P,W,B),gt(B,D,T);const $=As($b);nn(B,e,$);const K=As();nn(B,n),nn($,e,$),nn($,n,K),nn(K,e,$),nn(K,n,K),gt($,D,T),gt(K,D,T)}return gt(r,h0,M),gt(r,Wk,TTe),{start:r,tokens:qq}}function NTe(t,e,n){let i=n.length,r=0,a=[],s=[];for(;r<i;){let o=t,l=null,c=null,u=0,f=null,m=-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()?(m=0,f=o):m>=0&&m++,r++,u++;if(m<0)r-=u,r<i&&(s.push(n[r]),r++);else{s.length>0&&(a.push(N2(p8,e,s)),s=[]),r-=m,u-=m;const g=f.t,y=n.slice(r-u,r);a.push(N2(g,e,y))}}return s.length>0&&a.push(N2(p8,e,s)),a}function N2(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 RTe=typeof console<"u"&&console&&console.warn||(()=>{}),PTe="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ri={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kTe(){return Oa.groups={},ri.scanner=null,ri.parser=null,ri.tokenQueue=[],ri.pluginQueue=[],ri.customSchemes=[],ri.initialized=!1,ri}function m8(t,e=!1){if(ri.initialized&&RTe(`linkifyjs: already initialized - will not register custom scheme "${t}" ${PTe}`),!/^[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`);ri.customSchemes.push([t,e])}function DTe(){ri.scanner=ETe(ri.customSchemes);for(let t=0;t<ri.tokenQueue.length;t++)ri.tokenQueue[t][1]({scanner:ri.scanner});ri.parser=CTe(ri.scanner.tokens);for(let t=0;t<ri.pluginQueue.length;t++)ri.pluginQueue[t][1]({scanner:ri.scanner,parser:ri.parser});return ri.initialized=!0,ri}function Qk(t){return ri.initialized||DTe(),NTe(ri.parser.start,t,Xq(ri.scanner.start,t))}Qk.scan=Xq;function Yq(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 Zk(n),r=Qk(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 Jk="[\0- -\u2029 ]",OTe=new RegExp(Jk),LTe=new RegExp(`${Jk}$`),ITe=new RegExp(Jk,"g");function jTe(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function UTe(t){return new xi({key:new ur("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=mq(n.doc,[...e]);if(Sq(o).forEach(({newRange:c})=>{const u=_Ee(i.doc,c,g=>g.isTextblock);let f,m;if(u.length>1)f=u[0],m=i.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){const g=i.doc.textBetween(c.from,c.to," "," ");if(!LTe.test(g))return;f=u[0],m=i.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&m){const g=m.split(OTe).filter(Boolean);if(g.length<=0)return!1;const y=g[g.length-1],_=f.pos+m.lastIndexOf(y);if(!y)return!1;const v=Qk(y).map(x=>x.toObject(t.defaultProtocol));if(!jTe(v))return!1;v.filter(x=>x.isLink).map(x=>({...x,from:_+x.start+1,to:_+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=>{zk(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 FTe(t){return new xi({key:new ur("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 u=i.target;const f=[];for(;u.nodeName!=="DIV";)f.push(u),u=u.parentNode;s=f.find(m=>m.nodeName==="A")}if(!s)return!1;const o=_q(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 zTe(t){return new xi({key:new ur("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(u=>{l+=u.textContent});const c=Yq(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||r!==void 0&&!r(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Ud(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(ITe,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Zq=od.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"){m8(t);return}m8(t.scheme,t.optionalSlashes)})},onDestroy(){kTe()},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)=>!!Ud(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=>!!Ud(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=>!!Ud(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ai(this.options.HTMLAttributes,t),0]:["a",Ai(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=>!!Ud(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=>!!Ud(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[Df({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:i}=this.options,r=Yq(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:s=>!!Ud(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(UTe({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:i=>this.options.isAllowedUri(i,{defaultValidate:r=>!!Ud(r,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(FTe({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(zTe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),BTe=Zq,HTe=Object.defineProperty,$Te=(t,e)=>{for(var n in e)HTe(t,n,{get:e[n],enumerable:!0})},VTe="listItem",g8="textStyle",x8=/^\s*([-+*])\s$/,Qq=Ha.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",Ai(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(VTe,this.editor.getAttributes(g8)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=sm({find:x8,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=sm({find:x8,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(g8),editor:this.editor})),[t]}}),Jq=Ha.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ai(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)=>Vk(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)}}}),GTe={};$Te(GTe,{findListItemPos:()=>G0,getNextListDepth:()=>eD,handleBackspace:()=>dR,handleDelete:()=>fR,hasListBefore:()=>eX,hasListItemAfter:()=>WTe,hasListItemBefore:()=>tX,listItemHasSubList:()=>nX,nextListIsDeeper:()=>iX,nextListIsHigher:()=>rX});var G0=(t,e)=>{const{$from:n}=e.selection,i=Yi(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}},eD=(t,e)=>{const n=G0(t,e);if(!n)return!1;const[,i]=PEe(e,t,n.$pos.pos+4);return i},eX=(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))},tX=(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)},nX=(t,e,n)=>{if(!n)return!1;const i=Yi(t,e.schema);let r=!1;return n.descendants(a=>{a.type===i&&(r=!0)}),r},dR=(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)&&eX(t.state,e,n)){const{$anchor:o}=t.state.selection,l=t.state.doc.resolve(o.before()-1),c=[];l.node().descendants((m,g)=>{m.type.name===e&&c.push({node:m,pos:g})});const u=c.at(-1);if(!u)return!1;const f=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},f.end()).joinForward().run()}if(!Qu(t.state,e)||!LEe(t.state))return!1;const i=G0(e,t.state);if(!i)return!1;const a=t.state.doc.resolve(i.$pos.pos-2).node(i.depth),s=nX(e,t.state,a);return tX(e,t.state)&&!s?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},iX=(t,e)=>{const n=eD(t,e),i=G0(t,e);return!i||!n?!1:n>i.depth},rX=(t,e)=>{const n=eD(t,e),i=G0(t,e);return!i||!n?!1:n<i.depth},fR=(t,e)=>{if(!Qu(t.state,e)||!OEe(t.state,e))return!1;const{selection:n}=t.state,{$from:i,$to:r}=n;return!n.empty&&i.sameParent(r)?!1:iX(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():rX(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},WTe=(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)},aX=Wn.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&&fR(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&&fR(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&&dR(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&&dR(t,n,i)&&(e=!0)}),e}}}}),v8=/^(\s*)(\d+)\.\s+(.*)$/,qTe=/^\s/;function XTe(t){const e=[];let n=0,i=0;for(;n<t.length;){const r=t[n],a=r.match(v8);if(!a)break;const[,s,o,l]=a,c=s.length;let u=l,f=n+1;const m=[r];for(;f<t.length;){const g=t[f];if(g.match(v8))break;if(g.trim()==="")m.push(g),u+=`
- `,f+=1;else if(g.match(qTe))m.push(g),u+=`
- ${g.slice(c+2)}`,f+=1;else break}e.push({indent:c,number:parseInt(o,10),content:u.trim(),raw:m.join(`
- `)}),i=f,n=f}return[e,i]}function sX(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 u=o.slice(1).join(`
- `).trim();if(u){const g=n.blockTokens(u);c.push(...g)}let f=a+1;const m=[];for(;f<t.length&&t[f].indent>e;)m.push(t[f]),f+=1;if(m.length>0){const g=Math.min(...m.map(_=>_.indent)),y=sX(m,g,n);c.push({type:"list",ordered:!0,start:m[0].number,items:y,raw:m.map(_=>_.raw).join(`
- `)})}r.push({type:"list_item",raw:s.raw,tokens:c}),a=f}else a+=1}return r}function KTe(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 YTe="listItem",y8="textStyle",b8=/^(\d+)\.\s$/,oX=Ha.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",Ai(this.options.HTMLAttributes,n),0]:["ol",Ai(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?KTe(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]=XTe(r);if(a.length===0)return;const o=sX(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(YTe,this.editor.getAttributes(y8)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=sm({find:b8,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=sm({find:b8,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(y8)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),ZTe=/^\s*(\[([( |x])?\])\s$/,QTe=Ha.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",Ai(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 Vk(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=u=>{var f,m;o.ariaLabel=((m=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:m.call(f,u,o.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",u=>u.preventDefault()),o.addEventListener("change",u=>{if(!i.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=u.target;i.isEditable&&typeof n=="function"&&i.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const g=n();if(typeof g!="number")return!1;const y=m.doc.nodeAt(g);return m.setNodeMarkup(g,void 0,{...y?.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(([u,f])=>{r.setAttribute(u,f)}),r.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),r.append(a,l),Object.entries(e).forEach(([u,f])=>{r.setAttribute(u,f)}),{dom:r,contentDOM:l,update:u=>u.type!==this.type?!1:(r.dataset.checked=u.attrs.checked,o.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[sm({find:ZTe,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),JTe=Ha.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",Ai(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=tR(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=tR(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()}}});Wn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Qq.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Jq.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(aX.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(oX.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(QTe.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(JTe.configure(this.options.taskList)),t}});var e2e=Ha.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ai(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()}}}),t2e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,n2e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,i2e=od.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",Ai(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[am({find:t2e,type:this.type})]},addPasteRules(){return[Df({find:n2e,type:this.type})]}}),r2e=Ha.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),lX=od.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",Ai(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()}}}),a2e=lX;function s2e(t={}){return new xi({view(e){return new o2e(e,t)}})}class o2e{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,m=e.nodeAfter;if(f||m){let g=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(g){let y=g.getBoundingClientRect(),_=f?y.bottom:y.top;f&&m&&(_=(_+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*o;i={left:y.left,right:y.right,top:_-v,bottom:_+v}}}}if(!i){let f=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*s;i={left:f.left-m,right:f.left+m,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,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),m=f.width/l.offsetWidth,g=f.height/l.offsetHeight;c=f.left-l.scrollLeft*m,u=f.top-l.scrollTop*g}this.element.style.left=(i.left-c)/s+"px",this.element.style.top=(i.top-u)/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=oW(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 Mi extends on{constructor(e){super(e,e)}map(e,n){let i=e.resolve(n.map(this.head));return Mi.valid(i)?new Mi(i):on.near(i)}content(){return Mt.empty}eq(e){return e instanceof Mi&&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 Mi(e.resolve(n.pos))}getBookmark(){return new tD(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!l2e(e)||!c2e(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&&Mi.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(Mi.valid(l))return l}for(;;){let s=n>0?a.firstChild:a.lastChild;if(!s){if(a.isAtom&&!a.isText&&!Ft.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(Mi.valid(o))return o}return null}}}Mi.prototype.visible=!1;Mi.findFrom=Mi.findGapCursorFrom;on.jsonID("gapcursor",Mi);class tD{constructor(e){this.pos=e}map(e){return new tD(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Mi.valid(n)?new Mi(n):on.near(n)}}function cX(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function l2e(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||cX(r.type))return!0;if(r.inlineContent)return!1}}return!0}function c2e(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||cX(r.type))return!0;if(r.inlineContent)return!1}}return!0}function u2e(){return new xi({props:{decorations:p2e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Mi.valid(n)?new Mi(n):null},handleClick:f2e,handleKeyDown:d2e,handleDOMEvents:{beforeinput:h2e}}})}const d2e=oq({ArrowLeft:Vb("horiz",-1),ArrowRight:Vb("horiz",1),ArrowUp:Vb("vert",-1),ArrowDown:Vb("vert",1)});function Vb(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 Gt){if(!a.endOfTextblock(n)||o.depth==0)return!1;l=!1,o=i.doc.resolve(e>0?o.after():o.before())}let c=Mi.findGapCursorFrom(o,e,l);return c?(r&&r(i.tr.setSelection(new Mi(c))),!0):!1}}function f2e(t,e,n){if(!t||!t.editable)return!1;let i=t.state.doc.resolve(e);if(!Mi.valid(i))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return r&&r.inside>-1&&Ft.isSelectable(t.state.doc.nodeAt(r.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Mi(i))),!0)}function h2e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Mi))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=ht.empty;for(let s=i.length-1;s>=0;s--)r=ht.from(i[s].createAndFill(null,r));let a=t.state.tr.replace(n.pos,n.pos,new Mt(r,0,0));return a.setSelection(Gt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function p2e(t){if(!(t.selection instanceof Mi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",pi.create(t.doc,[pa.widget(t.selection.head,e,{key:"gapcursor"})])}var W1=200,Nr=function(){};Nr.prototype.append=function(e){return e.length?(e=Nr.from(e),!this.length&&e||e.length<W1&&this.leafAppend(e)||this.length<W1&&e.leafPrepend(this)||this.appendInner(e)):this};Nr.prototype.prepend=function(e){return e.length?Nr.from(e).append(this):this};Nr.prototype.appendInner=function(e){return new m2e(this,e)};Nr.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Nr.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Nr.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Nr.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)};Nr.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};Nr.from=function(e){return e instanceof Nr?e:e&&e.length?new uX(e):Nr.empty};var uX=(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<=W1)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=W1)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})(Nr);Nr.empty=new uX([]);var m2e=(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})(Nr);const g2e=500;class fo{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=[],u=[];return this.items.forEach((f,m)=>{if(!f.step){r||(r=this.remapping(i,m+1),a=r.maps.length),a--,u.push(f);return}if(r){u.push(new zo(f.map));let g=f.step.map(r.slice(a)),y;g&&s.maybeStep(g).doc&&(y=s.mapping.maps[s.mapping.maps.length-1],c.push(new zo(y,void 0,void 0,c.length+u.length))),a--,y&&r.appendMap(y,a)}else s.maybeStep(f.step);if(f.selection)return o=r?f.selection.map(r.slice(a)):f.selection,l=new fo(this.items.slice(0,i).append(u.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 u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),m=new zo(e.mapping.maps[u],f,n),g;(g=l&&l.merge(m))&&(m=g,u?a.pop():o=o.slice(0,o.length-1)),a.push(m),n&&(s++,n=void 0),r||(l=m)}let c=s-i.depth;return c>v2e&&(o=x2e(o,c),s-=c),new fo(o.append(a),s)}remapping(e,n){let i=new o0;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 fo(this.items.append(e.map(n=>new zo(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(m=>{m.selection&&o--},r);let l=n;this.items.forEach(m=>{let g=a.getMirror(--l);if(g==null)return;s=Math.min(s,g);let y=a.maps[g];if(m.step){let _=e.steps[g].invert(e.docs[g]),v=m.selection&&m.selection.map(a.slice(l+1,g));v&&o++,i.push(new zo(y,_,v))}else i.push(new zo(y))},r);let c=[];for(let m=n;m<s;m++)c.push(new zo(a.maps[m]));let u=this.items.slice(0,r).append(c).append(i),f=new fo(u,o);return f.emptyItemCount()>g2e&&(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 u=s.selection&&s.selection.map(n.slice(i));u&&a++;let f=new zo(c.invert(),l,u),m,g=r.length-1;(m=r.length&&r[g].merge(f))?r[g]=m:r.push(f)}}else s.map&&i--},this.items.length,0),new fo(Nr.from(r.reverse()),a)}}fo.empty=new fo(Nr.empty,0);function x2e(t,e){let n;return t.forEach((i,r)=>{if(i.selection&&e--==0)return n=r,!1}),t.slice(n)}class zo{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 zo(n.getMap().invert(),n,this.selection)}}}class wu{constructor(e,n,i,r,a){this.done=e,this.undone=n,this.prevRanges=i,this.prevTime=r,this.prevComposition=a}}const v2e=20;function y2e(t,e,n,i){let r=n.getMeta(ff),a;if(r)return r.historyState;n.getMeta(S2e)&&(t=new wu(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(ff))return s.getMeta(ff).redo?new wu(t.done.addTransform(n,void 0,i,C_(e)),t.undone,_8(n.mapping.maps),t.prevTime,t.prevComposition):new wu(t.done,t.undone.addTransform(n,void 0,i,C_(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||!b2e(n,t.prevRanges)),c=s?R2(t.prevRanges,n.mapping):_8(n.mapping.maps);return new wu(t.done.addTransform(n,l?e.selection.getBookmark():void 0,i,C_(e)),fo.empty,c,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new wu(t.done.rebased(n,a),t.undone.rebased(n,a),R2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new wu(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),R2(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function b2e(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 _8(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 R2(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 _2e(t,e,n){let i=C_(e),r=ff.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 wu(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(s).setMeta(ff,{redo:n,historyState:l})}let P2=!1,S8=null;function C_(t){let e=t.plugins;if(S8!=e){P2=!1,S8=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){P2=!0;break}}return P2}const ff=new ur("history"),S2e=new ur("closeHistory");function w2e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new xi({key:ff,state:{init(){return new wu(fo.empty,fo.empty,null,0,-1)},apply(e,n,i){return y2e(n,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let i=n.inputType,r=i=="historyUndo"?fX:i=="historyRedo"?hX:null;return!r||!e.editable?!1:(n.preventDefault(),r(e.state,e.dispatch))}}}})}function dX(t,e){return(n,i)=>{let r=ff.getState(n);if(!r||(t?r.undone:r.done).eventCount==0)return!1;if(i){let a=_2e(r,n,t);a&&i(e?a.scrollIntoView():a)}return!0}}const fX=dX(!1,!0),hX=dX(!0,!0);Wn.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 xi({key:new ur("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,u=o;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>i)}})]}});var M2e=Wn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[s2e(this.options)]}});Wn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new xi({key:new ur("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:i}=this.editor,{anchor:r}=e,a=[];if(!n||!i)return pi.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(pa.node(c,c+l.nodeSize,{class:this.options.className}))}),pi.create(t,a)}}})]}});var E2e=Wn.create({name:"gapCursor",addProseMirrorPlugins(){return[u2e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=On(Ut(t,"allowGapCursor",n)))!=null?e:null}}});Wn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new xi({key:new ur("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&&bw(s);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];a&&u.push(this.options.emptyEditorClass);const f=pa.node(o,o+s.nodeSize,{class:u.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}),pi.create(t,r)}}})]}});Wn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new xi({key:new ur("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||wq(n.selection)||t.view.dragging?null:pi.create(n.doc,[pa.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function w8({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var A2e=Wn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ur(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 xi({key:e,appendTransaction:(r,a,s)=>{const{doc:o,tr:l,schema:c}=s,u=e.getState(s),f=o.content.size,m=c.nodes[n];if(u)return l.insert(f,m.create())},state:{init:(r,a)=>{const s=a.tr.doc.lastChild;return!w8({node:s,types:i})},apply:(r,a)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return a;const s=r.doc.lastChild;return!w8({node:s,types:i})}}})]}}),T2e=Wn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>fX(t,e),redo:()=>({state:t,dispatch:e})=>hX(t,e)}},addProseMirrorPlugins(){return[w2e(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()}}}),C2e=Wn.create({name:"starterKit",addExtensions(){var t,e,n,i;const r=[];return this.options.bold!==!1&&r.push(tTe.configure(this.options.bold)),this.options.blockquote!==!1&&r.push(YAe.configure(this.options.blockquote)),this.options.bulletList!==!1&&r.push(Qq.configure(this.options.bulletList)),this.options.code!==!1&&r.push(rTe.configure(this.options.code)),this.options.codeBlock!==!1&&r.push(oTe.configure(this.options.codeBlock)),this.options.document!==!1&&r.push(lTe.configure(this.options.document)),this.options.dropcursor!==!1&&r.push(M2e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&r.push(E2e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&r.push(cTe.configure(this.options.hardBreak)),this.options.heading!==!1&&r.push(uTe.configure(this.options.heading)),this.options.undoRedo!==!1&&r.push(T2e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&r.push(dTe.configure(this.options.horizontalRule)),this.options.italic!==!1&&r.push(gTe.configure(this.options.italic)),this.options.listItem!==!1&&r.push(Jq.configure(this.options.listItem)),this.options.listKeymap!==!1&&r.push(aX.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&r.push(Zq.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&r.push(oX.configure(this.options.orderedList)),this.options.paragraph!==!1&&r.push(e2e.configure(this.options.paragraph)),this.options.strike!==!1&&r.push(i2e.configure(this.options.strike)),this.options.text!==!1&&r.push(r2e.configure(this.options.text)),this.options.underline!==!1&&r.push(lX.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&r.push(A2e.configure((i=this.options)==null?void 0:i.trailingNode)),r}}),N2e=C2e,R2e=Wn.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")}}}),P2e=R2e,k2e=20,pX=(t,e=0)=>{const n=[];return!t.children.length||e>k2e||Array.from(t.children).forEach(i=>{i.tagName==="SPAN"?n.push(i):i.children.length&&n.push(...pX(i,e+1))}),n},D2e=t=>{if(!t.children.length)return;const e=pX(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}`)})},mX=od.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&D2e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Ai(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}}}}),O2e=Wn.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()}}}),gX=Wn.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()}}}),L2e=Wn.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()}}}),I2e=Wn.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()}}}),j2e=Wn.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()}}});Wn.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(O2e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(gX.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(L2e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(I2e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(j2e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(mX.configure(this.options.textStyle)),t}});var U2e=gX,F2e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,z2e=Ha.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",Ai(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(([u,f])=>{if(f!=null)switch(u){case"width":case"height":break;default:o.setAttribute(u,f);break}}),o.src=s.src;const l=new yAe({element:o,node:r,getPos:a,onResize:(u,f)=>{o.style.width=`${u}px`,o.style.height=`${f}px`},onCommit:(u,f)=>{const m=a();m!==void 0&&this.editor.chain().setNodeSelection(m).updateAttributes(this.name,{width:u,height:f}).run()},onUpdate:(u,f,m)=>u.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[Uq({find:F2e,type:this.type,getAttributes:t=>{const[,,e,n,i]=t;return{src:n,alt:e,title:i}}})]}}),B2e=z2e;function M8({content:t,onChange:e,placeholder:n}){const i=GAe({extensions:[N2e.configure({heading:!1,codeBlock:!1,code:!1}),a2e,BTe.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),P2e.configure({types:["paragraph"]}),mX,U2e,B2e.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})=>h.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 h.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[h.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[h.jsx(r,{onClick:()=>i.chain().focus().toggleBold().run(),isActive:i.isActive("bold"),title:"Bold",children:h.jsx(Fae,{className:"w-4 h-4"})}),h.jsx(r,{onClick:()=>i.chain().focus().toggleItalic().run(),isActive:i.isActive("italic"),title:"Italic",children:h.jsx(Xse,{className:"w-4 h-4"})}),h.jsx(r,{onClick:()=>i.chain().focus().toggleUnderline().run(),isActive:i.isActive("underline"),title:"Underline",children:h.jsx(Sle,{className:"w-4 h-4"})}),h.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),h.jsx(r,{onClick:()=>i.chain().focus().toggleBulletList().run(),isActive:i.isActive("bulletList"),title:"Bullet List",children:h.jsx(e9,{className:"w-4 h-4"})}),h.jsx(r,{onClick:()=>i.chain().focus().toggleOrderedList().run(),isActive:i.isActive("orderedList"),title:"Numbered List",children:h.jsx(JG,{className:"w-4 h-4"})}),h.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),h.jsx(r,{onClick:()=>i.chain().focus().setTextAlign("left").run(),isActive:i.isActive({textAlign:"left"}),title:"Align Left",children:h.jsx(gle,{className:"w-4 h-4"})}),h.jsx(r,{onClick:()=>i.chain().focus().setTextAlign("center").run(),isActive:i.isActive({textAlign:"center"}),title:"Align Center",children:h.jsx(fle,{className:"w-4 h-4"})}),h.jsx(r,{onClick:()=>i.chain().focus().setTextAlign("right").run(),isActive:i.isActive({textAlign:"right"}),title:"Align Right",children:h.jsx(ple,{className:"w-4 h-4"})}),h.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),h.jsx(r,{onClick:a,isActive:i.isActive("link"),title:"Add Link",children:h.jsx(QG,{className:"w-4 h-4"})}),i.isActive("link")&&h.jsx(r,{onClick:()=>i.chain().focus().unsetLink().run(),title:"Remove Link",children:h.jsx(o9,{className:"w-4 h-4"})})]}),h.jsx(UAe,{editor:i})]})}function H2e({archiveId:t,archiveName:e,onClose:n}){const i=In(),[r,a]=E.useState(!1),[s,o]=E.useState(null),[l,c]=E.useState({}),{data:u,isLoading:f,error:m}=Dt({queryKey:["archive-project-page",t],queryFn:()=>$e.getArchiveProjectPage(t)}),g=Nt({mutationFn:T=>$e.updateArchiveProjectPage(t,T),onSuccess:()=>{i.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),c({})}});E.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 y=[...u?.model_pictures||[],...u?.profile_pictures||[]],_=()=>{c({title:u?.title||"",description:u?.description||"",designer:u?.designer||"",license:u?.license||"",profile_title:u?.profile_title||"",profile_description:u?.profile_description||""}),a(!0)},v=()=>{g.mutate(l)},x=()=>{a(!1),c({})},M=T=>{const P=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],A=new DOMParser().parseFromString(T,"text/html"),j=N=>{if(N.nodeType===Node.TEXT_NODE)return N.textContent||"";if(N.nodeType===Node.ELEMENT_NODE){const k=N,F=k.tagName.toLowerCase();if(!P.includes(F))return Array.from(k.childNodes).map(j).join("");let I="";if(F==="a"&&k.getAttribute("href")){const D=k.getAttribute("href");D?.toLowerCase().startsWith("http")&&(I=` href="${D}" target="_blank" rel="noopener noreferrer"`)}if(F==="img"){const D=k.getAttribute("src");if(!D?.toLowerCase().startsWith("http"))return"";I=` src="${D}" style="max-width: 100%; height: auto;"`}const W=Array.from(k.childNodes).map(j).join("");return["br","img"].includes(F)?`<${F}${I} />`:`<${F}${I}>${W}</${F}>`}return""};return Array.from(A.body.childNodes).map(j).join("")},w=u&&(u.title||u.description||u.designer||u.profile_title||y.length>0),C=T=>{T.target===T.currentTarget&&n()};return h.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:C,children:[h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(xp,{className:"w-5 h-5 text-bambu-green"}),h.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&h.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[!r&&w&&h.jsxs(Ye,{variant:"ghost",size:"sm",onClick:_,children:[h.jsx(zP,{className:"w-4 h-4 mr-1"}),"Edit"]}),r&&h.jsxs(h.Fragment,{children:[h.jsx(Ye,{variant:"ghost",size:"sm",onClick:x,children:"Cancel"}),h.jsxs(Ye,{variant:"primary",size:"sm",onClick:v,disabled:g.isPending,children:[h.jsx(Sm,{className:"w-4 h-4 mr-1"}),"Save"]})]}),h.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(Sn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&h.jsx("div",{className:"flex items-center justify-center py-12",children:h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),m&&h.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),u&&!w&&h.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[h.jsx(xp,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),h.jsx("p",{children:"No project page data found in this 3MF file."}),h.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),u&&w&&h.jsxs("div",{className:"space-y-6",children:[h.jsxs("div",{className:"space-y-4",children:[r?h.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"}):u.title&&h.jsx("h3",{className:"text-xl font-semibold text-white",children:u.title}),h.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[r?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(XU,{className:"w-4 h-4 text-bambu-gray"}),h.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"})]}):u.designer&&h.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[h.jsx(XU,{className:"w-4 h-4"}),h.jsx("span",{children:u.designer}),u.designer_user_id&&h.jsx("a",{href:`https://makerworld.com/en/@${u.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:h.jsx(mc,{className:"w-3 h-3"})})]}),u.creation_date&&h.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[h.jsx(Zo,{className:"w-4 h-4"}),h.jsx("span",{children:u.creation_date})]}),r?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(xp,{className:"w-4 h-4 text-bambu-gray"}),h.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"})]}):u.license&&h.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[h.jsx(xp,{className:"w-4 h-4"}),h.jsx("span",{children:u.license})]}),u.origin&&h.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:u.origin})]})]}),(u.description||r)&&h.jsxs("div",{className:"space-y-2",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),r?h.jsx(M8,{content:l.description||"",onChange:T=>c({...l,description:T}),placeholder:"Enter description..."}):h.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.description||"")}})]}),(u.profile_title||u.profile_description||r)&&h.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),r?h.jsxs("div",{className:"space-y-2",children:[h.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"}),h.jsx(M8,{content:l.profile_description||"",onChange:T=>c({...l,profile_description:T}),placeholder:"Profile description..."})]}):h.jsxs(h.Fragment,{children:[u.profile_title&&h.jsx("p",{className:"text-white font-medium",children:u.profile_title}),u.profile_description&&h.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:M(u.profile_description)}}),u.profile_user_name&&h.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",u.profile_user_name]})]})]}),y.length>0&&h.jsxs("div",{className:"space-y-2",children:[h.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[h.jsx(KS,{className:"w-4 h-4"}),"Images (",y.length,")"]}),h.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:y.map((T,P)=>h.jsx("button",{onClick:()=>o(P),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:h.jsx("img",{src:T.url,alt:T.name,className:"w-full h-full object-cover"})},T.path))})]}),u.design_model_id&&h.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("a",{href:`https://makerworld.com/en/models/${u.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[h.jsx(mc,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),s!==null&&y[s]&&h.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>o(null),children:[h.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:h.jsx(_f,{className:"w-6 h-6 text-white"})}),h.jsx("img",{src:y[s].url,alt:y[s].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:T=>T.stopPropagation()}),h.jsx("button",{onClick:T=>{T.stopPropagation(),o(Math.min(y.length-1,s+1))},disabled:s===y.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:h.jsx(_m,{className:"w-6 h-6 text-white"})}),h.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:h.jsx(Sn,{className:"w-6 h-6 text-white"})}),h.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[s+1," / ",y.length]})]})]})}const $2e=[.25,.5,.75,1,1.5,2,3,4];function V2e({src:t,title:e,downloadFilename:n,onClose:i}){const r=E.useRef(null),[a,s]=E.useState(!0),[o,l]=E.useState(.5),[c,u]=E.useState(0),[f,m]=E.useState(0);E.useEffect(()=>{const w=r.current;w&&(w.playbackRate=o)},[o]),E.useEffect(()=>{const w=C=>{C.key==="Escape"&&i()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[i]),E.useEffect(()=>{const w=r.current;if(!w)return;const C=()=>u(w.currentTime),T=()=>m(w.duration),P=()=>s(!0),A=()=>s(!1);return w.addEventListener("timeupdate",C),w.addEventListener("durationchange",T),w.addEventListener("play",P),w.addEventListener("pause",A),()=>{w.removeEventListener("timeupdate",C),w.removeEventListener("durationchange",T),w.removeEventListener("play",P),w.removeEventListener("pause",A)}},[]);const g=()=>{const w=r.current;w&&(a?w.pause():w.play())},y=w=>{const C=r.current;C&&(C.currentTime=parseFloat(w.target.value))},_=()=>{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 C=Math.floor(w/60),T=Math.floor(w%60);return`${C}:${T.toString().padStart(2,"0")}`},M=()=>{const w=document.createElement("a");w.href=t,w.download=n,w.click()};return h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:h.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[h.jsx(Mp,{className:"w-5 h-5 text-bambu-green"}),e]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:M,children:[h.jsx(pc,{className:"w-4 h-4"}),"Download"]}),h.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:h.jsx(Sn,{className:"w-5 h-5 text-bambu-gray"})})]})]}),h.jsxs("div",{className:"p-4",children:[h.jsx("video",{ref:r,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:g}),h.jsxs("div",{className:"mt-4 space-y-3",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:x(c)}),h.jsx("input",{type:"range",min:0,max:f||100,value:c,onChange:y,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`}),h.jsx("span",{className:"text-xs text-bambu-gray w-12",children:x(f)})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:_,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:h.jsx(Zoe,{className:"w-5 h-5 text-bambu-gray"})}),h.jsx("button",{onClick:g,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:a?h.jsx(Moe,{className:"w-5 h-5 text-white"}):h.jsx(YS,{className:"w-5 h-5 text-white"})}),h.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:h.jsx(r9,{className:"w-5 h-5 text-bambu-gray"})})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),h.jsx("div",{className:"flex gap-1",children:$2e.map(w=>h.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 G2e({archiveId:t,archiveName:e,onClose:n}){const i=In(),{showToast:r}=wa(),[a,s]=E.useState(null),[o,l]=E.useState("asap"),[c,u]=E.useState(""),[f,m]=E.useState(!1),[g,y]=E.useState(!1),{data:_}=Dt({queryKey:["printers"],queryFn:()=>$e.getPrinters()});E.useEffect(()=>{_?.length===1&&!a&&s(_[0].id)},[_,a]),E.useEffect(()=>{const w=C=>{C.key==="Escape"&&n()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]);const v=Nt({mutationFn:w=>$e.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 C={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:g};o==="scheduled"&&c&&(C.scheduled_time=new Date(c).toISOString()),v.mutate(C)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:h.jsx($t,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:h.jsxs(Qt,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Zo,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),h.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),h.jsx("p",{className:"text-white font-medium truncate",children:e})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),_?.length===0?h.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[h.jsx(Ec,{className:"w-4 h-4"}),"No printers configured"]}):h.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:[h.jsx("option",{value:"",children:"Select printer..."}),_?.map(w=>h.jsx("option",{value:w.id,children:w.name},w.id))]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),h.jsxs("div",{className:"flex gap-2",children:[h.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:[h.jsx(ar,{className:"w-4 h-4"}),"ASAP (when idle)"]}),h.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:[h.jsx(Zo,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),h.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=>u(w.target.value),min:M(),required:!0})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>m(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:g,onChange:w=>y(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[h.jsx(Bf,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),h.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."}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(Ye,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),h.jsx(Ye,{type:"submit",className:"flex-1",disabled:v.isPending||!a||_?.length===0,children:v.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function hR(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Zg(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function E8(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function W2e({archive:t,printerName:e,isSelected:n,onSelect:i,selectionMode:r}){const a=In(),{showToast:s}=wa(),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,m]=E.useState(!1),[g,y]=E.useState(!1),[_,v]=E.useState(!1),[x,M]=E.useState(!1),[w,C]=E.useState([]),[T,P]=E.useState(!1),[A,j]=E.useState(!1),[N,k]=E.useState(!1),[F,I]=E.useState(!1),[W,D]=E.useState(!1),[B,$]=E.useState(null),K=E.useRef(null),X=Nt({mutationFn:ie=>$e.uploadSource3mf(t.id,ie),onSuccess:ie=>{a.invalidateQueries({queryKey:["archives"]}),s(`Source 3MF attached: ${ie.filename}`)},onError:ie=>{s(ie.message||"Failed to upload source 3MF","error")}}),Y=Nt({mutationFn:()=>$e.deleteSource3mf(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Source 3MF removed")},onError:ie=>{s(ie.message||"Failed to remove source 3MF","error")}}),ee=Nt({mutationFn:()=>$e.scanArchiveTimelapse(t.id),onSuccess:ie=>{ie.status==="attached"?(a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${ie.filename}`)):ie.status==="exists"?s("Timelapse already attached"):ie.status==="not_found"&&ie.available_files&&ie.available_files.length>0?(C(ie.available_files),M(!0)):s(ie.message||"No matching timelapse found","warning")},onError:ie=>{s(ie.message||"Failed to scan for timelapse","error")}}),z=Nt({mutationFn:ie=>$e.selectArchiveTimelapse(t.id,ie),onSuccess:ie=>{a.invalidateQueries({queryKey:["archives"]}),s(`Timelapse attached: ${ie.filename}`),M(!1),C([])},onError:ie=>{s(ie.message||"Failed to attach timelapse","error")}}),V=Nt({mutationFn:()=>$e.deleteArchive(t.id),onSuccess:()=>{a.invalidateQueries({queryKey:["archives"]}),s("Archive deleted")},onError:()=>{s("Failed to delete archive","error")}}),re=Nt({mutationFn:()=>$e.toggleFavorite(t.id),onSuccess:ie=>{a.invalidateQueries({queryKey:["archives"]}),s(ie.is_favorite?"Added to favorites":"Removed from favorites")}}),le=ie=>{ie.preventDefault(),$({x:ie.clientX,y:ie.clientY})},ge=[{label:"Print",icon:h.jsx(Qo,{className:"w-4 h-4"}),onClick:()=>u(!0)},{label:"Schedule",icon:h.jsx(Zo,{className:"w-4 h-4"}),onClick:()=>I(!0)},{label:"Open in Bambu Studio",icon:h.jsx(mc,{className:"w-4 h-4"}),onClick:()=>{const ie=t.print_name||t.filename||"model",xe=`${window.location.origin}${$e.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(xe)}`}},{label:"View on MakerWorld",icon:h.jsx($_,{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:h.jsx(Gx,{className:"w-4 h-4"}),onClick:()=>l(!0)},{label:"View Timelapse",icon:h.jsx(Mp,{className:"w-4 h-4"}),onClick:()=>v(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:h.jsx(Hoe,{className:"w-4 h-4"}),onClick:()=>ee.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ee.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:h.jsx(VU,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const ie=document.createElement("a");ie.href=$e.getSource3mfDownloadUrl(t.id),ie.download=`${t.print_name||t.filename}_source.3mf`,ie.click()}else K.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:h.jsx($p,{className:"w-4 h-4"}),onClick:()=>K.current?.click()},{label:"Remove Source 3MF",icon:h.jsx(Ei,{className:"w-4 h-4"}),onClick:()=>D(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:h.jsx(pc,{className:"w-4 h-4"}),onClick:()=>{const ie=document.createElement("a");ie.href=$e.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()}},{label:"Copy Download Link",icon:h.jsx(Up,{className:"w-4 h-4"}),onClick:()=>{const ie=`${window.location.origin}${$e.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ie).then(()=>{s("Link copied to clipboard")}).catch(()=>{s("Failed to copy link","error")})}},{label:"QR Code",icon:h.jsx(Loe,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:h.jsx(H_,{className:"w-4 h-4"}),onClick:()=>j(!0),disabled:!t.photos?.length},{label:"Project Page",icon:h.jsx(xp,{className:"w-4 h-4"}),onClick:()=>k(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:h.jsx(qx,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>re.mutate()},{label:"Edit",icon:h.jsx(zp,{className:"w-4 h-4"}),onClick:()=>y(!0)},{label:n?"Deselect":"Select",icon:n?h.jsx(Sf,{className:"w-4 h-4"}):h.jsx(Hp,{className:"w-4 h-4"}),onClick:()=>i(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:h.jsx(Ei,{className:"w-4 h-4"}),onClick:()=>m(!0),danger:!0}];return h.jsxs($t,{className:`relative flex flex-col ${n?"ring-2 ring-bambu-green":""} ${r?"cursor-pointer":""}`,onContextMenu:le,onClick:r?()=>i(t.id):void 0,children:[r&&h.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),i(t.id)},children:n?h.jsx(Sf,{className:"w-5 h-5 text-bambu-green"}):h.jsx(Hp,{className:"w-5 h-5 text-white"})}),h.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?h.jsx("img",{src:$e.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):h.jsx("div",{className:"w-full h-full flex items-center justify-center",children:h.jsx(KS,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),h.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:ie=>{ie.stopPropagation(),re.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:h.jsx(qx,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),t.status==="failed"&&h.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&&h.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:[h.jsx(Up,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&h.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation();const xe=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",ke=`${window.location.origin}${$e.getSource3mfForSlicer(t.id,xe)}`;window.location.href=`bambustudioopen://${encodeURIComponent(ke)}`},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:h.jsx(VU,{className:"w-4 h-4 text-orange-400"})}),t.timelapse_path&&h.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ie=>{ie.stopPropagation(),v(!0)},title:"View timelapse",children:h.jsx(Mp,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&h.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:ie=>{ie.stopPropagation(),j(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[h.jsx(H_,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&h.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})]})]}),h.jsxs(Qt,{className:"p-4 flex-1 flex flex-col",children:[h.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),h.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:e}),h.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)&&h.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${Zg(t.print_time_seconds||0)}
- Actual: ${Zg(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${Zg(t.actual_time_seconds)}`:`Estimated: ${Zg(t.print_time_seconds||0)}`,children:[h.jsx(ar,{className:"w-3 h-3"}),Zg(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&h.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&&h.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[h.jsx(G_,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&h.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[h.jsx(Fp,{className:"w-3 h-3"}),t.total_layers&&h.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&h.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&h.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.filament_type&&h.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[h.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&h.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ie,xe)=>h.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ie},title:ie},xe))})]})]}),(t.tags||t.notes)&&h.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&h.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:h.jsx(a9,{className:"w-3 h-3"})}),t.tags?.split(",").map((ie,xe)=>h.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ie.trim()},xe))]}),h.jsx("div",{className:"flex-1"}),h.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[h.jsx("span",{children:E8(t.created_at)}),h.jsx("span",{children:hR(t.file_size)})]}),h.jsxs("div",{className:"flex gap-1 mt-3",children:[h.jsxs(Ye,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>u(!0),children:[h.jsx(Qo,{className:"w-3 h-3 flex-shrink-0"}),h.jsx("span",{className:"hidden sm:inline",children:"Print"})]}),h.jsx(Ye,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=t.print_name||t.filename||"model",xe=`${window.location.origin}${$e.getArchiveForSlicer(t.id,ie)}`;window.location.href=`bambustudioopen://${encodeURIComponent(xe)}`},title:"Open in Bambu Studio",children:h.jsx(mc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(Ye,{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:h.jsx($_,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),h.jsx(Ye,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>l(!0),title:"3D Preview",children:h.jsx(Gx,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(Ye,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ie=document.createElement("a");ie.href=$e.getArchiveDownload(t.id),ie.download=`${t.print_name||t.filename}.3mf`,ie.click()},title:"Download",children:h.jsx(pc,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(Ye,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>y(!0),title:"Edit",children:h.jsx(zp,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),h.jsx(Ye,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>m(!0),title:"Delete",children:h.jsx(Ei,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),g&&h.jsx(g1e,{archive:t,onClose:()=>y(!1)}),o&&h.jsx(f1e,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>l(!1)}),c&&h.jsx(h1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>u(!1),onSuccess:()=>{}}),f&&h.jsx(Ia,{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:()=>{V.mutate(),m(!1)},onCancel:()=>m(!1)}),W&&h.jsx(Ia,{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:()=>{Y.mutate(),D(!1)},onCancel:()=>D(!1)}),B&&h.jsx(x1e,{x:B.x,y:B.y,items:ge,onClose:()=>$(null)}),_&&t.timelapse_path&&h.jsx(V2e,{src:$e.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&&h.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:h.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),h.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),h.jsx("button",{onClick:()=>{M(!1),C([])},className:"text-gray-400 hover:text-white p-1",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:w.map(ie=>h.jsxs("button",{onClick:()=>z.mutate(ie.name),disabled:z.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:[h.jsx(Mp,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("p",{className:"text-white font-medium truncate",children:ie.name}),h.jsxs("p",{className:"text-sm text-gray-400",children:[hR(ie.size),ie.mtime&&` • ${E8(ie.mtime)}`]})]})]},ie.name))}),h.jsx("div",{className:"p-4 border-t border-gray-700",children:h.jsx(Ye,{variant:"secondary",onClick:()=>{M(!1),C([])},className:"w-full",children:"Cancel"})})]})}),T&&h.jsx(M1e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),A&&t.photos&&t.photos.length>0&&h.jsx(E1e,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>j(!1),onDelete:async ie=>{try{await $e.deleteArchivePhoto(t.id,ie),a.invalidateQueries({queryKey:["archives"]}),s("Photo deleted")}catch{s("Failed to delete photo","error")}}}),N&&h.jsx(H2e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>k(!1)}),F&&h.jsx(G2e,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>I(!1)}),h.jsx("input",{ref:K,type:"file",accept:".3mf",className:"hidden",onChange:ie=>{const xe=ie.target.files?.[0];xe&&X.mutate(xe),ie.target.value=""}})]})}const q2e=[{id:"all",label:"All Archives",icon:h.jsx(Ise,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:h.jsx(ar,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:h.jsx(Zo,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:h.jsx(Zo,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:h.jsx(qx,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:h.jsx(Ec,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:h.jsx(Up,{className:"w-4 h-4"})}];function X2e(){const t=In(),{showToast:e}=wa(),n=E.useRef(null),[i,r]=E.useState(""),[a,s]=E.useState(null),[o,l]=E.useState(null),[c,u]=E.useState(new Set),[f,m]=E.useState("or"),[g,y]=E.useState(!1),[_,v]=E.useState(null),[x,M]=E.useState(!1),[w,C]=E.useState([]),[T,P]=E.useState(!1),[A,j]=E.useState(new Set),[N,k]=E.useState(!1),[F,I]=E.useState(!1),[W,D]=E.useState(!1),[B,$]=E.useState("grid"),[K,X]=E.useState("date-desc"),[Y,ee]=E.useState("all"),{data:z,isLoading:V}=Dt({queryKey:["archives",a],queryFn:()=>$e.getArchives(a||void 0)}),{data:re}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),le=Nt({mutationFn:async ne=>(await Promise.all(ne.map(U=>$e.deleteArchive(U))),ne.length),onSuccess:ne=>{t.invalidateQueries({queryKey:["archives"]}),j(new Set),e(`${ne} archive${ne!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}}),ge=new Map(re?.map(ne=>[ne.id,ne.name])||[]),ie=[...new Set(z?.flatMap(ne=>ne.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),xe=[...new Set(z?.flatMap(ne=>ne.filament_color?.split(",")||[]).filter(Boolean)||[])],ke=[...new Set(z?.flatMap(ne=>ne.tags?.split(",").map(U=>U.trim())||[]).filter(Boolean)||[])].sort(),he=z?.filter(ne=>{const U=new Date,L=new Date(ne.created_at);let J=!0;switch(Y){case"recent":J=U.getTime()-L.getTime()<1440*60*1e3;break;case"this-week":J=U.getTime()-L.getTime()<10080*60*1e3;break;case"this-month":J=L.getMonth()===U.getMonth()&&L.getFullYear()===U.getFullYear();break;case"favorites":J=ne.is_favorite===!0;break;case"failed":J=ne.status==="failed";break;case"duplicates":J=ne.duplicate_count>0;break}const me=(ne.print_name||ne.filename).toLowerCase().includes(i.toLowerCase()),ye=!o||ne.filament_type?.split(", ").includes(o),pe=ne.filament_color?.split(",")||[],Qe=c.size===0||(f==="or"?pe.some(Ie=>c.has(Ie)):[...c].every(Ie=>pe.includes(Ie))),Le=Y==="favorites"||!g||ne.is_favorite,Xe=ne.tags?.split(",").map(Ie=>Ie.trim())||[],st=!_||Xe.includes(_);return J&&me&&ye&&Qe&&Le&&st}).sort((ne,U)=>{switch(K){case"date-desc":return new Date(U.created_at).getTime()-new Date(ne.created_at).getTime();case"date-asc":return new Date(ne.created_at).getTime()-new Date(U.created_at).getTime();case"name-asc":return(ne.print_name||ne.filename).localeCompare(U.print_name||U.filename);case"name-desc":return(U.print_name||U.filename).localeCompare(ne.print_name||ne.filename);case"size-desc":return U.file_size-ne.file_size;case"size-asc":return ne.file_size-U.file_size;default:return 0}}),we=N||A.size>0,Ue=ne=>{j(U=>{const L=new Set(U);return L.has(ne)?L.delete(ne):L.add(ne),L})},ue=()=>{he&&j(new Set(he.map(ne=>ne.id)))},lt=()=>{j(new Set),k(!1)},H=ne=>{u(U=>{const L=new Set(U);return L.has(ne)?L.delete(ne):L.add(ne),L})},q=()=>{u(new Set)},oe=()=>{r(""),s(null),l(null),y(!1),v(null)},Z=i||a||o||g||_,Q=E.useCallback(ne=>{ne.preventDefault(),ne.dataTransfer.types.includes("Files")&&P(!0)},[]),se=E.useCallback(ne=>{ne.preventDefault(),ne.currentTarget===ne.target&&P(!1)},[]),Ce=E.useCallback(ne=>{ne.preventDefault(),P(!1);const U=Array.from(ne.dataTransfer.files).filter(L=>L.name.endsWith(".3mf"));U.length>0?(C(U),M(!0)):ne.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),Ee=E.useCallback(ne=>{const U=ne.target;if(U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable){ne.key==="Escape"&&U.blur();return}switch(ne.key){case"/":ne.preventDefault(),n.current?.focus();break;case"u":case"U":!ne.metaKey&&!ne.ctrlKey&&(ne.preventDefault(),M(!0));break;case"Escape":we&<();break}},[we]);return E.useEffect(()=>(document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)),[Ee]),h.jsxs("div",{className:"p-8 relative min-h-full",onDragOver:Q,onDragLeave:se,onDrop:Ce,children:[T&&h.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:h.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[h.jsx($p,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),h.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),h.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),we&&h.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:[h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:lt,children:[h.jsx(Sn,{className:"w-4 h-4"}),"Close"]}),h.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),h.jsxs("span",{className:"text-white font-medium",children:[A.size," selected"]}),h.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),h.jsx(Ye,{variant:"secondary",size:"sm",onClick:ue,children:"Select All"}),h.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>D(!0),children:[h.jsx(Xx,{className:"w-4 h-4"}),"Tags"]}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>{const ne=Array.from(A);Promise.all(ne.map(U=>$e.toggleFavorite(U))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ne.length} archive${ne.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[h.jsx(qx,{className:"w-4 h-4"}),"Favorite"]}),h.jsxs(Ye,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>I(!0),children:[h.jsx(Ei,{className:"w-4 h-4"}),"Delete"]})]}),h.jsxs("div",{className:"flex items-center justify-between mb-8",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),h.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:Y,onChange:ne=>ee(ne.target.value),children:q2e.map(ne=>h.jsx("option",{value:ne.id,children:ne.label},ne.id))})]}),h.jsxs("p",{className:"text-bambu-gray",children:[he?.length||0," of ",z?.length||0," prints"]})]}),h.jsxs("div",{className:"flex items-center gap-3",children:[!we&&h.jsxs(Ye,{variant:"secondary",onClick:()=>k(!0),children:[h.jsx(Sf,{className:"w-4 h-4"}),"Select"]}),h.jsxs(Ye,{onClick:()=>M(!0),children:[h.jsx($p,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),h.jsx($t,{className:"mb-6",children:h.jsxs(Qt,{className:"py-4",children:[h.jsxs("div",{className:"flex gap-4 items-center flex-wrap",children:[h.jsxs("div",{className:"flex-1 relative min-w-[200px]",children:[h.jsx(Bp,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.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:ne=>r(ne.target.value)})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(XG,{className:"w-4 h-4 text-bambu-gray"}),h.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:ne=>s(ne.target.value?Number(ne.target.value):null),children:[h.jsx("option",{value:"",children:"All Printers"}),re?.map(ne=>h.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(G_,{className:"w-4 h-4 text-bambu-gray"}),h.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:ne=>l(ne.target.value||null),children:[h.jsx("option",{value:"",children:"All Materials"}),ie.map(ne=>h.jsx("option",{value:ne,children:ne},ne))]})]}),h.jsxs("button",{onClick:()=>y(!g),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${g?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:g?"Show all":"Show favorites only",children:[h.jsx(qx,{className:`w-4 h-4 ${g?"fill-yellow-400":""}`}),h.jsx("span",{className:"text-sm",children:"Favorites"})]}),ke.length>0&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Xx,{className:"w-4 h-4 text-bambu-gray"}),h.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:_||"",onChange:ne=>v(ne.target.value||null),children:[h.jsx("option",{value:"",children:"All Tags"}),ke.map(ne=>h.jsx("option",{value:ne,children:ne},ne))]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Lae,{className:"w-4 h-4 text-bambu-gray"}),h.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:K,onChange:ne=>X(ne.target.value),children:[h.jsx("option",{value:"date-desc",children:"Newest first"}),h.jsx("option",{value:"date-asc",children:"Oldest first"}),h.jsx("option",{value:"name-asc",children:"Name A-Z"}),h.jsx("option",{value:"name-desc",children:"Name Z-A"}),h.jsx("option",{value:"size-desc",children:"Largest first"}),h.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),h.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[h.jsx("button",{className:`p-2 ${B==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>$("grid"),title:"Grid view",children:h.jsx(ZG,{className:"w-4 h-4"})}),h.jsx("button",{className:`p-2 ${B==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>$("list"),title:"List view",children:h.jsx(e9,{className:"w-4 h-4"})}),h.jsx("button",{className:`p-2 ${B==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>$("calendar"),title:"Calendar view",children:h.jsx(Vae,{className:"w-4 h-4"})})]}),Z&&h.jsxs(Ye,{variant:"ghost",size:"sm",onClick:oe,className:"text-bambu-gray hover:text-white",children:[h.jsx(Sn,{className:"w-4 h-4"}),"Reset"]})]}),xe.length>0&&h.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),c.size>1&&h.jsx("button",{onClick:()=>m(ne=>ne==="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()}),h.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:xe.map(ne=>h.jsx("button",{onClick:()=>H(ne),className:`w-6 h-6 rounded-full border-2 transition-all ${c.has(ne)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ne},title:ne},ne))}),c.size>0&&h.jsxs("button",{onClick:q,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[h.jsx(Sn,{className:"w-3 h-3"}),"Clear"]})]})]})}),V?h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):he?.length===0?h.jsx($t,{children:h.jsxs(Qt,{className:"text-center py-12",children:[h.jsx("p",{className:"text-bambu-gray",children:i?"No archives match your search":"No archives yet"}),h.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):B==="calendar"?h.jsx($t,{className:"p-6",children:h.jsx(w1e,{archives:he||[],onArchiveClick:ne=>{r(ne.print_name||ne.filename),$("grid")}})}):B==="grid"?h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:he?.map(ne=>h.jsx(W2e,{archive:ne,printerName:ne.printer_id?ge.get(ne.printer_id)||"Unknown":"No Printer",isSelected:A.has(ne.id),onSelect:Ue,selectionMode:we},ne.id))}):B==="list"?h.jsx($t,{children:h.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[h.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[h.jsx("div",{className:"col-span-1"}),h.jsx("div",{className:"col-span-4",children:"Name"}),h.jsx("div",{className:"col-span-2",children:"Printer"}),h.jsx("div",{className:"col-span-2",children:"Date"}),h.jsx("div",{className:"col-span-1",children:"Size"}),h.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),he?.map(ne=>h.jsxs("div",{className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${A.has(ne.id)?"bg-bambu-green/10":""}`,children:[h.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[we&&h.jsx("button",{onClick:()=>Ue(ne.id),children:A.has(ne.id)?h.jsx(Sf,{className:"w-4 h-4 text-bambu-green"}):h.jsx(Hp,{className:"w-4 h-4 text-bambu-gray"})}),ne.thumbnail_path?h.jsx("img",{src:$e.getArchiveThumbnail(ne.id),alt:"",className:"w-10 h-10 object-cover rounded"}):h.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:h.jsx(KS,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),h.jsxs("div",{className:"col-span-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("p",{className:"text-white text-sm truncate",children:ne.print_name||ne.filename}),ne.timelapse_path&&h.jsx("span",{title:"Has timelapse",children:h.jsx(Mp,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})})]}),ne.filament_type&&h.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:ne.filament_type}),ne.filament_color&&h.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:ne.filament_color.split(",").map((U,L)=>h.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:U},title:U},L))})]})]}),h.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:ne.printer_id?ge.get(ne.printer_id)||"Unknown":"No Printer"}),h.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:new Date(ne.created_at).toLocaleDateString()}),h.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:hR(ne.file_size)}),h.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[h.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>{const U=ne.print_name||ne.filename||"model",L=`${window.location.origin}${$e.getArchiveForSlicer(ne.id,U)}`;window.location.href=`bambustudioopen://${encodeURIComponent(L)}`},title:"Open in Slicer",children:h.jsx(mc,{className:"w-4 h-4"})}),ne.makerworld_url&&h.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>window.open(ne.makerworld_url,"_blank"),title:"MakerWorld",children:h.jsx($_,{className:"w-4 h-4"})}),h.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>{const U=document.createElement("a");U.href=$e.getArchiveDownload(ne.id),U.download=`${ne.print_name||ne.filename}.3mf`,U.click()},title:"Download",children:h.jsx(pc,{className:"w-4 h-4"})})]})]},ne.id))]})}):null,x&&h.jsx(p1e,{onClose:()=>{M(!1),C([])},initialFiles:w}),F&&h.jsx(Ia,{title:"Delete Archives",message:`Are you sure you want to delete ${A.size} archive${A.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${A.size}`,variant:"danger",onConfirm:()=>{le.mutate(Array.from(A)),I(!1)},onCancel:()=>I(!1)}),W&&h.jsx(v1e,{selectedIds:Array.from(A),existingTags:ke,onClose:()=>D(!1)})]})}function K2e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>i=>{e.forEach(r=>r(i))},e)}const Mw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Nm(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function nD(t){return"nodeType"in t}function $a(t){var e,n;return t?Nm(t)?t:nD(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function iD(t){const{Document:e}=$a(t);return t instanceof e}function W0(t){return Nm(t)?!1:t instanceof $a(t).HTMLElement}function xX(t){return t instanceof $a(t).SVGElement}function Rm(t){return t?Nm(t)?t.document:nD(t)?iD(t)?t:W0(t)||xX(t)?t.ownerDocument:document:document:document}const rl=Mw?E.useLayoutEffect:E.useEffect;function rD(t){const e=E.useRef(t);return rl(()=>{e.current=t}),E.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 Y2e(){const t=E.useRef(null),e=E.useCallback((i,r)=>{t.current=setInterval(i,r)},[]),n=E.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function m0(t,e){e===void 0&&(e=[t]);const n=E.useRef(t);return rl(()=>{n.current!==t&&(n.current=t)},e),n}function q0(t,e){const n=E.useRef();return E.useMemo(()=>{const i=t(n.current);return n.current=i,i},[...e])}function q1(t){const e=rD(t),n=E.useRef(null),i=E.useCallback(r=>{r!==n.current&&e?.(r,n.current),n.current=r},[]);return[n,i]}function pR(t){const e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}let k2={};function X0(t,e){return E.useMemo(()=>{if(e)return e;const n=k2[t]==null?0:k2[t]+1;return k2[t]=n,t+"-"+n},[t,e])}function vX(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 u=a[l];u!=null&&(a[l]=u+t*c)}return a},{...e})}}const Dp=vX(1),g0=vX(-1);function Z2e(t){return"clientX"in t&&"clientY"in t}function aD(t){if(!t)return!1;const{KeyboardEvent:e}=$a(t.target);return e&&t instanceof e}function Q2e(t){if(!t)return!1;const{TouchEvent:e}=$a(t.target);return e&&t instanceof e}function mR(t){if(Q2e(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 Z2e(t)?{x:t.clientX,y:t.clientY}:null}const om=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[om.Translate.toString(t),om.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:i}=t;return e+" "+n+"ms "+i}}}),A8="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function J2e(t){return t.matches(A8)?t:t.querySelector(A8)}const eCe={display:"none"};function tCe(t){let{id:e,value:n}=t;return ui.createElement("div",{id:e,style:eCe},n)}function nCe(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 ui.createElement("div",{id:e,style:r,role:"status","aria-live":i,"aria-atomic":!0},n)}function iCe(){const[t,e]=E.useState("");return{announce:E.useCallback(i=>{i!=null&&e(i)},[]),announcement:t}}const yX=E.createContext(null);function rCe(t){const e=E.useContext(yX);E.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function aCe(){const[t]=E.useState(()=>new Set),e=E.useCallback(i=>(t.add(i),()=>t.delete(i)),[t]);return[E.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 sCe={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.
- `},oCe={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 lCe(t){let{announcements:e=oCe,container:n,hiddenTextDescribedById:i,screenReaderInstructions:r=sCe}=t;const{announce:a,announcement:s}=iCe(),o=X0("DndLiveRegion"),[l,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),rCe(E.useMemo(()=>({onDragStart(f){let{active:m}=f;a(e.onDragStart({active:m}))},onDragMove(f){let{active:m,over:g}=f;e.onDragMove&&a(e.onDragMove({active:m,over:g}))},onDragOver(f){let{active:m,over:g}=f;a(e.onDragOver({active:m,over:g}))},onDragEnd(f){let{active:m,over:g}=f;a(e.onDragEnd({active:m,over:g}))},onDragCancel(f){let{active:m,over:g}=f;a(e.onDragCancel({active:m,over:g}))}}),[a,e])),!l)return null;const u=ui.createElement(ui.Fragment,null,ui.createElement(tCe,{id:i,value:r.draggable}),ui.createElement(nCe,{id:o,announcement:s}));return n?Zl.createPortal(u,n):u}var ir;(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"})(ir||(ir={}));function X1(){}function K1(t,e){return E.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function bX(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return E.useMemo(()=>[...e].filter(i=>i!=null),[...e])}const Mo=Object.freeze({x:0,y:0});function _X(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function SX(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return n-i}function cCe(t,e){let{data:{value:n}}=t,{data:{value:i}}=e;return i-n}function T8(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 wX(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function C8(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 MX=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=C8(e,e.left,e.top),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=_X(C8(l),r);a.push({id:o,data:{droppableContainer:s,value:c}})}}return a.sort(SX)},uCe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:i}=t;const r=T8(e),a=[];for(const s of i){const{id:o}=s,l=n.get(o);if(l){const c=T8(l),u=r.reduce((m,g,y)=>m+_X(c[y],g),0),f=Number((u/4).toFixed(4));a.push({id:o,data:{droppableContainer:s,value:f}})}}return a.sort(SX)};function dCe(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,u=s*o,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const fCe=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=dCe(o,e);l>0&&r.push({id:s,data:{droppableContainer:a,value:l}})}}return r.sort(cCe)};function hCe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function EX(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Mo}function pCe(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 mCe=pCe(1);function gCe(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 xCe(t,e,n){const i=gCe(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)),u=r?t.width/r:t.width,f=a?t.height/a:t.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const vCe={ignoreTransform:!1};function Pm(t,e){e===void 0&&(e=vCe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=$a(t).getComputedStyle(t);c&&(n=xCe(n,c,u))}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 N8(t){return Pm(t,{ignoreTransform:!0})}function yCe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function bCe(t,e){return e===void 0&&(e=$a(t).getComputedStyle(t)),e.position==="fixed"}function _Ce(t,e){e===void 0&&(e=$a(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 Ew(t,e){const n=[];function i(r){if(e!=null&&n.length>=e||!r)return n;if(iD(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!W0(r)||xX(r)||n.includes(r))return n;const a=$a(t).getComputedStyle(r);return r!==t&&_Ce(r,a)&&n.push(r),bCe(r,a)?n:i(r.parentNode)}return t?i(t):n}function AX(t){const[e]=Ew(t,1);return e??null}function D2(t){return!Mw||!t?null:Nm(t)?t:nD(t)?iD(t)||t===Rm(t).scrollingElement?window:W0(t)?t:null:null}function TX(t){return Nm(t)?t.scrollX:t.scrollLeft}function CX(t){return Nm(t)?t.scrollY:t.scrollTop}function gR(t){return{x:TX(t),y:CX(t)}}var Er;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Er||(Er={}));function NX(t){return!Mw||!t?!1:t===document.scrollingElement}function RX(t){const e={x:0,y:0},n=NX(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 SCe={x:.2,y:.2};function wCe(t,e,n,i,r){let{top:a,left:s,right:o,bottom:l}=n;i===void 0&&(i=10),r===void 0&&(r=SCe);const{isTop:c,isBottom:u,isLeft:f,isRight:m}=RX(t),g={x:0,y:0},y={x:0,y:0},_={height:e.height*r.y,width:e.width*r.x};return!c&&a<=e.top+_.height?(g.y=Er.Backward,y.y=i*Math.abs((e.top+_.height-a)/_.height)):!u&&l>=e.bottom-_.height&&(g.y=Er.Forward,y.y=i*Math.abs((e.bottom-_.height-l)/_.height)),!m&&o>=e.right-_.width?(g.x=Er.Forward,y.x=i*Math.abs((e.right-_.width-o)/_.width)):!f&&s<=e.left+_.width&&(g.x=Er.Backward,y.x=i*Math.abs((e.left+_.width-s)/_.width)),{direction:g,speed:y}}function MCe(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 PX(t){return t.reduce((e,n)=>Dp(e,gR(n)),Mo)}function ECe(t){return t.reduce((e,n)=>e+TX(n),0)}function ACe(t){return t.reduce((e,n)=>e+CX(n),0)}function TCe(t,e){if(e===void 0&&(e=Pm),!t)return;const{top:n,left:i,bottom:r,right:a}=e(t);AX(t)&&(r<=0||a<=0||n>=window.innerHeight||i>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const CCe=[["x",["left","right"],ECe],["y",["top","bottom"],ACe]];class sD{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=Ew(n),r=PX(i);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,s,o]of CCe)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=o(i),u=r[a]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ix{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 NCe(t){const{EventTarget:e}=$a(t);return t instanceof e?t:Rm(t)}function O2(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 Ls;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Ls||(Ls={}));function R8(t){t.preventDefault()}function RCe(t){t.stopPropagation()}var bn;(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"})(bn||(bn={}));const kX={start:[bn.Space,bn.Enter],cancel:[bn.Esc],end:[bn.Space,bn.Enter,bn.Tab]},PCe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case bn.Right:return{...n,x:n.x+25};case bn.Left:return{...n,x:n.x-25};case bn.Down:return{...n,y:n.y+25};case bn.Up:return{...n,y:n.y-25}}};class Aw{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 Ix(Rm(n)),this.windowListeners=new Ix($a(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Ls.Resize,this.handleCancel),this.windowListeners.add(Ls.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Ls.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,i=e.node.current;i&&TCe(i),n(Mo)}handleKeyDown(e){if(aD(e)){const{active:n,context:i,options:r}=this.props,{keyboardCodes:a=kX,coordinateGetter:s=PCe,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,u=c?{x:c.left,y:c.top}:Mo;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(e,{active:n,context:i.current,currentCoordinates:u});if(f){const m=g0(f,u),g={x:0,y:0},{scrollableAncestors:y}=i.current;for(const _ of y){const v=e.code,{isTop:x,isRight:M,isLeft:w,isBottom:C,maxScroll:T,minScroll:P}=RX(_),A=MCe(_),j={x:Math.min(v===bn.Right?A.right-A.width/2:A.right,Math.max(v===bn.Right?A.left:A.left+A.width/2,f.x)),y:Math.min(v===bn.Down?A.bottom-A.height/2:A.bottom,Math.max(v===bn.Down?A.top:A.top+A.height/2,f.y))},N=v===bn.Right&&!M||v===bn.Left&&!w,k=v===bn.Down&&!C||v===bn.Up&&!x;if(N&&j.x!==f.x){const F=_.scrollLeft+m.x,I=v===bn.Right&&F<=T.x||v===bn.Left&&F>=P.x;if(I&&!m.y){_.scrollTo({left:F,behavior:o});return}I?g.x=_.scrollLeft-F:g.x=v===bn.Right?_.scrollLeft-T.x:_.scrollLeft-P.x,g.x&&_.scrollBy({left:-g.x,behavior:o});break}else if(k&&j.y!==f.y){const F=_.scrollTop+m.y,I=v===bn.Down&&F<=T.y||v===bn.Up&&F>=P.y;if(I&&!m.x){_.scrollTo({top:F,behavior:o});return}I?g.y=_.scrollTop-F:g.y=v===bn.Down?_.scrollTop-T.y:_.scrollTop-P.y,g.y&&_.scrollBy({top:-g.y,behavior:o});break}}this.handleMove(e,Dp(g0(f,this.referenceCoordinates),g))}}}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()}}Aw.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:i=kX,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 P8(t){return!!(t&&"distance"in t)}function k8(t){return!!(t&&"delay"in t)}class oD{constructor(e,n,i){var r;i===void 0&&(i=NCe(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=Rm(s),this.documentListeners=new Ix(this.document),this.listeners=new Ix(i),this.windowListeners=new Ix($a(s)),this.initialCoordinates=(r=mR(a))!=null?r:Mo,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(Ls.Resize,this.handleCancel),this.windowListeners.add(Ls.DragStart,R8),this.windowListeners.add(Ls.VisibilityChange,this.handleCancel),this.windowListeners.add(Ls.ContextMenu,R8),this.documentListeners.add(Ls.Keydown,this.handleKeydown),n){if(i!=null&&i({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(k8(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(P8(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(Ls.Click,RCe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Ls.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=mR(e))!=null?n:Mo,c=g0(r,l);if(!i&&o){if(P8(o)){if(o.tolerance!=null&&O2(c,o.tolerance))return this.handleCancel();if(O2(c,o.distance))return this.handleStart()}if(k8(o)&&O2(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===bn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const kCe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Tw extends oD{constructor(e){const{event:n}=e,i=Rm(n.target);super(e,kCe,i)}}Tw.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 DCe={move:{name:"mousemove"},end:{name:"mouseup"}};var xR;(function(t){t[t.RightClick=2]="RightClick"})(xR||(xR={}));class OCe extends oD{constructor(e){super(e,DCe,Rm(e.event.target))}}OCe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:i}=e;return n.button===xR.RightClick?!1:(i?.({event:n}),!0)}}];const L2={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class LCe extends oD{constructor(e){super(e,L2)}static setup(){return window.addEventListener(L2.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(L2.move.name,e)};function e(){}}}LCe.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 jx;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(jx||(jx={}));var Y1;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Y1||(Y1={}));function ICe(t){let{acceleration:e,activator:n=jx.Pointer,canScroll:i,draggingRect:r,enabled:a,interval:s=5,order:o=Y1.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:m}=t;const g=UCe({delta:f,disabled:!a}),[y,_]=Y2e(),v=E.useRef({x:0,y:0}),x=E.useRef({x:0,y:0}),M=E.useMemo(()=>{switch(n){case jx.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case jx.DraggableRect:return r}},[n,r,l]),w=E.useRef(null),C=E.useCallback(()=>{const P=w.current;if(!P)return;const A=v.current.x*x.current.x,j=v.current.y*x.current.y;P.scrollBy(A,j)},[]),T=E.useMemo(()=>o===Y1.TreeOrder?[...c].reverse():c,[o,c]);E.useEffect(()=>{if(!a||!c.length||!M){_();return}for(const P of T){if(i?.(P)===!1)continue;const A=c.indexOf(P),j=u[A];if(!j)continue;const{direction:N,speed:k}=wCe(P,j,M,e,m);for(const F of["x","y"])g[F][N[F]]||(k[F]=0,N[F]=0);if(k.x>0||k.y>0){_(),w.current=P,y(C,s),v.current=k,x.current=N;return}}v.current={x:0,y:0},x.current={x:0,y:0},_()},[e,C,i,_,a,s,JSON.stringify(M),JSON.stringify(g),y,c,T,u,JSON.stringify(m)])}const jCe={x:{[Er.Backward]:!1,[Er.Forward]:!1},y:{[Er.Backward]:!1,[Er.Forward]:!1}};function UCe(t){let{delta:e,disabled:n}=t;const i=pR(e);return q0(r=>{if(n||!i||!r)return jCe;const a={x:Math.sign(e.x-i.x),y:Math.sign(e.y-i.y)};return{x:{[Er.Backward]:r.x[Er.Backward]||a.x===-1,[Er.Forward]:r.x[Er.Forward]||a.x===1},y:{[Er.Backward]:r.y[Er.Backward]||a.y===-1,[Er.Forward]:r.y[Er.Forward]||a.y===1}}},[n,e,i])}function FCe(t,e){const n=e!=null?t.get(e):void 0,i=n?n.node.current:null;return q0(r=>{var a;return e==null?null:(a=i??r)!=null?a:null},[i,e])}function zCe(t,e){return E.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 x0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(x0||(x0={}));var vR;(function(t){t.Optimized="optimized"})(vR||(vR={}));const D8=new Map;function BCe(t,e){let{dragging:n,dependencies:i,config:r}=e;const[a,s]=E.useState(null),{frequency:o,measure:l,strategy:c}=r,u=E.useRef(t),f=v(),m=m0(f),g=E.useCallback(function(x){x===void 0&&(x=[]),!m.current&&s(M=>M===null?x:M.concat(x.filter(w=>!M.includes(w))))},[m]),y=E.useRef(null),_=q0(x=>{if(f&&!n)return D8;if(!x||x===D8||u.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 C=w.node.current,T=C?new sD(l(C),C):null;w.rect.current=T,T&&M.set(w.id,T)}return M}return x},[t,a,n,f,l]);return E.useEffect(()=>{u.current=t},[t]),E.useEffect(()=>{f||g()},[n,f]),E.useEffect(()=>{a&&a.length>0&&s(null)},[JSON.stringify(a)]),E.useEffect(()=>{f||typeof o!="number"||y.current!==null||(y.current=setTimeout(()=>{g(),y.current=null},o))},[o,f,g,...i]),{droppableRects:_,measureDroppableContainers:g,measuringScheduled:a!=null};function v(){switch(c){case x0.Always:return!1;case x0.BeforeDragging:return n;default:return!n}}}function DX(t,e){return q0(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function HCe(t,e){return DX(t,e)}function $Ce(t){let{callback:e,disabled:n}=t;const i=rD(e),r=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(i)},[i,n]);return E.useEffect(()=>()=>r?.disconnect(),[r]),r}function Cw(t){let{callback:e,disabled:n}=t;const i=rD(e),r=E.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(i)},[n]);return E.useEffect(()=>()=>r?.disconnect(),[r]),r}function VCe(t){return new sD(Pm(t),t)}function O8(t,e,n){e===void 0&&(e=VCe);const[i,r]=E.useState(null);function a(){r(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=$Ce({callback(l){if(t)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),o=Cw({callback:a});return rl(()=>{a(),t?(o?.observe(t),s?.observe(document.body,{childList:!0,subtree:!0})):(o?.disconnect(),s?.disconnect())},[t]),i}function GCe(t){const e=DX(t);return EX(t,e)}const L8=[];function WCe(t){const e=E.useRef(t),n=q0(i=>t?i&&i!==L8&&t&&e.current&&t.parentNode===e.current.parentNode?i:Ew(t):L8,[t]);return E.useEffect(()=>{e.current=t},[t]),n}function qCe(t){const[e,n]=E.useState(null),i=E.useRef(t),r=E.useCallback(a=>{const s=D2(a.target);s&&n(o=>o?(o.set(s,gR(s)),new Map(o)):null)},[]);return E.useEffect(()=>{const a=i.current;if(t!==a){s(a);const o=t.map(l=>{const c=D2(l);return c?(c.addEventListener("scroll",r,{passive:!0}),[c,gR(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=D2(l);c?.removeEventListener("scroll",r)})}},[r,t]),E.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,s)=>Dp(a,s),Mo):PX(t):Mo,[t,e])}function I8(t,e){e===void 0&&(e=[]);const n=E.useRef(null);return E.useEffect(()=>{n.current=null},e),E.useEffect(()=>{const i=t!==Mo;i&&!n.current&&(n.current=t),!i&&n.current&&(n.current=null)},[t]),n.current?g0(t,n.current):Mo}function XCe(t){E.useEffect(()=>{if(!Mw)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 KCe(t,e){return E.useMemo(()=>t.reduce((n,i)=>{let{eventName:r,handler:a}=i;return n[r]=s=>{a(s,e)},n},{}),[t,e])}function OX(t){return E.useMemo(()=>t?yCe(t):null,[t])}const j8=[];function YCe(t,e){e===void 0&&(e=Pm);const[n]=t,i=OX(n?$a(n):null),[r,a]=E.useState(j8);function s(){a(()=>t.length?t.map(l=>NX(l)?i:new sD(e(l),l)):j8)}const o=Cw({callback:s});return rl(()=>{o?.disconnect(),s(),t.forEach(l=>o?.observe(l))},[t]),r}function ZCe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return W0(e)?e:t}function QCe(t){let{measure:e}=t;const[n,i]=E.useState(null),r=E.useCallback(c=>{for(const{target:u}of c)if(W0(u)){i(f=>{const m=e(u);return f?{...f,width:m.width,height:m.height}:m});break}},[e]),a=Cw({callback:r}),s=E.useCallback(c=>{const u=ZCe(c);a?.disconnect(),u&&a?.observe(u),i(u?e(u):null)},[e,a]),[o,l]=q1(s);return E.useMemo(()=>({nodeRef:o,rect:n,setRef:l}),[n,o,l])}const JCe=[{sensor:Tw,options:{}},{sensor:Aw,options:{}}],eNe={current:{}},N_={draggable:{measure:N8},droppable:{measure:N8,strategy:x0.WhileDragging,frequency:vR.Optimized},dragOverlay:{measure:Pm}};class Ux 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 tNe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ux,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:X1},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:N_,measureDroppableContainers:X1,windowRect:null,measuringScheduled:!1},nNe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:X1,draggableNodes:new Map,over:null,measureDroppableContainers:X1},Nw=E.createContext(nNe),LX=E.createContext(tNe);function iNe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ux}}}function rNe(t,e){switch(e.type){case ir.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case ir.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 ir.DragEnd:case ir.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ir.RegisterDroppable:{const{element:n}=e,{id:i}=n,r=new Ux(t.droppable.containers);return r.set(i,n),{...t,droppable:{...t.droppable,containers:r}}}case ir.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 Ux(t.droppable.containers);return s.set(n,{...a,disabled:r}),{...t,droppable:{...t.droppable,containers:s}}}case ir.UnregisterDroppable:{const{id:n,key:i}=e,r=t.droppable.containers.get(n);if(!r||i!==r.key)return t;const a=new Ux(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function aNe(t){let{disabled:e}=t;const{active:n,activatorEvent:i,draggableNodes:r}=E.useContext(Nw),a=pR(i),s=pR(n?.id);return E.useEffect(()=>{if(!e&&!i&&a&&s!=null){if(!aD(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 u of[l.current,c.current]){if(!u)continue;const f=J2e(u);if(f){f.focus();break}}})}},[i,e,r,s,a]),null}function sNe(t,e){let{transform:n,...i}=e;return t!=null&&t.length?t.reduce((r,a)=>a({transform:r,...i}),n):n}function oNe(t){return E.useMemo(()=>({draggable:{...N_.draggable,...t?.draggable},droppable:{...N_.droppable,...t?.droppable},dragOverlay:{...N_.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function lNe(t){let{activeNode:e,measure:n,initialRect:i,config:r=!0}=t;const a=E.useRef(!1),{x:s,y:o}=typeof r=="boolean"?{x:r,y:r}:r;rl(()=>{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 u=n(c),f=EX(u,i);if(s||(f.x=0),o||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const m=AX(c);m&&m.scrollBy({top:f.y,left:f.x})}},[e,s,o,i,n])}const IX=E.createContext({...Mo,scaleX:1,scaleY:1});var Mu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Mu||(Mu={}));const jX=E.memo(function(e){var n,i,r,a;let{id:s,accessibility:o,autoScroll:l=!0,children:c,sensors:u=JCe,collisionDetection:f=fCe,measuring:m,modifiers:g,...y}=e;const _=E.useReducer(rNe,void 0,iNe),[v,x]=_,[M,w]=aCe(),[C,T]=E.useState(Mu.Uninitialized),P=C===Mu.Initialized,{draggable:{active:A,nodes:j,translate:N},droppable:{containers:k}}=v,F=A!=null?j.get(A):null,I=E.useRef({initial:null,translated:null}),W=E.useMemo(()=>{var Oe;return A!=null?{id:A,data:(Oe=F?.data)!=null?Oe:eNe,rect:I}:null},[A,F]),D=E.useRef(null),[B,$]=E.useState(null),[K,X]=E.useState(null),Y=m0(y,Object.values(y)),ee=X0("DndDescribedBy",s),z=E.useMemo(()=>k.getEnabled(),[k]),V=oNe(m),{droppableRects:re,measureDroppableContainers:le,measuringScheduled:ge}=BCe(z,{dragging:P,dependencies:[N.x,N.y],config:V.droppable}),ie=FCe(j,A),xe=E.useMemo(()=>K?mR(K):null,[K]),ke=fe(),he=HCe(ie,V.draggable.measure);lNe({activeNode:A!=null?j.get(A):null,config:ke.layoutShiftCompensation,initialRect:he,measure:V.draggable.measure});const we=O8(ie,V.draggable.measure,he),Ue=O8(ie?ie.parentElement:null),ue=E.useRef({activatorEvent:null,active:null,activeNode:ie,collisionRect:null,collisions:null,droppableRects:re,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),lt=k.getNodeFor((n=ue.current.over)==null?void 0:n.id),H=QCe({measure:V.dragOverlay.measure}),q=(i=H.nodeRef.current)!=null?i:ie,oe=P?(r=H.rect)!=null?r:we:null,Z=!!(H.nodeRef.current&&H.rect),Q=GCe(Z?null:we),se=OX(q?$a(q):null),Ce=WCe(P?lt??ie:null),Ee=YCe(Ce),ne=sNe(g,{transform:{x:N.x-Q.x,y:N.y-Q.y,scaleX:1,scaleY:1},activatorEvent:K,active:W,activeNodeRect:we,containerNodeRect:Ue,draggingNodeRect:oe,over:ue.current.over,overlayNodeRect:H.rect,scrollableAncestors:Ce,scrollableAncestorRects:Ee,windowRect:se}),U=xe?Dp(xe,N):null,L=qCe(Ce),J=I8(L),me=I8(L,[we]),ye=Dp(ne,J),pe=oe?mCe(oe,ne):null,Qe=W&&pe?f({active:W,collisionRect:pe,droppableRects:re,droppableContainers:z,pointerCoordinates:U}):null,Le=wX(Qe,"id"),[Xe,st]=E.useState(null),Ie=Z?ne:Dp(ne,me),Pe=hCe(Ie,(a=Xe?.rect)!=null?a:null,we),pt=E.useRef(null),it=E.useCallback((Oe,Me)=>{let{sensor:ve,options:Be}=Me;if(D.current==null)return;const ct=j.get(D.current);if(!ct)return;const bt=Oe.nativeEvent,Rt=new ve({active:D.current,activeNode:ct,event:bt,options:Be,context:ue,onAbort(Ot){if(!j.get(Ot))return;const{onDragAbort:qn}=Y.current,mr={id:Ot};qn?.(mr),M({type:"onDragAbort",event:mr})},onPending(Ot,Rn,qn,mr){if(!j.get(Ot))return;const{onDragPending:gr}=Y.current,Pr={id:Ot,constraint:Rn,initialCoordinates:qn,offset:mr};gr?.(Pr),M({type:"onDragPending",event:Pr})},onStart(Ot){const Rn=D.current;if(Rn==null)return;const qn=j.get(Rn);if(!qn)return;const{onDragStart:mr}=Y.current,Qi={activatorEvent:bt,active:{id:Rn,data:qn.data,rect:I}};Zl.unstable_batchedUpdates(()=>{mr?.(Qi),T(Mu.Initializing),x({type:ir.DragStart,initialCoordinates:Ot,active:Rn}),M({type:"onDragStart",event:Qi}),$(pt.current),X(bt)})},onMove(Ot){x({type:ir.DragMove,coordinates:Ot})},onEnd:ln(ir.DragEnd),onCancel:ln(ir.DragCancel)});pt.current=Rt;function ln(Ot){return async function(){const{active:qn,collisions:mr,over:Qi,scrollAdjustedTranslate:gr}=ue.current;let Pr=null;if(qn&&gr){const{cancelDrop:qr}=Y.current;Pr={activatorEvent:bt,active:qn,collisions:mr,delta:gr,over:Qi},Ot===ir.DragEnd&&typeof qr=="function"&&await Promise.resolve(qr(Pr))&&(Ot=ir.DragCancel)}D.current=null,Zl.unstable_batchedUpdates(()=>{x({type:Ot}),T(Mu.Uninitialized),st(null),$(null),X(null),pt.current=null;const qr=Ot===ir.DragEnd?"onDragEnd":"onDragCancel";if(Pr){const Ii=Y.current[qr];Ii?.(Pr),M({type:qr,event:Pr})}})}}},[j]),nt=E.useCallback((Oe,Me)=>(ve,Be)=>{const ct=ve.nativeEvent,bt=j.get(Be);if(D.current!==null||!bt||ct.dndKit||ct.defaultPrevented)return;const Rt={active:bt};Oe(ve,Me.options,Rt)===!0&&(ct.dndKit={capturedBy:Me.sensor},D.current=Be,it(ve,Me))},[j,it]),dt=zCe(u,nt);XCe(u),rl(()=>{we&&C===Mu.Initializing&&T(Mu.Initialized)},[we,C]),E.useEffect(()=>{const{onDragMove:Oe}=Y.current,{active:Me,activatorEvent:ve,collisions:Be,over:ct}=ue.current;if(!Me||!ve)return;const bt={active:Me,activatorEvent:ve,collisions:Be,delta:{x:ye.x,y:ye.y},over:ct};Zl.unstable_batchedUpdates(()=>{Oe?.(bt),M({type:"onDragMove",event:bt})})},[ye.x,ye.y]),E.useEffect(()=>{const{active:Oe,activatorEvent:Me,collisions:ve,droppableContainers:Be,scrollAdjustedTranslate:ct}=ue.current;if(!Oe||D.current==null||!Me||!ct)return;const{onDragOver:bt}=Y.current,Rt=Be.get(Le),ln=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,Ot={active:Oe,activatorEvent:Me,collisions:ve,delta:{x:ct.x,y:ct.y},over:ln};Zl.unstable_batchedUpdates(()=>{st(ln),bt?.(Ot),M({type:"onDragOver",event:Ot})})},[Le]),rl(()=>{ue.current={activatorEvent:K,active:W,activeNode:ie,collisionRect:pe,collisions:Qe,droppableRects:re,draggableNodes:j,draggingNode:q,draggingNodeRect:oe,droppableContainers:k,over:Xe,scrollableAncestors:Ce,scrollAdjustedTranslate:ye},I.current={initial:oe,translated:pe}},[W,ie,Qe,pe,j,q,oe,re,k,Xe,Ce,ye]),ICe({...ke,delta:N,draggingRect:pe,pointerCoordinates:U,scrollableAncestors:Ce,scrollableAncestorRects:Ee});const de=E.useMemo(()=>({active:W,activeNode:ie,activeNodeRect:we,activatorEvent:K,collisions:Qe,containerNodeRect:Ue,dragOverlay:H,draggableNodes:j,droppableContainers:k,droppableRects:re,over:Xe,measureDroppableContainers:le,scrollableAncestors:Ce,scrollableAncestorRects:Ee,measuringConfiguration:V,measuringScheduled:ge,windowRect:se}),[W,ie,we,K,Qe,Ue,H,j,k,re,Xe,le,Ce,Ee,V,ge,se]),rt=E.useMemo(()=>({activatorEvent:K,activators:dt,active:W,activeNodeRect:we,ariaDescribedById:{draggable:ee},dispatch:x,draggableNodes:j,over:Xe,measureDroppableContainers:le}),[K,dt,W,we,x,ee,j,Xe,le]);return ui.createElement(yX.Provider,{value:w},ui.createElement(Nw.Provider,{value:rt},ui.createElement(LX.Provider,{value:de},ui.createElement(IX.Provider,{value:Pe},c)),ui.createElement(aNe,{disabled:o?.restoreFocus===!1})),ui.createElement(lCe,{...o,hiddenTextDescribedById:ee}));function fe(){const Oe=B?.autoScrollEnabled===!1,Me=typeof l=="object"?l.enabled===!1:l===!1,ve=P&&!Oe&&!Me;return typeof l=="object"?{...l,enabled:ve}:{enabled:ve}}}),cNe=E.createContext(null),U8="button",uNe="Draggable";function dNe(t){let{id:e,data:n,disabled:i=!1,attributes:r}=t;const a=X0(uNe),{activators:s,activatorEvent:o,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:m}=E.useContext(Nw),{role:g=U8,roleDescription:y="draggable",tabIndex:_=0}=r??{},v=l?.id===e,x=E.useContext(v?IX:cNe),[M,w]=q1(),[C,T]=q1(),P=KCe(s,e),A=m0(n);rl(()=>(f.set(e,{id:e,key:a,node:M,activatorNode:C,data:A}),()=>{const N=f.get(e);N&&N.key===a&&f.delete(e)}),[f,e]);const j=E.useMemo(()=>({role:g,tabIndex:_,"aria-disabled":i,"aria-pressed":v&&g===U8?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[i,g,_,v,y,u.draggable]);return{active:l,activatorEvent:o,activeNodeRect:c,attributes:j,isDragging:v,listeners:i?void 0:P,node:M,over:m,setNodeRef:w,setActivatorNodeRef:T,transform:x}}function fNe(){return E.useContext(LX)}const hNe="Droppable",pNe={timeout:25};function mNe(t){let{data:e,disabled:n=!1,id:i,resizeObserverConfig:r}=t;const a=X0(hNe),{active:s,dispatch:o,over:l,measureDroppableContainers:c}=E.useContext(Nw),u=E.useRef({disabled:n}),f=E.useRef(!1),m=E.useRef(null),g=E.useRef(null),{disabled:y,updateMeasurementsFor:_,timeout:v}={...pNe,...r},x=m0(_??i),M=E.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(x.current)?x.current:[x.current]),g.current=null},v)},[v]),w=Cw({callback:M,disabled:y||!s}),C=E.useCallback((j,N)=>{w&&(N&&(w.unobserve(N),f.current=!1),j&&w.observe(j))},[w]),[T,P]=q1(C),A=m0(e);return E.useEffect(()=>{!w||!T.current||(w.disconnect(),f.current=!1,w.observe(T.current))},[T,w]),E.useEffect(()=>(o({type:ir.RegisterDroppable,element:{id:i,key:a,disabled:n,node:T,rect:m,data:A}}),()=>o({type:ir.UnregisterDroppable,key:a,id:i})),[i]),E.useEffect(()=>{n!==u.current.disabled&&(o({type:ir.SetDroppableDisabled,id:i,key:a,disabled:n}),u.current.disabled=n)},[i,a,n,o]),{active:s,rect:m,isOver:l?.id===i,node:T,over:l,setNodeRef:P}}function Rw(t,e,n){const i=t.slice();return i.splice(n<0?i.length+n:n,0,i.splice(e,1)[0]),i}function gNe(t,e){return t.reduce((n,i,r)=>{const a=e.get(i);return a&&(n[r]=a),n},Array(t.length))}function Gb(t){return t!==null&&t>=0}function xNe(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 vNe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const lD=t=>{let{rects:e,activeIndex:n,overIndex:i,index:r}=t;const a=Rw(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}},Wb={scaleX:1,scaleY:1},yNe=t=>{var e;let{activeIndex:n,activeNodeRect:i,index:r,rects:a,overIndex:s}=t;const o=(e=a[n])!=null?e:i;if(!o)return null;if(r===n){const c=a[s];return c?{x:0,y:n<s?c.top+c.height-(o.top+o.height):c.top-o.top,...Wb}:null}const l=bNe(a,r,n);return r>n&&r<=s?{x:0,y:-o.height-l,...Wb}:r<n&&r>=s?{x:0,y:o.height+l,...Wb}:{x:0,y:0,...Wb}};function bNe(t,e,n){const i=t[e],r=t[e-1],a=t[e+1];return i?n<e?r?i.top-(r.top+r.height):a?a.top-(i.top+i.height):0:a?a.top-(i.top+i.height):r?i.top-(r.top+r.height):0:0}const UX="Sortable",FX=ui.createContext({activeIndex:-1,containerId:UX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lD,disabled:{draggable:!1,droppable:!1}});function zX(t){let{children:e,id:n,items:i,strategy:r=lD,disabled:a=!1}=t;const{active:s,dragOverlay:o,droppableRects:l,over:c,measureDroppableContainers:u}=fNe(),f=X0(UX,n),m=o.rect!==null,g=E.useMemo(()=>i.map(P=>typeof P=="object"&&"id"in P?P.id:P),[i]),y=s!=null,_=s?g.indexOf(s.id):-1,v=c?g.indexOf(c.id):-1,x=E.useRef(g),M=!xNe(g,x.current),w=v!==-1&&_===-1||M,C=vNe(a);rl(()=>{M&&y&&u(g)},[M,g,y,u]),E.useEffect(()=>{x.current=g},[g]);const T=E.useMemo(()=>({activeIndex:_,containerId:f,disabled:C,disableTransforms:w,items:g,overIndex:v,useDragOverlay:m,sortedRects:gNe(g,l),strategy:r}),[_,f,C.draggable,C.droppable,w,g,v,l,m,r]);return ui.createElement(FX.Provider,{value:T},e)}const _Ne=t=>{let{id:e,items:n,activeIndex:i,overIndex:r}=t;return Rw(n,i,r).indexOf(e)},SNe=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},wNe={duration:200,easing:"ease"},BX="transform",MNe=om.Transition.toString({property:BX,duration:0,easing:"linear"}),ENe={roleDescription:"sortable"};function ANe(t){let{disabled:e,index:n,node:i,rect:r}=t;const[a,s]=E.useState(null),o=E.useRef(n);return rl(()=>{if(!e&&n!==o.current&&i.current){const l=r.current;if(l){const c=Pm(i.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==o.current&&(o.current=n)},[e,n,i,r]),E.useEffect(()=>{a&&s(null)},[a]),a}function HX(t){let{animateLayoutChanges:e=SNe,attributes:n,disabled:i,data:r,getNewIndex:a=_Ne,id:s,strategy:o,resizeObserverConfig:l,transition:c=wNe}=t;const{items:u,containerId:f,activeIndex:m,disabled:g,disableTransforms:y,sortedRects:_,overIndex:v,useDragOverlay:x,strategy:M}=E.useContext(FX),w=TNe(i,g),C=u.indexOf(s),T=E.useMemo(()=>({sortable:{containerId:f,index:C,items:u},...r}),[f,r,C,u]),P=E.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:A,node:j,isOver:N,setNodeRef:k}=mNe({id:s,data:T,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:P,...l}}),{active:F,activatorEvent:I,activeNodeRect:W,attributes:D,setNodeRef:B,listeners:$,isDragging:K,over:X,setActivatorNodeRef:Y,transform:ee}=dNe({id:s,data:T,attributes:{...ENe,...n},disabled:w.draggable}),z=K2e(k,B),V=!!F,re=V&&!y&&Gb(m)&&Gb(v),le=!x&&K,ge=le&&re?ee:null,xe=re?ge??(o??M)({rects:_,activeNodeRect:W,activeIndex:m,overIndex:v,index:C}):null,ke=Gb(m)&&Gb(v)?a({id:s,items:u,activeIndex:m,overIndex:v}):C,he=F?.id,we=E.useRef({activeId:he,items:u,newIndex:ke,containerId:f}),Ue=u!==we.current.items,ue=e({active:F,containerId:f,isDragging:K,isSorting:V,id:s,index:C,items:u,newIndex:we.current.newIndex,previousItems:we.current.items,previousContainerId:we.current.containerId,transition:c,wasDragging:we.current.activeId!=null}),lt=ANe({disabled:!ue,index:C,node:j,rect:A});return E.useEffect(()=>{V&&we.current.newIndex!==ke&&(we.current.newIndex=ke),f!==we.current.containerId&&(we.current.containerId=f),u!==we.current.items&&(we.current.items=u)},[V,ke,f,u]),E.useEffect(()=>{if(he===we.current.activeId)return;if(he!=null&&we.current.activeId==null){we.current.activeId=he;return}const q=setTimeout(()=>{we.current.activeId=he},50);return()=>clearTimeout(q)},[he]),{active:F,activeIndex:m,attributes:D,data:T,rect:A,index:C,newIndex:ke,items:u,isOver:N,isSorting:V,isDragging:K,listeners:$,node:j,overIndex:v,over:X,setNodeRef:z,setActivatorNodeRef:Y,setDroppableNodeRef:k,setDraggableNodeRef:B,transform:lt??xe,transition:H()};function H(){if(lt||Ue&&we.current.newIndex===C)return MNe;if(!(le&&!aD(I)||!c)&&(V||ue))return om.Transition.toString({...c,property:BX})}}function TNe(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 Z1(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 CNe=[bn.Down,bn.Right,bn.Up,bn.Left],$X=(t,e)=>{let{context:{active:n,collisionRect:i,droppableRects:r,droppableContainers:a,over:s,scrollableAncestors:o}}=e;if(CNe.includes(t.code)){if(t.preventDefault(),!n||!i)return;const l=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=r.get(f.id);if(m)switch(t.code){case bn.Down:i.top<m.top&&l.push(f);break;case bn.Up:i.top>m.top&&l.push(f);break;case bn.Left:i.left>m.left&&l.push(f);break;case bn.Right:i.left<m.left&&l.push(f);break}});const c=uCe({collisionRect:i,droppableRects:r,droppableContainers:l});let u=wX(c,"id");if(u===s?.id&&c.length>1&&(u=c[1].id),u!=null){const f=a.get(n.id),m=a.get(u),g=m?r.get(m.id):null,y=m?.node.current;if(y&&g&&f&&m){const v=Ew(y).some((P,A)=>o[A]!==P),x=VX(f,m),M=NNe(f,m),w=v||!x?{x:0,y:0}:{x:M?i.width-g.width:0,y:M?i.height-g.height:0},C={x:g.left,y:g.top};return w.x&&w.y?C:g0(C,w)}}}};function VX(t,e){return!Z1(t)||!Z1(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function NNe(t,e){return!Z1(t)||!Z1(e)||!VX(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function RNe({item:t,onClose:e}){const n=In(),{showToast:i}=wa(),[r,a]=E.useState(t.printer_id),s=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[o,l]=E.useState(t.scheduled_time&&!s?"scheduled":"asap"),[c,u]=E.useState(()=>t.scheduled_time&&!s?new Date(t.scheduled_time).toISOString().slice(0,16):""),[f,m]=E.useState(t.require_previous_success),[g,y]=E.useState(t.auto_off_after),{data:_}=Dt({queryKey:["printers"],queryFn:()=>$e.getPrinters()});E.useEffect(()=>{const w=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e]);const v=Nt({mutationFn:w=>$e.updateQueueItem(t.id,w),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),i("Queue item updated"),e()},onError:w=>{i(w.message||"Failed to update queue item","error")}}),x=w=>{w.preventDefault();const C={printer_id:r,require_previous_success:f,auto_off_after:g};o==="scheduled"&&c?C.scheduled_time=new Date(c).toISOString():C.scheduled_time=null,v.mutate(C)},M=()=>{const w=new Date;return w.setMinutes(w.getMinutes()+1),w.toISOString().slice(0,16)};return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:h.jsx($t,{className:"w-full max-w-md",onClick:w=>w.stopPropagation(),children:h.jsxs(Qt,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(zp,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:x,className:"p-4 space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),h.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),_?.length===0?h.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[h.jsx(Ec,{className:"w-4 h-4"}),"No printers configured"]}):h.jsx("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:r,onChange:w=>a(Number(w.target.value)),required:!0,children:_?.map(w=>h.jsx("option",{value:w.id,children:w.name},w.id))})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),h.jsxs("div",{className:"flex gap-2",children:[h.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:[h.jsx(ar,{className:"w-4 h-4"}),"ASAP (when idle)"]}),h.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:[h.jsx(Zo,{className:"w-4 h-4"}),"Scheduled"]})]})]}),o==="scheduled"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),h.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=>u(w.target.value),min:M(),required:!0})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:w=>m(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:g,onChange:w=>y(w.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),h.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[h.jsx(Bf,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),h.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."}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(Ye,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsx(Ye,{type:"submit",className:"flex-1",disabled:v.isPending||_?.length===0,children:v.isPending?"Saving...":"Save Changes"})]})]})]})})})}function GX(t){if(!t)return"--";const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function PNe(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 kNe({status:t}){const e={pending:{icon:ar,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:YS,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:hc,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:j0,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:r9,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:Sn,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:i,label:r}=e[t];return h.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${i}`,children:[h.jsx(n,{className:"w-3.5 h-3.5"}),r]})}function I2({item:t,position:e,onEdit:n,onCancel:i,onRemove:r,onStop:a,onRequeue:s}){const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:f,isDragging:m}=HX({id:t.id,disabled:t.status!=="pending"}),g={transform:om.Transform.toString(u),transition:f},y=t.status==="printing",_=t.status==="pending",v=["completed","failed","skipped","cancelled"].includes(t.status);return h.jsx("div",{ref:c,style:g,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${m?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${y?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:h.jsxs("div",{className:"flex items-center gap-4 p-4",children:[_?h.jsx("div",{...o,...l,className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors",children:h.jsx(FP,{className:"w-4 h-4 text-bambu-gray"})}):e!==void 0?h.jsxs("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium",children:["#",e]}):h.jsx("div",{className:"w-8"}),h.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?h.jsx("img",{src:$e.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):h.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:h.jsx(Fp,{className:"w-6 h-6"})})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),h.jsx(XS,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:h.jsx(mc,{className:"w-3.5 h-3.5"})})]}),h.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx(Qo,{className:"w-3.5 h-3.5"}),t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx(s9,{className:"w-3.5 h-3.5"}),GX(t.print_time_seconds)]}),_&&h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx(ar,{className:"w-3.5 h-3.5"}),PNe(t.scheduled_time)]})]}),h.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.require_previous_success&&h.jsx("span",{className:"text-xs px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20",children:"Requires previous success"}),t.auto_off_after&&h.jsxs("span",{className:"text-xs px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1",children:[h.jsx(Bf,{className:"w-3 h-3"}),"Auto power off"]})]}),y&&h.jsxs("div",{className:"mt-3",children:[h.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:h.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&h.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[h.jsx(Ec,{className:"w-3 h-3"}),t.error_message]})]}),h.jsx(kNe,{status:t.status}),h.jsxs("div",{className:"flex items-center gap-1",children:[y&&h.jsx(Ye,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:h.jsx(sse,{className:"w-4 h-4"})}),_&&h.jsxs(h.Fragment,{children:[h.jsx(Ye,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:h.jsx(zp,{className:"w-4 h-4"})}),h.jsx(Ye,{variant:"ghost",size:"sm",onClick:i,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:h.jsx(Sn,{className:"w-4 h-4"})})]}),v&&h.jsxs(h.Fragment,{children:[h.jsx(Ye,{variant:"ghost",size:"sm",onClick:s,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:h.jsx(wo,{className:"w-4 h-4"})}),h.jsx(Ye,{variant:"ghost",size:"sm",onClick:r,title:"Remove",children:h.jsx(Ei,{className:"w-4 h-4"})})]})]})]})})}function DNe(){const t=In(),{showToast:e}=wa(),[n,i]=E.useState(null),[r,a]=E.useState(""),[s,o]=E.useState(!1),[l,c]=E.useState(null),[u,f]=E.useState(null),[m,g]=E.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[y,_]=E.useState(()=>{const Y=localStorage.getItem("queue.historySortAsc");return Y!==null?Y==="true":!1}),[v,x]=E.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[M,w]=E.useState(()=>{const Y=localStorage.getItem("queue.pendingSortAsc");return Y!==null?Y==="true":!0});E.useEffect(()=>{localStorage.setItem("queue.historySortBy",m)},[m]),E.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(y))},[y]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",v)},[v]),E.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(M))},[M]);const C=bX(K1(Tw,{activationConstraint:{distance:8}}),K1(Aw,{coordinateGetter:$X})),{data:T,isLoading:P}=Dt({queryKey:["queue",n,r],queryFn:()=>$e.getQueue(n||void 0,r||void 0),refetchInterval:5e3}),{data:A}=Dt({queryKey:["printers"],queryFn:()=>$e.getPrinters()}),j=Nt({mutationFn:Y=>$e.cancelQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),N=Nt({mutationFn:Y=>$e.removeFromQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),k=Nt({mutationFn:Y=>$e.stopQueueItem(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),F=Nt({mutationFn:Y=>$e.reorderQueue(Y),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),I=Nt({mutationFn:Y=>{const ee=new Date;return ee.setFullYear(ee.getFullYear()+1),$e.addToQueue({printer_id:Y.printer_id,archive_id:Y.archive_id,scheduled_time:ee.toISOString(),require_previous_success:!1,auto_off_after:!1})},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e("Added back to queue - please set schedule"),c(Y)},onError:Y=>e(Y.message||"Failed to re-queue item","error")}),W=Nt({mutationFn:async()=>{const Y=T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[];for(const ee of Y)await $e.removeFromQueue(ee.id);return Y.length},onSuccess:Y=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${Y} history item${Y!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),D=E.useMemo(()=>{const Y=T?.filter(z=>z.status==="pending")||[],ee=z=>{if(!z.scheduled_time)return 0;const V=new Date(z.scheduled_time).getTime(),re=Date.now()+4320*60*60*1e3;return V>re?0:V};return[...Y].sort((z,V)=>{let re;return v==="name"?re=(z.archive_name||"").localeCompare(V.archive_name||""):v==="printer"?re=(z.printer_name||"").localeCompare(V.printer_name||""):v==="time"?re=ee(z)-ee(V):re=z.position-V.position,M?re:-re})},[T,v,M]),B=T?.filter(Y=>Y.status==="printing")||[],$=E.useMemo(()=>[...T?.filter(ee=>["completed","failed","skipped","cancelled"].includes(ee.status))||[]].sort((ee,z)=>{let V;return m==="name"?V=(ee.archive_name||"").localeCompare(z.archive_name||""):m==="printer"?V=(ee.printer_name||"").localeCompare(z.printer_name||""):V=new Date(z.completed_at||z.created_at).getTime()-new Date(ee.completed_at||ee.created_at).getTime(),y?-V:V}),[T,m,y]),K=E.useMemo(()=>D.reduce((Y,ee)=>Y+(ee.print_time_seconds||0),0),[D]),X=Y=>{const{active:ee,over:z}=Y;if(!z||ee.id===z.id)return;const V=D.findIndex(le=>le.id===ee.id),re=D.findIndex(le=>le.id===z.id);if(V!==-1&&re!==-1){const ge=Rw(D,V,re).map((ie,xe)=>({id:ie.id,position:xe+1}));F.mutate(ge)}};return h.jsxs("div",{className:"p-8",children:[h.jsx("div",{className:"flex items-center justify-between mb-8",children:h.jsxs("div",{children:[h.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[h.jsx(JG,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),h.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),h.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[h.jsx($t,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:h.jsx(Qt,{className:"p-4",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:h.jsx(YS,{className:"w-5 h-5 text-blue-400"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-2xl font-bold text-white",children:B.length}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),h.jsx($t,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:h.jsx(Qt,{className:"p-4",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:h.jsx(ar,{className:"w-5 h-5 text-yellow-400"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-2xl font-bold text-white",children:D.length}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),h.jsx($t,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:h.jsx(Qt,{className:"p-4",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:h.jsx(s9,{className:"w-5 h-5 text-bambu-green"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-2xl font-bold text-white",children:GX(K)}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),h.jsx($t,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:h.jsx(Qt,{className:"p-4",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:h.jsx(hc,{className:"w-5 h-5 text-gray-400"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-2xl font-bold text-white",children:$.length}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),h.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:n||"",onChange:Y=>i(Y.target.value?Number(Y.target.value):null),children:[h.jsx("option",{value:"",children:"All Printers"}),A?.map(Y=>h.jsx("option",{value:Y.id,children:Y.name},Y.id))]}),h.jsxs("select",{className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:Y=>a(Y.target.value),children:[h.jsx("option",{value:"",children:"All Status"}),h.jsx("option",{value:"pending",children:"Pending"}),h.jsx("option",{value:"printing",children:"Printing"}),h.jsx("option",{value:"completed",children:"Completed"}),h.jsx("option",{value:"failed",children:"Failed"}),h.jsx("option",{value:"skipped",children:"Skipped"}),h.jsx("option",{value:"cancelled",children:"Cancelled"})]}),h.jsx("div",{className:"flex-1"}),$.length>0&&h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:[h.jsx(Ei,{className:"w-4 h-4"}),"Clear History"]})]}),P?h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):T?.length===0?h.jsxs($t,{className:"p-12 text-center border-dashed",children:[h.jsx(Zo,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),h.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),h.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'})]}):h.jsxs("div",{className:"space-y-8",children:[B.length>0&&h.jsxs("div",{children:[h.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[h.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),h.jsx("div",{className:"space-y-3",children:B.map(Y=>h.jsx(I2,{item:Y,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>f({type:"stop",item:Y}),onRequeue:()=>{}},Y.id))})]}),D.length>0&&h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[h.jsx(ar,{className:"w-5 h-5 text-yellow-400"}),"Queued",h.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",D.length," item",D.length!==1?"s":"",")"]}),h.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:"Position only affects ASAP items. Scheduled items run at their set time.",children:"Drag to reorder (ASAP only)"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:v,onChange:Y=>x(Y.target.value),children:[h.jsx("option",{value:"position",children:"Sort by Position"}),h.jsx("option",{value:"name",children:"Sort by Name"}),h.jsx("option",{value:"printer",children:"Sort by Printer"}),h.jsx("option",{value:"time",children:"Sort by Schedule"})]}),h.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>w(!M),title:M?"Ascending":"Descending",className:"px-2",children:M?h.jsx(jp,{className:"w-4 h-4"}):h.jsx(Vx,{className:"w-4 h-4"})})]})]}),h.jsx(jX,{sensors:C,collisionDetection:MX,onDragEnd:X,children:h.jsx(zX,{items:D.map(Y=>Y.id),strategy:yNe,children:h.jsx("div",{className:"space-y-3",children:D.map((Y,ee)=>h.jsx(I2,{item:Y,position:ee+1,onEdit:()=>c(Y),onCancel:()=>f({type:"cancel",item:Y}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{}},Y.id))})})})]}),$.length>0&&h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[h.jsx(hc,{className:"w-5 h-5 text-bambu-gray"}),"History",h.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",$.length," item",$.length!==1?"s":"",")"]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("select",{className:"px-3 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:m,onChange:Y=>g(Y.target.value),children:[h.jsx("option",{value:"date",children:"Sort by Date"}),h.jsx("option",{value:"name",children:"Sort by Name"}),h.jsx("option",{value:"printer",children:"Sort by Printer"})]}),h.jsx(Ye,{variant:"ghost",size:"sm",onClick:()=>_(!y),title:y?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:y?h.jsx(jp,{className:"w-4 h-4"}):h.jsx(Vx,{className:"w-4 h-4"})})]})]}),h.jsx("div",{className:"space-y-3",children:$.slice(0,20).map((Y,ee)=>h.jsx(I2,{item:Y,position:ee+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>f({type:"remove",item:Y}),onStop:()=>{},onRequeue:()=>I.mutate(Y)},Y.id))})]})]}),l&&h.jsx(RNe,{item:l,onClose:()=>c(null)}),u&&h.jsx(Ia,{title:u.type==="cancel"?"Cancel Scheduled Print":u.type==="stop"?"Stop Print":"Remove from History",message:u.type==="cancel"?`Are you sure you want to cancel "${u.item.archive_name||"this print"}"?`:u.type==="stop"?`Are you sure you want to stop the current print "${u.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${u.item.archive_name||"this item"}" from the queue history?`,confirmText:u.type==="cancel"?"Cancel Print":u.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{u.type==="cancel"?j.mutate(u.item.id):u.type==="stop"?k.mutate(u.item.id):N.mutate(u.item.id),f(null)},onCancel:()=>f(null)}),s&&h.jsx(Ia,{title:"Clear History",message:`Are you sure you want to remove all ${$.length} item${$.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{W.mutate(),o(!1)},onCancel:()=>o(!1)})]})}function ONe({printDates:t,months:e=3}){const{weeks:n,monthLabels:i,printCounts:r}=E.useMemo(()=>{const l={};t.forEach(x=>{const M=x.split("T")[0];l[M]=(l[M]||0)+1});const c=new Date,u=new Date(c);u.setMonth(u.getMonth()-e),u.setDate(u.getDate()-u.getDay());const f=[],m=[];let g=[],y=-1;const _=new Date(u);let v=0;for(;_<=c;)_.getDay()===0&&g.length>0&&(f.push(g),g=[],v++),_.getMonth()!==y&&(m.push({month:_.toLocaleDateString("en-US",{month:"short"}),weekIndex:v}),y=_.getMonth()),g.push(new Date(_)),_.setDate(_.getDate()+1);return g.length>0&&f.push(g),{weeks:f,monthLabels:m,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 h.jsxs("div",{className:"overflow-x-auto",children:[h.jsx("div",{className:"flex mb-1 ml-8",children:i.map(({month:l,weekIndex:c},u)=>h.jsx("div",{className:"text-xs text-bambu-gray",style:{marginLeft:u===0?0:`${(c-(i[u-1]?.weekIndex||0))*14-24}px`},children:l},u))}),h.jsxs("div",{className:"flex gap-0.5",children:[h.jsx("div",{className:"flex flex-col gap-0.5 mr-1",children:o.map((l,c)=>h.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)=>h.jsx("div",{className:"flex flex-col gap-0.5",children:[0,1,2,3,4,5,6].map(u=>{const f=l.find(_=>_.getDay()===u);if(!f)return h.jsx("div",{className:"w-3 h-3"},u);const m=f.toISOString().split("T")[0],g=r[m]||0,y=m===new Date().toISOString().split("T")[0];return h.jsx("div",{className:`w-3 h-3 rounded-sm ${s(g)} ${y?"ring-1 ring-white":""}`,title:`${f.toLocaleDateString()}: ${g} print${g!==1?"s":""}`},u)})},c))]}),h.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-bambu-gray",children:[h.jsx("span",{children:"Less"}),h.jsxs("div",{className:"flex gap-0.5",children:[h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-dark"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/30"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/50"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green/75"}),h.jsx("div",{className:"w-3 h-3 rounded-sm bg-bambu-green"})]}),h.jsx("span",{children:"More"})]})]})}function WX(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=WX(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function An(){for(var t,e,n=0,i="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=WX(t))&&(i&&(i+=" "),i+=e);return i}var LNe=["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 cD(t){if(typeof t!="string")return!1;var e=LNe;return e.includes(t)}var INe=["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"],jNe=new Set(INe);function qX(t){return typeof t!="string"?!1:jNe.has(t)}function XX(t){return typeof t=="string"&&t.startsWith("data-")}function Ba(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(qX(n)||XX(n))&&(e[n]=t[n]);return e}function Of(t){if(t==null)return null;if(E.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ba(e)}return typeof t=="object"&&!Array.isArray(t)?Ba(t):null}function ba(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(qX(n)||XX(n)||cD(n))&&(e[n]=t[n]);return e}function UNe(t){return t==null?null:E.isValidElement(t)?ba(t.props):typeof t=="object"&&!Array.isArray(t)?ba(t):null}var FNe=["children","width","height","viewBox","className","style","title","desc"];function yR(){return yR=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},yR.apply(null,arguments)}function zNe(t,e){if(t==null)return{};var n,i,r=BNe(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 BNe(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 uD=E.forwardRef((t,e)=>{var{children:n,width:i,height:r,viewBox:a,className:s,style:o,title:l,desc:c}=t,u=zNe(t,FNe),f=a||{width:i,height:r,x:0,y:0},m=An("recharts-surface",s);return E.createElement("svg",yR({},ba(u),{className:m,width:i,height:r,style:o,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),E.createElement("title",null,l),E.createElement("desc",null,c),n)}),HNe=["children","className"];function bR(){return bR=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},bR.apply(null,arguments)}function $Ne(t,e){if(t==null)return{};var n,i,r=VNe(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 VNe(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 Li=E.forwardRef((t,e)=>{var{children:n,className:i}=t,r=$Ne(t,HNe),a=An("recharts-layer",i);return E.createElement("g",bR({className:a},ba(r),{ref:e}),n)}),KX=E.createContext(null),GNe=()=>E.useContext(KX);function Qn(t){return function(){return t}}const YX=Math.cos,Q1=Math.sin,Co=Math.sqrt,J1=Math.PI,Pw=2*J1,_R=Math.PI,SR=2*_R,zd=1e-6,WNe=SR-zd;function ZX(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function qNe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return ZX;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 XNe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?ZX:qNe(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,u=s-e,f=o-n,m=u*u+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(m>zd)if(!(Math.abs(f*l-c*u)>zd)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let g=i-s,y=r-o,_=l*l+c*c,v=g*g+y*y,x=Math.sqrt(_),M=Math.sqrt(m),w=a*Math.tan((_R-Math.acos((_+m-v)/(2*x*M)))/2),C=w/M,T=w/x;Math.abs(C-1)>zd&&this._append`L${e+C*u},${n+C*f}`,this._append`A${a},${a},0,0,${+(f*g>u*y)},${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,u=n+l,f=1^s,m=s?r-a:a-r;this._x1===null?this._append`M${c},${u}`:(Math.abs(this._x1-c)>zd||Math.abs(this._y1-u)>zd)&&this._append`L${c},${u}`,i&&(m<0&&(m=m%SR+SR),m>WNe?this._append`A${i},${i},0,1,${f},${e-o},${n-l}A${i},${i},0,1,${f},${this._x1=c},${this._y1=u}`:m>zd&&this._append`A${i},${i},0,${+(m>=_R)},${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 dD(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 XNe(e)}function fD(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function QX(t){this._context=t}QX.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 kw(t){return new QX(t)}function JX(t){return t[0]}function eK(t){return t[1]}function tK(t,e){var n=Qn(!0),i=null,r=kw,a=null,s=dD(o);t=typeof t=="function"?t:t===void 0?JX:Qn(t),e=typeof e=="function"?e:e===void 0?eK:Qn(e);function o(l){var c,u=(l=fD(l)).length,f,m=!1,g;for(i==null&&(a=r(g=s())),c=0;c<=u;++c)!(c<u&&n(f=l[c],c,l))===m&&((m=!m)?a.lineStart():a.lineEnd()),m&&a.point(+t(f,c,l),+e(f,c,l));if(g)return a=null,g+""||null}return o.x=function(l){return arguments.length?(t=typeof l=="function"?l:Qn(+l),o):t},o.y=function(l){return arguments.length?(e=typeof l=="function"?l:Qn(+l),o):e},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:Qn(!!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 qb(t,e,n){var i=null,r=Qn(!0),a=null,s=kw,o=null,l=dD(c);t=typeof t=="function"?t:t===void 0?JX:Qn(+t),e=typeof e=="function"?e:Qn(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?eK:Qn(+n);function c(f){var m,g,y,_=(f=fD(f)).length,v,x=!1,M,w=new Array(_),C=new Array(_);for(a==null&&(o=s(M=l())),m=0;m<=_;++m){if(!(m<_&&r(v=f[m],m,f))===x)if(x=!x)g=m,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),y=m-1;y>=g;--y)o.point(w[y],C[y]);o.lineEnd(),o.areaEnd()}x&&(w[m]=+t(v,m,f),C[m]=+e(v,m,f),o.point(i?+i(v,m,f):w[m],n?+n(v,m,f):C[m]))}if(M)return o=null,M+""||null}function u(){return tK().defined(r).curve(s).context(a)}return c.x=function(f){return arguments.length?(t=typeof f=="function"?f:Qn(+f),i=null,c):t},c.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Qn(+f),c):t},c.x1=function(f){return arguments.length?(i=f==null?null:typeof f=="function"?f:Qn(+f),c):i},c.y=function(f){return arguments.length?(e=typeof f=="function"?f:Qn(+f),n=null,c):e},c.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Qn(+f),c):e},c.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Qn(+f),c):n},c.lineX0=c.lineY0=function(){return u().x(t).y(e)},c.lineY1=function(){return u().x(t).y(n)},c.lineX1=function(){return u().x(i).y(e)},c.defined=function(f){return arguments.length?(r=typeof f=="function"?f:Qn(!!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 nK{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 KNe(t){return new nK(t,!0)}function YNe(t){return new nK(t,!1)}const hD={draw(t,e){const n=Co(e/J1);t.moveTo(n,0),t.arc(0,0,n,0,Pw)}},ZNe={draw(t,e){const n=Co(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()}},iK=Co(1/3),QNe=iK*2,JNe={draw(t,e){const n=Co(e/QNe),i=n*iK;t.moveTo(0,-n),t.lineTo(i,0),t.lineTo(0,n),t.lineTo(-i,0),t.closePath()}},e3e={draw(t,e){const n=Co(e),i=-n/2;t.rect(i,i,n,n)}},t3e=.8908130915292852,rK=Q1(J1/10)/Q1(7*J1/10),n3e=Q1(Pw/10)*rK,i3e=-YX(Pw/10)*rK,r3e={draw(t,e){const n=Co(e*t3e),i=n3e*n,r=i3e*n;t.moveTo(0,-n),t.lineTo(i,r);for(let a=1;a<5;++a){const s=Pw*a/5,o=YX(s),l=Q1(s);t.lineTo(l*n,-o*n),t.lineTo(o*i-l*r,l*i+o*r)}t.closePath()}},j2=Co(3),a3e={draw(t,e){const n=-Co(e/(j2*3));t.moveTo(0,n*2),t.lineTo(-j2*n,-n),t.lineTo(j2*n,-n),t.closePath()}},Ts=-.5,Cs=Co(3)/2,wR=1/Co(12),s3e=(wR/2+1)*3,o3e={draw(t,e){const n=Co(e/s3e),i=n/2,r=n*wR,a=i,s=n*wR+n,o=-a,l=s;t.moveTo(i,r),t.lineTo(a,s),t.lineTo(o,l),t.lineTo(Ts*i-Cs*r,Cs*i+Ts*r),t.lineTo(Ts*a-Cs*s,Cs*a+Ts*s),t.lineTo(Ts*o-Cs*l,Cs*o+Ts*l),t.lineTo(Ts*i+Cs*r,Ts*r-Cs*i),t.lineTo(Ts*a+Cs*s,Ts*s-Cs*a),t.lineTo(Ts*o+Cs*l,Ts*l-Cs*o),t.closePath()}};function l3e(t,e){let n=null,i=dD(r);t=typeof t=="function"?t:Qn(t||hD),e=typeof e=="function"?e:Qn(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:Qn(a),r):t},r.size=function(a){return arguments.length?(e=typeof a=="function"?a:Qn(+a),r):e},r.context=function(a){return arguments.length?(n=a??null,r):n},r}function eS(){}function tS(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 aK(t){this._context=t}aK.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:tS(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:tS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function c3e(t){return new aK(t)}function sK(t){this._context=t}sK.prototype={areaStart:eS,areaEnd:eS,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:tS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function u3e(t){return new sK(t)}function oK(t){this._context=t}oK.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:tS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function d3e(t){return new oK(t)}function lK(t){this._context=t}lK.prototype={areaStart:eS,areaEnd:eS,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 f3e(t){return new lK(t)}function F8(t){return t<0?-1:1}function z8(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(F8(a)+F8(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(o))||0}function B8(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function U2(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 nS(t){this._context=t}nS.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:U2(this,this._t0,B8(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,U2(this,B8(this,n=z8(this,t,e)),n);break;default:U2(this,this._t0,n=z8(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function cK(t){this._context=new uK(t)}(cK.prototype=Object.create(nS.prototype)).point=function(t,e){nS.prototype.point.call(this,e,t)};function uK(t){this._context=t}uK.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 h3e(t){return new nS(t)}function p3e(t){return new cK(t)}function dK(t){this._context=t}dK.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=H8(t),r=H8(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 H8(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 m3e(t){return new dK(t)}function Dw(t,e){this._context=t,this._t=e}Dw.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 g3e(t){return new Dw(t,.5)}function x3e(t){return new Dw(t,0)}function v3e(t){return new Dw(t,1)}function lm(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 MR(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function y3e(t,e){return t[e]}function b3e(t){const e=[];return e.key=t,e}function _3e(){var t=Qn([]),e=MR,n=lm,i=y3e;function r(a){var s=Array.from(t.apply(this,arguments),b3e),o,l=s.length,c=-1,u;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,u=fD(e(s));o<l;++o)s[u[o]].index=o;return n(s,u),s}return r.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Qn(Array.from(a)),r):t},r.value=function(a){return arguments.length?(i=typeof a=="function"?a:Qn(+a),r):i},r.order=function(a){return arguments.length?(e=a==null?MR:typeof a=="function"?a:Qn(Array.from(a)),r):e},r.offset=function(a){return arguments.length?(n=a??lm,r):n},r}function S3e(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}lm(t,e)}}function w3e(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}lm(t,e)}}function M3e(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 u=t[e[o]],f=u[i][1]||0,m=u[i-1][1]||0,g=(f-m)/2,y=0;y<o;++y){var _=t[e[y]],v=_[i][1]||0,x=_[i-1][1]||0;g+=v-x}l+=f,c+=g*f}r[i-1][1]+=r[i-1][0]=n,l&&(n-=c/l)}r[i-1][1]+=r[i-1][0]=n,lm(t,e)}}var F2={},z2={},$8;function E3e(){return $8||($8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(z2)),z2}var B2={},V8;function fK(){return V8||(V8=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})(B2)),B2}var H2={},G8;function pD(){return G8||(G8=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})(H2)),H2}var $2={},V2={},W8;function A3e(){return W8||(W8=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})(V2)),V2}var q8;function mD(){return q8||(q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=A3e(),n=pD();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="",u=!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:u?f==='"'||f==="'"?c=f:f==="]"?(u=!1,a.push(l),l=""):l+=f:f==="["?(u=!0,l&&(a.push(l),l="")):f==="."?l&&(a.push(l),l=""):l+=f,o++}return l&&a.push(l),a}t.toPath=i})($2)),$2}var X8;function gD(){return X8||(X8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=E3e(),n=fK(),i=pD(),r=mD();function a(o,l,c){if(o==null)return c;switch(typeof l){case"string":{if(e.isUnsafeProperty(l))return c;const u=o[l];return u===void 0?n.isDeepKey(l)?a(o,r.toPath(l),c):c:u}case"number":case"symbol":{typeof l=="number"&&(l=i.toKey(l));const u=o[l];return u===void 0?c:u}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 u=o[l];return u===void 0?c:u}}}function s(o,l,c){if(l.length===0)return c;let u=o;for(let f=0;f<l.length;f++){if(u==null||e.isUnsafeProperty(l[f]))return c;u=u[l[f]]}return u===void 0?c:u}t.get=a})(F2)),F2}var G2,K8;function T3e(){return K8||(K8=1,G2=gD().get),G2}var C3e=T3e();const Lf=Ys(C3e);var Tr=t=>t===0?0:t>0?1:-1,qs=t=>typeof t=="number"&&t!=+t,vc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Et=t=>(typeof t=="number"||t instanceof Number)&&!qs(t),al=t=>Et(t)||typeof t=="string",N3e=0,v0=t=>{var e=++N3e;return"".concat(t||"").concat(e)},ra=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(vc(e)){if(n==null)return i;var s=e.indexOf("%");a=n*parseFloat(e.slice(0,s))/100}else a=+e;return qs(a)&&(a=i),r&&n!=null&&a>n&&(a=n),a},hK=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 si(t,e,n){return Et(t)&&Et(e)?t+n*(e-t):e}function pK(t,e,n){if(!(!t||!t.length))return t.find(i=>i&&(typeof e=="function"?e(i):Lf(i,e))===n)}var gi=t=>t===null||typeof t>"u",K0=t=>gi(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function R3e(t){return t!=null}function Y0(){}var P3e=["type","size","sizeType"];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 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 Z8(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){k3e(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 k3e(t,e,n){return(e=D3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D3e(t){var e=O3e(t,"string");return typeof e=="symbol"?e:e+""}function O3e(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 L3e(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 mK={symbolCircle:hD,symbolCross:ZNe,symbolDiamond:JNe,symbolSquare:e3e,symbolStar:r3e,symbolTriangle:a3e,symbolWye:o3e},j3e=Math.PI/180,U3e=t=>{var e="symbol".concat(K0(t));return mK[e]||hD},F3e=(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*j3e;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}},z3e=(t,e)=>{mK["symbol".concat(K0(t))]=e},xD=t=>{var{type:e="circle",size:n=64,sizeType:i="area"}=t,r=L3e(t,P3e),a=Z8(Z8({},r),{},{type:e,size:n,sizeType:i}),s="circle";typeof e=="string"&&(s=e);var o=()=>{var m=U3e(s),g=l3e().type(m).size(F3e(n,i,s)),y=g();if(y!==null)return y},{className:l,cx:c,cy:u}=a,f=ba(a);return Et(c)&&Et(u)&&Et(n)?E.createElement("path",ER({},f,{className:An("recharts-symbols",l),transform:"translate(".concat(c,", ").concat(u,")"),d:o()})):null};xD.registerSymbol=z3e;var gK=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,vD=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(E.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var i={};return Object.keys(n).forEach(r=>{cD(r)&&(i[r]=(a=>n[r](n,a)))}),i},B3e=(t,e,n)=>i=>(t(e,n,i),null),Z0=(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];cD(r)&&typeof a=="function"&&(i||(i={}),i[r]=B3e(a,e,n))}),i};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 H3e(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){$3e(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 $3e(t,e,n){return(e=V3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function V3e(t){var e=G3e(t,"string");return typeof e=="symbol"?e:e+""}function G3e(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 Zi(t,e){var n=H3e({},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 iS(){return iS=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},iS.apply(null,arguments)}function J8(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 W3e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J8(Object(n),!0).forEach(function(i){q3e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J8(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function q3e(t,e,n){return(e=X3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function X3e(t){var e=K3e(t,"string");return typeof e=="symbol"?e:e+""}function K3e(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 Ps=32,Y3e={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function Z3e(t){var{data:e,iconType:n,inactiveColor:i}=t,r=Ps/2,a=Ps/6,s=Ps/3,o=e.inactive?i:e.color,l=n??e.type;if(l==="none")return null;if(l==="plainline"){var c;return E.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:Ps,y2:r,className:"recharts-legend-icon"})}if(l==="line")return E.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(Ps,"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 E.createElement("path",{stroke:"none",fill:o,d:"M0,".concat(Ps/8,"h").concat(Ps,"v").concat(Ps*3/4,"h").concat(-Ps,"z"),className:"recharts-legend-icon"});if(E.isValidElement(e.legendIcon)){var u=W3e({},e);return delete u.legendIcon,E.cloneElement(e.legendIcon,u)}return E.createElement(xD,{fill:o,cx:r,cy:r,size:Ps,sizeType:"diameter",type:l})}function Q3e(t){var{payload:e,iconSize:n,layout:i,formatter:r,inactiveColor:a,iconType:s}=t,o={x:0,y:0,width:Ps,height:Ps},l={display:i==="horizontal"?"inline-block":"block",marginRight:10},c={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((u,f)=>{var m=u.formatter||r,g=An({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:u.inactive});if(u.type==="none")return null;var y=u.inactive?a:u.color,_=m?m(u.value,u,f):u.value;return E.createElement("li",iS({className:g,style:l,key:"legend-item-".concat(f)},Z0(t,u,f)),E.createElement(uD,{width:n,height:n,viewBox:o,style:c,"aria-label":"".concat(_," legend icon")},E.createElement(Z3e,{data:u,iconType:s,inactiveColor:a})),E.createElement("span",{className:"recharts-legend-item-text",style:{color:y}},_))})}var J3e=t=>{var e=Zi(t,Y3e),{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 E.createElement("ul",{className:"recharts-default-legend",style:a},E.createElement(Q3e,iS({},e,{payload:n})))},W2={},q2={},e6;function eRe(){return e6||(e6=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})(q2)),q2}var X2={},t6;function xK(){return t6||(t6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(X2)),X2}var K2={},Y2={},Z2={},n6;function tRe(){return n6||(n6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(Z2)),Z2}var i6;function yD(){return i6||(i6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tRe();function n(i){return i!=null&&typeof i!="function"&&e.isLength(i.length)}t.isArrayLike=n})(Y2)),Y2}var Q2={},r6;function nRe(){return r6||(r6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(Q2)),Q2}var a6;function iRe(){return a6||(a6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yD(),n=nRe();function i(r){return n.isObjectLike(r)&&e.isArrayLike(r)}t.isArrayLikeObject=i})(K2)),K2}var J2={},eC={},s6;function rRe(){return s6||(s6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gD();function n(i){return function(r){return e.get(r,i)}}t.property=n})(eC)),eC}var tC={},nC={},iC={},rC={},o6;function vK(){return o6||(o6=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})(rC)),rC}var aC={},l6;function yK(){return l6||(l6=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})(aC)),aC}var sC={},c6;function bK(){return c6||(c6=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})(sC)),sC}var u6;function aRe(){return u6||(u6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=vK(),n=yK(),i=bK();function r(u,f,m){return typeof m!="function"?r(u,f,()=>{}):a(u,f,function g(y,_,v,x,M,w){const C=m(y,_,v,x,M,w);return C!==void 0?!!C:a(y,_,g,w)},new Map)}function a(u,f,m,g){if(f===u)return!0;switch(typeof f){case"object":return s(u,f,m,g);case"function":return Object.keys(f).length>0?a(u,{...f},m,g):i.eq(u,f);default:return e.isObject(u)?typeof f=="string"?f==="":!0:i.eq(u,f)}}function s(u,f,m,g){if(f==null)return!0;if(Array.isArray(f))return l(u,f,m,g);if(f instanceof Map)return o(u,f,m,g);if(f instanceof Set)return c(u,f,m,g);const y=Object.keys(f);if(u==null)return y.length===0;if(y.length===0)return!0;if(g?.has(f))return g.get(f)===u;g?.set(f,u);try{for(let _=0;_<y.length;_++){const v=y[_];if(!n.isPrimitive(u)&&!(v in u)||f[v]===void 0&&u[v]!==void 0||f[v]===null&&u[v]!==null||!m(u[v],f[v],v,u,f,g))return!1}return!0}finally{g?.delete(f)}}function o(u,f,m,g){if(f.size===0)return!0;if(!(u instanceof Map))return!1;for(const[y,_]of f.entries()){const v=u.get(y);if(m(v,_,y,u,f,g)===!1)return!1}return!0}function l(u,f,m,g){if(f.length===0)return!0;if(!Array.isArray(u))return!1;const y=new Set;for(let _=0;_<f.length;_++){const v=f[_];let x=!1;for(let M=0;M<u.length;M++){if(y.has(M))continue;const w=u[M];let C=!1;if(m(w,v,_,u,f,g)&&(C=!0),C){y.add(M),x=!0;break}}if(!x)return!1}return!0}function c(u,f,m,g){return f.size===0?!0:u instanceof Set?l([...u],[...f],m,g):!1}t.isMatchWith=r,t.isSetMatch=c})(iC)),iC}var d6;function _K(){return d6||(d6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=aRe();function n(i,r){return e.isMatchWith(i,r,()=>{})}t.isMatch=n})(nC)),nC}var oC={},lC={},cC={},f6;function sRe(){return f6||(f6=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})(cC)),cC}var uC={},h6;function SK(){return h6||(h6=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})(uC)),uC}var dC={},p6;function wK(){return p6||(p6=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]",u="[object Array]",f="[object Function]",m="[object ArrayBuffer]",g="[object Object]",y="[object Error]",_="[object DataView]",v="[object Uint8Array]",x="[object Uint8ClampedArray]",M="[object Uint16Array]",w="[object Uint32Array]",C="[object BigUint64Array]",T="[object Int8Array]",P="[object Int16Array]",A="[object Int32Array]",j="[object BigInt64Array]",N="[object Float32Array]",k="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=m,t.arrayTag=u,t.bigInt64ArrayTag=j,t.bigUint64ArrayTag=C,t.booleanTag=r,t.dataViewTag=_,t.dateTag=o,t.errorTag=y,t.float32ArrayTag=N,t.float64ArrayTag=k,t.functionTag=f,t.int16ArrayTag=P,t.int32ArrayTag=A,t.int8ArrayTag=T,t.mapTag=l,t.numberTag=i,t.objectTag=g,t.regexpTag=e,t.setTag=c,t.stringTag=n,t.symbolTag=s,t.uint16ArrayTag=M,t.uint32ArrayTag=w,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=x})(dC)),dC}var fC={},m6;function oRe(){return m6||(m6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(fC)),fC}var g6;function MK(){return g6||(g6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sRe(),n=SK(),i=wK(),r=yK(),a=oRe();function s(u,f){return o(u,void 0,u,new Map,f)}function o(u,f,m,g=new Map,y=void 0){const _=y?.(u,f,m,g);if(_!==void 0)return _;if(r.isPrimitive(u))return u;if(g.has(u))return g.get(u);if(Array.isArray(u)){const v=new Array(u.length);g.set(u,v);for(let x=0;x<u.length;x++)v[x]=o(u[x],x,m,g,y);return Object.hasOwn(u,"index")&&(v.index=u.index),Object.hasOwn(u,"input")&&(v.input=u.input),v}if(u instanceof Date)return new Date(u.getTime());if(u instanceof RegExp){const v=new RegExp(u.source,u.flags);return v.lastIndex=u.lastIndex,v}if(u instanceof Map){const v=new Map;g.set(u,v);for(const[x,M]of u)v.set(x,o(M,x,m,g,y));return v}if(u instanceof Set){const v=new Set;g.set(u,v);for(const x of u)v.add(o(x,void 0,m,g,y));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(u))return u.subarray();if(a.isTypedArray(u)){const v=new(Object.getPrototypeOf(u)).constructor(u.length);g.set(u,v);for(let x=0;x<u.length;x++)v[x]=o(u[x],x,m,g,y);return v}if(u instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&u instanceof SharedArrayBuffer)return u.slice(0);if(u instanceof DataView){const v=new DataView(u.buffer.slice(0),u.byteOffset,u.byteLength);return g.set(u,v),l(v,u,m,g,y),v}if(typeof File<"u"&&u instanceof File){const v=new File([u],u.name,{type:u.type});return g.set(u,v),l(v,u,m,g,y),v}if(typeof Blob<"u"&&u instanceof Blob){const v=new Blob([u],{type:u.type});return g.set(u,v),l(v,u,m,g,y),v}if(u instanceof Error){const v=new u.constructor;return g.set(u,v),v.message=u.message,v.name=u.name,v.stack=u.stack,v.cause=u.cause,l(v,u,m,g,y),v}if(u instanceof Boolean){const v=new Boolean(u.valueOf());return g.set(u,v),l(v,u,m,g,y),v}if(u instanceof Number){const v=new Number(u.valueOf());return g.set(u,v),l(v,u,m,g,y),v}if(u instanceof String){const v=new String(u.valueOf());return g.set(u,v),l(v,u,m,g,y),v}if(typeof u=="object"&&c(u)){const v=Object.create(Object.getPrototypeOf(u));return g.set(u,v),l(v,u,m,g,y),v}return u}function l(u,f,m=u,g,y){const _=[...Object.keys(f),...e.getSymbols(f)];for(let v=0;v<_.length;v++){const x=_[v],M=Object.getOwnPropertyDescriptor(u,x);(M==null||M.writable)&&(u[x]=o(f[x],x,m,g,y))}}function c(u){switch(n.getTag(u)){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})(lC)),lC}var x6;function lRe(){return x6||(x6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MK();function n(i){return e.cloneDeepWithImpl(i,void 0,i,new Map,void 0)}t.cloneDeep=n})(oC)),oC}var v6;function cRe(){return v6||(v6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_K(),n=lRe();function i(r){return r=n.cloneDeep(r),a=>e.isMatch(a,r)}t.matches=i})(tC)),tC}var hC={},pC={},mC={},y6;function uRe(){return y6||(y6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=MK(),n=wK();function i(r,a){return e.cloneDeepWith(r,(s,o,l,c)=>{const u=a?.(s,o,l,c);if(u!==void 0)return u;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})(mC)),mC}var b6;function dRe(){return b6||(b6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=uRe();function n(i){return e.cloneDeepWith(i)}t.cloneDeep=n})(pC)),pC}var gC={},xC={},_6;function EK(){return _6||(_6=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})(xC)),xC}var vC={},S6;function fRe(){return S6||(S6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=SK();function n(i){return i!==null&&typeof i=="object"&&e.getTag(i)==="[object Arguments]"}t.isArguments=n})(vC)),vC}var w6;function hRe(){return w6||(w6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fK(),n=EK(),i=fRe(),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 u=0;u<l.length;u++){const f=l[u];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})(gC)),gC}var M6;function pRe(){return M6||(M6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_K(),n=pD(),i=dRe(),r=gD(),a=hRe();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 u=r.get(c,o);return u===void 0?a.has(c,o):l===void 0?u===void 0:e.isMatch(u,l)}}t.matchesProperty=s})(hC)),hC}var E6;function mRe(){return E6||(E6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xK(),n=rRe(),i=cRe(),r=pRe();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})(J2)),J2}var A6;function gRe(){return A6||(A6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eRe(),n=xK(),i=iRe(),r=mRe();function a(s,o=n.identity){return i.isArrayLikeObject(s)?e.uniqBy(Array.from(s),r.iteratee(o)):[]}t.uniqBy=a})(W2)),W2}var yC,T6;function xRe(){return T6||(T6=1,yC=gRe().uniqBy),yC}var vRe=xRe();const C6=Ys(vRe);function AK(t,e,n){return e===!0?C6(t,n):typeof e=="function"?C6(t,e):t}var bD=E.createContext(null),yRe=t=>t,ei=()=>{var t=E.useContext(bD);return t?t.store.dispatch:yRe},R_=()=>{},bRe=()=>R_,_Re=(t,e)=>t===e;function At(t){var e=E.useContext(bD);return zq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:bRe,e?e.store.getState:R_,e?e.store.getState:R_,e?t:R_,_Re)}function SRe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function wRe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function MRe(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 N6=t=>Array.isArray(t)?t:[t];function ERe(t){const e=Array.isArray(t[0])?t[0]:t;return MRe(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function ARe(t,e){const n=[],{length:i}=t;for(let r=0;r<i;r++)n.push(t[r].apply(null,e));return n}var TRe=class{constructor(t){this.value=t}deref(){return this.value}},CRe=typeof WeakRef<"u"?WeakRef:TRe,NRe=0,R6=1;function Xb(){return{s:NRe,v:void 0,o:null,p:null}}function TK(t,e={}){let n=Xb();const{resultEqualityCheck:i}=e;let r,a=0;function s(){let o=n;const{length:l}=arguments;for(let f=0,m=l;f<m;f++){const g=arguments[f];if(typeof g=="function"||typeof g=="object"&&g!==null){let y=o.o;y===null&&(o.o=y=new WeakMap);const _=y.get(g);_===void 0?(o=Xb(),y.set(g,o)):o=_}else{let y=o.p;y===null&&(o.p=y=new Map);const _=y.get(g);_===void 0?(o=Xb(),y.set(g,o)):o=_}}const c=o;let u;if(o.s===R6)u=o.v;else if(u=t.apply(null,arguments),a++,i){const f=r?.deref?.()??r;f!=null&&i(f,u)&&(u=f,a!==0&&a--),r=typeof u=="object"&&u!==null||typeof u=="function"?new CRe(u):u}return c.s=R6,c.v=u,u}return s.clearCache=()=>{n=Xb(),s.resetResultsCount()},s.resultsCount=()=>a,s.resetResultsCount=()=>{a=0},s}function RRe(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()),SRe(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...n,...l},{memoize:f,memoizeOptions:m=[],argsMemoize:g=TK,argsMemoizeOptions:y=[]}=u,_=N6(m),v=N6(y),x=ERe(r),M=f(function(){return a++,c.apply(null,arguments)},..._),w=g(function(){s++;const T=ARe(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:g})};return Object.assign(i,{withTypes:()=>i}),i}var He=RRe(TK),PRe=Object.assign((t,e=He)=>{wRe(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:()=>PRe}),bC={},_C={},SC={},P6;function kRe(){return P6||(P6=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})(SC)),SC}var wC={},MC={},k6;function CK(){return k6||(k6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(MC)),MC}var D6;function DRe(){return D6||(D6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CK(),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})(wC)),wC}var O6;function ORe(){return O6||(O6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kRe(),n=DRe(),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(g=>String(g));const c=(g,y)=>{let _=g;for(let v=0;v<y.length&&_!=null;++v)_=_[y[v]];return _},u=(g,y)=>y==null||g==null?y:typeof g=="object"&&"key"in g?Object.hasOwn(y,g.key)?y[g.key]:c(y,g.path):typeof g=="function"?g(y):Array.isArray(g)?c(y,g):typeof y=="object"?y[g]:y,f=s.map(g=>(Array.isArray(g)&&g.length===1&&(g=g[0]),g==null||typeof g=="function"||Array.isArray(g)||n.isKey(g)?g:{key:g,path:i.toPath(g)}));return a.map(g=>({original:g,criteria:f.map(y=>u(y,g))})).slice().sort((g,y)=>{for(let _=0;_<f.length;_++){const v=e.compareValues(g.criteria[_],y.criteria[_],o[_]);if(v!==0)return v}return 0}).map(g=>g.original)}t.orderBy=r})(_C)),_C}var EC={},L6;function LRe(){return L6||(L6=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 u=o[c];Array.isArray(u)&&l<a?s(u,l+1):r.push(u)}};return s(n,0),r}t.flatten=e})(EC)),EC}var AC={},I6;function NK(){return I6||(I6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=EK(),n=yD(),i=vK(),r=bK();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})(AC)),AC}var j6;function IRe(){return j6||(j6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ORe(),n=LRe(),i=NK();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})(bC)),bC}var TC,U6;function jRe(){return U6||(U6=1,TC=IRe().sortBy),TC}var URe=jRe();const Ow=Ys(URe);var RK=t=>t.legend.settings,FRe=t=>t.legend.size,zRe=t=>t.legend.payload,BRe=He([zRe,RK],(t,e)=>{var{itemSorter:n}=e,i=t.flat(1);return n?Ow(i,n):i});function HRe(){return At(BRe)}var Kb=1;function PK(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=E.useState({height:0,left:0,top:0,width:0}),i=E.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)>Kb||Math.abs(s.left-e.left)>Kb||Math.abs(s.top-e.top)>Kb||Math.abs(s.width-e.width)>Kb)&&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 zr(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 $Re=typeof Symbol=="function"&&Symbol.observable||"@@observable",F6=$Re,CC=()=>Math.random().toString(36).substring(7).split("").join("."),VRe={INIT:`@@redux/INIT${CC()}`,REPLACE:`@@redux/REPLACE${CC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${CC()}`},rS=VRe;function _D(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 kK(t,e,n){if(typeof t!="function")throw new Error(zr(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(zr(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(zr(1));return n(kK)(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 u(){if(l)throw new Error(zr(3));return r}function f(v){if(typeof v!="function")throw new Error(zr(4));if(l)throw new Error(zr(5));let x=!0;c();const M=o++;return s.set(M,v),function(){if(x){if(l)throw new Error(zr(6));x=!1,c(),s.delete(M),a=null}}}function m(v){if(!_D(v))throw new Error(zr(7));if(typeof v.type>"u")throw new Error(zr(8));if(typeof v.type!="string")throw new Error(zr(17));if(l)throw new Error(zr(9));try{l=!0,r=i(r,v)}finally{l=!1}return(a=s).forEach(M=>{M()}),v}function g(v){if(typeof v!="function")throw new Error(zr(10));i=v,m({type:rS.REPLACE})}function y(){const v=f;return{subscribe(x){if(typeof x!="object"||x===null)throw new Error(zr(11));function M(){const C=x;C.next&&C.next(u())}return M(),{unsubscribe:v(M)}},[F6](){return this}}}return m({type:rS.INIT}),{dispatch:m,subscribe:f,getState:u,replaceReducer:g,[F6]:y}}function GRe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:rS.INIT})>"u")throw new Error(zr(12));if(typeof n(void 0,{type:rS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(zr(13))})}function DK(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{GRe(n)}catch(a){r=a}return function(s={},o){if(r)throw r;let l=!1;const c={};for(let u=0;u<i.length;u++){const f=i[u],m=n[f],g=s[f],y=m(g,o);if(typeof y>"u")throw o&&o.type,new Error(zr(14));c[f]=y,l=l||y!==g}return l=l||i.length!==Object.keys(s).length,l?c:s}}function aS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...i)=>e(n(...i)))}function WRe(...t){return e=>(n,i)=>{const r=e(n,i);let a=()=>{throw new Error(zr(15))};const s={getState:r.getState,dispatch:(l,...c)=>a(l,...c)},o=t.map(l=>l(s));return a=aS(...o)(r.dispatch),{...r,dispatch:a}}}function OK(t){return _D(t)&&"type"in t&&typeof t.type=="string"}var LK=Symbol.for("immer-nothing"),z6=Symbol.for("immer-draftable"),_a=Symbol.for("immer-state");function ho(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var cs=Object,cm=cs.getPrototypeOf,sS="constructor",Lw="prototype",AR="configurable",oS="enumerable",P_="writable",y0="value",yc=t=>!!t&&!!t[_a];function Eo(t){return t?IK(t)||Iw(t)||!!t[z6]||!!t[sS]?.[z6]||jw(t)||Uw(t):!1}var qRe=cs[Lw][sS].toString(),B6=new WeakMap;function IK(t){if(!t||!SD(t))return!1;const e=cm(t);if(e===null||e===cs[Lw])return!0;const n=cs.hasOwnProperty.call(e,sS)&&e[sS];if(n===Object)return!0;if(!gp(n))return!1;let i=B6.get(n);return i===void 0&&(i=Function.toString.call(n),B6.set(n,i)),i===qRe}function Q0(t,e,n=!0){J0(t)===0?(n?Reflect.ownKeys(t):cs.keys(t)).forEach(r=>{e(r,t[r],t)}):t.forEach((i,r)=>e(r,i,t))}function J0(t){const e=t[_a];return e?e.type_:Iw(t)?1:jw(t)?2:Uw(t)?3:0}var H6=(t,e,n=J0(t))=>n===2?t.has(e):cs[Lw].hasOwnProperty.call(t,e),TR=(t,e,n=J0(t))=>n===2?t.get(e):t[e],lS=(t,e,n,i=J0(t))=>{i===2?t.set(e,n):i===3?t.add(n):t[e]=n};function XRe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Iw=Array.isArray,jw=t=>t instanceof Map,Uw=t=>t instanceof Set,SD=t=>typeof t=="object",gp=t=>typeof t=="function",NC=t=>typeof t=="boolean",ql=t=>t.copy_||t.base_,wD=t=>t.modified_?t.copy_:t.base_;function CR(t,e){if(jw(t))return new Map(t);if(Uw(t))return new Set(t);if(Iw(t))return Array[Lw].slice.call(t);const n=IK(t);if(e===!0||e==="class_only"&&!n){const i=cs.getOwnPropertyDescriptors(t);delete i[_a];let r=Reflect.ownKeys(i);for(let a=0;a<r.length;a++){const s=r[a],o=i[s];o[P_]===!1&&(o[P_]=!0,o[AR]=!0),(o.get||o.set)&&(i[s]={[AR]:!0,[P_]:!0,[oS]:o[oS],[y0]:t[s]})}return cs.create(cm(t),i)}else{const i=cm(t);if(i!==null&&n)return{...t};const r=cs.create(i);return cs.assign(r,t)}}function MD(t,e=!1){return Fw(t)||yc(t)||!Eo(t)||(J0(t)>1&&cs.defineProperties(t,{set:Yb,add:Yb,clear:Yb,delete:Yb}),cs.freeze(t),e&&Q0(t,(n,i)=>{MD(i,!0)},!1)),t}function KRe(){ho(2)}var Yb={[y0]:KRe};function Fw(t){return t===null||!SD(t)?!0:cs.isFrozen(t)}var cS="MapSet",NR="Patches",jK={};function um(t){const e=jK[t];return e||ho(0,t),e}var YRe=t=>!!jK[t],b0,UK=()=>b0,ZRe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:YRe(cS)?um(cS):void 0});function $6(t,e){e&&(t.patchPlugin_=um(NR),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function RR(t){PR(t),t.drafts_.forEach(QRe),t.drafts_=null}function PR(t){t===b0&&(b0=t.parent_)}var V6=t=>b0=ZRe(b0,t);function QRe(t){const e=t[_a];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function G6(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[_a].modified_&&(RR(e),ho(4)),Eo(t)&&(t=W6(e,t));const{patchPlugin_:r}=e;r&&r.generateReplacementPatches_(n[_a].base_,t,e)}else t=W6(e,n);return JRe(e,t,!0),RR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==LK?t:void 0}function W6(t,e){if(Fw(e))return e;const n=e[_a];if(!n)return ED(e,t.handledSet_,t);if(!zw(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);BK(n,t)}return n.copy_}function JRe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&MD(e,n)}function FK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var zw=(t,e)=>t.scope_===e,ePe=[];function zK(t,e,n,i){const r=ql(t),a=t.type_;if(i!==void 0&&TR(r,i,a)===e){lS(r,i,n,a);return}if(!t.draftLocations_){const o=t.draftLocations_=new Map;Q0(r,(l,c)=>{if(yc(c)){const u=o.get(c)||[];u.push(l),o.set(c,u)}})}const s=t.draftLocations_.get(e)??ePe;for(const o of s)lS(r,o,n,a)}function tPe(t,e,n){t.callbacks_.push(function(r){const a=e;if(!a||!zw(a,r))return;r.mapSetPlugin_?.fixSetContents(a);const s=wD(a);zK(t,a.draft_??a,s,n),BK(a,r)})}function BK(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)}FK(t)}}function nPe(t,e,n){const{scope_:i}=t;if(yc(n)){const r=n[_a];zw(r,i)&&r.callbacks_.push(function(){k_(t);const s=wD(r);zK(t,n,s,e)})}else Eo(n)&&t.callbacks_.push(function(){const a=ql(t);TR(a,e,t.type_)===n&&i.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&ED(TR(t.copy_,e,t.type_),i.handledSet_,i)})}function ED(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||yc(t)||e.has(t)||!Eo(t)||Fw(t)||(e.add(t),Q0(t,(i,r)=>{if(yc(r)){const a=r[_a];if(zw(a,n)){const s=wD(a);lS(t,i,s,t.type_),FK(a)}}else Eo(r)&&ED(r,e,n)})),t}function iPe(t,e){const n=Iw(t),i={type_:n?1:0,scope_:e?e.scope_:UK(),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=AD;n&&(r=[i],a=_0);const{revoke:s,proxy:o}=Proxy.revocable(r,a);return i.draft_=o,i.revoke_=s,[o,i]}var AD={get(t,e){if(e===_a)return t;const n=ql(t);if(!H6(n,e,t.type_))return rPe(t,n,e);const i=n[e];if(t.finalized_||!Eo(i))return i;if(i===RC(t.base_,e)){k_(t);const r=t.type_===1?+e:e,a=DR(t.scope_,i,t,r);return t.copy_[r]=a}return i},has(t,e){return e in ql(t)},ownKeys(t){return Reflect.ownKeys(ql(t))},set(t,e,n){const i=HK(ql(t),e);if(i?.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const r=RC(ql(t),e),a=r?.[_a];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(XRe(n,r)&&(n!==void 0||H6(t.base_,e,t.type_)))return!0;k_(t),kR(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),nPe(t,e,n)),!0},deleteProperty(t,e){return k_(t),RC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),kR(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=ql(t),i=Reflect.getOwnPropertyDescriptor(n,e);return i&&{[P_]:!0,[AR]:t.type_!==1||e!=="length",[oS]:i[oS],[y0]:n[e]}},defineProperty(){ho(11)},getPrototypeOf(t){return cm(t.base_)},setPrototypeOf(){ho(12)}},_0={};Q0(AD,(t,e)=>{_0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});_0.deleteProperty=function(t,e){return _0.set.call(this,t,e,void 0)};_0.set=function(t,e,n){return AD.set.call(this,t[0],e,n,t[0])};function RC(t,e){const n=t[_a];return(n?ql(n):t)[e]}function rPe(t,e,n){const i=HK(e,n);return i?y0 in i?i[y0]:i.get?.call(t.draft_):void 0}function HK(t,e){if(!(e in t))return;let n=cm(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,e);if(i)return i;n=cm(n)}}function kR(t){t.modified_||(t.modified_=!0,t.parent_&&kR(t.parent_))}function k_(t){t.copy_||(t.assigned_=new Map,t.copy_=CR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var aPe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,i,r)=>{if(gp(n)&&!gp(i)){const s=i;i=n;const o=this;return function(c=s,...u){return o.produce(c,f=>i.call(this,f,...u))}}gp(i)||ho(6),r!==void 0&&!gp(r)&&ho(7);let a;if(Eo(n)){const s=V6(this),o=DR(s,n,void 0);let l=!0;try{a=i(o),l=!1}finally{l?RR(s):PR(s)}return $6(s,r),G6(a,s)}else if(!n||!SD(n)){if(a=i(n),a===void 0&&(a=n),a===LK&&(a=void 0),this.autoFreeze_&&MD(a,!0),r){const s=[],o=[];um(NR).generateReplacementPatches_(n,a,{patches_:s,inversePatches_:o}),r(s,o)}return a}else ho(1,n)},this.produceWithPatches=(n,i)=>{if(gp(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]},NC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),NC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),NC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Eo(e)||ho(8),yc(e)&&(e=bo(e));const n=V6(this),i=DR(n,e,void 0);return i[_a].isManual_=!0,PR(n),i}finishDraft(e,n){const i=e&&e[_a];(!i||!i.isManual_)&&ho(9);const{scope_:r}=i;return $6(r,n),G6(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=um(NR).applyPatches_;return yc(e)?r(e,n):this.produce(e,a=>r(a,n))}};function DR(t,e,n,i){const[r,a]=jw(e)?um(cS).proxyMap_(e,n):Uw(e)?um(cS).proxySet_(e,n):iPe(e,n);return(n?.scope_??UK()).drafts_.push(r),a.callbacks_=n?.callbacks_??[],a.key_=i,n&&i!==void 0?tPe(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 bo(t){return yc(t)||ho(10,t),$K(t)}function $K(t){if(!Eo(t)||Fw(t))return t;const e=t[_a];let n,i=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=CR(t,e.scope_.immer_.useStrictShallowCopy_),i=e.scope_.immer_.shouldUseStrictIteration()}else n=CR(t,!0);return Q0(n,(r,a)=>{lS(n,r,$K(a))},i),e&&(e.finalized_=!1),n}var sPe=new aPe,VK=sPe.produce;function GK(t){return({dispatch:n,getState:i})=>r=>a=>typeof a=="function"?a(n,i,t):r(a)}var oPe=GK(),lPe=GK,cPe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?aS:aS.apply(null,arguments)};function Xs(t,e){function n(...i){if(e){let r=e(...i);if(!r)throw new Error(hs(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=>OK(i)&&i.type===t,n}var WK=class mx extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,mx.prototype)}static get[Symbol.species](){return mx}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new mx(...e[0].concat(this)):new mx(...e.concat(this))}};function q6(t){return Eo(t)?VK(t,()=>{}):t}function Zb(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function uPe(t){return typeof t=="boolean"}var dPe=()=>function(e){const{thunk:n=!0,immutableCheck:i=!0,serializableCheck:r=!0,actionCreatorCheck:a=!0}=e??{};let s=new WK;return n&&(uPe(n)?s.push(oPe):s.push(lPe(n.extraArgument))),s},qK="RTK_autoBatch",ci=()=>t=>({payload:t,meta:{[qK]:!0}}),X6=t=>e=>{setTimeout(e,t)},XK=(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:X6(10):t.type==="callback"?t.queueNotification:X6(t.timeout),c=()=>{s=!1,a&&(a=!1,o.forEach(u=>u()))};return Object.assign({},i,{subscribe(u){const f=()=>r&&u(),m=i.subscribe(f);return o.add(u),()=>{m(),o.delete(u)}},dispatch(u){try{return r=!u?.meta?.[qK],a=!r,a&&(s||(s=!0,l(c))),i.dispatch(u)}finally{r=!0}}})},fPe=t=>function(n){const{autoBatch:i=!0}=n??{};let r=new WK(t);return i&&r.push(XK(typeof i=="object"?i:void 0)),r};function hPe(t){const e=dPe(),{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(_D(n))o=DK(n);else throw new Error(hs(1));let l;typeof i=="function"?l=i(e):l=e();let c=aS;r&&(c=cPe({trace:!1,...typeof r=="object"&&r}));const u=WRe(...l),f=fPe(u);let m=typeof s=="function"?s(f):f();const g=c(...m);return kK(o,a,g)}function KK(t){const e={},n=[];let i;const r={addCase(a,s){const o=typeof a=="string"?a:a.type;if(!o)throw new Error(hs(28));if(o in e)throw new Error(hs(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 pPe(t){return typeof t=="function"}function mPe(t,e){let[n,i,r]=KK(e),a;if(pPe(t))a=()=>q6(t());else{const o=q6(t);a=()=>o}function s(o=a(),l){let c=[n[l.type],...i.filter(({matcher:u})=>u(l)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[r]),c.reduce((u,f)=>{if(f)if(yc(u)){const g=f(u,l);return g===void 0?u:g}else{if(Eo(u))return VK(u,m=>f(m,l));{const m=f(u,l);if(m===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return m}}return u},o)}return s.getInitialState=a,s}var gPe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",xPe=(t=21)=>{let e="",n=t;for(;n--;)e+=gPe[Math.random()*64|0];return e},vPe=Symbol.for("rtk-slice-createasyncthunk");function yPe(t,e){return`${t}/${e}`}function bPe({creators:t}={}){const e=t?.asyncThunk?.[vPe];return function(i){const{name:r,reducerPath:a=r}=i;if(!r)throw new Error(hs(11));const s=(typeof i.reducers=="function"?i.reducers(SPe()):i.reducers)||{},o=Object.keys(s),l={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},c={addCase(w,C){const T=typeof w=="string"?w:w.type;if(!T)throw new Error(hs(12));if(T in l.sliceCaseReducersByType)throw new Error(hs(13));return l.sliceCaseReducersByType[T]=C,c},addMatcher(w,C){return l.sliceMatchers.push({matcher:w,reducer:C}),c},exposeAction(w,C){return l.actionCreators[w]=C,c},exposeCaseReducer(w,C){return l.sliceCaseReducersByName[w]=C,c}};o.forEach(w=>{const C=s[w],T={reducerName:w,type:yPe(r,w),createNotation:typeof i.reducers=="function"};MPe(C)?APe(T,C,c,e):wPe(T,C,c)});function u(){const[w={},C=[],T=void 0]=typeof i.extraReducers=="function"?KK(i.extraReducers):[i.extraReducers],P={...w,...l.sliceCaseReducersByType};return mPe(i.initialState,A=>{for(let j in P)A.addCase(j,P[j]);for(let j of l.sliceMatchers)A.addMatcher(j.matcher,j.reducer);for(let j of C)A.addMatcher(j.matcher,j.reducer);T&&A.addDefaultCase(T)})}const f=w=>w,m=new Map,g=new WeakMap;let y;function _(w,C){return y||(y=u()),y(w,C)}function v(){return y||(y=u()),y.getInitialState()}function x(w,C=!1){function T(A){let j=A[w];return typeof j>"u"&&C&&(j=Zb(g,T,v)),j}function P(A=f){const j=Zb(m,C,()=>new WeakMap);return Zb(j,A,()=>{const N={};for(const[k,F]of Object.entries(i.selectors??{}))N[k]=_Pe(F,A,()=>Zb(g,A,v),C);return N})}return{reducerPath:w,getSelectors:P,get selectors(){return P(T)},selectSlice:T}}const M={name:r,reducer:_,actions:l.actionCreators,caseReducers:l.sliceCaseReducersByName,getInitialState:v,...x(a),injectInto(w,{reducerPath:C,...T}={}){const P=C??a;return w.inject({reducerPath:P,reducer:_},T),{...M,...x(P,!0)}}};return M}}function _Pe(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 Va=bPe();function SPe(){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 wPe({type:t,reducerName:e,createNotation:n},i,r){let a,s;if("reducer"in i){if(n&&!EPe(i))throw new Error(hs(17));a=i.reducer,s=i.prepare}else a=i;r.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,s?Xs(t,s):Xs(t))}function MPe(t){return t._reducerDefinitionType==="asyncThunk"}function EPe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function APe({type:t,reducerName:e},n,i,r){if(!r)throw new Error(hs(18));const{payloadCreator:a,fulfilled:s,pending:o,rejected:l,settled:c,options:u}=n,f=r(t,a,u);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||Qb,pending:o||Qb,rejected:l||Qb,settled:c||Qb})}function Qb(){}var TPe="task",YK="listener",ZK="completed",TD="cancelled",CPe=`task-${TD}`,NPe=`task-${ZK}`,OR=`${YK}-${TD}`,RPe=`${YK}-${ZK}`,Bw=class{constructor(t){this.code=t,this.message=`${TPe} ${TD} (reason: ${t})`}name="TaskAbortError";message},CD=(t,e)=>{if(typeof t!="function")throw new TypeError(hs(32))},uS=()=>{},QK=(t,e=uS)=>(t.catch(e),t),JK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),hf=(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))},pf=t=>{if(t.aborted){const{reason:e}=t;throw new Bw(e)}};function eY(t,e){let n=uS;return new Promise((i,r)=>{const a=()=>r(new Bw(t.reason));if(t.aborted){a();return}n=JK(t,a),e.finally(()=>n()).then(i,r)}).finally(()=>{n=uS})}var PPe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof Bw?"cancelled":"rejected",error:n}}finally{e?.()}},dS=t=>e=>QK(eY(t,e).then(n=>(pf(t),n))),tY=t=>{const e=dS(t);return n=>e(new Promise(i=>setTimeout(i,n)))},{assign:Op}=Object,K6={},Hw="listenerMiddleware",kPe=(t,e)=>{const n=i=>JK(t,()=>hf(i,t.reason));return(i,r)=>{CD(i);const a=new AbortController;n(a);const s=PPe(async()=>{pf(t),pf(a.signal);const o=await i({pause:dS(a.signal),delay:tY(a.signal),signal:a.signal});return pf(a.signal),o},()=>hf(a,NPe));return r?.autoJoin&&e.push(s.catch(uS)),{result:dS(t)(s),cancel(){hf(a,CPe)}}}},DPe=(t,e)=>{const n=async(i,r)=>{pf(e);let a=()=>{};const o=[new Promise((l,c)=>{let u=t({predicate:i,effect:(f,m)=>{m.unsubscribe(),l([f,m.getState(),m.getOriginalState()])}});a=()=>{u(),c()}})];r!=null&&o.push(new Promise(l=>setTimeout(l,r,null)));try{const l=await eY(e,Promise.race(o));return pf(e),l}finally{a()}};return(i,r)=>QK(n(i,r))},nY=t=>{let{type:e,actionCreator:n,matcher:i,predicate:r,effect:a}=t;if(e)r=Xs(e).match;else if(n)e=n.type,r=n.match;else if(i)r=i;else if(!r)throw new Error(hs(21));return CD(a),{predicate:r,type:e,effect:a}},iY=Op(t=>{const{type:e,predicate:n,effect:i}=nY(t);return{id:xPe(),effect:i,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(hs(22))}}},{withTypes:()=>iY}),Y6=(t,e)=>{const{type:n,effect:i,predicate:r}=nY(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===r)&&a.effect===i)},LR=t=>{t.pending.forEach(e=>{hf(e,OR)})},OPe=(t,e)=>()=>{for(const n of e.keys())LR(n);t.clear()},Z6=(t,e,n)=>{try{t(e,n)}catch(i){setTimeout(()=>{throw i},0)}},rY=Op(Xs(`${Hw}/add`),{withTypes:()=>rY}),LPe=Xs(`${Hw}/removeAll`),aY=Op(Xs(`${Hw}/remove`),{withTypes:()=>aY}),IPe=(...t)=>{console.error(`${Hw}/error`,...t)},ev=(t={})=>{const e=new Map,n=new Map,i=g=>{const y=n.get(g)??0;n.set(g,y+1)},r=g=>{const y=n.get(g)??1;y===1?n.delete(g):n.set(g,y-1)},{extra:a,onError:s=IPe}=t;CD(s);const o=g=>(g.unsubscribe=()=>e.delete(g.id),e.set(g.id,g),y=>{g.unsubscribe(),y?.cancelActive&&LR(g)}),l=g=>{const y=Y6(e,g)??iY(g);return o(y)};Op(l,{withTypes:()=>l});const c=g=>{const y=Y6(e,g);return y&&(y.unsubscribe(),g.cancelActive&&LR(y)),!!y};Op(c,{withTypes:()=>c});const u=async(g,y,_,v)=>{const x=new AbortController,M=DPe(l,x.signal),w=[];try{g.pending.add(x),i(g),await Promise.resolve(g.effect(y,Op({},_,{getOriginalState:v,condition:(C,T)=>M(C,T).then(Boolean),take:M,delay:tY(x.signal),pause:dS(x.signal),extra:a,signal:x.signal,fork:kPe(x.signal,w),unsubscribe:g.unsubscribe,subscribe:()=>{e.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((C,T,P)=>{C!==x&&(hf(C,OR),P.delete(C))})},cancel:()=>{hf(x,OR),g.pending.delete(x)},throwIfCancelled:()=>{pf(x.signal)}})))}catch(C){C instanceof Bw||Z6(s,C,{raisedBy:"effect"})}finally{await Promise.all(w),hf(x,RPe),r(g),g.pending.delete(x)}},f=OPe(e,n);return{middleware:g=>y=>_=>{if(!OK(_))return y(_);if(rY.match(_))return l(_.payload);if(LPe.match(_)){f();return}if(aY.match(_))return c(_.payload);let v=g.getState();const x=()=>{if(v===K6)throw new Error(hs(23));return v};let M;try{if(M=y(_),e.size>0){const w=g.getState(),C=Array.from(e.values());for(const T of C){let P=!1;try{P=T.predicate(_,w,v)}catch(A){P=!1,Z6(s,A,{raisedBy:"predicate"})}P&&u(T,_,g,x)}}}finally{v=K6}return M},startListening:l,stopListening:c,clearListeners:f}};function hs(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 jPe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},sY=Va({name:"chartLayout",initialState:jPe,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:UPe,setLayout:FPe,setChartSize:zPe,setScale:BPe}=sY.actions,HPe=sY.reducer;function oY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function Q6(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 _p(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q6(Object(n),!0).forEach(function(i){$Pe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q6(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function $Pe(t,e,n){return(e=VPe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VPe(t){var e=GPe(t,"string");return typeof e=="symbol"?e:e+""}function GPe(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 Yn(t,e,n){return gi(t)||gi(e)?n:al(e)?Lf(t,e,n):typeof e=="function"?e(t):n}var WPe=(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 _p(_p({},t),{},{[a]:t[a]+(i||0)});if((o==="horizontal"||o==="vertical"&&a==="center")&&s!=="middle"&&Et(t[s]))return _p(_p({},t),{},{[s]:t[s]+(r||0)})}return t},Tc=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",lY=(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},cY=(t,e,n)=>{if(!t)return null;var{duplicateDomain:i,type:r,range:a,scale:s,realScaleType:o,isCategorical:l,categoricalDomain:c,tickCount:u,ticks:f,niceTicks:m,axisType:g}=t;if(!s)return null;var y=o==="scaleBand"&&s.bandwidth?s.bandwidth()/2:2,_=r==="category"&&s.bandwidth?s.bandwidth()/y:0;if(_=g==="angleAxis"&&a&&a.length>=2?Tr(a[0]-a[1])*2*_:_,f||m){var v=(f||m||[]).map((x,M)=>{var w=i?i.indexOf(x):x;return{coordinate:s(w)+_,value:x,offset:_,index:M}});return v.filter(x=>!qs(x.coordinate))}return l&&c?c.map((x,M)=>({coordinate:s(x)+_,value:x,index:M,offset:_})):s.ticks&&u!=null?s.ticks(u).map((x,M)=>({coordinate:s(x)+_,value:x,offset:_,index:M})):s.domain().map((x,M)=>({coordinate:s(x)+_,value:i?i[x]:x,index:M,offset:_}))},J6=1e-4,qPe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,i=t.range(),r=Math.min(i[0],i[1])-J6,a=Math.max(i[0],i[1])+J6,s=t(e[0]),o=t(e[n-1]);(s<r||s>a||o<r||o>a)&&t.domain([e[0],e[n-1]])}},XPe=(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},KPe=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=qs(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])}},YPe=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=qs(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)}},ZPe={sign:KPe,expand:S3e,none:lm,silhouette:w3e,wiggle:M3e,positive:YPe},QPe=(t,e,n)=>{var i=ZPe[n],r=_3e().keys(e).value((a,s)=>Number(Yn(a,s,0))).order(MR).offset(i);return r(t)};function uY(t){return t==null?void 0:String(t)}function eH(t){var{axis:e,ticks:n,bandSize:i,entry:r,index:a,dataKey:s}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!gi(r[e.dataKey])){var o=pK(n,"value",r[e.dataKey]);if(o)return o.coordinate+i/2}return n[a]?n[a].coordinate+i/2:null}var l=Yn(r,gi(s)?e.dataKey:s);return gi(l)?null:e.scale(l)}var tH=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=Yn(a,e.dataKey,e.scale.domain()[s]);return gi(o)?null:e.scale(o)-r/2+i},JPe=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]},eke=t=>{var e=t.flat(2).filter(Et);return[Math.min(...e),Math.max(...e)]},tke=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],nke=(t,e,n)=>{if(t!=null)return tke(Object.keys(t).reduce((i,r)=>{var a=t[r],{stackedData:s}=a,o=s.reduce((l,c)=>{var u=oY(c,e,n),f=eke(u);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]))},nH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,iH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,dm=(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=Ow(e,u=>u.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 rH(t){var{tooltipEntrySettings:e,dataKey:n,payload:i,value:r,name:a}=t;return _p(_p({},e),{},{dataKey:n,payload:i,value:r,name:a})}function km(t,e){if(t)return String(t);if(typeof e=="string")return e}var ike=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},rke=(t,e)=>e==="centric"?t.angle:t.radius,Cc=t=>t.layout.width,Nc=t=>t.layout.height,ake=t=>t.layout.scale,dY=t=>t.layout.margin,$w=He(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),Vw=He(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),fY="data-recharts-item-index",hY="data-recharts-item-data-key",tv=60;function aH(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 Jb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aH(Object(n),!0).forEach(function(i){ske(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function ske(t,e,n){return(e=oke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oke(t){var e=lke(t,"string");return typeof e=="symbol"?e:e+""}function lke(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 cke=t=>t.brush.height;function uke(t){var e=Vw(t);return e.reduce((n,i)=>{if(i.orientation==="left"&&!i.mirror&&!i.hide){var r=typeof i.width=="number"?i.width:tv;return n+r}return n},0)}function dke(t){var e=Vw(t);return e.reduce((n,i)=>{if(i.orientation==="right"&&!i.mirror&&!i.hide){var r=typeof i.width=="number"?i.width:tv;return n+r}return n},0)}function fke(t){var e=$w(t);return e.reduce((n,i)=>i.orientation==="top"&&!i.mirror&&!i.hide?n+i.height:n,0)}function hke(t){var e=$w(t);return e.reduce((n,i)=>i.orientation==="bottom"&&!i.mirror&&!i.hide?n+i.height:n,0)}var dr=He([Cc,Nc,dY,cke,uke,dke,fke,hke,RK,FRe],(t,e,n,i,r,a,s,o,l,c)=>{var u={left:(n.left||0)+r,right:(n.right||0)+a},f={top:(n.top||0)+s,bottom:(n.bottom||0)+o},m=Jb(Jb({},f),u),g=m.bottom;m.bottom+=i,m=WPe(m,l,c);var y=t-m.left-m.right,_=e-m.top-m.bottom;return Jb(Jb({brushBottom:g},m),{},{width:Math.max(y,0),height:Math.max(_,0)})}),pke=He(dr,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),ND=He(Cc,Nc,(t,e)=>({x:0,y:0,width:t,height:e})),mke=E.createContext(null),oa=()=>E.useContext(mke)!=null,Gw=t=>t.brush,Ww=He([Gw,dr,dY],(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})),PC={},kC={},DC={},sH;function gke(){return sH||(sH=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"),u=()=>{o!==null&&(n.apply(s,o),s=void 0,o=null)},f=()=>{c&&u(),_()};let m=null;const g=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,f()},i)},y=()=>{m!==null&&(clearTimeout(m),m=null)},_=()=>{y(),s=void 0,o=null},v=()=>{u()},x=function(...M){if(r?.aborted)return;s=this,o=M;const w=m==null;g(),l&&w&&u()};return x.schedule=g,x.cancel=_,x.flush=v,r?.addEventListener("abort",_,{once:!0}),x}t.debounce=e})(DC)),DC}var oH;function xke(){return oH||(oH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gke();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 u,f=null;const m=e.debounce(function(..._){u=i.apply(this,_),f=null},r,{edges:c}),g=function(..._){return l!=null&&(f===null&&(f=Date.now()),Date.now()-f>=l)?(u=i.apply(this,_),f=Date.now(),m.cancel(),m.schedule(),u):(m.apply(this,_),u)},y=()=>(m.flush(),u);return g.cancel=m.cancel,g.flush=y,g}t.debounce=n})(kC)),kC}var lH;function vke(){return lH||(lH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=xke();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})(PC)),PC}var OC,cH;function yke(){return cH||(cH=1,OC=vke().throttle),OC}var bke=yke();const _ke=Ys(bke);var fS=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++]))}},pY=(t,e,n)=>{var{width:i="100%",height:r="100%",aspect:a,maxHeight:s}=n,o=vc(i)?t:Number(i),l=vc(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}},Ske={width:0,height:0,overflow:"visible"},wke={width:0,overflowX:"visible"},Mke={height:0,overflowY:"visible"},Eke={},Ake=t=>{var{width:e,height:n}=t,i=vc(e),r=vc(n);return i&&r?Ske:i?wke:r?Mke:Eke};function Tke(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 oi(t){return Number.isFinite(t)}function sl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}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 uH(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 dH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uH(Object(n),!0).forEach(function(i){Cke(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function Cke(t,e,n){return(e=Nke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Nke(t){var e=Rke(t,"string");return typeof e=="symbol"?e:e+""}function Rke(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 mY=E.createContext({width:-1,height:-1});function Pke(t){return sl(t.width)&&sl(t.height)}function gY(t){var{children:e,width:n,height:i}=t,r=E.useMemo(()=>({width:n,height:i}),[n,i]);return Pke(r)?E.createElement(mY.Provider,{value:r},e):null}var RD=()=>E.useContext(mY),kke=E.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:u=0,id:f,className:m,onResize:g,style:y={}}=t,_=E.useRef(null),v=E.useRef();v.current=g,E.useImperativeHandle(e,()=>_.current);var[x,M]=E.useState({containerWidth:i.width,containerHeight:i.height}),w=E.useCallback((j,N)=>{M(k=>{var F=Math.round(j),I=Math.round(N);return k.containerWidth===F&&k.containerHeight===I?k:{containerWidth:F,containerHeight:I}})},[]);E.useEffect(()=>{if(_.current==null||typeof ResizeObserver>"u")return Y0;var j=I=>{var W,{width:D,height:B}=I[0].contentRect;w(D,B),(W=v.current)===null||W===void 0||W.call(v,D,B)};u>0&&(j=_ke(j,u,{trailing:!0,leading:!1}));var N=new ResizeObserver(j),{width:k,height:F}=_.current.getBoundingClientRect();return w(k,F),N.observe(_.current),()=>{N.disconnect()}},[w,u]);var{containerWidth:C,containerHeight:T}=x;fS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:P,calculatedHeight:A}=pY(C,T,{width:r,height:a,aspect:n,maxHeight:l});return fS(P!=null&&P>0||A!=null&&A>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,A,r,a,s,o,n),E.createElement("div",{id:f?"".concat(f):void 0,className:An("recharts-responsive-container",m),style:dH(dH({},y),{},{width:r,height:a,minWidth:s,minHeight:o,maxHeight:l}),ref:_},E.createElement("div",{style:Ake({width:r,height:a})},E.createElement(gY,{width:P,height:A},c)))}),LC=E.forwardRef((t,e)=>{var n=RD();if(sl(n.width)&&sl(n.height))return t.children;var{width:i,height:r}=Tke({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:s}=pY(void 0,void 0,{width:i,height:r,aspect:t.aspect,maxHeight:t.maxHeight});return Et(a)&&Et(s)?E.createElement(gY,{width:a,height:s},t.children):E.createElement(kke,IR({},t,{width:i,height:r,ref:e}))});function xY(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 qw=()=>{var t,e=oa(),n=At(pke),i=At(Ww),r=(t=At(Gw))===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}},Dke={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},vY=()=>{var t;return(t=At(dr))!==null&&t!==void 0?t:Dke},PD=()=>At(Cc),kD=()=>At(Nc),Oke=()=>At(t=>t.layout.margin),_n=t=>t.layout.layoutType,Dm=()=>At(_n),Lke=()=>{var t=Dm();if(t==="horizontal"||t==="vertical")return t},Ike=()=>{var t=Dm();return t!==void 0},Xw=t=>{var e=ei(),n=oa(),{width:i,height:r}=t,a=RD(),s=i,o=r;return a&&(s=a.width>0?a.width:i,o=a.height>0?a.height:r),E.useEffect(()=>{!n&&sl(s)&&sl(o)&&e(zPe({width:s,height:o}))},[e,n,s,o]),null},yY=Symbol.for("immer-nothing"),fH=Symbol.for("immer-draftable"),ms=Symbol.for("immer-state");function po(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var S0=Object.getPrototypeOf;function fm(t){return!!t&&!!t[ms]}function If(t){return t?bY(t)||Array.isArray(t)||!!t[fH]||!!t.constructor?.[fH]||nv(t)||Yw(t):!1}var jke=Object.prototype.constructor.toString(),hH=new WeakMap;function bY(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=hH.get(n);return i===void 0&&(i=Function.toString.call(n),hH.set(n,i)),i===jke}function hS(t,e,n=!0){Kw(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 Kw(t){const e=t[ms];return e?e.type_:Array.isArray(t)?1:nv(t)?2:Yw(t)?3:0}function jR(t,e){return Kw(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function _Y(t,e,n){const i=Kw(t);i===2?t.set(e,n):i===3?t.add(n):t[e]=n}function Uke(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function nv(t){return t instanceof Map}function Yw(t){return t instanceof Set}function Bd(t){return t.copy_||t.base_}function UR(t,e){if(nv(t))return new Map(t);if(Yw(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=bY(t);if(e===!0||e==="class_only"&&!n){const i=Object.getOwnPropertyDescriptors(t);delete i[ms];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(S0(t),i)}else{const i=S0(t);if(i!==null&&n)return{...t};const r=Object.create(i);return Object.assign(r,t)}}function DD(t,e=!1){return Zw(t)||fm(t)||!If(t)||(Kw(t)>1&&Object.defineProperties(t,{set:e_,add:e_,clear:e_,delete:e_}),Object.freeze(t),e&&Object.values(t).forEach(n=>DD(n,!0))),t}function Fke(){po(2)}var e_={value:Fke};function Zw(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var zke={};function jf(t){const e=zke[t];return e||po(0,t),e}var w0;function SY(){return w0}function Bke(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function pH(t,e){e&&(jf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function FR(t){zR(t),t.drafts_.forEach(Hke),t.drafts_=null}function zR(t){t===w0&&(w0=t.parent_)}function mH(t){return w0=Bke(w0,t)}function Hke(t){const e=t[ms];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function gH(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[ms].modified_&&(FR(e),po(4)),If(t)&&(t=pS(e,t),e.parent_||mS(e,t)),e.patches_&&jf("Patches").generateReplacementPatches_(n[ms].base_,t,e.patches_,e.inversePatches_)):t=pS(e,n,[]),FR(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==yY?t:void 0}function pS(t,e,n){if(Zw(e))return e;const i=t.immer_.shouldUseStrictIteration(),r=e[ms];if(!r)return hS(e,(a,s)=>xH(t,r,e,a,s,n),i),e;if(r.scope_!==t)return e;if(!r.modified_)return mS(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),hS(s,(l,c)=>xH(t,r,a,l,c,n,o),i),mS(t,a,!1),n&&t.patches_&&jf("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function xH(t,e,n,i,r,a,s){if(r==null||typeof r!="object"&&!s)return;const o=Zw(r);if(!(o&&!s)){if(fm(r)){const l=a&&e&&e.type_!==3&&!jR(e.assigned_,i)?a.concat(i):void 0,c=pS(t,r,l);if(_Y(n,i,c),fm(c))t.canAutoFreeze_=!1;else return}else s&&n.add(r);if(If(r)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[i]===r&&o)return;pS(t,r),(!e||!e.scope_.parent_)&&typeof i!="symbol"&&(nv(n)?n.has(i):Object.prototype.propertyIsEnumerable.call(n,i))&&mS(t,r)}}}function mS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&DD(e,n)}function $ke(t,e){const n=Array.isArray(t),i={type_:n?1:0,scope_:e?e.scope_:SY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=i,a=OD;n&&(r=[i],a=M0);const{revoke:s,proxy:o}=Proxy.revocable(r,a);return i.draft_=o,i.revoke_=s,o}var OD={get(t,e){if(e===ms)return t;const n=Bd(t);if(!jR(n,e))return Vke(t,n,e);const i=n[e];return t.finalized_||!If(i)?i:i===IC(t.base_,e)?(jC(t),t.copy_[e]=HR(i,t)):i},has(t,e){return e in Bd(t)},ownKeys(t){return Reflect.ownKeys(Bd(t))},set(t,e,n){const i=wY(Bd(t),e);if(i?.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const r=IC(Bd(t),e),a=r?.[ms];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Uke(n,r)&&(n!==void 0||jR(t.base_,e)))return!0;jC(t),BR(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 IC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,jC(t),BR(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Bd(t),i=Reflect.getOwnPropertyDescriptor(n,e);return i&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:i.enumerable,value:n[e]}},defineProperty(){po(11)},getPrototypeOf(t){return S0(t.base_)},setPrototypeOf(){po(12)}},M0={};hS(OD,(t,e)=>{M0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});M0.deleteProperty=function(t,e){return M0.set.call(this,t,e,void 0)};M0.set=function(t,e,n){return OD.set.call(this,t[0],e,n,t[0])};function IC(t,e){const n=t[ms];return(n?Bd(n):t)[e]}function Vke(t,e,n){const i=wY(e,n);return i?"value"in i?i.value:i.get?.call(t.draft_):void 0}function wY(t,e){if(!(e in t))return;let n=S0(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,e);if(i)return i;n=S0(n)}}function BR(t){t.modified_||(t.modified_=!0,t.parent_&&BR(t.parent_))}function jC(t){t.copy_||(t.copy_=UR(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Gke=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,u=>n.call(this,u,...c))}}typeof n!="function"&&po(6),i!==void 0&&typeof i!="function"&&po(7);let r;if(If(e)){const a=mH(this),s=HR(e,void 0);let o=!0;try{r=n(s),o=!1}finally{o?FR(a):zR(a)}return pH(a,i),gH(r,a)}else if(!e||typeof e!="object"){if(r=n(e),r===void 0&&(r=e),r===yY&&(r=void 0),this.autoFreeze_&&DD(r,!0),i){const a=[],s=[];jf("Patches").generateReplacementPatches_(e,r,a,s),i(a,s)}return r}else po(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){If(t)||po(8),fm(t)&&(t=Wke(t));const e=mH(this),n=HR(t,void 0);return n[ms].isManual_=!0,zR(e),n}finishDraft(t,e){const n=t&&t[ms];(!n||!n.isManual_)&&po(9);const{scope_:i}=n;return pH(i,e),gH(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=jf("Patches").applyPatches_;return fm(t)?i(t,e):this.produce(t,r=>i(r,e))}};function HR(t,e){const n=nv(t)?jf("MapSet").proxyMap_(t,e):Yw(t)?jf("MapSet").proxySet_(t,e):$ke(t,e);return(e?e.scope_:SY()).drafts_.push(n),n}function Wke(t){return fm(t)||po(10,t),MY(t)}function MY(t){if(!If(t)||Zw(t))return t;const e=t[ms];let n,i=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=UR(t,e.scope_.immer_.useStrictShallowCopy_),i=e.scope_.immer_.shouldUseStrictIteration()}else n=UR(t,!0);return hS(n,(r,a)=>{_Y(n,r,MY(a))},i),e&&(e.finalized_=!1),n}var qke=new Gke;qke.produce;var Xke={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},EY=Va({name:"legend",initialState:Xke,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:ci()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:i}=e.payload,r=bo(t).payload.indexOf(n);r>-1&&(t.payload[r]=i)},prepare:ci()},removeLegendPayload:{reducer(t,e){var n=bo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:ci()}}}),{setLegendSize:vH,setLegendSettings:Kke,addLegendPayload:AY,replaceLegendPayload:TY,removeLegendPayload:CY}=EY.actions,Yke=EY.reducer,Zke=["contextPayload"];function $R(){return $R=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},$R.apply(null,arguments)}function yH(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 hm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yH(Object(n),!0).forEach(function(i){Qke(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function Qke(t,e,n){return(e=Jke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jke(t){var e=eDe(t,"string");return typeof e=="symbol"?e:e+""}function eDe(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 tDe(t,e){if(t==null)return{};var n,i,r=nDe(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 nDe(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 iDe(t){return t.value}function rDe(t){var{contextPayload:e}=t,n=tDe(t,Zke),i=AK(e,t.payloadUniqBy,iDe),r=hm(hm({},n),{},{payload:i});return E.isValidElement(t.content)?E.cloneElement(t.content,r):typeof t.content=="function"?E.createElement(t.content,r):E.createElement(J3e,r)}function aDe(t,e,n,i,r,a){var{layout:s,align:o,verticalAlign:l}=e,c,u;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"?u={top:((r||0)-a.height)/2}:u=l==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),hm(hm({},c),u)}function sDe(t){var e=ei();return E.useEffect(()=>{e(Kke(t))},[e,t]),null}function oDe(t){var e=ei();return E.useEffect(()=>(e(vH(t)),()=>{e(vH({width:0,height:0}))}),[e,t]),null}function lDe(t,e,n,i){return t==="vertical"&&Et(e)?{height:e}:t==="horizontal"?{width:n||i}:null}var cDe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function NY(t){var e=Zi(t,cDe),n=HRe(),i=GNe(),r=Oke(),{width:a,height:s,wrapperStyle:o,portal:l}=e,[c,u]=PK([n]),f=PD(),m=kD();if(f==null||m==null)return null;var g=f-(r?.left||0)-(r?.right||0),y=lDe(e.layout,s,a,g),_=l?o:hm(hm({position:"absolute",width:y?.width||a||"auto",height:y?.height||s||"auto"},aDe(o,e,r,f,m,c)),o),v=l??i;if(v==null||n==null)return null;var x=E.createElement("div",{className:"recharts-legend-wrapper",style:_,ref:u},E.createElement(sDe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!l&&E.createElement(oDe,{width:c.width,height:c.height}),E.createElement(rDe,$R({},e,y,{margin:r,chartWidth:f,chartHeight:m,contextPayload:n})));return Zl.createPortal(x,v)}NY.displayName="Legend";function VR(){return VR=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},VR.apply(null,arguments)}function bH(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 UC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?bH(Object(n),!0).forEach(function(i){uDe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):bH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function uDe(t,e,n){return(e=dDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dDe(t){var e=fDe(t,"string");return typeof e=="symbol"?e:e+""}function fDe(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 hDe(t){return Array.isArray(t)&&al(t[0])&&al(t[1])?t.join(" ~ "):t}var pDe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:i={},labelStyle:r={},payload:a,formatter:s,itemSorter:o,wrapperClassName:l,labelClassName:c,label:u,labelFormatter:f,accessibilityLayer:m=!1}=t,g=()=>{if(a&&a.length){var T={padding:0,margin:0},P=(o?Ow(a,o):a).map((A,j)=>{if(A.type==="none")return null;var N=A.formatter||s||hDe,{value:k,name:F}=A,I=k,W=F;if(N){var D=N(k,F,A,j,a);if(Array.isArray(D))[I,W]=D;else if(D!=null)I=D;else return null}var B=UC({display:"block",paddingTop:4,paddingBottom:4,color:A.color||"#000"},i);return E.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(j),style:B},al(W)?E.createElement("span",{className:"recharts-tooltip-item-name"},W):null,al(W)?E.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,E.createElement("span",{className:"recharts-tooltip-item-value"},I),E.createElement("span",{className:"recharts-tooltip-item-unit"},A.unit||""))});return E.createElement("ul",{className:"recharts-tooltip-item-list",style:T},P)}return null},y=UC({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),_=UC({margin:0},r),v=!gi(u),x=v?u:"",M=An("recharts-default-tooltip",l),w=An("recharts-tooltip-label",c);v&&f&&a!==void 0&&a!==null&&(x=f(u,a));var C=m?{role:"status","aria-live":"assertive"}:{};return E.createElement("div",VR({className:M,style:y},C),E.createElement("p",{className:w,style:_},E.isValidElement(x)?x:"".concat(x)),g())},Qg="recharts-tooltip-wrapper",mDe={visibility:"hidden"};function gDe(t){var{coordinate:e,translateX:n,translateY:i}=t;return An(Qg,{["".concat(Qg,"-right")]:Et(n)&&e&&Et(e.x)&&n>=e.x,["".concat(Qg,"-left")]:Et(n)&&e&&Et(e.x)&&n<e.x,["".concat(Qg,"-bottom")]:Et(i)&&e&&Et(e.y)&&i>=e.y,["".concat(Qg,"-top")]:Et(i)&&e&&Et(e.y)&&i<e.y})}function _H(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 u=n[i]-o-(r>0?r:0),f=n[i]+r;if(e[i])return s[i]?u:f;var m=l[i];if(m==null)return 0;if(s[i]){var g=u,y=m;return g<y?Math.max(f,m):Math.max(u,m)}if(c==null)return 0;var _=f+o,v=m+c;return _>v?Math.max(u,m):Math.max(f,m)}function xDe(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 vDe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:i,position:r,reverseDirection:a,tooltipBox:s,useTranslate3d:o,viewBox:l}=t,c,u,f;return s.height>0&&s.width>0&&n?(u=_H({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:i,position:r,reverseDirection:a,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=_H({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:i,position:r,reverseDirection:a,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),c=xDe({translateX:u,translateY:f,useTranslate3d:o})):c=mDe,{cssProperties:c,cssClasses:gDe({translateX:u,translateY:f,coordinate:n})}}function SH(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 t_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SH(Object(n),!0).forEach(function(i){GR(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function GR(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=bDe(t,"string");return typeof e=="symbol"?e:e+""}function bDe(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 _De extends E.PureComponent{constructor(){super(...arguments),GR(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),GR(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:u,reverseDirection:f,useTranslate3d:m,viewBox:g,wrapperStyle:y,lastBoundingBox:_,innerRef:v,hasPortalFromProps:x}=this.props,{cssClasses:M,cssProperties:w}=vDe({allowEscapeViewBox:n,coordinate:s,offsetTopLeft:c,position:u,reverseDirection:f,tooltipBox:{height:_.height,width:_.width},useTranslate3d:m,viewBox:g}),C=x?{}:t_(t_({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=t_(t_({},C),{},{visibility:!this.state.dismissed&&e&&o?"visible":"hidden"},y);return E.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:M,style:T,ref:v},a)}}var RY=()=>{var t;return(t=At(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};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 wH(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 MH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wH(Object(n),!0).forEach(function(i){SDe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function SDe(t,e,n){return(e=wDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wDe(t){var e=MDe(t,"string");return typeof e=="symbol"?e:e+""}function MDe(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 EH={curveBasisClosed:u3e,curveBasisOpen:d3e,curveBasis:c3e,curveBumpX:KNe,curveBumpY:YNe,curveLinearClosed:f3e,curveLinear:kw,curveMonotoneX:h3e,curveMonotoneY:p3e,curveNatural:m3e,curveStep:g3e,curveStepAfter:v3e,curveStepBefore:x3e},gS=t=>oi(t.x)&&oi(t.y),AH=t=>t.base!=null&&gS(t.base)&&gS(t),Jg=t=>t.x,ex=t=>t.y,EDe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(K0(t));return(n==="curveMonotone"||n==="curveBump")&&e?EH["".concat(n).concat(e==="vertical"?"Y":"X")]:EH[n]||kw},ADe=t=>{var{type:e="linear",points:n=[],baseLine:i,layout:r,connectNulls:a=!1}=t,s=EDe(e,r),o=a?n.filter(gS):n,l;if(Array.isArray(i)){var c=n.map((g,y)=>MH(MH({},g),{},{base:i[y]}));r==="vertical"?l=qb().y(ex).x1(Jg).x0(g=>g.base.x):l=qb().x(Jg).y1(ex).y0(g=>g.base.y);var u=l.defined(AH).curve(s),f=a?c.filter(AH):c;return u(f)}r==="vertical"&&Et(i)?l=qb().y(ex).x1(Jg).x0(i):Et(i)?l=qb().x(Jg).y1(ex).y0(i):l=tK().x(Jg).y(ex);var m=l.defined(gS).curve(s);return m(o)},Lp=t=>{var{className:e,points:n,path:i,pathRef:r}=t;if((!n||!n.length)&&!i)return null;var a=n&&n.length?ADe(t):i;return E.createElement("path",WR({},Ba(t),vD(t),{className:An("recharts-curve",e),d:a===null?void 0:a,ref:r}))},TDe=["x","y","top","left","width","height","className"];function qR(){return qR=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},qR.apply(null,arguments)}function TH(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 CDe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TH(Object(n),!0).forEach(function(i){NDe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function NDe(t,e,n){return(e=RDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RDe(t){var e=PDe(t,"string");return typeof e=="symbol"?e:e+""}function PDe(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 kDe(t,e){if(t==null)return{};var n,i,r=DDe(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 DDe(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 ODe=(t,e,n,i,r,a)=>"M".concat(t,",").concat(r,"v").concat(i,"M").concat(a,",").concat(e,"h").concat(n),LDe=t=>{var{x:e=0,y:n=0,top:i=0,left:r=0,width:a=0,height:s=0,className:o}=t,l=kDe(t,TDe),c=CDe({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:E.createElement("path",qR({},ba(c),{className:An("recharts-cross",o),d:ODe(e,n,a,s,i,r)}))};function IDe(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 CH(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 NH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CH(Object(n),!0).forEach(function(i){jDe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function jDe(t,e,n){return(e=UDe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UDe(t){var e=FDe(t,"string");return typeof e=="symbol"?e:e+""}function FDe(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 zDe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),PY=(t,e,n)=>t.map(i=>"".concat(zDe(i)," ").concat(e,"ms ").concat(n)).join(","),BDe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,i)=>n.filter(r=>i.includes(r))),E0=(t,e)=>Object.keys(e).reduce((n,i)=>NH(NH({},n),{},{[i]:t(i,e[i])}),{});function RH(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 nr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RH(Object(n),!0).forEach(function(i){HDe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function HDe(t,e,n){return(e=$De(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $De(t){var e=VDe(t,"string");return typeof e=="symbol"?e:e+""}function VDe(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 xS=(t,e,n)=>t+(e-t)*n,XR=t=>{var{from:e,to:n}=t;return e!==n},kY=(t,e,n)=>{var i=E0((r,a)=>{if(XR(a)){var[s,o]=t(a.from,a.to,a.velocity);return nr(nr({},a),{},{from:s,velocity:o})}return a},e);return n<1?E0((r,a)=>XR(a)?nr(nr({},a),{},{velocity:xS(a.velocity,i[r].velocity,n),from:xS(a.from,i[r].from,n)}):a,e):kY(t,i,n-1)};function GDe(t,e,n,i,r,a){var s,o=i.reduce((m,g)=>nr(nr({},m),{},{[g]:{from:t[g],velocity:0,to:e[g]}}),{}),l=()=>E0((m,g)=>g.from,o),c=()=>!Object.values(o).filter(XR).length,u=null,f=m=>{s||(s=m);var g=m-s,y=g/n.dt;o=kY(n,o,y),r(nr(nr(nr({},t),e),l())),s=m,c()||(u=a.setTimeout(f))};return()=>(u=a.setTimeout(f),()=>{var m;(m=u)===null||m===void 0||m()})}function WDe(t,e,n,i,r,a,s){var o=null,l=r.reduce((f,m)=>nr(nr({},f),{},{[m]:[t[m],e[m]]}),{}),c,u=f=>{c||(c=f);var m=(f-c)/i,g=E0((_,v)=>xS(...v,n(m)),l);if(a(nr(nr(nr({},t),e),g)),m<1)o=s.setTimeout(u);else{var y=E0((_,v)=>xS(...v,n(1)),l);a(nr(nr(nr({},t),e),y))}};return()=>(o=s.setTimeout(u),()=>{var f;(f=o)===null||f===void 0||f()})}const qDe=(t,e,n,i,r,a)=>{var s=BDe(t,e);return n==null?()=>(r(nr(nr({},t),e)),()=>{}):n.isStepper===!0?GDe(t,e,n,s,r,a):WDe(t,e,n,i,s,r,a)};var vS=1e-4,DY=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],OY=(t,e)=>t.map((n,i)=>n*e**i).reduce((n,i)=>n+i),PH=(t,e)=>n=>{var i=DY(t,e);return OY(i,n)},XDe=(t,e)=>n=>{var i=DY(t,e),r=[...i.map((a,s)=>a*s).slice(1),0];return OY(r,n)},KDe=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]},YDe=(t,e,n,i)=>{var r=PH(t,n),a=PH(e,i),s=XDe(t,n),o=c=>c>1?1:c<0?0:c,l=c=>{for(var u=c>1?1:c,f=u,m=0;m<8;++m){var g=r(f)-u,y=s(f);if(Math.abs(g-u)<vS||y<vS)return a(f);f=o(f-g/y)}return a(f)};return l.isStepper=!1,l},kH=function(){return YDe(...KDe(...arguments))},ZDe=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,u=l*i,f=l+(c-u)*r/1e3,m=l*r/1e3+s;return Math.abs(m-o)<vS&&Math.abs(f)<vS?[o,0]:[m,f]};return a.isStepper=!0,a.dt=r,a},QDe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return kH(t);case"spring":return ZDe();default:if(t.split("(")[0]==="cubic-bezier")return kH(t)}return typeof t=="function"?t:null};function JDe(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 eOe{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 tOe(){return JDe(new eOe)}var nOe=E.createContext(tOe);function iOe(t,e){var n=E.useContext(nOe);return E.useMemo(()=>e??n(t),[t,e,n])}var rOe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Om={devToolsEnabled:!1,isSsr:rOe()},aOe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},DH={t:0},FC={t:1};function iv(t){var e=Zi(t,aOe),{isActive:n,canBegin:i,duration:r,easing:a,begin:s,onAnimationEnd:o,onAnimationStart:l,children:c}=e,u=n==="auto"?!Om.isSsr:n,f=iOe(e.animationId,e.animationManager),[m,g]=E.useState(u?DH:FC),y=E.useRef(null);return E.useEffect(()=>{u||g(FC)},[u]),E.useEffect(()=>{if(!u||!i)return Y0;var _=qDe(DH,FC,QDe(a),r,g,f.getTimeoutController()),v=()=>{y.current=_()};return f.start([l,s,v,r,o]),()=>{f.stop(),y.current&&y.current(),o()}},[u,i,r,a,s,l,o,f]),c(m.t)}function rv(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=E.useRef(v0(e)),i=E.useRef(t);return i.current!==t&&(n.current=v0(e),i.current=t),n.current}var sOe=["radius"],oOe=["radius"];function OH(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 LH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OH(Object(n),!0).forEach(function(i){lOe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function lOe(t,e,n){return(e=cOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cOe(t){var e=uOe(t,"string");return typeof e=="symbol"?e:e+""}function uOe(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 yS(){return yS=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},yS.apply(null,arguments)}function IH(t,e){if(t==null)return{};var n,i,r=dOe(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 dOe(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 jH=(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 u=[0,0,0,0],f=0,m=4;f<m;f++)u[f]=r[f]>a?a:r[f];c="M".concat(t,",").concat(e+s*u[0]),u[0]>0&&(c+="A ".concat(u[0],",").concat(u[0],",0,0,").concat(l,",").concat(t+o*u[0],",").concat(e)),c+="L ".concat(t+n-o*u[1],",").concat(e),u[1]>0&&(c+="A ".concat(u[1],",").concat(u[1],",0,0,").concat(l,`,
- `).concat(t+n,",").concat(e+s*u[1])),c+="L ".concat(t+n,",").concat(e+i-s*u[2]),u[2]>0&&(c+="A ".concat(u[2],",").concat(u[2],",0,0,").concat(l,`,
- `).concat(t+n-o*u[2],",").concat(e+i)),c+="L ".concat(t+o*u[3],",").concat(e+i),u[3]>0&&(c+="A ".concat(u[3],",").concat(u[3],",0,0,").concat(l,`,
- `).concat(t,",").concat(e+i-s*u[3])),c+="Z"}else if(a>0&&r===+r&&r>0){var g=Math.min(a,r);c="M ".concat(t,",").concat(e+s*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(l,",").concat(t+o*g,",").concat(e,`
- L `).concat(t+n-o*g,",").concat(e,`
- A `).concat(g,",").concat(g,",0,0,").concat(l,",").concat(t+n,",").concat(e+s*g,`
- L `).concat(t+n,",").concat(e+i-s*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(l,",").concat(t+n-o*g,",").concat(e+i,`
- L `).concat(t+o*g,",").concat(e+i,`
- A `).concat(g,",").concat(g,",0,0,").concat(l,",").concat(t,",").concat(e+i-s*g," Z")}else c="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(i," h ").concat(-n," Z");return c},UH={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},LY=t=>{var e=Zi(t,UH),n=E.useRef(null),[i,r]=E.useState(-1);E.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var K=n.current.getTotalLength();K&&r(K)}catch{}},[]);var{x:a,y:s,width:o,height:l,radius:c,className:u}=e,{animationEasing:f,animationDuration:m,animationBegin:g,isAnimationActive:y,isUpdateAnimationActive:_}=e,v=E.useRef(o),x=E.useRef(l),M=E.useRef(a),w=E.useRef(s),C=E.useMemo(()=>({x:a,y:s,width:o,height:l,radius:c}),[a,s,o,l,c]),T=rv(C,"rectangle-");if(a!==+a||s!==+s||o!==+o||l!==+l||o===0||l===0)return null;var P=An("recharts-rectangle",u);if(!_){var A=ba(e),{radius:j}=A,N=IH(A,sOe);return E.createElement("path",yS({},N,{radius:typeof c=="number"?c:void 0,className:P,d:jH(a,s,o,l,c)}))}var k=v.current,F=x.current,I=M.current,W=w.current,D="0px ".concat(i===-1?1:i,"px"),B="".concat(i,"px 0px"),$=PY(["strokeDasharray"],m,typeof f=="string"?f:UH.animationEasing);return E.createElement(iv,{animationId:T,key:T,canBegin:i>0,duration:m,easing:f,isActive:_,begin:g},K=>{var X=si(k,o,K),Y=si(F,l,K),ee=si(I,a,K),z=si(W,s,K);n.current&&(v.current=X,x.current=Y,M.current=ee,w.current=z);var V;y?K>0?V={transition:$,strokeDasharray:B}:V={strokeDasharray:D}:V={strokeDasharray:B};var re=ba(e),{radius:le}=re,ge=IH(re,oOe);return E.createElement("path",yS({},ge,{radius:typeof c=="number"?c:void 0,className:P,d:jH(ee,z,X,Y,c),ref:n,style:LH(LH({},V),e.style)}))})};function FH(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 zH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FH(Object(n),!0).forEach(function(i){fOe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FH(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function fOe(t,e,n){return(e=hOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function hOe(t){var e=pOe(t,"string");return typeof e=="symbol"?e:e+""}function pOe(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 bS=Math.PI/180,mOe=t=>t*180/Math.PI,Wi=(t,e,n,i)=>({x:t+Math.cos(-bS*i)*n,y:e+Math.sin(-bS*i)*n}),IY=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},gOe=(t,e)=>{var{x:n,y:i}=t,{x:r,y:a}=e;return Math.sqrt((n-r)**2+(i-a)**2)},xOe=(t,e)=>{var{x:n,y:i}=t,{cx:r,cy:a}=e,s=gOe({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:mOe(l),angleInRadian:l}},vOe=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}},yOe=(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},bOe=(t,e)=>{var{chartX:n,chartY:i}=t,{radius:r,angle:a}=xOe({x:n,y:i},e),{innerRadius:s,outerRadius:o}=e;if(r<s||r>o||r===0)return null;var{startAngle:l,endAngle:c}=vOe(e),u=a,f;if(l<=c){for(;u>c;)u-=360;for(;u<l;)u+=360;f=u>=l&&u<=c}else{for(;u>l;)u-=360;for(;u<c;)u+=360;f=u>=c&&u<=l}return f?zH(zH({},e),{},{radius:r,angle:yOe(u,e)}):null};function jY(t){var{cx:e,cy:n,radius:i,startAngle:r,endAngle:a}=t,s=Wi(e,n,i,r),o=Wi(e,n,i,a);return{points:[s,o],cx:e,cy:n,radius:i,startAngle:r,endAngle:a}}function KR(){return KR=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},KR.apply(null,arguments)}var _Oe=(t,e)=>{var n=Tr(e-t),i=Math.min(Math.abs(e-t),359.999);return n*i},n_=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,u=Math.asin(o/c)/bS,f=l?r:r+a*u,m=Wi(e,n,c,f),g=Wi(e,n,i,f),y=l?r-a*u:r,_=Wi(e,n,c*Math.cos(u*bS),y);return{center:m,circleTangency:g,lineTangency:_,theta:u}},UY=t=>{var{cx:e,cy:n,innerRadius:i,outerRadius:r,startAngle:a,endAngle:s}=t,o=_Oe(a,s),l=a+o,c=Wi(e,n,r,a),u=Wi(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(u.x,",").concat(u.y,`
- `);if(i>0){var m=Wi(e,n,i,a),g=Wi(e,n,i,l);f+="L ".concat(g.x,",").concat(g.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(o)>180),",").concat(+(a<=l),`,
- `).concat(m.x,",").concat(m.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},SOe=t=>{var{cx:e,cy:n,innerRadius:i,outerRadius:r,cornerRadius:a,forceCornerRadius:s,cornerIsExternal:o,startAngle:l,endAngle:c}=t,u=Tr(c-l),{circleTangency:f,lineTangency:m,theta:g}=n_({cx:e,cy:n,radius:r,angle:l,sign:u,cornerRadius:a,cornerIsExternal:o}),{circleTangency:y,lineTangency:_,theta:v}=n_({cx:e,cy:n,radius:r,angle:c,sign:-u,cornerRadius:a,cornerIsExternal:o}),x=o?Math.abs(l-c):Math.abs(l-c)-g-v;if(x<0)return s?"M ".concat(m.x,",").concat(m.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
- `):UY({cx:e,cy:n,innerRadius:i,outerRadius:r,startAngle:l,endAngle:c});var M="M ".concat(m.x,",").concat(m.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(x>180),",").concat(+(u<0),",").concat(y.x,",").concat(y.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(_.x,",").concat(_.y,`
- `);if(i>0){var{circleTangency:w,lineTangency:C,theta:T}=n_({cx:e,cy:n,radius:i,angle:l,sign:u,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),{circleTangency:P,lineTangency:A,theta:j}=n_({cx:e,cy:n,radius:i,angle:c,sign:-u,isExternal:!0,cornerRadius:a,cornerIsExternal:o}),N=o?Math.abs(l-c):Math.abs(l-c)-T-j;if(N<0&&a===0)return"".concat(M,"L").concat(e,",").concat(n,"Z");M+="L".concat(A.x,",").concat(A.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(P.x,",").concat(P.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(N>180),",").concat(+(u>0),",").concat(w.x,",").concat(w.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(u<0),",").concat(C.x,",").concat(C.y,"Z")}else M+="L".concat(e,",").concat(n,"Z");return M},wOe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},FY=t=>{var e=Zi(t,wOe),{cx:n,cy:i,innerRadius:r,outerRadius:a,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u,className:f}=e;if(a<r||c===u)return null;var m=An("recharts-sector",f),g=a-r,y=ra(s,g,0,!0),_;return y>0&&Math.abs(c-u)<360?_=SOe({cx:n,cy:i,innerRadius:r,outerRadius:a,cornerRadius:Math.min(y,g/2),forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}):_=UY({cx:n,cy:i,innerRadius:r,outerRadius:a,startAngle:c,endAngle:u}),E.createElement("path",KR({},ba(e),{className:m,d:_}))};function MOe(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(gK(e)){if(t==="centric"){var{cx:i,cy:r,innerRadius:a,outerRadius:s,angle:o}=e,l=Wi(i,r,a,o),c=Wi(i,r,s,o);return[{x:l.x,y:l.y},{x:c.x,y:c.y}]}return jY(e)}}var zC={},BC={},HC={},BH;function EOe(){return BH||(BH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CK();function n(i){return e.isSymbol(i)?NaN:Number(i)}t.toNumber=n})(HC)),HC}var HH;function AOe(){return HH||(HH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=EOe();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})(BC)),BC}var $H;function TOe(){return $H||($H=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=NK(),n=AOe();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})(zC)),zC}var $C,VH;function COe(){return VH||(VH=1,$C=TOe().range),$C}var NOe=COe();const zY=Ys(NOe);function Wu(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ROe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function LD(t){let e,n,i;t.length!==2?(e=Wu,n=(o,l)=>Wu(t(o),l),i=(o,l)=>t(o)-l):(e=t===Wu||t===ROe?t:POe,n=t,i=t);function r(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;n(o[f],l)<0?c=f+1:u=f}while(c<u)}return c}function a(o,l,c=0,u=o.length){if(c<u){if(e(l,l)!==0)return u;do{const f=c+u>>>1;n(o[f],l)<=0?c=f+1:u=f}while(c<u)}return c}function s(o,l,c=0,u=o.length){const f=r(o,l,c,u-1);return f>c&&i(o[f-1],l)>-i(o[f],l)?f-1:f}return{left:r,center:s,right:a}}function POe(){return 0}function BY(t){return t===null?NaN:+t}function*kOe(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const DOe=LD(Wu),av=DOe.right;LD(BY).center;class GH extends Map{constructor(e,n=IOe){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(WH(this,e))}has(e){return super.has(WH(this,e))}set(e,n){return super.set(OOe(this,e),n)}delete(e){return super.delete(LOe(this,e))}}function WH({_intern:t,_key:e},n){const i=e(n);return t.has(i)?t.get(i):n}function OOe({_intern:t,_key:e},n){const i=e(n);return t.has(i)?t.get(i):(t.set(i,n),n)}function LOe({_intern:t,_key:e},n){const i=e(n);return t.has(i)&&(n=t.get(i),t.delete(i)),n}function IOe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function jOe(t=Wu){if(t===Wu)return HY;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 HY(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const UOe=Math.sqrt(50),FOe=Math.sqrt(10),zOe=Math.sqrt(2);function _S(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>=UOe?10:a>=FOe?5:a>=zOe?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?_S(t,e,n*2):[o,l,c]}function YR(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?_S(e,t,n):_S(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 ZR(t,e,n){return e=+e,t=+t,n=+n,_S(t,e,n)[2]}function QR(t,e,n){e=+e,t=+t,n=+n;const i=e<t,r=i?ZR(e,t,n):ZR(t,e,n);return(i?-1:1)*(r<0?1/-r:r)}function qH(t,e){let n;for(const i of t)i!=null&&(n<i||n===void 0&&i>=i)&&(n=i);return n}function XH(t,e){let n;for(const i of t)i!=null&&(n>i||n===void 0&&i>=i)&&(n=i);return n}function $Y(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?HY:jOe(r);i>n;){if(i-n>600){const l=i-n+1,c=e-n+1,u=Math.log(l),f=.5*Math.exp(2*u/3),m=.5*Math.sqrt(u*f*(l-f)/l)*(c-l/2<0?-1:1),g=Math.max(n,Math.floor(e-c*f/l+m)),y=Math.min(i,Math.floor(e+(l-c)*f/l+m));$Y(t,e,g,y,r)}const a=t[e];let s=n,o=i;for(tx(t,n,e),r(t[i],a)>0&&tx(t,n,i);s<o;){for(tx(t,s,o),++s,--o;r(t[s],a)<0;)++s;for(;r(t[o],a)>0;)--o}r(t[n],a)===0?tx(t,n,o):(++o,tx(t,o,i)),o<=e&&(n=o+1),e<=o&&(i=o-1)}return t}function tx(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function BOe(t,e,n){if(t=Float64Array.from(kOe(t)),!(!(i=t.length)||isNaN(e=+e))){if(e<=0||i<2)return XH(t);if(e>=1)return qH(t);var i,r=(i-1)*e,a=Math.floor(r),s=qH($Y(t,a).subarray(0,a+1)),o=XH(t.subarray(a+1));return s+(o-s)*(r-a)}}function HOe(t,e,n=BY){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 $Oe(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 Zs(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Rc(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 JR=Symbol("implicit");function ID(){var t=new GH,e=[],n=[],i=JR;function r(a){let s=t.get(a);if(s===void 0){if(i!==JR)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 GH;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 ID(e,n).unknown(i)},Zs.apply(r,arguments),r}function jD(){var t=ID().unknown(void 0),e=t.domain,n=t.range,i=0,r=1,a,s,o=!1,l=0,c=0,u=.5;delete t.unknown;function f(){var m=e().length,g=r<i,y=g?r:i,_=g?i:r;a=(_-y)/Math.max(1,m-l+c*2),o&&(a=Math.floor(a)),y+=(_-y-a*(m-l))*u,s=a*(1-l),o&&(y=Math.round(y),s=Math.round(s));var v=$Oe(m).map(function(x){return y+a*x});return n(g?v.reverse():v)}return t.domain=function(m){return arguments.length?(e(m),f()):e()},t.range=function(m){return arguments.length?([i,r]=m,i=+i,r=+r,f()):[i,r]},t.rangeRound=function(m){return[i,r]=m,i=+i,r=+r,o=!0,f()},t.bandwidth=function(){return s},t.step=function(){return a},t.round=function(m){return arguments.length?(o=!!m,f()):o},t.padding=function(m){return arguments.length?(l=Math.min(1,c=+m),f()):l},t.paddingInner=function(m){return arguments.length?(l=Math.min(1,m),f()):l},t.paddingOuter=function(m){return arguments.length?(c=+m,f()):c},t.align=function(m){return arguments.length?(u=Math.max(0,Math.min(1,m)),f()):u},t.copy=function(){return jD(e(),[i,r]).round(o).paddingInner(l).paddingOuter(c).align(u)},Zs.apply(f(),arguments)}function VY(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return VY(e())},t}function VOe(){return VY(jD.apply(null,arguments).paddingInner(1))}function UD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function GY(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function sv(){}var A0=.7,SS=1/A0,Ip="\\s*([+-]?\\d+)\\s*",T0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Yo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",GOe=/^#([0-9a-f]{3,8})$/,WOe=new RegExp(`^rgb\\(${Ip},${Ip},${Ip}\\)$`),qOe=new RegExp(`^rgb\\(${Yo},${Yo},${Yo}\\)$`),XOe=new RegExp(`^rgba\\(${Ip},${Ip},${Ip},${T0}\\)$`),KOe=new RegExp(`^rgba\\(${Yo},${Yo},${Yo},${T0}\\)$`),YOe=new RegExp(`^hsl\\(${T0},${Yo},${Yo}\\)$`),ZOe=new RegExp(`^hsla\\(${T0},${Yo},${Yo},${T0}\\)$`),KH={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};UD(sv,C0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:YH,formatHex:YH,formatHex8:QOe,formatHsl:JOe,formatRgb:ZH,toString:ZH});function YH(){return this.rgb().formatHex()}function QOe(){return this.rgb().formatHex8()}function JOe(){return WY(this).formatHsl()}function ZH(){return this.rgb().formatRgb()}function C0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=GOe.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?QH(e):n===3?new La(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?i_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?i_(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=WOe.exec(t))?new La(e[1],e[2],e[3],1):(e=qOe.exec(t))?new La(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=XOe.exec(t))?i_(e[1],e[2],e[3],e[4]):(e=KOe.exec(t))?i_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=YOe.exec(t))?t$(e[1],e[2]/100,e[3]/100,1):(e=ZOe.exec(t))?t$(e[1],e[2]/100,e[3]/100,e[4]):KH.hasOwnProperty(t)?QH(KH[t]):t==="transparent"?new La(NaN,NaN,NaN,0):null}function QH(t){return new La(t>>16&255,t>>8&255,t&255,1)}function i_(t,e,n,i){return i<=0&&(t=e=n=NaN),new La(t,e,n,i)}function eLe(t){return t instanceof sv||(t=C0(t)),t?(t=t.rgb(),new La(t.r,t.g,t.b,t.opacity)):new La}function eP(t,e,n,i){return arguments.length===1?eLe(t):new La(t,e,n,i??1)}function La(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}UD(La,eP,GY(sv,{brighter(t){return t=t==null?SS:Math.pow(SS,t),new La(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?A0:Math.pow(A0,t),new La(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new La(mf(this.r),mf(this.g),mf(this.b),wS(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:JH,formatHex:JH,formatHex8:tLe,formatRgb:e$,toString:e$}));function JH(){return`#${tf(this.r)}${tf(this.g)}${tf(this.b)}`}function tLe(){return`#${tf(this.r)}${tf(this.g)}${tf(this.b)}${tf((isNaN(this.opacity)?1:this.opacity)*255)}`}function e$(){const t=wS(this.opacity);return`${t===1?"rgb(":"rgba("}${mf(this.r)}, ${mf(this.g)}, ${mf(this.b)}${t===1?")":`, ${t})`}`}function wS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function mf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function tf(t){return t=mf(t),(t<16?"0":"")+t.toString(16)}function t$(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new mo(t,e,n,i)}function WY(t){if(t instanceof mo)return new mo(t.h,t.s,t.l,t.opacity);if(t instanceof sv||(t=C0(t)),!t)return new mo;if(t instanceof mo)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 mo(s,o,l,t.opacity)}function nLe(t,e,n,i){return arguments.length===1?WY(t):new mo(t,e,n,i??1)}function mo(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}UD(mo,nLe,GY(sv,{brighter(t){return t=t==null?SS:Math.pow(SS,t),new mo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?A0:Math.pow(A0,t),new mo(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 La(VC(t>=240?t-240:t+120,r,i),VC(t,r,i),VC(t<120?t+240:t-120,r,i),this.opacity)},clamp(){return new mo(n$(this.h),r_(this.s),r_(this.l),wS(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=wS(this.opacity);return`${t===1?"hsl(":"hsla("}${n$(this.h)}, ${r_(this.s)*100}%, ${r_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function n$(t){return t=(t||0)%360,t<0?t+360:t}function r_(t){return Math.max(0,Math.min(1,t||0))}function VC(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 FD=t=>()=>t;function iLe(t,e){return function(n){return t+n*e}}function rLe(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 aLe(t){return(t=+t)==1?qY:function(e,n){return n-e?rLe(e,n,t):FD(isNaN(e)?n:e)}}function qY(t,e){var n=e-t;return n?iLe(t,n):FD(isNaN(t)?e:t)}const i$=(function t(e){var n=aLe(e);function i(r,a){var s=n((r=eP(r)).r,(a=eP(a)).r),o=n(r.g,a.g),l=n(r.b,a.b),c=qY(r.opacity,a.opacity);return function(u){return r.r=s(u),r.g=o(u),r.b=l(u),r.opacity=c(u),r+""}}return i.gamma=t,i})(1);function sLe(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 oLe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function lLe(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]=Lm(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 cLe(t,e){var n=new Date;return t=+t,e=+e,function(i){return n.setTime(t*(1-i)+e*i),n}}function MS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function uLe(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]=Lm(t[r],e[r]):i[r]=e[r];return function(a){for(r in n)i[r]=n[r](a);return i}}var tP=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,GC=new RegExp(tP.source,"g");function dLe(t){return function(){return t}}function fLe(t){return function(e){return t(e)+""}}function hLe(t,e){var n=tP.lastIndex=GC.lastIndex=0,i,r,a,s=-1,o=[],l=[];for(t=t+"",e=e+"";(i=tP.exec(t))&&(r=GC.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:MS(i,r)})),n=GC.lastIndex;return n<e.length&&(a=e.slice(n),o[s]?o[s]+=a:o[++s]=a),o.length<2?l[0]?fLe(l[0].x):dLe(e):(e=l.length,function(c){for(var u=0,f;u<e;++u)o[(f=l[u]).i]=f.x(c);return o.join("")})}function Lm(t,e){var n=typeof e,i;return e==null||n==="boolean"?FD(e):(n==="number"?MS:n==="string"?(i=C0(e))?(e=i,i$):hLe:e instanceof C0?i$:e instanceof Date?cLe:oLe(e)?sLe:Array.isArray(e)?lLe:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?uLe:MS)(t,e)}function zD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function pLe(t,e){e===void 0&&(e=t,t=Lm);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 mLe(t){return function(){return t}}function ES(t){return+t}var r$=[0,1];function ma(t){return t}function nP(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:mLe(isNaN(e)?NaN:.5)}function gLe(t,e){var n;return t>e&&(n=t,t=e,e=n),function(i){return Math.max(t,Math.min(e,i))}}function xLe(t,e,n){var i=t[0],r=t[1],a=e[0],s=e[1];return r<i?(i=nP(r,i),a=n(s,a)):(i=nP(i,r),a=n(a,s)),function(o){return a(i(o))}}function vLe(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]=nP(t[s],t[s+1]),a[s]=n(e[s],e[s+1]);return function(o){var l=av(t,o,1,i)-1;return a[l](r[l](o))}}function ov(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Qw(){var t=r$,e=r$,n=Lm,i,r,a,s=ma,o,l,c;function u(){var m=Math.min(t.length,e.length);return s!==ma&&(s=gLe(t[0],t[m-1])),o=m>2?vLe:xLe,l=c=null,f}function f(m){return m==null||isNaN(m=+m)?a:(l||(l=o(t.map(i),e,n)))(i(s(m)))}return f.invert=function(m){return s(r((c||(c=o(e,t.map(i),MS)))(m)))},f.domain=function(m){return arguments.length?(t=Array.from(m,ES),u()):t.slice()},f.range=function(m){return arguments.length?(e=Array.from(m),u()):e.slice()},f.rangeRound=function(m){return e=Array.from(m),n=zD,u()},f.clamp=function(m){return arguments.length?(s=m?!0:ma,u()):s!==ma},f.interpolate=function(m){return arguments.length?(n=m,u()):n},f.unknown=function(m){return arguments.length?(a=m,f):a},function(m,g){return i=m,r=g,u()}}function BD(){return Qw()(ma,ma)}function yLe(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function AS(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 pm(t){return t=AS(Math.abs(t)),t?t[1]:NaN}function bLe(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 _Le(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var SLe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function N0(t){if(!(e=SLe.exec(t)))throw new Error("invalid format: "+t);var e;return new HD({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]})}N0.prototype=HD.prototype;function HD(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+""}HD.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 wLe(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 XY;function MLe(t,e){var n=AS(t,e);if(!n)return t+"";var i=n[0],r=n[1],a=r-(XY=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")+AS(t,Math.max(0,e+a-1))[0]}function a$(t,e){var n=AS(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 s$={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:yLe,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)=>a$(t*100,e),r:a$,s:MLe,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function o$(t){return t}var l$=Array.prototype.map,c$=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ELe(t){var e=t.grouping===void 0||t.thousands===void 0?o$:bLe(l$.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?o$:_Le(l$.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=N0(f);var m=f.fill,g=f.align,y=f.sign,_=f.symbol,v=f.zero,x=f.width,M=f.comma,w=f.precision,C=f.trim,T=f.type;T==="n"?(M=!0,T="g"):s$[T]||(w===void 0&&(w=12),C=!0,T="g"),(v||m==="0"&&g==="=")&&(v=!0,m="0",g="=");var P=_==="$"?n:_==="#"&&/[boxX]/.test(T)?"0"+T.toLowerCase():"",A=_==="$"?i:/[%p]/.test(T)?s:"",j=s$[T],N=/[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 k(F){var I=P,W=A,D,B,$;if(T==="c")W=j(F)+W,F="";else{F=+F;var K=F<0||1/F<0;if(F=isNaN(F)?l:j(Math.abs(F),w),C&&(F=wLe(F)),K&&+F==0&&y!=="+"&&(K=!1),I=(K?y==="("?y:o:y==="-"||y==="("?"":y)+I,W=(T==="s"?c$[8+XY/3]:"")+W+(K&&y==="("?")":""),N){for(D=-1,B=F.length;++D<B;)if($=F.charCodeAt(D),48>$||$>57){W=($===46?r+F.slice(D+1):F.slice(D))+W,F=F.slice(0,D);break}}}M&&!v&&(F=e(F,1/0));var X=I.length+F.length+W.length,Y=X<x?new Array(x-X+1).join(m):"";switch(M&&v&&(F=e(Y+F,Y.length?x-W.length:1/0),Y=""),g){case"<":F=I+F+W+Y;break;case"=":F=I+Y+F+W;break;case"^":F=Y.slice(0,X=Y.length>>1)+I+F+W+Y.slice(X);break;default:F=Y+I+F+W;break}return a(F)}return k.toString=function(){return f+""},k}function u(f,m){var g=c((f=N0(f),f.type="f",f)),y=Math.max(-8,Math.min(8,Math.floor(pm(m)/3)))*3,_=Math.pow(10,-y),v=c$[8+y/3];return function(x){return g(_*x)+v}}return{format:c,formatPrefix:u}}var a_,$D,KY;ALe({thousands:",",grouping:[3],currency:["$",""]});function ALe(t){return a_=ELe(t),$D=a_.format,KY=a_.formatPrefix,a_}function TLe(t){return Math.max(0,-pm(Math.abs(t)))}function CLe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(pm(e)/3)))*3-pm(Math.abs(t)))}function NLe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,pm(e)-pm(t))+1}function YY(t,e,n,i){var r=QR(t,e,n),a;switch(i=N0(i??",f"),i.type){case"s":{var s=Math.max(Math.abs(t),Math.abs(e));return i.precision==null&&!isNaN(a=CLe(r,s))&&(i.precision=a),KY(i,s)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(a=NLe(r,Math.max(Math.abs(t),Math.abs(e))))&&(i.precision=a-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(a=TLe(r))&&(i.precision=a-(i.type==="%")*2);break}}return $D(i)}function ld(t){var e=t.domain;return t.ticks=function(n){var i=e();return YR(i[0],i[i.length-1],n??10)},t.tickFormat=function(n,i){var r=e();return YY(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,u=10;for(o<s&&(c=s,s=o,o=c,c=r,r=a,a=c);u-- >0;){if(c=ZR(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 ZY(){var t=BD();return t.copy=function(){return ov(t,ZY())},Zs.apply(t,arguments),ld(t)}function QY(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,ES),n):t.slice()},n.unknown=function(i){return arguments.length?(e=i,n):e},n.copy=function(){return QY(t).unknown(e)},t=arguments.length?Array.from(t,ES):[0,1],ld(n)}function JY(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 u$(t){return Math.log(t)}function d$(t){return Math.exp(t)}function RLe(t){return-Math.log(-t)}function PLe(t){return-Math.exp(-t)}function kLe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function DLe(t){return t===10?kLe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function OLe(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 f$(t){return(e,n)=>-t(-e,n)}function VD(t){const e=t(u$,d$),n=e.domain;let i=10,r,a;function s(){return r=OLe(i),a=DLe(i),n()[0]<0?(r=f$(r),a=f$(a),t(RLe,PLe)):t(u$,d$),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],u=l[l.length-1];const f=u<c;f&&([c,u]=[u,c]);let m=r(c),g=r(u),y,_;const v=o==null?10:+o;let x=[];if(!(i%1)&&g-m<v){if(m=Math.floor(m),g=Math.ceil(g),c>0){for(;m<=g;++m)for(y=1;y<i;++y)if(_=m<0?y/a(-m):y*a(m),!(_<c)){if(_>u)break;x.push(_)}}else for(;m<=g;++m)for(y=i-1;y>=1;--y)if(_=m>0?y/a(-m):y*a(m),!(_<c)){if(_>u)break;x.push(_)}x.length*2<v&&(x=YR(c,u,v))}else x=YR(m,g,Math.min(g-m,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=N0(l)).precision==null&&(l.trim=!0),l=$D(l)),o===1/0)return l;const c=Math.max(1,i*o/e.ticks().length);return u=>{let f=u/a(Math.round(r(u)));return f*i<i-.5&&(f*=i),f<=c?l(u):""}},e.nice=()=>n(JY(n(),{floor:o=>a(Math.floor(r(o))),ceil:o=>a(Math.ceil(r(o)))})),e}function eZ(){const t=VD(Qw()).domain([1,10]);return t.copy=()=>ov(t,eZ()).base(t.base()),Zs.apply(t,arguments),t}function h$(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function p$(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function GD(t){var e=1,n=t(h$(e),p$(e));return n.constant=function(i){return arguments.length?t(h$(e=+i),p$(e)):e},ld(n)}function tZ(){var t=GD(Qw());return t.copy=function(){return ov(t,tZ()).constant(t.constant())},Zs.apply(t,arguments)}function m$(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function LLe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function ILe(t){return t<0?-t*t:t*t}function WD(t){var e=t(ma,ma),n=1;function i(){return n===1?t(ma,ma):n===.5?t(LLe,ILe):t(m$(n),m$(1/n))}return e.exponent=function(r){return arguments.length?(n=+r,i()):n},ld(e)}function qD(){var t=WD(Qw());return t.copy=function(){return ov(t,qD()).exponent(t.exponent())},Zs.apply(t,arguments),t}function jLe(){return qD.apply(null,arguments).exponent(.5)}function g$(t){return Math.sign(t)*t*t}function ULe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function nZ(){var t=BD(),e=[0,1],n=!1,i;function r(a){var s=ULe(t(a));return isNaN(s)?i:n?Math.round(s):s}return r.invert=function(a){return t.invert(g$(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,ES)).map(g$)),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 nZ(t.domain(),e).round(n).clamp(t.clamp()).unknown(i)},Zs.apply(r,arguments),ld(r)}function iZ(){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]=HOe(t,s/o);return a}function a(s){return s==null||isNaN(s=+s)?i:e[av(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(Wu),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 iZ().domain(t).range(e).unknown(i)},Zs.apply(a,arguments)}function rZ(){var t=0,e=1,n=1,i=[.5],r=[0,1],a;function s(l){return l!=null&&l<=l?r[av(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 rZ().domain([t,e]).range(r).unknown(a)},Zs.apply(ld(s),arguments)}function aZ(){var t=[.5],e=[0,1],n,i=1;function r(a){return a!=null&&a<=a?e[av(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 aZ().domain(t).range(e).unknown(n)},Zs.apply(r,arguments)}const WC=new Date,qC=new Date;function fr(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=>fr(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)=>(WC.setTime(+a),qC.setTime(+s),t(WC),t(qC),Math.floor(n(WC,qC))),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 TS=fr(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);TS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?fr(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):TS);TS.range;const nc=1e3,Hs=nc*60,ic=Hs*60,bc=ic*24,XD=bc*7,x$=bc*30,XC=bc*365,nf=fr(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*nc)},(t,e)=>(e-t)/nc,t=>t.getUTCSeconds());nf.range;const KD=fr(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*nc)},(t,e)=>{t.setTime(+t+e*Hs)},(t,e)=>(e-t)/Hs,t=>t.getMinutes());KD.range;const YD=fr(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Hs)},(t,e)=>(e-t)/Hs,t=>t.getUTCMinutes());YD.range;const ZD=fr(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*nc-t.getMinutes()*Hs)},(t,e)=>{t.setTime(+t+e*ic)},(t,e)=>(e-t)/ic,t=>t.getHours());ZD.range;const QD=fr(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*ic)},(t,e)=>(e-t)/ic,t=>t.getUTCHours());QD.range;const lv=fr(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Hs)/bc,t=>t.getDate()-1);lv.range;const Jw=fr(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/bc,t=>t.getUTCDate()-1);Jw.range;const sZ=fr(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/bc,t=>Math.floor(t/bc));sZ.range;function Gf(t){return fr(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())*Hs)/XD)}const eM=Gf(0),CS=Gf(1),FLe=Gf(2),zLe=Gf(3),mm=Gf(4),BLe=Gf(5),HLe=Gf(6);eM.range;CS.range;FLe.range;zLe.range;mm.range;BLe.range;HLe.range;function Wf(t){return fr(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)/XD)}const tM=Wf(0),NS=Wf(1),$Le=Wf(2),VLe=Wf(3),gm=Wf(4),GLe=Wf(5),WLe=Wf(6);tM.range;NS.range;$Le.range;VLe.range;gm.range;GLe.range;WLe.range;const JD=fr(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());JD.range;const eO=fr(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());eO.range;const _c=fr(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());_c.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:fr(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)});_c.range;const Sc=fr(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());Sc.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:fr(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)});Sc.range;function oZ(t,e,n,i,r,a){const s=[[nf,1,nc],[nf,5,5*nc],[nf,15,15*nc],[nf,30,30*nc],[a,1,Hs],[a,5,5*Hs],[a,15,15*Hs],[a,30,30*Hs],[r,1,ic],[r,3,3*ic],[r,6,6*ic],[r,12,12*ic],[i,1,bc],[i,2,2*bc],[n,1,XD],[e,1,x$],[e,3,3*x$],[t,1,XC]];function o(c,u,f){const m=u<c;m&&([c,u]=[u,c]);const g=f&&typeof f.range=="function"?f:l(c,u,f),y=g?g.range(c,+u+1):[];return m?y.reverse():y}function l(c,u,f){const m=Math.abs(u-c)/f,g=LD(([,,v])=>v).right(s,m);if(g===s.length)return t.every(QR(c/XC,u/XC,f));if(g===0)return TS.every(Math.max(QR(c,u,f),1));const[y,_]=s[m/s[g-1][2]<s[g][2]/m?g-1:g];return y.every(_)}return[o,l]}const[qLe,XLe]=oZ(Sc,eO,tM,sZ,QD,YD),[KLe,YLe]=oZ(_c,JD,eM,lv,ZD,KD);function KC(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 YC(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 nx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function ZLe(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=ix(r),u=rx(r),f=ix(a),m=rx(a),g=ix(s),y=rx(s),_=ix(o),v=rx(o),x=ix(l),M=rx(l),w={a:K,A:X,b:Y,B:ee,c:null,d:w$,e:w$,f:bIe,g:RIe,G:kIe,H:xIe,I:vIe,j:yIe,L:lZ,m:_Ie,M:SIe,p:z,q:V,Q:A$,s:T$,S:wIe,u:MIe,U:EIe,V:AIe,w:TIe,W:CIe,x:null,X:null,y:NIe,Y:PIe,Z:DIe,"%":E$},C={a:re,A:le,b:ge,B:ie,c:null,d:M$,e:M$,f:jIe,g:qIe,G:KIe,H:OIe,I:LIe,j:IIe,L:uZ,m:UIe,M:FIe,p:xe,q:ke,Q:A$,s:T$,S:zIe,u:BIe,U:HIe,V:$Ie,w:VIe,W:GIe,x:null,X:null,y:WIe,Y:XIe,Z:YIe,"%":E$},T={a:k,A:F,b:I,B:W,c:D,d:_$,e:_$,f:hIe,g:b$,G:y$,H:S$,I:S$,j:cIe,L:fIe,m:lIe,M:uIe,p:N,q:oIe,Q:mIe,s:gIe,S:dIe,u:nIe,U:iIe,V:rIe,w:tIe,W:aIe,x:B,X:$,y:b$,Y:y$,Z:sIe,"%":pIe};w.x=P(n,w),w.X=P(i,w),w.c=P(e,w),C.x=P(n,C),C.X=P(i,C),C.c=P(e,C);function P(he,we){return function(Ue){var ue=[],lt=-1,H=0,q=he.length,oe,Z,Q;for(Ue instanceof Date||(Ue=new Date(+Ue));++lt<q;)he.charCodeAt(lt)===37&&(ue.push(he.slice(H,lt)),(Z=v$[oe=he.charAt(++lt)])!=null?oe=he.charAt(++lt):Z=oe==="e"?" ":"0",(Q=we[oe])&&(oe=Q(Ue,Z)),ue.push(oe),H=lt+1);return ue.push(he.slice(H,lt)),ue.join("")}}function A(he,we){return function(Ue){var ue=nx(1900,void 0,1),lt=j(ue,he,Ue+="",0),H,q;if(lt!=Ue.length)return null;if("Q"in ue)return new Date(ue.Q);if("s"in ue)return new Date(ue.s*1e3+("L"in ue?ue.L:0));if(we&&!("Z"in ue)&&(ue.Z=0),"p"in ue&&(ue.H=ue.H%12+ue.p*12),ue.m===void 0&&(ue.m="q"in ue?ue.q:0),"V"in ue){if(ue.V<1||ue.V>53)return null;"w"in ue||(ue.w=1),"Z"in ue?(H=YC(nx(ue.y,0,1)),q=H.getUTCDay(),H=q>4||q===0?NS.ceil(H):NS(H),H=Jw.offset(H,(ue.V-1)*7),ue.y=H.getUTCFullYear(),ue.m=H.getUTCMonth(),ue.d=H.getUTCDate()+(ue.w+6)%7):(H=KC(nx(ue.y,0,1)),q=H.getDay(),H=q>4||q===0?CS.ceil(H):CS(H),H=lv.offset(H,(ue.V-1)*7),ue.y=H.getFullYear(),ue.m=H.getMonth(),ue.d=H.getDate()+(ue.w+6)%7)}else("W"in ue||"U"in ue)&&("w"in ue||(ue.w="u"in ue?ue.u%7:"W"in ue?1:0),q="Z"in ue?YC(nx(ue.y,0,1)).getUTCDay():KC(nx(ue.y,0,1)).getDay(),ue.m=0,ue.d="W"in ue?(ue.w+6)%7+ue.W*7-(q+5)%7:ue.w+ue.U*7-(q+6)%7);return"Z"in ue?(ue.H+=ue.Z/100|0,ue.M+=ue.Z%100,YC(ue)):KC(ue)}}function j(he,we,Ue,ue){for(var lt=0,H=we.length,q=Ue.length,oe,Z;lt<H;){if(ue>=q)return-1;if(oe=we.charCodeAt(lt++),oe===37){if(oe=we.charAt(lt++),Z=T[oe in v$?we.charAt(lt++):oe],!Z||(ue=Z(he,Ue,ue))<0)return-1}else if(oe!=Ue.charCodeAt(ue++))return-1}return ue}function N(he,we,Ue){var ue=c.exec(we.slice(Ue));return ue?(he.p=u.get(ue[0].toLowerCase()),Ue+ue[0].length):-1}function k(he,we,Ue){var ue=g.exec(we.slice(Ue));return ue?(he.w=y.get(ue[0].toLowerCase()),Ue+ue[0].length):-1}function F(he,we,Ue){var ue=f.exec(we.slice(Ue));return ue?(he.w=m.get(ue[0].toLowerCase()),Ue+ue[0].length):-1}function I(he,we,Ue){var ue=x.exec(we.slice(Ue));return ue?(he.m=M.get(ue[0].toLowerCase()),Ue+ue[0].length):-1}function W(he,we,Ue){var ue=_.exec(we.slice(Ue));return ue?(he.m=v.get(ue[0].toLowerCase()),Ue+ue[0].length):-1}function D(he,we,Ue){return j(he,e,we,Ue)}function B(he,we,Ue){return j(he,n,we,Ue)}function $(he,we,Ue){return j(he,i,we,Ue)}function K(he){return s[he.getDay()]}function X(he){return a[he.getDay()]}function Y(he){return l[he.getMonth()]}function ee(he){return o[he.getMonth()]}function z(he){return r[+(he.getHours()>=12)]}function V(he){return 1+~~(he.getMonth()/3)}function re(he){return s[he.getUTCDay()]}function le(he){return a[he.getUTCDay()]}function ge(he){return l[he.getUTCMonth()]}function ie(he){return o[he.getUTCMonth()]}function xe(he){return r[+(he.getUTCHours()>=12)]}function ke(he){return 1+~~(he.getUTCMonth()/3)}return{format:function(he){var we=P(he+="",w);return we.toString=function(){return he},we},parse:function(he){var we=A(he+="",!1);return we.toString=function(){return he},we},utcFormat:function(he){var we=P(he+="",C);return we.toString=function(){return he},we},utcParse:function(he){var we=A(he+="",!0);return we.toString=function(){return he},we}}}var v$={"-":"",_:" ",0:"0"},Rr=/^\s*\d+/,QLe=/^%/,JLe=/[\\^$*+?|[\]().{}]/g;function Tn(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 eIe(t){return t.replace(JLe,"\\$&")}function ix(t){return new RegExp("^(?:"+t.map(eIe).join("|")+")","i")}function rx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function tIe(t,e,n){var i=Rr.exec(e.slice(n,n+1));return i?(t.w=+i[0],n+i[0].length):-1}function nIe(t,e,n){var i=Rr.exec(e.slice(n,n+1));return i?(t.u=+i[0],n+i[0].length):-1}function iIe(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.U=+i[0],n+i[0].length):-1}function rIe(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.V=+i[0],n+i[0].length):-1}function aIe(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.W=+i[0],n+i[0].length):-1}function y$(t,e,n){var i=Rr.exec(e.slice(n,n+4));return i?(t.y=+i[0],n+i[0].length):-1}function b$(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function sIe(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 oIe(t,e,n){var i=Rr.exec(e.slice(n,n+1));return i?(t.q=i[0]*3-3,n+i[0].length):-1}function lIe(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.m=i[0]-1,n+i[0].length):-1}function _$(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.d=+i[0],n+i[0].length):-1}function cIe(t,e,n){var i=Rr.exec(e.slice(n,n+3));return i?(t.m=0,t.d=+i[0],n+i[0].length):-1}function S$(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.H=+i[0],n+i[0].length):-1}function uIe(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.M=+i[0],n+i[0].length):-1}function dIe(t,e,n){var i=Rr.exec(e.slice(n,n+2));return i?(t.S=+i[0],n+i[0].length):-1}function fIe(t,e,n){var i=Rr.exec(e.slice(n,n+3));return i?(t.L=+i[0],n+i[0].length):-1}function hIe(t,e,n){var i=Rr.exec(e.slice(n,n+6));return i?(t.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function pIe(t,e,n){var i=QLe.exec(e.slice(n,n+1));return i?n+i[0].length:-1}function mIe(t,e,n){var i=Rr.exec(e.slice(n));return i?(t.Q=+i[0],n+i[0].length):-1}function gIe(t,e,n){var i=Rr.exec(e.slice(n));return i?(t.s=+i[0],n+i[0].length):-1}function w$(t,e){return Tn(t.getDate(),e,2)}function xIe(t,e){return Tn(t.getHours(),e,2)}function vIe(t,e){return Tn(t.getHours()%12||12,e,2)}function yIe(t,e){return Tn(1+lv.count(_c(t),t),e,3)}function lZ(t,e){return Tn(t.getMilliseconds(),e,3)}function bIe(t,e){return lZ(t,e)+"000"}function _Ie(t,e){return Tn(t.getMonth()+1,e,2)}function SIe(t,e){return Tn(t.getMinutes(),e,2)}function wIe(t,e){return Tn(t.getSeconds(),e,2)}function MIe(t){var e=t.getDay();return e===0?7:e}function EIe(t,e){return Tn(eM.count(_c(t)-1,t),e,2)}function cZ(t){var e=t.getDay();return e>=4||e===0?mm(t):mm.ceil(t)}function AIe(t,e){return t=cZ(t),Tn(mm.count(_c(t),t)+(_c(t).getDay()===4),e,2)}function TIe(t){return t.getDay()}function CIe(t,e){return Tn(CS.count(_c(t)-1,t),e,2)}function NIe(t,e){return Tn(t.getFullYear()%100,e,2)}function RIe(t,e){return t=cZ(t),Tn(t.getFullYear()%100,e,2)}function PIe(t,e){return Tn(t.getFullYear()%1e4,e,4)}function kIe(t,e){var n=t.getDay();return t=n>=4||n===0?mm(t):mm.ceil(t),Tn(t.getFullYear()%1e4,e,4)}function DIe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+Tn(e/60|0,"0",2)+Tn(e%60,"0",2)}function M$(t,e){return Tn(t.getUTCDate(),e,2)}function OIe(t,e){return Tn(t.getUTCHours(),e,2)}function LIe(t,e){return Tn(t.getUTCHours()%12||12,e,2)}function IIe(t,e){return Tn(1+Jw.count(Sc(t),t),e,3)}function uZ(t,e){return Tn(t.getUTCMilliseconds(),e,3)}function jIe(t,e){return uZ(t,e)+"000"}function UIe(t,e){return Tn(t.getUTCMonth()+1,e,2)}function FIe(t,e){return Tn(t.getUTCMinutes(),e,2)}function zIe(t,e){return Tn(t.getUTCSeconds(),e,2)}function BIe(t){var e=t.getUTCDay();return e===0?7:e}function HIe(t,e){return Tn(tM.count(Sc(t)-1,t),e,2)}function dZ(t){var e=t.getUTCDay();return e>=4||e===0?gm(t):gm.ceil(t)}function $Ie(t,e){return t=dZ(t),Tn(gm.count(Sc(t),t)+(Sc(t).getUTCDay()===4),e,2)}function VIe(t){return t.getUTCDay()}function GIe(t,e){return Tn(NS.count(Sc(t)-1,t),e,2)}function WIe(t,e){return Tn(t.getUTCFullYear()%100,e,2)}function qIe(t,e){return t=dZ(t),Tn(t.getUTCFullYear()%100,e,2)}function XIe(t,e){return Tn(t.getUTCFullYear()%1e4,e,4)}function KIe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?gm(t):gm.ceil(t),Tn(t.getUTCFullYear()%1e4,e,4)}function YIe(){return"+0000"}function E$(){return"%"}function A$(t){return+t}function T$(t){return Math.floor(+t/1e3)}var lp,fZ,hZ;ZIe({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 ZIe(t){return lp=ZLe(t),fZ=lp.format,lp.parse,hZ=lp.utcFormat,lp.utcParse,lp}function QIe(t){return new Date(t)}function JIe(t){return t instanceof Date?+t:+new Date(+t)}function tO(t,e,n,i,r,a,s,o,l,c){var u=BD(),f=u.invert,m=u.domain,g=c(".%L"),y=c(":%S"),_=c("%I:%M"),v=c("%I %p"),x=c("%a %d"),M=c("%b %d"),w=c("%B"),C=c("%Y");function T(P){return(l(P)<P?g:o(P)<P?y:s(P)<P?_:a(P)<P?v:i(P)<P?r(P)<P?x:M:n(P)<P?w:C)(P)}return u.invert=function(P){return new Date(f(P))},u.domain=function(P){return arguments.length?m(Array.from(P,JIe)):m().map(QIe)},u.ticks=function(P){var A=m();return t(A[0],A[A.length-1],P??10)},u.tickFormat=function(P,A){return A==null?T:c(A)},u.nice=function(P){var A=m();return(!P||typeof P.range!="function")&&(P=e(A[0],A[A.length-1],P??10)),P?m(JY(A,P)):u},u.copy=function(){return ov(u,tO(t,e,n,i,r,a,s,o,l,c))},u}function eje(){return Zs.apply(tO(KLe,YLe,_c,JD,eM,lv,ZD,KD,nf,fZ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function tje(){return Zs.apply(tO(qLe,XLe,Sc,eO,tM,Jw,QD,YD,nf,hZ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function nM(){var t=0,e=1,n,i,r,a,s=ma,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 u(f){return function(m){var g,y;return arguments.length?([g,y]=m,s=f(g,y),c):[s(0),s(1)]}}return c.range=u(Lm),c.rangeRound=u(zD),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 cd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function pZ(){var t=ld(nM()(ma));return t.copy=function(){return cd(t,pZ())},Rc.apply(t,arguments)}function mZ(){var t=VD(nM()).domain([1,10]);return t.copy=function(){return cd(t,mZ()).base(t.base())},Rc.apply(t,arguments)}function gZ(){var t=GD(nM());return t.copy=function(){return cd(t,gZ()).constant(t.constant())},Rc.apply(t,arguments)}function nO(){var t=WD(nM());return t.copy=function(){return cd(t,nO()).exponent(t.exponent())},Rc.apply(t,arguments)}function nje(){return nO.apply(null,arguments).exponent(.5)}function xZ(){var t=[],e=ma;function n(i){if(i!=null&&!isNaN(i=+i))return e((av(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(Wu),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)=>BOe(t,a/i))},n.copy=function(){return xZ(e).domain(t)},Rc.apply(n,arguments)}function iM(){var t=0,e=.5,n=1,i=1,r,a,s,o,l,c=ma,u,f=!1,m;function g(_){return isNaN(_=+_)?m:(_=.5+((_=+u(_))-a)*(i*_<i*a?o:l),c(f?Math.max(0,Math.min(1,_)):_))}g.domain=function(_){return arguments.length?([t,e,n]=_,r=u(t=+t),a=u(e=+e),s=u(n=+n),o=r===a?0:.5/(a-r),l=a===s?0:.5/(s-a),i=a<r?-1:1,g):[t,e,n]},g.clamp=function(_){return arguments.length?(f=!!_,g):f},g.interpolator=function(_){return arguments.length?(c=_,g):c};function y(_){return function(v){var x,M,w;return arguments.length?([x,M,w]=v,c=pLe(_,[x,M,w]),g):[c(0),c(.5),c(1)]}}return g.range=y(Lm),g.rangeRound=y(zD),g.unknown=function(_){return arguments.length?(m=_,g):m},function(_){return u=_,r=_(t),a=_(e),s=_(n),o=r===a?0:.5/(a-r),l=a===s?0:.5/(s-a),i=a<r?-1:1,g}}function vZ(){var t=ld(iM()(ma));return t.copy=function(){return cd(t,vZ())},Rc.apply(t,arguments)}function yZ(){var t=VD(iM()).domain([.1,1,10]);return t.copy=function(){return cd(t,yZ()).base(t.base())},Rc.apply(t,arguments)}function bZ(){var t=GD(iM());return t.copy=function(){return cd(t,bZ()).constant(t.constant())},Rc.apply(t,arguments)}function iO(){var t=WD(iM());return t.copy=function(){return cd(t,iO()).exponent(t.exponent())},Rc.apply(t,arguments)}function ije(){return iO.apply(null,arguments).exponent(.5)}const gx=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:jD,scaleDiverging:vZ,scaleDivergingLog:yZ,scaleDivergingPow:iO,scaleDivergingSqrt:ije,scaleDivergingSymlog:bZ,scaleIdentity:QY,scaleImplicit:JR,scaleLinear:ZY,scaleLog:eZ,scaleOrdinal:ID,scalePoint:VOe,scalePow:qD,scaleQuantile:iZ,scaleQuantize:rZ,scaleRadial:nZ,scaleSequential:pZ,scaleSequentialLog:mZ,scaleSequentialPow:nO,scaleSequentialQuantile:xZ,scaleSequentialSqrt:nje,scaleSequentialSymlog:gZ,scaleSqrt:jLe,scaleSymlog:tZ,scaleThreshold:aZ,scaleTime:eje,scaleUtc:tje,tickFormat:YY},Symbol.toStringTag,{value:"Module"}));var ud=t=>t.chartData,rO=He([ud],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),rM=(t,e,n,i)=>i?rO(t):ud(t);function Ju(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(oi(e)&&oi(n))return!0}return!1}function C$(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function _Z(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,i]=t,r,a;if(oi(n))r=n;else if(typeof n=="function")return;if(oi(i))a=i;else if(typeof i=="function")return;var s=[r,a];if(Ju(s))return s}}function rje(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var i=t(e,n);if(Ju(i))return C$(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"&&nH.test(r)){var l=nH.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"&&iH.test(a)){var u=iH.exec(a);if(u==null||e==null)o=void 0;else{var f=+u[1];o=e[1]+f}}else o=e?.[1];var m=[s,o];if(Ju(m))return e==null?m:C$(m,e,n)}}}var Im=1e9,aje={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},sO,di=!0,Ks="[DecimalError] ",gf=Ks+"Invalid argument: ",aO=Ks+"Exponent out of range: ",jm=Math.floor,Hd=Math.pow,sje=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ls,Mr=1e7,ai=7,SZ=9007199254740991,RS=jm(SZ/ai),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)*ai;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 uc(this,new this.constructor(t))};Tt.dividedToIntegerBy=Tt.idiv=function(t){var e=this,n=e.constructor;return Zn(uc(e,new n(t),0,1),n.precision)};Tt.equals=Tt.eq=function(t){return!this.cmp(t)};Tt.exponent=function(){return Ki(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(ls))throw Error(Ks+"NaN");if(n.s<1)throw Error(Ks+(n.s?"NaN":"-Infinity"));return n.eq(ls)?new i(0):(di=!1,e=uc(R0(n,a),R0(t,a),a),di=!0,Zn(e,r))};Tt.minus=Tt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?EZ(e,t):wZ(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(Ks+"NaN");return n.s?(di=!1,e=uc(n,t,0,1).times(t),di=!0,n.minus(e)):Zn(new i(n),r)};Tt.naturalExponential=Tt.exp=function(){return MZ(this)};Tt.naturalLogarithm=Tt.ln=function(){return R0(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?wZ(e,t):EZ(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(gf+t);if(e=Ki(r)+1,i=r.d.length-1,n=i*ai+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(Ks+"NaN")}for(t=Ki(o),di=!1,r=Math.sqrt(+o),r==0||r==1/0?(e=qo(o.d),(e.length+t)%2==0&&(e+="0"),r=Math.sqrt(e),t=jm((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(uc(o,a,s+2)).times(.5),qo(a.d).slice(0,s)===(e=qo(i.d)).slice(0,s)){if(e=e.slice(s-3,s+1),r==s&&e=="4999"){if(Zn(a,n+1,0),a.times(a).eq(o)){i=a;break}}else if(e!="9999")break;s+=4}return di=!0,Zn(i,n)};Tt.times=Tt.mul=function(t){var e,n,i,r,a,s,o,l,c,u=this,f=u.constructor,m=u.d,g=(t=new f(t)).d;if(!u.s||!t.s)return new f(0);for(t.s*=u.s,n=u.e+t.e,l=m.length,c=g.length,l<c&&(a=m,m=g,g=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]+g[i]*m[r-i-1]+e,a[r--]=o%Mr|0,e=o/Mr|0;a[r]=(a[r]+e)%Mr|0}for(;!a[--s];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,di?Zn(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:(ol(t,0,Im),e===void 0?e=i.rounding:ol(e,0,8),Zn(n,t+Ki(n)+1,e))};Tt.toExponential=function(t,e){var n,i=this,r=i.constructor;return t===void 0?n=Uf(i,!0):(ol(t,0,Im),e===void 0?e=r.rounding:ol(e,0,8),i=Zn(new r(i),t+1,e),n=Uf(i,!0,t+1)),n};Tt.toFixed=function(t,e){var n,i,r=this,a=r.constructor;return t===void 0?Uf(r):(ol(t,0,Im),e===void 0?e=a.rounding:ol(e,0,8),i=Zn(new a(r),t+Ki(r)+1,e),n=Uf(i.abs(),!1,t+Ki(i)+1),r.isneg()&&!r.isZero()?"-"+n:n)};Tt.toInteger=Tt.toint=function(){var t=this,e=t.constructor;return Zn(new e(t),Ki(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,u=+(t=new l(t));if(!t.s)return new l(ls);if(o=new l(o),!o.s){if(t.s<1)throw Error(Ks+"Infinity");return o}if(o.eq(ls))return o;if(i=l.precision,t.eq(ls))return Zn(o,i);if(e=t.e,n=t.d.length-1,s=e>=n,a=o.s,s){if((n=u<0?-u:u)<=SZ){for(r=new l(ls),e=Math.ceil(i/ai+4),di=!1;n%2&&(r=r.times(o),R$(r.d,e)),n=jm(n/2),n!==0;)o=o.times(o),R$(o.d,e);return di=!0,t.s<0?new l(ls).div(r):Zn(r,i)}}else if(a<0)throw Error(Ks+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,o.s=1,di=!1,r=t.times(R0(o,i+c)),di=!0,r=MZ(r),r.s=a,r};Tt.toPrecision=function(t,e){var n,i,r=this,a=r.constructor;return t===void 0?(n=Ki(r),i=Uf(r,n<=a.toExpNeg||n>=a.toExpPos)):(ol(t,1,Im),e===void 0?e=a.rounding:ol(e,0,8),r=Zn(new a(r),t,e),n=Ki(r),i=Uf(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):(ol(t,1,Im),e===void 0?e=i.rounding:ol(e,0,8)),Zn(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=Ki(t),n=t.constructor;return Uf(t,e<=n.toExpNeg||e>=n.toExpPos)};function wZ(t,e){var n,i,r,a,s,o,l,c,u=t.constructor,f=u.precision;if(!t.s||!e.s)return e.s||(e=new u(t)),di?Zn(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/ai),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)/Mr|0,l[a]%=Mr;for(n&&(l.unshift(n),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=r,di?Zn(e,f):e}function ol(t,e,n){if(t!==~~t||t<e||t>n)throw Error(gf+t)}function qo(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=ai-i.length,n&&(a+=Eu(n)),a+=i;s=t[e],i=s+"",n=ai-i.length,n&&(a+=Eu(n))}else if(s===0)return"0";for(;s%10===0;)s/=10;return a+s}var uc=(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%Mr|0,s=a/Mr|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*Mr+i[a]-r[a];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,a,s){var o,l,c,u,f,m,g,y,_,v,x,M,w,C,T,P,A,j,N=i.constructor,k=i.s==r.s?1:-1,F=i.d,I=r.d;if(!i.s)return new N(i);if(!r.s)throw Error(Ks+"Division by zero");for(l=i.e-r.e,A=I.length,T=F.length,g=new N(k),y=g.d=[],c=0;I[c]==(F[c]||0);)++c;if(I[c]>(F[c]||0)&&--l,a==null?M=a=N.precision:s?M=a+(Ki(i)-Ki(r))+1:M=a,M<0)return new N(0);if(M=M/ai+2|0,c=0,A==1)for(u=0,I=I[0],M++;(c<T||u)&&M--;c++)w=u*Mr+(F[c]||0),y[c]=w/I|0,u=w%I|0;else{for(u=Mr/(I[0]+1)|0,u>1&&(I=t(I,u),F=t(F,u),A=I.length,T=F.length),C=A,_=F.slice(0,A),v=_.length;v<A;)_[v++]=0;j=I.slice(),j.unshift(0),P=I[0],I[1]>=Mr/2&&++P;do u=0,o=e(I,_,A,v),o<0?(x=_[0],A!=v&&(x=x*Mr+(_[1]||0)),u=x/P|0,u>1?(u>=Mr&&(u=Mr-1),f=t(I,u),m=f.length,v=_.length,o=e(f,_,m,v),o==1&&(u--,n(f,A<m?j:I,m))):(u==0&&(o=u=1),f=I.slice()),m=f.length,m<v&&f.unshift(0),n(_,f,v),o==-1&&(v=_.length,o=e(I,_,A,v),o<1&&(u++,n(_,A<v?j:I,v))),v=_.length):o===0&&(u++,_=[0]),y[c++]=u,o&&_[0]?_[v++]=F[C]||0:(_=[F[C]],v=1);while((C++<T||_[0]!==void 0)&&M--)}return y[0]||y.shift(),g.e=l,Zn(g,s?a+Ki(g)+1:a)}})();function MZ(t,e){var n,i,r,a,s,o,l=0,c=0,u=t.constructor,f=u.precision;if(Ki(t)>16)throw Error(aO+Ki(t));if(!t.s)return new u(ls);for(di=!1,o=f,s=new u(.03125);t.abs().gte(.1);)t=t.times(s),c+=5;for(i=Math.log(Hd(2,c))/Math.LN10*2+5|0,o+=i,n=r=a=new u(ls),u.precision=o;;){if(r=Zn(r.times(t),o),n=n.times(++l),s=a.plus(uc(r,n,o)),qo(s.d).slice(0,o)===qo(a.d).slice(0,o)){for(;c--;)a=Zn(a.times(a),o);return u.precision=f,e==null?(di=!0,Zn(a,f)):a}a=s}}function Ki(t){for(var e=t.e*ai,n=t.d[0];n>=10;n/=10)e++;return e}function ZC(t,e,n){if(e>t.LN10.sd())throw di=!0,n&&(t.precision=n),Error(Ks+"LN10 precision limit exceeded");return Zn(new t(t.LN10),e)}function Eu(t){for(var e="";t--;)e+="0";return e}function R0(t,e){var n,i,r,a,s,o,l,c,u,f=1,m=10,g=t,y=g.d,_=g.constructor,v=_.precision;if(g.s<1)throw Error(Ks+(g.s?"NaN":"-Infinity"));if(g.eq(ls))return new _(0);if(e==null?(di=!1,c=v):c=e,g.eq(10))return e==null&&(di=!0),ZC(_,c);if(c+=m,_.precision=c,n=qo(y),i=n.charAt(0),a=Ki(g),Math.abs(a)<15e14){for(;i<7&&i!=1||i==1&&n.charAt(1)>3;)g=g.times(t),n=qo(g.d),i=n.charAt(0),f++;a=Ki(g),i>1?(g=new _("0."+n),a++):g=new _(i+"."+n.slice(1))}else return l=ZC(_,c+2,v).times(a+""),g=R0(new _(i+"."+n.slice(1)),c-m).plus(l),_.precision=v,e==null?(di=!0,Zn(g,v)):g;for(o=s=g=uc(g.minus(ls),g.plus(ls),c),u=Zn(g.times(g),c),r=3;;){if(s=Zn(s.times(u),c),l=o.plus(uc(s,new _(r),c)),qo(l.d).slice(0,c)===qo(o.d).slice(0,c))return o=o.times(2),a!==0&&(o=o.plus(ZC(_,c+2,v).times(a+""))),o=uc(o,new _(f),c),_.precision=v,e==null?(di=!0,Zn(o,v)):o;o=l,r+=2}}function N$(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=jm(n/ai),t.d=[],i=(n+1)%ai,n<0&&(i+=ai),i<r){for(i&&t.d.push(+e.slice(0,i)),r-=ai;i<r;)t.d.push(+e.slice(i,i+=ai));e=e.slice(i),i=ai-e.length}else i-=r;for(;i--;)e+="0";if(t.d.push(+e),di&&(t.e>RS||t.e<-RS))throw Error(aO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Zn(t,e,n){var i,r,a,s,o,l,c,u,f=t.d;for(s=1,a=f[0];a>=10;a/=10)s++;if(i=e-s,i<0)i+=ai,r=e,c=f[u=0];else{if(u=Math.ceil((i+1)/ai),a=f.length,u>=a)return t;for(c=a=f[u],s=1;a>=10;a/=10)s++;i%=ai,r=i-ai+s}if(n!==void 0&&(a=Hd(10,s-r-1),o=c/a%10|0,l=e<0||f[u+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/Hd(10,s-r):0:f[u-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return l?(a=Ki(t),f.length=1,e=e-a-1,f[0]=Hd(10,(ai-e%ai)%ai),t.e=jm(-e/ai)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(i==0?(f.length=u,a=1,u--):(f.length=u+1,a=Hd(10,ai-i),f[u]=r>0?(c/Hd(10,s-r)%Hd(10,r)|0)*a:0),l)for(;;)if(u==0){(f[0]+=a)==Mr&&(f[0]=1,++t.e);break}else{if(f[u]+=a,f[u]!=Mr)break;f[u--]=0,a=1}for(i=f.length;f[--i]===0;)f.pop();if(di&&(t.e>RS||t.e<-RS))throw Error(aO+Ki(t));return t}function EZ(t,e){var n,i,r,a,s,o,l,c,u,f,m=t.constructor,g=m.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new m(t),di?Zn(e,g):e;if(l=t.d,f=e.d,i=e.e,c=t.e,l=l.slice(),s=c-i,s){for(u=s<0,u?(n=l,s=-s,o=f.length):(n=f,i=c,o=l.length),r=Math.max(Math.ceil(g/ai),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,u=r<o,u&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){u=l[r]<f[r];break}s=0}for(u&&(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]=Mr-1;--l[a],l[r]+=Mr}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,di?Zn(e,g):e):new m(0)}function Uf(t,e,n){var i,r=Ki(t),a=qo(t.d),s=a.length;return e?(n&&(i=n-s)>0?a=a.charAt(0)+"."+a.slice(1)+Eu(i):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(r<0?"e":"e+")+r):r<0?(a="0."+Eu(-r-1)+a,n&&(i=n-s)>0&&(a+=Eu(i))):r>=s?(a+=Eu(r+1-s),n&&(i=n-r-1)>0&&(a=a+"."+Eu(i))):((i=r+1)<s&&(a=a.slice(0,i)+"."+a.slice(i)),n&&(i=n-s)>0&&(r+1===s&&(a+="."),a+=Eu(i))),t.s<0?"-"+a:a}function R$(t,e){if(t.length>e)return t.length=e,!0}function AZ(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(gf+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 N$(s,a.toString())}else if(typeof a!="string")throw Error(gf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),s.s=-1):s.s=1,sje.test(a))N$(s,a);else throw Error(gf+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=AZ,r.config=r.set=oje,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 oje(t){if(!t||typeof t!="object")throw Error(Ks+"Object expected");var e,n,i,r=["precision",1,Im,"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(jm(i)===i&&i>=r[e+1]&&i<=r[e+2])this[n]=i;else throw Error(gf+n+": "+i);if((i=t[n="LN10"])!==void 0)if(i==Math.LN10)this[n]=new this(i);else throw Error(gf+n+": "+i);return this}var sO=AZ(aje);ls=new sO(1);const Ln=sO;var lje=t=>t,TZ={},CZ=t=>t===TZ,P$=t=>function e(){return arguments.length===0||arguments.length===1&&CZ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},NZ=(t,e)=>t===1?e:P$(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!==TZ).length;return a>=t?e(...i):NZ(t-a,P$(function(){for(var s=arguments.length,o=new Array(s),l=0;l<s;l++)o[l]=arguments[l];var c=i.map(u=>CZ(u)?o.shift():u);return e(...c,...o)}))}),cje=t=>NZ(t.length,t),iP=(t,e)=>{for(var n=[],i=t;i<e;++i)n[i-t]=i;return n},uje=cje((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),dje=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];if(!n.length)return lje;var r=n.reverse(),a=r[0],s=r.slice(1);return function(){return s.reduce((o,l)=>l(o),a(...arguments))}},rP=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function RZ(t){var e;return t===0?e=1:e=Math.floor(new Ln(t).abs().log(10).toNumber())+1,e}function PZ(t,e,n){for(var i=new Ln(t),r=0,a=[];i.lt(e)&&r<1e5;)a.push(i.toNumber()),i=i.add(n),r++;return a}var kZ=t=>{var[e,n]=t,[i,r]=[e,n];return e>n&&([i,r]=[n,e]),[i,r]},DZ=(t,e,n)=>{if(t.lte(0))return new Ln(0);var i=RZ(t.toNumber()),r=new Ln(10).pow(i),a=t.div(r),s=i!==1?.05:.1,o=new Ln(Math.ceil(a.div(s).toNumber())).add(n).mul(s),l=o.mul(r);return e?new Ln(l.toNumber()):new Ln(Math.ceil(l.toNumber()))},fje=(t,e,n)=>{var i=new Ln(1),r=new Ln(t);if(!r.isint()&&n){var a=Math.abs(t);a<1?(i=new Ln(10).pow(RZ(t)-1),r=new Ln(Math.floor(r.div(i).toNumber())).mul(i)):a>1&&(r=new Ln(Math.floor(t)))}else t===0?r=new Ln(Math.floor((e-1)/2)):n||(r=new Ln(Math.floor(t)));var s=Math.floor((e-1)/2),o=dje(uje(l=>r.add(new Ln(l-s).mul(i)).toNumber()),iP);return o(0,e)},OZ=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 Ln(0),tickMin:new Ln(0),tickMax:new Ln(0)};var s=DZ(new Ln(n).sub(e).div(i-1),r,a),o;e<=0&&n>=0?o=new Ln(0):(o=new Ln(e).add(n).div(2),o=o.sub(new Ln(o).mod(s)));var l=Math.ceil(o.sub(e).div(s).toNumber()),c=Math.ceil(new Ln(n).sub(o).div(s).toNumber()),u=l+c+1;return u>i?OZ(e,n,i,r,a+1):(u<i&&(c=n>0?c+(i-u):c,l=n>0?l:l+(i-u)),{step:s,tickMin:o.sub(new Ln(l).mul(s)),tickMax:o.add(new Ln(c).mul(s))})},hje=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]=kZ([n,i]);if(o===-1/0||l===1/0){var c=l===1/0?[o,...iP(0,r-1).map(()=>1/0)]:[...iP(0,r-1).map(()=>-1/0),l];return n>i?rP(c):c}if(o===l)return fje(o,r,a);var{step:u,tickMin:f,tickMax:m}=OZ(o,l,s,a,0),g=PZ(f,m.add(new Ln(.1).mul(u)),u);return n>i?rP(g):g},pje=function(e,n){var[i,r]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[s,o]=kZ([i,r]);if(s===-1/0||o===1/0)return[i,r];if(s===o)return[s];var l=Math.max(n,2),c=DZ(new Ln(o).sub(s).div(l-1),a,0),u=[...PZ(new Ln(s),new Ln(o),c),o];return a===!1&&(u=u.map(f=>Math.round(f))),i>r?rP(u):u},LZ=t=>t.rootProps.maxBarSize,mje=t=>t.rootProps.barGap,IZ=t=>t.rootProps.barCategoryGap,gje=t=>t.rootProps.barSize,cv=t=>t.rootProps.stackOffset,jZ=t=>t.rootProps.reverseStackOrder,oO=t=>t.options.chartName,lO=t=>t.rootProps.syncId,UZ=t=>t.rootProps.syncMethod,cO=t=>t.options.eventEmitter,xje=t=>t.rootProps.baseValue,qi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Kl={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},rs={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},aM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},vje={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Kl.angleAxisId,includeHidden:!1,name:void 0,reversed:Kl.reversed,scale:Kl.scale,tick:Kl.tick,tickCount:void 0,ticks:void 0,type:Kl.type,unit:void 0},yje={allowDataOverflow:rs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:rs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:rs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:rs.scale,tick:rs.tick,tickCount:rs.tickCount,ticks:void 0,type:rs.type,unit:void 0},bje={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Kl.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Kl.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Kl.scale,tick:Kl.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},_je={allowDataOverflow:rs.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:rs.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:rs.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:rs.scale,tick:rs.tick,tickCount:rs.tickCount,ticks:void 0,type:"category",unit:void 0},uO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?bje:vje,dO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?_je:yje,sM=t=>t.polarOptions,fO=He([Cc,Nc,dr],IY),FZ=He([sM,fO],(t,e)=>{if(t!=null)return ra(t.innerRadius,e,0)}),zZ=He([sM,fO],(t,e)=>{if(t!=null)return ra(t.outerRadius,e,e*.8)}),Sje=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},BZ=He([sM],Sje);He([uO,BZ],aM);var HZ=He([fO,FZ,zZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});He([dO,HZ],aM);var $Z=He([_n,sM,FZ,zZ,Cc,Nc],(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:ra(s,r,r/2),cy:ra(o,a,a/2),innerRadius:n,outerRadius:i,startAngle:l,endAngle:c,clockWise:!1}}}),fi=(t,e)=>e,uv=(t,e,n)=>n;function oM(t){return t?.id}function VZ(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 u=oM(o);c.forEach((f,m)=>{var g=a==null||r?m:String(Yn(f,a,null)),y=Yn(f,o.dataKey,0),_;s.has(g)?_=s.get(g):_={},Object.assign(_,{[u]:y}),s.set(g,_)})}}),Array.from(s.values())}function lM(t){return t.stackId!=null&&t.dataKey!=null}var cM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function uM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function wje(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 hr=t=>{var e=_n(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Um=t=>t.tooltip.settings.axisId;function k$(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 PS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?k$(Object(n),!0).forEach(function(i){Mje(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):k$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function Mje(t,e,n){return(e=Eje(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Eje(t){var e=Aje(t,"string");return typeof e=="symbol"?e:e+""}function Aje(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 aP=[0,"auto"],Sr={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},GZ=(t,e)=>t.cartesianAxis.xAxis[e],Pc=(t,e)=>{var n=GZ(t,e);return n??Sr},wr={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:aP,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:tv},WZ=(t,e)=>t.cartesianAxis.yAxis[e],kc=(t,e)=>{var n=WZ(t,e);return n??wr},Tje={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:""},hO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Tje},vi=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);case"zAxis":return hO(t,n);case"angleAxis":return uO(t,n);case"radiusAxis":return dO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Cje=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},dv=(t,e,n)=>{switch(e){case"xAxis":return Pc(t,n);case"yAxis":return kc(t,n);case"angleAxis":return uO(t,n);case"radiusAxis":return dO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},qZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function pO(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 dM=t=>t.graphicalItems.cartesianItems,Nje=He([fi,uv],pO),mO=(t,e,n)=>t.filter(n).filter(i=>e?.includeHidden===!0?!0:!i.hide),fv=He([dM,vi,Nje],mO,{memoizeOptions:{resultEqualityCheck:uM}}),XZ=He([fv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(lM)),KZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),Rje=He([fv],KZ),gO=t=>t.map(e=>e.data).filter(Boolean).flat(1),Pje=He([fv],gO,{memoizeOptions:{resultEqualityCheck:uM}}),xO=(t,e)=>{var{chartData:n=[],dataStartIndex:i,dataEndIndex:r}=e;return t.length>0?t:n.slice(i,r+1)},vO=He([Pje,rM],xO),yO=(t,e,n)=>e?.dataKey!=null?t.map(i=>({value:Yn(i,e.dataKey)})):n.length>0?n.map(i=>i.dataKey).flatMap(i=>t.map(r=>({value:Yn(r,i)}))):t.map(i=>({value:i})),fM=He([vO,vi,fv],yO);function YZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function D_(t){if(al(t)||t instanceof Date){var e=Number(t);if(oi(e))return e}}function D$(t){if(Array.isArray(t)){var e=[D_(t[0]),D_(t[1])];return Ju(e)?e:void 0}var n=D_(t);if(n!=null)return[n,n]}function wc(t){return t.map(D_).filter(R3e)}function kje(t,e,n){return!n||typeof e!="number"||qs(e)?[]:n.length?wc(n.flatMap(i=>{var r=Yn(t,i.dataKey),a,s;if(Array.isArray(r)?[a,s]=r:a=s=r,!(!oi(a)||!oi(s)))return[e-a,e+s]})):[]}var pr=t=>{var e=hr(t),n=Um(t);return dv(t,e,n)},hv=He([pr],t=>t?.dataKey),Dje=He([XZ,rM,pr],VZ),ZZ=(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,u=c.map(oM);return[o,{stackedData:QPe(t,u,n),graphicalItems:c}]}))},P0=He([Dje,XZ,cv,jZ],ZZ),QZ=(t,e,n,i)=>{var{dataStartIndex:r,dataEndIndex:a}=e;if(i==null&&n!=="zAxis"){var s=nke(t,r,a);if(!(s!=null&&s[0]===0&&s[1]===0))return s}},Oje=He([vi],t=>t.allowDataOverflow),bO=t=>{var e;if(t==null||!("domain"in t))return aP;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=wc(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:aP},_O=He([vi],bO),SO=He([_O,Oje],_Z),Lje=He([P0,ud,fi,SO],QZ,{memoizeOptions:{resultEqualityCheck:cM}}),hM=t=>t.errorBars,Ije=(t,e,n)=>t.flatMap(i=>e[i.id]).filter(Boolean).filter(i=>YZ(n,i)),kS=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]}},wO=(t,e,n,i,r)=>{var a,s;if(n.length>0&&t.forEach(o=>{n.forEach(l=>{var c,u,f=(c=i[l.id])===null||c===void 0?void 0:c.filter(x=>YZ(r,x)),m=Yn(o,(u=e.dataKey)!==null&&u!==void 0?u:l.dataKey),g=kje(o,m,f);if(g.length>=2){var y=Math.min(...g),_=Math.max(...g);(a==null||y<a)&&(a=y),(s==null||_>s)&&(s=_)}var v=D$(m);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=D$(Yn(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]))}),oi(a)&&oi(s))return[a,s]},jje=He([vO,vi,Rje,hM,fi],wO,{memoizeOptions:{resultEqualityCheck:cM}});function Uje(t){var{value:e}=t;if(al(e)||e instanceof Date)return e}var Fje=(t,e,n)=>{var i=t.map(Uje).filter(r=>r!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&hK(i))?zY(0,t.length):e.allowDuplicatedCategory?i:Array.from(new Set(i))},JZ=t=>t.referenceElements.dots,Fm=(t,e,n)=>t.filter(i=>i.ifOverflow==="extendDomain").filter(i=>e==="xAxis"?i.xAxisId===n:i.yAxisId===n),zje=He([JZ,fi,uv],Fm),eQ=t=>t.referenceElements.areas,Bje=He([eQ,fi,uv],Fm),tQ=t=>t.referenceElements.lines,Hje=He([tQ,fi,uv],Fm),nQ=(t,e)=>{var n=wc(t.map(i=>e==="xAxis"?i.x:i.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},$je=He(zje,fi,nQ),iQ=(t,e)=>{var n=wc(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)]},Vje=He([Bje,fi],iQ);function Gje(t){var e;if(t.x!=null)return wc([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(i=>i.x);return n==null||n.length===0?[]:wc(n)}function Wje(t){var e;if(t.y!=null)return wc([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(i=>i.y);return n==null||n.length===0?[]:wc(n)}var rQ=(t,e)=>{var n=t.flatMap(i=>e==="xAxis"?Gje(i):Wje(i));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},qje=He([Hje,fi],rQ),Xje=He($je,qje,Vje,(t,e,n)=>kS(t,n,e)),MO=(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?kS(i,a,r):kS(a,r);return rje(e,c,t.allowDataOverflow)},Kje=He([vi,_O,SO,Lje,jje,Xje,_n,fi],MO,{memoizeOptions:{resultEqualityCheck:cM}}),Yje=[0,1],EO=(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=Tc(e,a);if(c&&o==null){var u;return zY(0,(u=n?.length)!==null&&u!==void 0?u:0)}return l==="category"?Fje(i,t,c):r==="expand"?Yje:s}},AO=He([vi,_n,vO,fM,cv,fi,Kje],EO),aQ=(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(K0(a));return o in gx?o:"point"}}},zm=He([vi,_n,qZ,oO,fi],aQ);function Zje(t){if(t!=null){if(t in gx)return gx[t]();var e="scale".concat(K0(t));if(e in gx)return gx[e]()}}function TO(t,e,n,i){if(!(n==null||i==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(i);var r=Zje(e);if(r!=null){var a=r.domain(n).range(i);return qPe(a),a}}}var CO=(t,e,n)=>{var i=bO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(i)&&(i[0]==="auto"||i[1]==="auto")&&Ju(t))return hje(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Ju(t))return pje(t,e.tickCount,e.allowDecimals)}},NO=He([AO,dv,zm],CO),RO=(t,e,n,i)=>{if(i!=="angleAxis"&&t?.type==="number"&&Ju(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},Qje=He([vi,AO,NO,fi],RO),Jje=He(fM,vi,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,i=Array.from(wc(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}}),sQ=He(Jje,_n,IZ,dr,(t,e,n,i)=>i,(t,e,n,i,r)=>{if(!oi(t))return 0;var a=e==="vertical"?i.height:i.width;if(r==="gap")return t*a/2;if(r==="no-gap"){var s=ra(n,t*a),o=t*a/2;return o-s-(o-s)/a*s}return 0}),e4e=(t,e)=>{var n=Pc(t,e);return n==null||typeof n.padding!="string"?0:sQ(t,"xAxis",e,n.padding)},t4e=(t,e)=>{var n=kc(t,e);return n==null||typeof n.padding!="string"?0:sQ(t,"yAxis",e,n.padding)},n4e=He(Pc,e4e,(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}}),i4e=He(kc,t4e,(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}}),r4e=He([dr,n4e,Ww,Gw,(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]}),a4e=He([dr,_n,i4e,Ww,Gw,(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]}),pv=(t,e,n,i)=>{var r;switch(e){case"xAxis":return r4e(t,n,i);case"yAxis":return a4e(t,n,i);case"zAxis":return(r=hO(t,n))===null||r===void 0?void 0:r.range;case"angleAxis":return BZ(t);case"radiusAxis":return HZ(t,n);default:return}},oQ=He([vi,pv],aM),Bm=He([vi,zm,Qje,oQ],TO);He([fv,hM,fi],Ije);function lQ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var pM=(t,e)=>e,mM=(t,e,n)=>n,s4e=He($w,pM,mM,(t,e,n)=>t.filter(i=>i.orientation===e).filter(i=>i.mirror===n).sort(lQ)),o4e=He(Vw,pM,mM,(t,e,n)=>t.filter(i=>i.orientation===e).filter(i=>i.mirror===n).sort(lQ)),cQ=(t,e)=>({width:t.width,height:e.height}),l4e=(t,e)=>{var n=typeof e.width=="number"?e.width:tv;return{width:n,height:t.height}},uQ=He(dr,Pc,cQ),c4e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},u4e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},d4e=He(Nc,dr,s4e,pM,mM,(t,e,n,i,r)=>{var a={},s;return n.forEach(o=>{var l=cQ(e,o);s==null&&(s=c4e(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}),f4e=He(Cc,dr,o4e,pM,mM,(t,e,n,i,r)=>{var a={},s;return n.forEach(o=>{var l=l4e(e,o);s==null&&(s=u4e(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}),h4e=(t,e)=>{var n=Pc(t,e);if(n!=null)return d4e(t,n.orientation,n.mirror)},p4e=He([dr,Pc,h4e,(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}}}),m4e=(t,e)=>{var n=kc(t,e);if(n!=null)return f4e(t,n.orientation,n.mirror)},g4e=He([dr,kc,m4e,(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}}}),dQ=He(dr,kc,(t,e)=>{var n=typeof e.width=="number"?e.width:tv;return{width:n,height:t.height}}),O$=(t,e,n)=>{switch(e){case"xAxis":return uQ(t,n).width;case"yAxis":return dQ(t,n).height;default:return}},fQ=(t,e,n,i)=>{if(n!=null){var{allowDuplicatedCategory:r,type:a,dataKey:s}=n,o=Tc(t,i),l=e.map(c=>c.value);if(s&&o&&a==="category"&&r&&hK(l))return l}},PO=He([_n,fM,vi,fi],fQ),hQ=(t,e,n,i)=>{if(!(n==null||n.dataKey==null)){var{type:r,scale:a}=n,s=Tc(t,i);if(s&&(r==="number"||a!=="auto"))return e.map(o=>o.value)}},kO=He([_n,fM,dv,fi],hQ),L$=He([_n,Cje,zm,Bm,PO,kO,pv,NO,fi],(t,e,n,i,r,a,s,o,l)=>{if(e!=null){var c=Tc(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}}}),x4e=(t,e,n,i,r,a,s,o,l)=>{if(!(e==null||i==null)){var c=Tc(t,l),{type:u,ticks:f,tickCount:m}=e,g=n==="scaleBand"&&typeof i.bandwidth=="function"?i.bandwidth()/2:2,y=u==="category"&&i.bandwidth?i.bandwidth()/g:0;y=l==="angleAxis"&&a!=null&&a.length>=2?Tr(a[0]-a[1])*2*y:y;var _=f||r;if(_){var v=_.map((x,M)=>{var w=s?s.indexOf(x):x;return{index:M,coordinate:i(w)+y,value:x,offset:y}});return v.filter(x=>oi(x.coordinate))}return c&&o?o.map((x,M)=>({coordinate:i(x)+y,value:x,index:M,offset:y})).filter(x=>oi(x.coordinate)):i.ticks?i.ticks(m).map(x=>({coordinate:i(x)+y,value:x,offset:y})):i.domain().map((x,M)=>({coordinate:i(x)+y,value:s?s[x]:x,index:M,offset:y}))}},pQ=He([_n,dv,zm,Bm,NO,pv,PO,kO,fi],x4e),v4e=(t,e,n,i,r,a,s)=>{if(!(e==null||n==null||i==null||i[0]===i[1])){var o=Tc(t,s),{tickCount:l}=e,c=0;return c=s==="angleAxis"&&i?.length>=2?Tr(i[0]-i[1])*2*c:c,o&&a?a.map((u,f)=>({coordinate:n(u)+c,value:u,index:f,offset:c})):n.ticks?n.ticks(l).map(u=>({coordinate:n(u)+c,value:u,offset:c})):n.domain().map((u,f)=>({coordinate:n(u)+c,value:r?r[u]:u,index:f,offset:c}))}},ed=He([_n,dv,Bm,pv,PO,kO,fi],v4e),td=He(vi,Bm,(t,e)=>{if(!(t==null||e==null))return PS(PS({},t),{},{scale:e})}),y4e=He([vi,zm,AO,oQ],TO);He((t,e,n)=>hO(t,n),y4e,(t,e)=>{if(!(t==null||e==null))return PS(PS({},t),{},{scale:e})});var b4e=He([_n,$w,Vw],(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}}),mQ=t=>t.options.defaultTooltipEventType,gQ=t=>t.options.validateTooltipEventTypes;function xQ(t,e,n){if(t==null)return e;var i=t?"axis":"item";return n==null?e:n.includes(i)?i:e}function DO(t,e){var n=mQ(t),i=gQ(t);return xQ(e,n,i)}function _4e(t){return At(e=>DO(e,t))}var vQ=(t,e)=>{var n,i=Number(e);if(!(qs(i)||e==null))return i>=0?t==null||(n=t[i])===null||n===void 0?void 0:n.value:void 0},S4e=t=>t.tooltip.settings,Ru={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},w4e={itemInteraction:{click:Ru,hover:Ru},axisInteraction:{click:Ru,hover:Ru},keyboardInteraction:Ru,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}},yQ=Va({name:"tooltip",initialState:w4e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:ci()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:i}=e.payload,r=bo(t).tooltipItemPayloads.indexOf(n);r>-1&&(t.tooltipItemPayloads[r]=i)},prepare:ci()},removeTooltipEntrySettings:{reducer(t,e){var n=bo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:ci()},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:M4e,replaceTooltipEntrySettings:E4e,removeTooltipEntrySettings:A4e,setTooltipSettingsState:T4e,setActiveMouseOverItemIndex:bQ,mouseLeaveItem:C4e,mouseLeaveChart:_Q,setActiveClickItemIndex:N4e,setMouseOverAxisIndex:SQ,setMouseClickAxisIndex:R4e,setSyncInteraction:sP,setKeyboardInteraction:oP}=yQ.actions,P4e=yQ.reducer;function I$(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 s_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I$(Object(n),!0).forEach(function(i){k4e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function k4e(t,e,n){return(e=D4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D4e(t){var e=O4e(t,"string");return typeof e=="symbol"?e:e+""}function O4e(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 L4e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function I4e(t){return t.index!=null}var wQ=(t,e,n,i)=>{if(e==null)return Ru;var r=L4e(t,e,n);if(r==null)return Ru;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(I4e(r)){if(a)return s_(s_({},r),{},{active:!0})}else if(i!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:i,graphicalItemId:void 0};return s_(s_({},Ru),{},{coordinate:r.coordinate})};function j4e(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 U4e(t,e){var n=j4e(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 F4e(t,e,n){if(n==null||e==null)return!0;var i=Yn(t,e);return i==null||!Ju(n)?!0:U4e(i,n)}var OO=(t,e,n,i)=>{var r=t?.index;if(r==null)return null;var a=Number(r);if(!oi(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||F4e(c,n,i)?String(l):null},MQ=(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 u=r?.[Number(a)];if(u)switch(n){case"horizontal":return{x:u.coordinate,y:(i.top+e)/2};default:return{x:(i.left+t)/2,y:u.coordinate}}}},EQ=(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})},mv=t=>t.options.tooltipPayloadSearcher,Hm=t=>t.tooltip;function j$(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 U$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?j$(Object(n),!0).forEach(function(i){z4e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function z4e(t,e,n){return(e=B4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function B4e(t){var e=H4e(t,"string");return typeof e=="symbol"?e:e+""}function H4e(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 $4e(t,e){return t??e}var AQ=(t,e,n,i,r,a,s)=>{if(!(e==null||a==null)){var{chartData:o,computedData:l,dataStartIndex:c,dataEndIndex:u}=n,f=[];return t.reduce((m,g)=>{var y,{dataDefinedOnItem:_,settings:v}=g,x=$4e(_,o),M=Array.isArray(x)?oY(x,c,u):x,w=(y=v?.dataKey)!==null&&y!==void 0?y:i,C=v?.nameKey,T;if(i&&Array.isArray(M)&&!Array.isArray(M[0])&&s==="axis"?T=pK(M,i,r):T=a(M,e,l,C),Array.isArray(T))T.forEach(A=>{var j=U$(U$({},v),{},{name:A.name,unit:A.unit,color:void 0,fill:void 0});m.push(rH({tooltipEntrySettings:j,dataKey:A.dataKey,payload:A.payload,value:Yn(A.payload,A.dataKey),name:A.name}))});else{var P;m.push(rH({tooltipEntrySettings:v,dataKey:w,payload:T,value:Yn(T,w),name:(P=Yn(T,C))!==null&&P!==void 0?P:v?.name}))}return m},f)}},LO=He([pr,_n,qZ,oO,hr],aQ),V4e=He([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),G4e=He([hr,Um],pO),gv=He([V4e,pr,G4e],mO,{memoizeOptions:{resultEqualityCheck:uM}}),W4e=He([gv],t=>t.filter(lM)),q4e=He([gv],gO,{memoizeOptions:{resultEqualityCheck:uM}}),$m=He([q4e,ud],xO),X4e=He([W4e,ud,pr],VZ),IO=He([$m,pr,gv],yO),TQ=He([pr],bO),K4e=He([pr],t=>t.allowDataOverflow),CQ=He([TQ,K4e],_Z),Y4e=He([gv],t=>t.filter(lM)),Z4e=He([X4e,Y4e,cv,jZ],ZZ),Q4e=He([Z4e,ud,hr,CQ],QZ),J4e=He([gv],KZ),eUe=He([$m,pr,J4e,hM,hr],wO,{memoizeOptions:{resultEqualityCheck:cM}}),tUe=He([JZ,hr,Um],Fm),nUe=He([tUe,hr],nQ),iUe=He([eQ,hr,Um],Fm),rUe=He([iUe,hr],iQ),aUe=He([tQ,hr,Um],Fm),sUe=He([aUe,hr],rQ),oUe=He([nUe,sUe,rUe],kS),lUe=He([pr,TQ,CQ,Q4e,eUe,oUe,_n,hr],MO),xv=He([pr,_n,$m,IO,cv,hr,lUe],EO),cUe=He([xv,pr,LO],CO),uUe=He([pr,xv,cUe,hr],RO),NQ=t=>{var e=hr(t),n=Um(t),i=!1;return pv(t,e,n,i)},RQ=He([pr,NQ],aM),PQ=He([pr,LO,uUe,RQ],TO),dUe=He([_n,IO,pr,hr],fQ),fUe=He([_n,IO,pr,hr],hQ),hUe=(t,e,n,i,r,a,s,o)=>{if(e){var{type:l}=e,c=Tc(t,o);if(i){var u=n==="scaleBand"&&i.bandwidth?i.bandwidth()/2:2,f=l==="category"&&i.bandwidth?i.bandwidth()/u:0;return f=o==="angleAxis"&&r!=null&&r?.length>=2?Tr(r[0]-r[1])*2*f:f,c&&s?s.map((m,g)=>({coordinate:i(m)+f,value:m,index:g,offset:f})):i.domain().map((m,g)=>({coordinate:i(m)+f,value:a?a[m]:m,index:g,offset:f}))}}},Dc=He([_n,pr,LO,PQ,NQ,dUe,fUe,hr],hUe),jO=He([mQ,gQ,S4e],(t,e,n)=>xQ(n.shared,t,e)),kQ=t=>t.tooltip.settings.trigger,UO=t=>t.tooltip.settings.defaultIndex,vv=He([Hm,jO,kQ,UO],wQ),nd=He([vv,$m,hv,xv],OO),DQ=He([Dc,nd],vQ),FO=He([vv],t=>{if(t)return t.dataKey}),pUe=He([vv],t=>{if(t)return t.graphicalItemId}),OQ=He([Hm,jO,kQ,UO],EQ),mUe=He([Cc,Nc,_n,dr,Dc,UO,OQ,mv],MQ),gUe=He([vv,mUe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),xUe=He([vv],t=>t.active),vUe=He([OQ,nd,ud,hv,DQ,mv,jO],AQ),yUe=He([vUe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function F$(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 z$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F$(Object(n),!0).forEach(function(i){bUe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function bUe(t,e,n){return(e=_Ue(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _Ue(t){var e=SUe(t,"string");return typeof e=="symbol"?e:e+""}function SUe(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 wUe=()=>At(pr),MUe=()=>{var t=wUe(),e=At(Dc),n=At(PQ);return dm(!t||!n?void 0:z$(z$({},t),{},{scale:n}),e)};function B$(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 cp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B$(Object(n),!0).forEach(function(i){EUe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function EUe(t,e,n){return(e=AUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function AUe(t){var e=TUe(t,"string");return typeof e=="symbol"?e:e+""}function TUe(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 CUe=(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}},NUe=(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 cp(cp(cp({},i),Wi(i.cx,i.cy,s,a)),{},{angle:a,radius:s})}var o=r.coordinate,{angle:l}=i;return cp(cp(cp({},i),Wi(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 RUe(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 LQ=(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,u=n[l].coordinate,f=l>=o-1?n[0].coordinate:n[l+1].coordinate,m=void 0;if(Tr(u-c)!==Tr(f-u)){var g=[];if(Tr(f-u)===Tr(r[1]-r[0])){m=f;var y=u+r[1]-r[0];g[0]=Math.min(y,(y+c)/2),g[1]=Math.max(y,(y+c)/2)}else{m=c;var _=f+r[1]-r[0];g[0]=Math.min(u,(_+u)/2),g[1]=Math.max(u,(_+u)/2)}var v=[Math.min(u,(m+u)/2),Math.max(u,(m+u)/2)];if(t>v[0]&&t<=v[1]||t>=g[0]&&t<=g[1]){({index:s}=n[l]);break}}else{var x=Math.min(c,f),M=Math.max(c,f);if(t>(x+u)/2&&t<=(M+u)/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},IQ=()=>At(oO),zO=(t,e)=>e,jQ=(t,e,n)=>n,BO=(t,e,n,i)=>i,PUe=He(Dc,t=>Ow(t,e=>e.coordinate)),HO=He([Hm,zO,jQ,BO],wQ),$O=He([HO,$m,hv,xv],OO),kUe=(t,e,n)=>{if(e!=null){var i=Hm(t);return e==="axis"?n==="hover"?i.axisInteraction.hover.dataKey:i.axisInteraction.click.dataKey:n==="hover"?i.itemInteraction.hover.dataKey:i.itemInteraction.click.dataKey}},UQ=He([Hm,zO,jQ,BO],EQ),DS=He([Cc,Nc,_n,dr,Dc,BO,UQ,mv],MQ),DUe=He([HO,DS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),FQ=He([Dc,$O],vQ),OUe=He([UQ,$O,ud,hv,FQ,mv,zO],AQ),LUe=He([HO,$O],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),IUe=(t,e,n,i,r,a,s)=>{if(!(!t||!n||!i||!r)&&RUe(t,s)){var o=ike(t,e),l=LQ(o,a,r,n,i),c=CUe(e,r,l,t);return{activeIndex:String(l),activeCoordinate:c}}},jUe=(t,e,n,i,r,a,s)=>{if(!(!t||!i||!r||!a||!n)){var o=bOe(t,n);if(o){var l=rke(o,e),c=LQ(l,s,a,i,r),u=NUe(e,a,c,o);return{activeIndex:String(c),activeCoordinate:u}}}},UUe=(t,e,n,i,r,a,s,o)=>{if(!(!t||!e||!i||!r||!a))return e==="horizontal"||e==="vertical"?IUe(t,e,i,r,a,s,o):jUe(t,e,n,i,r,a,s)},FUe=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}}),zUe=He(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(i=>parseInt(i,10)).concat(Object.values(qi)),n=Array.from(new Set(e));return n.sort((i,r)=>i-r)},{memoizeOptions:{resultEqualityCheck:wje}});function H$(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 $$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H$(Object(n),!0).forEach(function(i){BUe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function BUe(t,e,n){return(e=HUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HUe(t){var e=$Ue(t,"string");return typeof e=="symbol"?e:e+""}function $Ue(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 VUe={},GUe={zIndexMap:Object.values(qi).reduce((t,e)=>$$($$({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),VUe)},WUe=new Set(Object.values(qi));function qUe(t){return WUe.has(t)}var zQ=Va({name:"zIndex",initialState:GUe,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:ci()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!qUe(n)&&delete t.zIndexMap[n])},prepare:ci()},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:ci()},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:ci()}}}),{registerZIndexPortal:XUe,unregisterZIndexPortal:KUe,registerZIndexPortalId:YUe,unregisterZIndexPortalId:ZUe}=zQ.actions,QUe=zQ.reducer;function Ga(t){var{zIndex:e,children:n}=t,i=Ike(),r=i&&e!==void 0&&e!==0,a=oa(),s=ei();E.useLayoutEffect(()=>r?(s(XUe({zIndex:e})),()=>{s(KUe({zIndex:e}))}):Y0,[s,e,r]);var o=At(c=>FUe(c,e,a));if(!r)return n;if(!o)return null;var l=document.getElementById(o);return l?Zl.createPortal(n,l):null}function lP(){return lP=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},lP.apply(null,arguments)}function V$(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 o_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V$(Object(n),!0).forEach(function(i){JUe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function JUe(t,e,n){return(e=eFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function eFe(t){var e=tFe(t,"string");return typeof e=="symbol"?e:e+""}function tFe(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 nFe(t){var{cursor:e,cursorComp:n,cursorProps:i}=t;return E.isValidElement(e)?E.cloneElement(e,i):E.createElement(n,i)}function iFe(t){var e,{coordinate:n,payload:i,index:r,offset:a,tooltipAxisBandSize:s,layout:o,cursor:l,tooltipEventType:c,chartName:u}=t,f=n,m=i,g=r;if(!l||!f||u!=="ScatterChart"&&c!=="axis")return null;var y,_,v;if(u==="ScatterChart")y=f,_=LDe,v=qi.cursorLine;else if(u==="BarChart")y=IDe(o,f,a,s),_=LY,v=qi.cursorRectangle;else if(o==="radial"&&gK(f)){var{cx:x,cy:M,radius:w,startAngle:C,endAngle:T}=jY(f);y={cx:x,cy:M,startAngle:C,endAngle:T,innerRadius:w,outerRadius:w},_=FY,v=qi.cursorLine}else y={points:MOe(o,f,a)},_=Lp,v=qi.cursorLine;var P=typeof l=="object"&&"className"in l?l.className:void 0,A=o_(o_(o_(o_({stroke:"#ccc",pointerEvents:"none"},a),y),Of(l)),{},{payload:m,payloadIndex:g,className:An("recharts-tooltip-cursor",P)});return E.createElement(Ga,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},E.createElement(nFe,{cursor:l,cursorComp:_,cursorProps:A}))}function rFe(t){var e=MUe(),n=vY(),i=Dm(),r=IQ();return e==null||n==null||i==null||r==null?null:E.createElement(iFe,lP({},t,{offset:n,layout:i,tooltipAxisBandSize:e,chartName:r}))}var BQ=E.createContext(null),aFe=()=>E.useContext(BQ),QC={exports:{}},G$;function sFe(){return G$||(G$=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,u){this.fn=l,this.context=c,this.once=u||!1}function a(l,c,u,f,m){if(typeof u!="function")throw new TypeError("The listener must be a function");var g=new r(u,f||l,m),y=n?n+c:c;return l._events[y]?l._events[y].fn?l._events[y]=[l._events[y],g]:l._events[y].push(g):(l._events[y]=g,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=[],u,f;if(this._eventsCount===0)return c;for(f in u=this._events)e.call(u,f)&&c.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=n?n+c:c,f=this._events[u];if(!f)return[];if(f.fn)return[f.fn];for(var m=0,g=f.length,y=new Array(g);m<g;m++)y[m]=f[m].fn;return y},o.prototype.listenerCount=function(c){var u=n?n+c:c,f=this._events[u];return f?f.fn?1:f.length:0},o.prototype.emit=function(c,u,f,m,g,y){var _=n?n+c:c;if(!this._events[_])return!1;var v=this._events[_],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,u),!0;case 3:return v.fn.call(v.context,u,f),!0;case 4:return v.fn.call(v.context,u,f,m),!0;case 5:return v.fn.call(v.context,u,f,m,g),!0;case 6:return v.fn.call(v.context,u,f,m,g,y),!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 C=v.length,T;for(w=0;w<C;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,u);break;case 3:v[w].fn.call(v[w].context,u,f);break;case 4:v[w].fn.call(v[w].context,u,f,m);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,u,f){return a(this,c,u,f,!1)},o.prototype.once=function(c,u,f){return a(this,c,u,f,!0)},o.prototype.removeListener=function(c,u,f,m){var g=n?n+c:c;if(!this._events[g])return this;if(!u)return s(this,g),this;var y=this._events[g];if(y.fn)y.fn===u&&(!m||y.once)&&(!f||y.context===f)&&s(this,g);else{for(var _=0,v=[],x=y.length;_<x;_++)(y[_].fn!==u||m&&!y[_].once||f&&y[_].context!==f)&&v.push(y[_]);v.length?this._events[g]=v.length===1?v[0]:v:s(this,g)}return this},o.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&s(this,u)):(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})(QC)),QC.exports}var oFe=sFe();const lFe=Ys(oFe);var k0=new lFe,cP="recharts.syncEvent.tooltip",W$="recharts.syncEvent.brush";function VO(t,e){if(e){var n=Number.parseInt(e,10);if(!qs(n))return t?.[n]}}var cFe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},HQ=Va({name:"options",initialState:cFe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),uFe=HQ.reducer,{createEventEmitter:dFe}=HQ.actions;function fFe(t){return t.tooltip.syncInteraction}var hFe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},$Q=Va({name:"chartData",initialState:hFe,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:q$,setDataStartEndIndexes:pFe,setComputedData:kGe}=$Q.actions,mFe=$Q.reducer,gFe=["x","y"];function X$(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 up(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X$(Object(n),!0).forEach(function(i){xFe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function xFe(t,e,n){return(e=vFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vFe(t){var e=yFe(t,"string");return typeof e=="symbol"?e:e+""}function yFe(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 bFe(t,e){if(t==null)return{};var n,i,r=_Fe(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 _Fe(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 SFe(){var t=At(lO),e=At(cO),n=ei(),i=At(UZ),r=At(Dc),a=Dm(),s=qw(),o=At(l=>l.rootProps.className);E.useEffect(()=>{if(t==null)return Y0;var l=(c,u,f)=>{if(e!==f&&t===c){if(i==="index"){var m;if(s&&u!==null&&u!==void 0&&(m=u.payload)!==null&&m!==void 0&&m.coordinate&&u.payload.sourceViewBox){var g=u.payload.coordinate,{x:y,y:_}=g,v=bFe(g,gFe),{x,y:M,width:w,height:C}=u.payload.sourceViewBox,T=up(up({},v),{},{x:s.x+(w?(y-x)/w:0)*s.width,y:s.y+(C?(_-M)/C:0)*s.height});n(up(up({},u),{},{payload:up(up({},u.payload),{},{coordinate:T})}))}else n(u);return}if(r!=null){var P;if(typeof i=="function"){var A={activeTooltipIndex:u.payload.index==null?void 0:Number(u.payload.index),isTooltipActive:u.payload.active,activeIndex:u.payload.index==null?void 0:Number(u.payload.index),activeLabel:u.payload.label,activeDataKey:u.payload.dataKey,activeCoordinate:u.payload.coordinate},j=i(r,A);P=r[j]}else i==="value"&&(P=r.find($=>String($.value)===u.payload.label));var{coordinate:N}=u.payload;if(P==null||u.payload.active===!1||N==null||s==null){n(sP({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:k,y:F}=N,I=Math.min(k,s.x+s.width),W=Math.min(F,s.y+s.height),D={x:a==="horizontal"?P.coordinate:I,y:a==="horizontal"?W:P.coordinate},B=sP({active:u.payload.active,coordinate:D,dataKey:u.payload.dataKey,index:String(P.index),label:u.payload.label,sourceViewBox:u.payload.sourceViewBox,graphicalItemId:u.payload.graphicalItemId});n(B)}}};return k0.on(cP,l),()=>{k0.off(cP,l)}},[o,n,e,t,i,r,a,s])}function wFe(){var t=At(lO),e=At(cO),n=ei();E.useEffect(()=>{if(t==null)return Y0;var i=(r,a,s)=>{e!==s&&t===r&&n(pFe(a))};return k0.on(W$,i),()=>{k0.off(W$,i)}},[n,e,t])}function MFe(){var t=ei();E.useEffect(()=>{t(dFe())},[t]),SFe(),wFe()}function EFe(t,e,n,i,r,a){var s=At(g=>kUe(g,t,e)),o=At(cO),l=At(lO),c=At(UZ),u=At(fFe),f=u?.active,m=qw();E.useEffect(()=>{if(!f&&l!=null&&o!=null){var g=sP({active:a,coordinate:n,dataKey:s,index:r,label:typeof i=="number"?String(i):i,sourceViewBox:m,graphicalItemId:void 0});k0.emit(cP,l,g,o)}},[f,n,s,r,i,o,l,c,a,m])}function K$(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 Y$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K$(Object(n),!0).forEach(function(i){AFe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function AFe(t,e,n){return(e=TFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function TFe(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)}function NFe(t){return t.dataKey}function RFe(t,e){return E.isValidElement(t)?E.cloneElement(t,e):typeof t=="function"?E.createElement(t,e):E.createElement(pDe,e)}var Z$=[],PFe={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 JC(t){var e,n,i=Zi(t,PFe),{active:r,allowEscapeViewBox:a,animationDuration:s,animationEasing:o,content:l,filterNull:c,isAnimationActive:u,offset:f,payloadUniqBy:m,position:g,reverseDirection:y,useTranslate3d:_,wrapperStyle:v,cursor:x,shared:M,trigger:w,defaultIndex:C,portal:T,axisId:P}=i,A=ei(),j=typeof C=="number"?String(C):C;E.useEffect(()=>{A(T4e({shared:M,trigger:w,axisId:P,active:r,defaultIndex:j}))},[A,M,w,P,r,j]);var N=qw(),k=RY(),F=_4e(M),{activeIndex:I,isActive:W}=(e=At(xe=>LUe(xe,F,w,j)))!==null&&e!==void 0?e:{},D=At(xe=>OUe(xe,F,w,j)),B=At(xe=>FQ(xe,F,w,j)),$=At(xe=>DUe(xe,F,w,j)),K=D,X=aFe(),Y=(n=r??W)!==null&&n!==void 0?n:!1,[ee,z]=PK([K,Y]),V=F==="axis"?B:void 0;EFe(F,w,$,V,I,Y);var re=T??X;if(re==null||N==null||F==null)return null;var le=K??Z$;Y||(le=Z$),c&&le.length&&(le=AK(le.filter(xe=>xe.value!=null&&(xe.hide!==!0||i.includeHidden)),m,NFe));var ge=le.length>0,ie=E.createElement(_De,{allowEscapeViewBox:a,animationDuration:s,animationEasing:o,isAnimationActive:u,active:Y,coordinate:$,hasPayload:ge,offset:f,position:g,reverseDirection:y,useTranslate3d:_,viewBox:N,wrapperStyle:v,lastBoundingBox:ee,innerRef:z,hasPortalFromProps:!!T},RFe(l,Y$(Y$({},i),{},{payload:le,label:V,active:Y,activeIndex:I,coordinate:$,accessibilityLayer:k})));return E.createElement(E.Fragment,null,Zl.createPortal(ie,re),Y&&E.createElement(rFe,{cursor:x,tooltipEventType:F,coordinate:$,payload:le,index:I}))}var yv=t=>null;yv.displayName="Cell";function kFe(t,e,n){return(e=DFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function DFe(t){var e=OFe(t,"string");return typeof e=="symbol"?e:e+""}function OFe(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 LFe{constructor(e){kFe(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 Q$(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 IFe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q$(Object(n),!0).forEach(function(i){jFe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q$(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function jFe(t,e,n){return(e=UFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UFe(t){var e=FFe(t,"string");return typeof e=="symbol"?e:e+""}function FFe(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 zFe={cacheSize:2e3,enableCache:!0},VQ=IFe({},zFe),J$=new LFe(VQ.cacheSize),BFe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},eV="recharts_measurement_span";function HFe(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 tV=(t,e)=>{try{var n=document.getElementById(eV);n||(n=document.createElement("span"),n.setAttribute("id",eV),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,BFe,e),n.textContent="".concat(t);var i=n.getBoundingClientRect();return{width:i.width,height:i.height}}catch{return{width:0,height:0}}},Fx=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Om.isSsr)return{width:0,height:0};if(!VQ.enableCache)return tV(e,n);var i=HFe(e,n),r=J$.get(i);if(r)return r;var a=tV(e,n);return J$.set(i,a),a},nV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,iV=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,$Fe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,VFe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,GQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},GFe=Object.keys(GQ),Sp="NaN";function WFe(t,e){return t*GQ[e]}class ka{static parse(e){var n,[,i,r]=(n=VFe.exec(e))!==null&&n!==void 0?n:[];return new ka(parseFloat(i),r??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,qs(e)&&(this.unit=""),n!==""&&!$Fe.test(n)&&(this.num=NaN,this.unit=""),GFe.includes(n)&&(this.num=WFe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new ka(NaN,""):new ka(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new ka(NaN,""):new ka(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ka(NaN,""):new ka(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new ka(NaN,""):new ka(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return qs(this.num)}}function WQ(t){if(t.includes(Sp))return Sp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,i,r,a]=(n=nV.exec(e))!==null&&n!==void 0?n:[],s=ka.parse(i??""),o=ka.parse(a??""),l=r==="*"?s.multiply(o):s.divide(o);if(l.isNaN())return Sp;e=e.replace(nV,l.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var c,[,u,f,m]=(c=iV.exec(e))!==null&&c!==void 0?c:[],g=ka.parse(u??""),y=ka.parse(m??""),_=f==="+"?g.add(y):g.subtract(y);if(_.isNaN())return Sp;e=e.replace(iV,_.toString())}return e}var rV=/\(([^()]*)\)/;function qFe(t){for(var e=t,n;(n=rV.exec(e))!=null;){var[,i]=n;e=e.replace(rV,WQ(i))}return e}function XFe(t){var e=t.replace(/\s+/g,"");return e=qFe(e),e=WQ(e),e}function KFe(t){try{return XFe(t)}catch{return Sp}}function eN(t){var e=KFe(t.slice(5,-1));return e===Sp?"":e}var YFe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],ZFe=["dx","dy","angle","className","breakAll"];function uP(){return uP=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},uP.apply(null,arguments)}function aV(t,e){if(t==null)return{};var n,i,r=QFe(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 QFe(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 qQ=/[ \f\n\r\t\v\u2028\u2029]+/,XQ=t=>{var{children:e,breakAll:n,style:i}=t;try{var r=[];gi(e)||(n?r=e.toString().split(""):r=e.toString().split(qQ));var a=r.map(o=>({word:o,width:Fx(o,i).width})),s=n?0:Fx(" ",i).width;return{wordsWithComputedWidth:a,spaceWidth:s}}catch{return null}};function JFe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var KQ=(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},[]),YQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),eze="…",sV=(t,e,n,i,r,a,s,o)=>{var l=t.slice(0,e),c=XQ({breakAll:n,style:i,children:l+eze});if(!c)return[!1,[]];var u=KQ(c.wordsWithComputedWidth,a,s,o),f=u.length>r||YQ(u).width>Number(a);return[f,u]},tze=(t,e,n,i,r)=>{var{maxLines:a,children:s,style:o,breakAll:l}=t,c=Et(a),u=String(s),f=KQ(e,i,n,r);if(!c||r)return f;var m=f.length>a||YQ(f).width>Number(i);if(!m)return f;for(var g=0,y=u.length-1,_=0,v;g<=y&&_<=u.length-1;){var x=Math.floor((g+y)/2),M=x-1,[w,C]=sV(u,M,l,o,a,i,n,r),[T]=sV(u,x,l,o,a,i,n,r);if(!w&&!T&&(g=x+1),w&&T&&(y=x-1),!w&&T){v=C;break}_++}return v||f},oV=t=>{var e=gi(t)?[]:t.toString().split(qQ);return[{words:e,width:void 0}]},nze=t=>{var{width:e,scaleToFit:n,children:i,style:r,breakAll:a,maxLines:s}=t;if((e||n)&&!Om.isSsr){var o,l,c=XQ({breakAll:a,children:i,style:r});if(c){var{wordsWithComputedWidth:u,spaceWidth:f}=c;o=u,l=f}else return oV(i);return tze({breakAll:a,children:i,maxLines:s,style:r},o,l,e,!!n)}return oV(i)},ZQ="#808080",ize={angle:0,breakAll:!1,capHeight:"0.71em",fill:ZQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},gM=E.forwardRef((t,e)=>{var n=Zi(t,ize),{x:i,y:r,lineHeight:a,capHeight:s,fill:o,scaleToFit:l,textAnchor:c,verticalAnchor:u}=n,f=aV(n,YFe),m=E.useMemo(()=>nze({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:g,dy:y,angle:_,className:v,breakAll:x}=f,M=aV(f,ZFe);if(!al(i)||!al(r)||m.length===0)return null;var w=Number(i)+(Et(g)?g:0),C=Number(r)+(Et(y)?y:0);if(!oi(w)||!oi(C))return null;var T;switch(u){case"start":T=eN("calc(".concat(s,")"));break;case"middle":T=eN("calc(".concat((m.length-1)/2," * -").concat(a," + (").concat(s," / 2))"));break;default:T=eN("calc(".concat(m.length-1," * -").concat(a,")"));break}var P=[];if(l){var A=m[0].width,{width:j}=f;P.push("scale(".concat(Et(j)&&Et(A)?j/A:1,")"))}return _&&P.push("rotate(".concat(_,", ").concat(w,", ").concat(C,")")),P.length&&(M.transform=P.join(" ")),E.createElement("text",uP({},ba(M),{ref:e,x:w,y:C,className:An("recharts-text",v),textAnchor:c,fill:o.includes("url")?ZQ:o}),m.map((N,k)=>{var F=N.words.join(x?"":" ");return E.createElement("tspan",{x:w,dy:k===0?T:a,key:"".concat(F,"-").concat(k)},F)}))});gM.displayName="Text";var rze=["labelRef"];function aze(t,e){if(t==null)return{};var n,i,r=sze(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 sze(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 lV(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 ki(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lV(Object(n),!0).forEach(function(i){oze(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function oze(t,e,n){return(e=lze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function lze(t){var e=cze(t,"string");return typeof e=="symbol"?e:e+""}function cze(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 Yl(){return Yl=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},Yl.apply(null,arguments)}var QQ=E.createContext(null),uze=t=>{var{x:e,y:n,upperWidth:i,lowerWidth:r,width:a,height:s,children:o}=t,l=E.useMemo(()=>({x:e,y:n,upperWidth:i,lowerWidth:r,width:a,height:s}),[e,n,i,r,a,s]);return E.createElement(QQ.Provider,{value:l},o)},JQ=()=>{var t=E.useContext(QQ),e=qw();return t||xY(e)},dze=E.createContext(null),fze=()=>{var t=E.useContext(dze),e=At($Z);return t||e},hze=t=>{var{value:e,formatter:n}=t,i=gi(t.children)?e:t.children;return typeof n=="function"?n(i):i},GO=t=>t!=null&&typeof t=="function",pze=(t,e)=>{var n=Tr(e-t),i=Math.min(Math.abs(e-t),360);return n*i},mze=(t,e,n,i,r)=>{var{offset:a,className:s}=t,{cx:o,cy:l,innerRadius:c,outerRadius:u,startAngle:f,endAngle:m,clockWise:g}=r,y=(c+u)/2,_=pze(f,m),v=_>=0?1:-1,x,M;switch(e){case"insideStart":x=f+v*a,M=g;break;case"insideEnd":x=m-v*a,M=!g;break;case"end":x=m+v*a,M=g;break;default:throw new Error("Unsupported position ".concat(e))}M=_<=0?M:!M;var w=Wi(o,l,y,x),C=Wi(o,l,y,x+(M?1:-1)*359),T="M".concat(w.x,",").concat(w.y,`
- A`).concat(y,",").concat(y,",0,1,").concat(M?0:1,`,
- `).concat(C.x,",").concat(C.y),P=gi(t.id)?v0("recharts-radial-line-"):t.id;return E.createElement("text",Yl({},i,{dominantBaseline:"central",className:An("recharts-radial-bar-label",s)}),E.createElement("defs",null,E.createElement("path",{id:P,d:T})),E.createElement("textPath",{xlinkHref:"#".concat(P)},n))},gze=(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:u,y:f}=Wi(i,r,s+e,c);return{x:u,y:f,textAnchor:u>=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 m=(a+s)/2,{x:g,y}=Wi(i,r,m,c);return{x:g,y,textAnchor:"middle",verticalAnchor:"middle"}},dP=t=>"cx"in t&&Et(t.cx),xze=(t,e)=>{var{parentViewBox:n,offset:i,position:r}=t,a;n!=null&&!dP(n)&&(a=n);var{x:s,y:o,upperWidth:l,lowerWidth:c,height:u}=e,f=s,m=s+(l-c)/2,g=(f+m)/2,y=(l+c)/2,_=f+l/2,v=u>=0?1:-1,x=v*i,M=v>0?"end":"start",w=v>0?"start":"end",C=l>=0?1:-1,T=C*i,P=C>0?"end":"start",A=C>0?"start":"end";if(r==="top"){var j={x:f+l/2,y:o-x,textAnchor:"middle",verticalAnchor:M};return ki(ki({},j),a?{height:Math.max(o-a.y,0),width:l}:{})}if(r==="bottom"){var N={x:m+c/2,y:o+u+x,textAnchor:"middle",verticalAnchor:w};return ki(ki({},N),a?{height:Math.max(a.y+a.height-(o+u),0),width:c}:{})}if(r==="left"){var k={x:g-T,y:o+u/2,textAnchor:P,verticalAnchor:"middle"};return ki(ki({},k),a?{width:Math.max(k.x-a.x,0),height:u}:{})}if(r==="right"){var F={x:g+y+T,y:o+u/2,textAnchor:A,verticalAnchor:"middle"};return ki(ki({},F),a?{width:Math.max(a.x+a.width-F.x,0),height:u}:{})}var I=a?{width:y,height:u}:{};return r==="insideLeft"?ki({x:g+T,y:o+u/2,textAnchor:A,verticalAnchor:"middle"},I):r==="insideRight"?ki({x:g+y-T,y:o+u/2,textAnchor:P,verticalAnchor:"middle"},I):r==="insideTop"?ki({x:f+l/2,y:o+x,textAnchor:"middle",verticalAnchor:w},I):r==="insideBottom"?ki({x:m+c/2,y:o+u-x,textAnchor:"middle",verticalAnchor:M},I):r==="insideTopLeft"?ki({x:f+T,y:o+x,textAnchor:A,verticalAnchor:w},I):r==="insideTopRight"?ki({x:f+l-T,y:o+x,textAnchor:P,verticalAnchor:w},I):r==="insideBottomLeft"?ki({x:m+T,y:o+u-x,textAnchor:A,verticalAnchor:M},I):r==="insideBottomRight"?ki({x:m+c-T,y:o+u-x,textAnchor:P,verticalAnchor:M},I):r&&typeof r=="object"&&(Et(r.x)||vc(r.x))&&(Et(r.y)||vc(r.y))?ki({x:s+ra(r.x,y),y:o+ra(r.y,u),textAnchor:"end",verticalAnchor:"end"},I):ki({x:_,y:o+u/2,textAnchor:"middle",verticalAnchor:"middle"},I)},vze={angle:0,offset:5,zIndex:qi.label,position:"middle",textBreakAll:!1};function Au(t){var e=Zi(t,vze),{viewBox:n,position:i,value:r,children:a,content:s,className:o="",textBreakAll:l,labelRef:c}=e,u=fze(),f=JQ(),m=i==="center"?f:u??f,g,y,_;if(n==null?g=m:dP(n)?g=n:g=xY(n),!g||gi(r)&&gi(a)&&!E.isValidElement(s)&&typeof s!="function")return null;var v=ki(ki({},e),{},{viewBox:g});if(E.isValidElement(s)){var{labelRef:x}=v,M=aze(v,rze);return E.cloneElement(s,M)}if(typeof s=="function"){if(y=E.createElement(s,v),E.isValidElement(y))return y}else y=hze(e);var w=ba(e);if(dP(g)){if(i==="insideStart"||i==="insideEnd"||i==="end")return mze(e,i,y,w,g);_=gze(g,e.offset,e.position)}else _=xze(e,g);return E.createElement(Ga,{zIndex:e.zIndex},E.createElement(gM,Yl({ref:c,className:An("recharts-label",o)},w,_,{textAnchor:JFe(w.textAnchor)?w.textAnchor:_.textAnchor,breakAll:l}),y))}Au.displayName="Label";var yze=(t,e,n)=>{if(!t)return null;var i={viewBox:e,labelRef:n};return t===!0?E.createElement(Au,Yl({key:"label-implicit"},i)):al(t)?E.createElement(Au,Yl({key:"label-implicit",value:t},i)):E.isValidElement(t)?t.type===Au?E.cloneElement(t,ki({key:"label-implicit"},i)):E.createElement(Au,Yl({key:"label-implicit",content:t},i)):GO(t)?E.createElement(Au,Yl({key:"label-implicit",content:t},i)):t&&typeof t=="object"?E.createElement(Au,Yl({},t,{key:"label-implicit"},i)):null};function bze(t){var{label:e,labelRef:n}=t,i=JQ();return yze(e,i,n)||null}var tN={},nN={},cV;function _ze(){return cV||(cV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(nN)),nN}var iN={},uV;function Sze(){return uV||(uV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(iN)),iN}var dV;function wze(){return dV||(dV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=_ze(),n=Sze(),i=yD();function r(a){if(i.isArrayLike(a))return e.last(n.toArray(a))}t.last=r})(tN)),tN}var rN,fV;function Mze(){return fV||(fV=1,rN=wze().last),rN}var Eze=Mze();const Aze=Ys(Eze);var Tze=["valueAccessor"],Cze=["dataKey","clockWise","id","textBreakAll","zIndex"];function OS(){return OS=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},OS.apply(null,arguments)}function hV(t,e){if(t==null)return{};var n,i,r=Nze(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 Nze(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 Rze=t=>Array.isArray(t.value)?Aze(t.value):t.value,eJ=E.createContext(void 0),tJ=eJ.Provider,nJ=E.createContext(void 0),Pze=nJ.Provider;function kze(){return E.useContext(eJ)}function Dze(){return E.useContext(nJ)}function O_(t){var{valueAccessor:e=Rze}=t,n=hV(t,Tze),{dataKey:i,clockWise:r,id:a,textBreakAll:s,zIndex:o}=n,l=hV(n,Cze),c=kze(),u=Dze(),f=c||u;return!f||!f.length?null:E.createElement(Ga,{zIndex:o??qi.label},E.createElement(Li,{className:"recharts-label-list"},f.map((m,g)=>{var y,_=gi(i)?e(m,g):Yn(m&&m.payload,i),v=gi(a)?{}:{id:"".concat(a,"-").concat(g)};return E.createElement(Au,OS({key:"label-".concat(g)},ba(m),l,v,{fill:(y=n.fill)!==null&&y!==void 0?y:m.fill,parentViewBox:m.parentViewBox,value:_,textBreakAll:s,viewBox:m.viewBox,index:g,zIndex:0}))})))}O_.displayName="LabelList";function WO(t){var{label:e}=t;return e?e===!0?E.createElement(O_,{key:"labelList-implicit"}):E.isValidElement(e)||GO(e)?E.createElement(O_,{key:"labelList-implicit",content:e}):typeof e=="object"?E.createElement(O_,OS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function fP(){return fP=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},fP.apply(null,arguments)}var iJ=t=>{var{cx:e,cy:n,r:i,className:r}=t,a=An("recharts-dot",r);return Et(e)&&Et(n)&&Et(i)?E.createElement("circle",fP({},Ba(t),vD(t),{className:a,cx:e,cy:n,r:i})):null},rJ=t=>t.graphicalItems.polarItems,Oze=He([fi,uv],pO),xM=He([rJ,vi,Oze],mO),Lze=He([xM],gO),vM=He([Lze,rO],xO),Ize=He([vM,vi,xM],yO);He([vM,vi,xM],(t,e,n)=>n.length>0?t.flatMap(i=>n.flatMap(r=>{var a,s=Yn(i,(a=e.dataKey)!==null&&a!==void 0?a:r.dataKey);return{value:s,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(i=>({value:Yn(i,e.dataKey),errorDomain:[]})):t.map(i=>({value:i,errorDomain:[]})));var pV=()=>{},jze=He([vM,vi,xM,hM,fi],wO),Uze=He([vi,_O,SO,pV,jze,pV,_n,fi],MO),aJ=He([vi,_n,vM,Ize,cv,fi,Uze],EO),Fze=He([aJ,vi,zm],CO);He([vi,aJ,Fze,fi],RO);var zze={radiusAxis:{},angleAxis:{}},sJ=Va({name:"polarAxis",initialState:zze,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:DGe,removeRadiusAxis:OGe,addAngleAxis:LGe,removeAngleAxis:IGe}=sJ.actions,Bze=sJ.reducer;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 gV(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){Hze(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 Hze(t,e,n){return(e=$ze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $ze(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)}var Gze=(t,e)=>e,qO=He([rJ,Gze],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),Wze=[],XO=(t,e,n)=>n?.length===0?Wze:n,oJ=He([rO,qO,XO],(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=>gV(gV({},e.presentationProps),a.props))),r!=null)return r}}),qze=He([oJ,qO,XO],(t,e,n)=>{if(!(t==null||e==null))return t.map((i,r)=>{var a,s=Yn(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:km(s,e.dataKey),color:o,payload:i,type:e.legendType}})}),Xze=He([oJ,qO,XO,dr],(t,e,n,i)=>{if(!(e==null||t==null))return K5e({offset:i,pieSettings:e,displayedData:t,cells:n})}),aN={exports:{}},zn={};var xV;function Kze(){if(xV)return zn;xV=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"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),m=Symbol.for("react.view_transition"),g=Symbol.for("react.client.reference");function y(_){if(typeof _=="object"&&_!==null){var v=_.$$typeof;switch(v){case t:switch(_=_.type,_){case n:case r:case i:case l:case c:case m:return _;default:switch(_=_&&_.$$typeof,_){case s:case o:case f:case u:return _;case a:return _;default:return v}}case e:return v}}}return zn.ContextConsumer=a,zn.ContextProvider=s,zn.Element=t,zn.ForwardRef=o,zn.Fragment=n,zn.Lazy=f,zn.Memo=u,zn.Portal=e,zn.Profiler=r,zn.StrictMode=i,zn.Suspense=l,zn.SuspenseList=c,zn.isContextConsumer=function(_){return y(_)===a},zn.isContextProvider=function(_){return y(_)===s},zn.isElement=function(_){return typeof _=="object"&&_!==null&&_.$$typeof===t},zn.isForwardRef=function(_){return y(_)===o},zn.isFragment=function(_){return y(_)===n},zn.isLazy=function(_){return y(_)===f},zn.isMemo=function(_){return y(_)===u},zn.isPortal=function(_){return y(_)===e},zn.isProfiler=function(_){return y(_)===r},zn.isStrictMode=function(_){return y(_)===i},zn.isSuspense=function(_){return y(_)===l},zn.isSuspenseList=function(_){return y(_)===c},zn.isValidElementType=function(_){return typeof _=="string"||typeof _=="function"||_===n||_===r||_===i||_===l||_===c||typeof _=="object"&&_!==null&&(_.$$typeof===f||_.$$typeof===u||_.$$typeof===s||_.$$typeof===a||_.$$typeof===o||_.$$typeof===g||_.getModuleId!==void 0)},zn.typeOf=y,zn}var vV;function Yze(){return vV||(vV=1,aN.exports=Kze()),aN.exports}var Zze=Yze(),yV=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",bV=null,sN=null,lJ=t=>{if(t===bV&&Array.isArray(sN))return sN;var e=[];return E.Children.forEach(t,n=>{gi(n)||(Zze.isFragment(n)?e=e.concat(lJ(n.props.children)):e.push(n))}),sN=e,bV=t,e};function KO(t,e){var n=[],i=[];return Array.isArray(e)?i=e.map(r=>yV(r)):i=[yV(e)],lJ(t).forEach(r=>{var a=Lf(r,"type.displayName")||Lf(r,"type.name");a&&i.indexOf(a)!==-1&&n.push(r)}),n}var cJ=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,oN={},_V;function Qze(){return _V||(_V=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})(oN)),oN}var lN,SV;function Jze(){return SV||(SV=1,lN=Qze().isPlainObject),lN}var e5e=Jze();const t5e=Ys(e5e);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 MV(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){n5e(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 n5e(t,e,n){return(e=i5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i5e(t){var e=r5e(t,"string");return typeof e=="symbol"?e:e+""}function r5e(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 LS(){return LS=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},LS.apply(null,arguments)}var EV=(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},a5e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},s5e=t=>{var e=Zi(t,a5e),{x:n,y:i,upperWidth:r,lowerWidth:a,height:s,className:o}=e,{animationEasing:l,animationDuration:c,animationBegin:u,isUpdateAnimationActive:f}=e,m=E.useRef(null),[g,y]=E.useState(-1),_=E.useRef(r),v=E.useRef(a),x=E.useRef(s),M=E.useRef(n),w=E.useRef(i),C=rv(t,"trapezoid-");if(E.useEffect(()=>{if(m.current&&m.current.getTotalLength)try{var D=m.current.getTotalLength();D&&y(D)}catch{}},[]),n!==+n||i!==+i||r!==+r||a!==+a||s!==+s||r===0&&a===0||s===0)return null;var T=An("recharts-trapezoid",o);if(!f)return E.createElement("g",null,E.createElement("path",LS({},ba(e),{className:T,d:EV(n,i,r,a,s)})));var P=_.current,A=v.current,j=x.current,N=M.current,k=w.current,F="0px ".concat(g===-1?1:g,"px"),I="".concat(g,"px 0px"),W=PY(["strokeDasharray"],c,l);return E.createElement(iv,{animationId:C,key:C,canBegin:g>0,duration:c,easing:l,isActive:f,begin:u},D=>{var B=si(P,r,D),$=si(A,a,D),K=si(j,s,D),X=si(N,n,D),Y=si(k,i,D);m.current&&(_.current=B,v.current=$,x.current=K,M.current=X,w.current=Y);var ee=D>0?{transition:W,strokeDasharray:I}:{strokeDasharray:F};return E.createElement("path",LS({},ba(e),{className:T,d:EV(X,Y,B,$,K),ref:m,style:MV(MV({},ee),e.style)}))})},o5e=["option","shapeType","propTransformer","activeClassName"];function l5e(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 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 IS(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){u5e(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 u5e(t,e,n){return(e=d5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d5e(t){var e=f5e(t,"string");return typeof e=="symbol"?e:e+""}function f5e(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 h5e(t,e){return IS(IS({},e),t)}function p5e(t,e){return t==="symbols"}function TV(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return E.createElement(LY,n);case"trapezoid":return E.createElement(s5e,n);case"sector":return E.createElement(FY,n);case"symbols":if(p5e(e))return E.createElement(xD,n);break;case"curve":return E.createElement(Lp,n);default:return null}}function m5e(t){return E.isValidElement(t)?t.props:t}function uJ(t){var{option:e,shapeType:n,propTransformer:i=h5e,activeClassName:r="recharts-active-shape"}=t,a=l5e(t,o5e),s;if(E.isValidElement(e))s=E.cloneElement(e,IS(IS({},a),m5e(e)));else if(typeof e=="function")s=e(a,a.index);else if(t5e(e)&&typeof e!="boolean"){var o=i(e,a);s=E.createElement(TV,{shapeType:n,elementProps:o})}else{var l=a;s=E.createElement(TV,{shapeType:n,elementProps:l})}return a.isActive?E.createElement(Li,{className:r},s):s}var YO=(t,e,n)=>{var i=ei();return(r,a)=>s=>{t?.(r,a,s),i(bQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:r.tooltipPosition,activeGraphicalItemId:n}))}},ZO=t=>{var e=ei();return(n,i)=>r=>{t?.(n,i,r),e(C4e())}},QO=(t,e,n)=>{var i=ei();return(r,a)=>s=>{t?.(r,a,s),i(N4e({activeIndex:String(a),activeDataKey:e,activeCoordinate:r.tooltipPosition,activeGraphicalItemId:n}))}};function JO(t){var{tooltipEntrySettings:e}=t,n=ei(),i=oa(),r=E.useRef(null);return E.useLayoutEffect(()=>{i||(r.current===null?n(M4e(e)):r.current!==e&&n(E4e({prev:r.current,next:e})),r.current=e)},[e,n,i]),E.useLayoutEffect(()=>()=>{r.current&&(n(A4e(r.current)),r.current=null)},[n]),null}function dJ(t){var{legendPayload:e}=t,n=ei(),i=oa(),r=E.useRef(null);return E.useLayoutEffect(()=>{i||(r.current===null?n(AY(e)):r.current!==e&&n(TY({prev:r.current,next:e})),r.current=e)},[n,i,e]),E.useLayoutEffect(()=>()=>{r.current&&(n(CY(r.current)),r.current=null)},[n]),null}function g5e(t){var{legendPayload:e}=t,n=ei(),i=At(_n),r=E.useRef(null);return E.useLayoutEffect(()=>{i!=="centric"&&i!=="radial"||(r.current===null?n(AY(e)):r.current!==e&&n(TY({prev:r.current,next:e})),r.current=e)},[n,i,e]),E.useLayoutEffect(()=>()=>{r.current&&(n(CY(r.current)),r.current=null)},[n]),null}var cN,x5e=()=>{var[t]=E.useState(()=>v0("uid-"));return t},v5e=(cN=cne.useId)!==null&&cN!==void 0?cN:x5e;function fJ(t,e){var n=v5e();return e||(t?"".concat(t,"-").concat(n):n)}var y5e=E.createContext(void 0),eL=t=>{var{id:e,type:n,children:i}=t,r=fJ("recharts-".concat(n),e);return E.createElement(y5e.Provider,{value:r},i(r))},b5e={cartesianItems:[],polarItems:[]},hJ=Va({name:"graphicalItems",initialState:b5e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:ci()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:i}=e.payload,r=bo(t).cartesianItems.indexOf(n);r>-1&&(t.cartesianItems[r]=i)},prepare:ci()},removeCartesianGraphicalItem:{reducer(t,e){var n=bo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:ci()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:ci()},removePolarGraphicalItem:{reducer(t,e){var n=bo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:ci()}}}),{addCartesianGraphicalItem:_5e,replaceCartesianGraphicalItem:S5e,removeCartesianGraphicalItem:w5e,addPolarGraphicalItem:M5e,removePolarGraphicalItem:E5e}=hJ.actions,A5e=hJ.reducer,T5e=t=>{var e=ei(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(_5e(t)):n.current!==t&&e(S5e({prev:n.current,next:t})),n.current=t},[e,t]),E.useLayoutEffect(()=>()=>{n.current&&(e(w5e(n.current)),n.current=null)},[e]),null},pJ=E.memo(T5e);function C5e(t){var e=ei();return E.useLayoutEffect(()=>(e(M5e(t)),()=>{e(E5e(t))}),[e,t]),null}var N5e=["key"],R5e=["onMouseEnter","onClick","onMouseLeave"],P5e=["id"],k5e=["id"];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 wi(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){D5e(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 D5e(t,e,n){return(e=O5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O5e(t){var e=L5e(t,"string");return typeof e=="symbol"?e:e+""}function L5e(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 id(){return id=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},id.apply(null,arguments)}function yM(t,e){if(t==null)return{};var n,i,r=I5e(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 I5e(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 j5e(t){var e=E.useMemo(()=>KO(t.children,yv),[t.children]),n=At(i=>qze(i,t.id,e));return n==null?null:E.createElement(g5e,{legendPayload:n})}var U5e=E.memo(t=>{var{dataKey:e,nameKey:n,sectors:i,stroke:r,strokeWidth:a,fill:s,name:o,hide:l,tooltipType:c}=t,u={dataDefinedOnItem:i.map(f=>f.tooltipPayload),positions:i.map(f=>f.tooltipPosition),settings:{stroke:r,strokeWidth:a,fill:s,dataKey:e,nameKey:n,name:km(o,e),hide:l,type:c,color:s,unit:""}};return E.createElement(JO,{tooltipEntrySettings:u})}),F5e=(t,e)=>t>e?"start":t<e?"end":"middle",z5e=(t,e,n)=>ra(typeof e=="function"?e(t):e,n,n*.8),B5e=(t,e,n)=>{var{top:i,left:r,width:a,height:s}=e,o=IY(a,s),l=r+ra(t.cx,a,a/2),c=i+ra(t.cy,s,s/2),u=ra(t.innerRadius,o,0),f=z5e(n,t.outerRadius,o),m=t.maxRadius||Math.sqrt(a*a+s*s)/2;return{cx:l,cy:c,innerRadius:u,outerRadius:f,maxRadius:m}},H5e=(t,e)=>{var n=Tr(e-t),i=Math.min(Math.abs(e-t),360);return n*i};function $5e(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var V5e=(t,e)=>{if(E.isValidElement(t))return E.cloneElement(t,e);if(typeof t=="function")return t(e);var n=An("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:i}=e,r=yM(e,N5e);return E.createElement(Lp,id({},r,{type:"linear",className:n}))},G5e=(t,e,n)=>{if(E.isValidElement(t))return E.cloneElement(t,e);var i=n;if(typeof t=="function"&&(i=t(e),E.isValidElement(i)))return i;var r=An("recharts-pie-label-text",$5e(t));return E.createElement(gM,id({},e,{alignmentBaseline:"middle",className:r}),i)};function W5e(t){var{sectors:e,props:n,showLabels:i}=t,{label:r,labelLine:a,dataKey:s}=n;if(!i||!r||!e)return null;var o=Ba(n),l=Of(r),c=Of(a),u=typeof r=="object"&&"offsetRadius"in r&&typeof r.offsetRadius=="number"&&r.offsetRadius||20,f=e.map((m,g)=>{var y=(m.startAngle+m.endAngle)/2,_=Wi(m.cx,m.cy,m.outerRadius+u,y),v=wi(wi(wi(wi({},o),m),{},{stroke:"none"},l),{},{index:g,textAnchor:F5e(_.x,m.cx)},_),x=wi(wi(wi(wi({},o),m),{},{fill:"none",stroke:m.fill},c),{},{index:g,points:[Wi(m.cx,m.cy,m.outerRadius,y),_],key:"line"});return E.createElement(Ga,{zIndex:qi.label,key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(g)},E.createElement(Li,null,a&&V5e(a,x),G5e(r,v,Yn(m,s))))});return E.createElement(Li,{className:"recharts-pie-labels"},f)}function q5e(t){var{sectors:e,props:n,showLabels:i}=t,{label:r}=n;return typeof r=="object"&&r!=null&&"position"in r?E.createElement(WO,{label:r}):E.createElement(W5e,{sectors:e,props:n,showLabels:i})}function X5e(t){var{sectors:e,activeShape:n,inactiveShape:i,allOtherPieProps:r,shape:a,id:s}=t,o=At(nd),l=At(FO),c=At(pUe),{onMouseEnter:u,onClick:f,onMouseLeave:m}=r,g=yM(r,R5e),y=YO(u,r.dataKey,s),_=ZO(m),v=QO(f,r.dataKey,s);return e==null||e.length===0?null:E.createElement(E.Fragment,null,e.map((x,M)=>{if(x?.startAngle===0&&x?.endAngle===0&&e.length!==1)return null;var w=c==null||c===s,C=String(M)===o&&(l==null||r.dataKey===l)&&w,T=o?i:null,P=n&&C?n:T,A=wi(wi({},x),{},{stroke:x.stroke,tabIndex:-1,[fY]:M,[hY]:r.dataKey});return E.createElement(Li,id({key:"sector-".concat(x?.startAngle,"-").concat(x?.endAngle,"-").concat(x.midAngle,"-").concat(M),tabIndex:-1,className:"recharts-pie-sector"},Z0(g,x,M),{onMouseEnter:y(x,M),onMouseLeave:_(x,M),onClick:v(x,M)}),E.createElement(uJ,id({option:a??P,index:M,shapeType:"sector",isActive:C},A)))}))}function K5e(t){var e,{pieSettings:n,displayedData:i,cells:r,offset:a}=t,{cornerRadius:s,startAngle:o,endAngle:l,dataKey:c,nameKey:u,tooltipType:f}=n,m=Math.abs(n.minAngle),g=H5e(o,l),y=Math.abs(g),_=i.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=i.filter(P=>Yn(P,c,0)!==0).length,x=(y>=360?v:v-1)*_,M=y-v*m-x,w=i.reduce((P,A)=>{var j=Yn(A,c,0);return P+(Et(j)?j:0)},0),C;if(w>0){var T;C=i.map((P,A)=>{var j=Yn(P,c,0),N=Yn(P,u,A),k=B5e(n,a,P),F=(Et(j)?j:0)/w,I,W=wi(wi({},P),r&&r[A]&&r[A].props);A?I=T.endAngle+Tr(g)*_*(j!==0?1:0):I=o;var D=I+Tr(g)*((j!==0?m:0)+F*M),B=(I+D)/2,$=(k.innerRadius+k.outerRadius)/2,K=[{name:N,value:j,payload:W,dataKey:c,type:f}],X=Wi(k.cx,k.cy,$,B);return T=wi(wi(wi(wi({},n.presentationProps),{},{percent:F,cornerRadius:typeof s=="string"?parseFloat(s):s,name:N,tooltipPayload:K,midAngle:B,middleRadius:$,tooltipPosition:X},W),k),{},{value:j,dataKey:c,startAngle:I,endAngle:D,payload:W,paddingAngle:Tr(g)*_}),T})}return C}function Y5e(t){var{showLabels:e,sectors:n,children:i}=t,r=E.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 E.createElement(Pze,{value:e?r:void 0},i)}function Z5e(t){var{props:e,previousSectorsRef:n,id:i}=t,{sectors:r,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,activeShape:c,inactiveShape:u,onAnimationStart:f,onAnimationEnd:m}=e,g=rv(e,"recharts-pie-"),y=n.current,[_,v]=E.useState(!1),x=E.useCallback(()=>{typeof m=="function"&&m(),v(!1)},[m]),M=E.useCallback(()=>{typeof f=="function"&&f(),v(!0)},[f]);return E.createElement(Y5e,{showLabels:!_,sectors:r},E.createElement(iv,{animationId:g,begin:s,duration:o,isActive:a,easing:l,onAnimationStart:M,onAnimationEnd:x,key:g},w=>{var C=[],T=r&&r[0],P=T?.startAngle;return r?.forEach((A,j)=>{var N=y&&y[j],k=j>0?Lf(A,"paddingAngle",0):0;if(N){var F=si(N.endAngle-N.startAngle,A.endAngle-A.startAngle,w),I=wi(wi({},A),{},{startAngle:P+k,endAngle:P+F+k});C.push(I),P=I.endAngle}else{var{endAngle:W,startAngle:D}=A,B=si(0,W-D,w),$=wi(wi({},A),{},{startAngle:P+k,endAngle:P+B+k});C.push($),P=$.endAngle}}),n.current=C,E.createElement(Li,null,E.createElement(X5e,{sectors:C,activeShape:c,inactiveShape:u,allOtherPieProps:e,shape:e.shape,id:i}))}),E.createElement(q5e,{showLabels:!_,sectors:r,props:e}),e.children)}var Q5e={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:qi.area};function J5e(t){var{id:e}=t,n=yM(t,P5e),{hide:i,className:r,rootTabIndex:a}=t,s=E.useMemo(()=>KO(t.children,yv),[t.children]),o=At(u=>Xze(u,e,s)),l=E.useRef(null),c=An("recharts-pie",r);return i||o==null?(l.current=null,E.createElement(Li,{tabIndex:a,className:c})):E.createElement(Ga,{zIndex:t.zIndex},E.createElement(U5e,{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}),E.createElement(Li,{tabIndex:a,className:c},E.createElement(Z5e,{props:wi(wi({},n),{},{sectors:o}),previousSectorsRef:l,id:e})))}function mJ(t){var e=Zi(t,Q5e),{id:n}=e,i=yM(e,k5e),r=Ba(i);return E.createElement(eL,{id:n,type:"pie"},a=>E.createElement(E.Fragment,null,E.createElement(C5e,{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}),E.createElement(j5e,id({},i,{id:a})),E.createElement(J5e,id({},i,{id:a}))))}mJ.displayName="Pie";var eBe=["points"];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 uN(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){tBe(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 tBe(t,e,n){return(e=nBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nBe(t){var e=iBe(t,"string");return typeof e=="symbol"?e:e+""}function iBe(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 jS(){return jS=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},jS.apply(null,arguments)}function rBe(t,e){if(t==null)return{};var n,i,r=aBe(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 aBe(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 sBe(t){var{option:e,dotProps:n,className:i}=t;if(E.isValidElement(e))return E.cloneElement(e,n);if(typeof e=="function")return e(n);var r=An(i,typeof e!="boolean"?e.className:""),a=n??{},{points:s}=a,o=rBe(a,eBe);return E.createElement(iJ,jS({},o,{className:r}))}function oBe(t,e){return t==null?!1:e?!0:t.length===1}function lBe(t){var{points:e,dot:n,className:i,dotClassName:r,dataKey:a,baseProps:s,needClip:o,clipPathId:l,zIndex:c=qi.scatter}=t;if(!oBe(e,n))return null;var u=cJ(n),f=UNe(n),m=e.map((y,_)=>{var v,x,M=uN(uN(uN({r:3},s),f),{},{index:_,cx:(v=y.x)!==null&&v!==void 0?v:void 0,cy:(x=y.y)!==null&&x!==void 0?x:void 0,dataKey:a,value:y.value,payload:y.payload,points:e});return E.createElement(sBe,{key:"dot-".concat(_),option:n,dotProps:M,className:r})}),g={};return o&&l!=null&&(g.clipPath="url(#clipPath-".concat(u?"":"dots-").concat(l,")")),E.createElement(Ga,{zIndex:c},E.createElement(Li,jS({className:i},g),m))}function RV(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?RV(Object(n),!0).forEach(function(i){cBe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function cBe(t,e,n){return(e=uBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uBe(t){var e=dBe(t,"string");return typeof e=="symbol"?e:e+""}function dBe(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 fBe={xAxis:{},yAxis:{},zAxis:{}},gJ=Va({name:"cartesianAxis",initialState:fBe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:ci()},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:ci()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:ci()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:ci()},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:ci()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:ci()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:ci()},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:ci()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:ci()},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:hBe,replaceXAxis:pBe,removeXAxis:mBe,addYAxis:gBe,replaceYAxis:xBe,removeYAxis:vBe,addZAxis:jGe,replaceZAxis:UGe,removeZAxis:FGe,updateYAxisWidth:yBe}=gJ.actions,bBe=gJ.reducer,_Be=He([dr],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),SBe=He([_Be,Cc,Nc],(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)}}),tL=()=>At(SBe),wBe=()=>At(yUe);function kV(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 dN(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?kV(Object(n),!0).forEach(function(i){MBe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):kV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function MBe(t,e,n){return(e=EBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EBe(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 TBe=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=dN(dN(dN({},o),Of(r)),vD(r)),c;return E.isValidElement(r)?c=E.cloneElement(r,l):typeof r=="function"?c=r(l):c=E.createElement(iJ,l),E.createElement(Li,{className:"recharts-active-dot",clipPath:s},c)};function DV(t){var{points:e,mainColor:n,activeDot:i,itemDataKey:r,clipPath:a,zIndex:s=qi.activeDot}=t,o=At(nd),l=wBe();if(e==null||l==null)return null;var c=e.find(u=>l.includes(u.payload));return gi(c)?null:E.createElement(Ga,{zIndex:s},E.createElement(TBe,{point:c,childIndex:Number(o),mainColor:n,dataKey:r,activeDot:i,clipPath:a}))}var CBe="Invariant failed";function NBe(t,e){throw new Error(CBe)}var RBe=["x","y"];function hP(){return hP=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},hP.apply(null,arguments)}function OV(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 ax(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OV(Object(n),!0).forEach(function(i){PBe(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function PBe(t,e,n){return(e=kBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kBe(t){var e=DBe(t,"string");return typeof e=="symbol"?e:e+""}function DBe(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 OBe(t,e){if(t==null)return{};var n,i,r=LBe(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 LBe(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 IBe(t,e){var{x:n,y:i}=t,r=OBe(t,RBe),a="".concat(n),s=parseInt(a,10),o="".concat(i),l=parseInt(o,10),c="".concat(e.height||r.height),u=parseInt(c,10),f="".concat(e.width||r.width),m=parseInt(f,10);return ax(ax(ax(ax(ax({},e),r),s?{x:s}:{}),l?{y:l}:{}),{},{height:u,width:m,name:e.name,radius:e.radius})}function US(t){return E.createElement(uJ,hP({shapeType:"rectangle",propTransformer:IBe,activeClassName:"recharts-active-bar"},t))}var jBe=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)||gi(i);return a?e(i,r):(a||NBe(),n)}},UBe={},xJ=Va({name:"errorBars",initialState:UBe,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:zGe,replaceErrorBar:BGe,removeErrorBar:HGe}=xJ.actions,FBe=xJ.reducer,zBe=["children"];function BBe(t,e){if(t==null)return{};var n,i,r=HBe(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 HBe(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 $Be={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},VBe=E.createContext($Be);function GBe(t){var{children:e}=t,n=BBe(t,zBe);return E.createElement(VBe.Provider,{value:n},e)}function nL(t,e){var n,i,r=At(c=>Pc(c,t)),a=At(c=>kc(c,e)),s=(n=r?.allowDataOverflow)!==null&&n!==void 0?n:Sr.allowDataOverflow,o=(i=a?.allowDataOverflow)!==null&&i!==void 0?i:wr.allowDataOverflow,l=s||o;return{needClip:l,needClipX:s,needClipY:o}}function vJ(t){var{xAxisId:e,yAxisId:n,clipPathId:i}=t,r=tL(),{needClipX:a,needClipY:s,needClip:o}=nL(e,n);if(!o||!r)return null;var{x:l,y:c,width:u,height:f}=r;return E.createElement("clipPath",{id:"clipPath-".concat(i)},E.createElement("rect",{x:a?l:l-u/2,y:s?c:c-f/2,width:a?u:u*2,height:s?f:f*2}))}function WBe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&oi(t.zIndex)?t.zIndex:e}var fN={exports:{}},hN={};var LV;function qBe(){if(LV)return hN;LV=1;var t=xm();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 hN.useSyncExternalStoreWithSelector=function(l,c,u,f,m){var g=r(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=s(function(){function v(T){if(!x){if(x=!0,M=T,T=f(T),m!==void 0&&y.hasValue){var P=y.value;if(m(P,T))return w=P}return w=T}if(P=w,n(M,T))return P;var A=f(T);return m!==void 0&&m(P,A)?(M=T,P):(M=T,w=A)}var x=!1,M,w,C=u===void 0?null:u;return[function(){return v(c())},C===null?void 0:function(){return v(C())}]},[c,u,f,m]);var _=i(l,g[0],g[1]);return a(function(){y.hasValue=!0,y.value=_},[_]),o(_),_},hN}var IV;function XBe(){return IV||(IV=1,fN.exports=qBe()),fN.exports}XBe();function KBe(t){t()}function YBe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){KBe(()=>{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 jV={notify(){},get:()=>[]};function ZBe(t,e){let n,i=jV,r=0,a=!1;function s(_){u();const v=i.subscribe(_);let x=!1;return()=>{x||(x=!0,v(),f())}}function o(){i.notify()}function l(){y.onStateChange&&y.onStateChange()}function c(){return a}function u(){r++,n||(n=t.subscribe(l),i=YBe())}function f(){r--,n&&r===0&&(n(),n=void 0,i.clear(),i=jV)}function m(){a||(a=!0,u())}function g(){a&&(a=!1,f())}const y={addNestedSub:s,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:m,tryUnsubscribe:g,getListeners:()=>i};return y}var QBe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",JBe=QBe(),e8e=()=>typeof navigator<"u"&&navigator.product==="ReactNative",t8e=e8e(),n8e=()=>JBe||t8e?E.useLayoutEffect:E.useEffect,i8e=n8e();function UV(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function r8e(t,e){if(UV(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])||!UV(t[n[r]],e[n[r]]))return!1;return!0}var a8e=Symbol.for("react-redux-context"),s8e=typeof globalThis<"u"?globalThis:{};function o8e(){if(!E.createContext)return{};const t=s8e[a8e]??=new Map;let e=t.get(E.createContext);return e||(e=E.createContext(null),t.set(E.createContext,e)),e}var l8e=o8e();function c8e(t){const{children:e,context:n,serverState:i,store:r}=t,a=E.useMemo(()=>{const l=ZBe(r);return{store:r,subscription:l,getServerState:i?()=>i:void 0}},[r,i]),s=E.useMemo(()=>r.getState(),[r]);i8e(()=>{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||l8e;return E.createElement(o.Provider,{value:a},e)}var u8e=c8e,d8e=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function f8e(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function bM(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var i of n)if(d8e.has(i)){if(t[i]==null&&e[i]==null)continue;if(!r8e(t[i],e[i]))return!1}else if(!f8e(t[i],e[i]))return!1;return!0}var h8e=["onMouseEnter","onMouseLeave","onClick"],p8e=["value","background","tooltipPosition"],m8e=["id"],g8e=["onMouseEnter","onClick","onMouseLeave"];function Mc(){return Mc=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},Mc.apply(null,arguments)}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 ha(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){x8e(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 x8e(t,e,n){return(e=v8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function v8e(t){var e=y8e(t,"string");return typeof e=="symbol"?e:e+""}function y8e(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 FS(t,e){if(t==null)return{};var n,i,r=b8e(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 b8e(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 _8e=t=>{var{dataKey:e,name:n,fill:i,legendType:r,hide:a}=t;return[{inactive:a,dataKey:e,type:r,color:i,value:km(n,e),payload:t}]},S8e=E.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:km(a,e),hide:s,type:l,color:r,unit:o}};return E.createElement(JO,{tooltipEntrySettings:c})});function w8e(t){var e=At(nd),{data:n,dataKey:i,background:r,allOtherBarProps:a}=t,{onMouseEnter:s,onMouseLeave:o,onClick:l}=a,c=FS(a,h8e),u=YO(s,i),f=ZO(o),m=QO(l,i);if(!r||n==null)return null;var g=Of(r);return E.createElement(Ga,{zIndex:WBe(r,qi.barBackground)},n.map((y,_)=>{var{value:v,background:x,tooltipPosition:M}=y,w=FS(y,p8e);if(!x)return null;var C=u(y,_),T=f(y,_),P=m(y,_),A=ha(ha(ha(ha(ha({option:r,isActive:String(_)===e},w),{},{fill:"#eee"},x),g),Z0(c,y,_)),{},{onMouseEnter:C,onMouseLeave:T,onClick:P,dataKey:i,index:_,className:"recharts-bar-background-rectangle"});return E.createElement(US,Mc({key:"background-bar-".concat(_)},A))}))}function M8e(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 ha(ha({},s),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:s,fill:a.fill})});return E.createElement(tJ,{value:e?r:void 0},n)}function E8e(t){var{shape:e,activeBar:n,baseProps:i,entry:r,index:a,dataKey:s}=t,o=At(nd),l=At(FO),c=n&&String(a)===o&&(l==null||s===l),u=c?n:e;return c?E.createElement(Ga,{zIndex:qi.activeBar},E.createElement(US,Mc({},i,{name:String(i.name)},r,{isActive:c,option:u,index:a,dataKey:s}))):E.createElement(US,Mc({},i,{name:String(i.name)},r,{isActive:c,option:u,index:a,dataKey:s}))}function A8e(t){var{shape:e,baseProps:n,entry:i,index:r,dataKey:a}=t;return E.createElement(US,Mc({},n,{name:String(n.name)},i,{isActive:!1,option:e,index:r,dataKey:a}))}function T8e(t){var e,{data:n,props:i}=t,r=(e=Ba(i))!==null&&e!==void 0?e:{},{id:a}=r,s=FS(r,m8e),{shape:o,dataKey:l,activeBar:c}=i,{onMouseEnter:u,onClick:f,onMouseLeave:m}=i,g=FS(i,g8e),y=YO(u,l),_=ZO(m),v=QO(f,l);return n?E.createElement(E.Fragment,null,n.map((x,M)=>E.createElement(Li,Mc({key:"rectangle-".concat(x?.x,"-").concat(x?.y,"-").concat(x?.value,"-").concat(M),className:"recharts-bar-rectangle"},Z0(g,x,M),{onMouseEnter:y(x,M),onMouseLeave:_(x,M),onClick:v(x,M)}),c?E.createElement(E8e,{shape:o,activeBar:c,baseProps:s,entry:x,index:M,dataKey:l}):E.createElement(A8e,{shape:o,baseProps:s,entry:x,index:M,dataKey:l})))):null}function C8e(t){var{props:e,previousRectanglesRef:n}=t,{data:i,layout:r,isAnimationActive:a,animationBegin:s,animationDuration:o,animationEasing:l,onAnimationEnd:c,onAnimationStart:u}=e,f=n.current,m=rv(e,"recharts-bar-"),[g,y]=E.useState(!1),_=!g,v=E.useCallback(()=>{typeof c=="function"&&c(),y(!1)},[c]),x=E.useCallback(()=>{typeof u=="function"&&u(),y(!0)},[u]);return E.createElement(M8e,{showLabels:_,rects:i},E.createElement(iv,{animationId:m,begin:s,duration:o,isActive:a,easing:l,onAnimationEnd:v,onAnimationStart:x,key:m},M=>{var w=M===1?i:i?.map((C,T)=>{var P=f&&f[T];if(P)return ha(ha({},C),{},{x:si(P.x,C.x,M),y:si(P.y,C.y,M),width:si(P.width,C.width,M),height:si(P.height,C.height,M)});if(r==="horizontal"){var A=si(0,C.height,M),j=si(C.stackedBarStart,C.y,M);return ha(ha({},C),{},{y:j,height:A})}var N=si(0,C.width,M),k=si(C.stackedBarStart,C.x,M);return ha(ha({},C),{},{width:N,x:k})});return M>0&&(n.current=w??null),w==null?null:E.createElement(Li,null,E.createElement(T8e,{props:e,data:w}))}),E.createElement(WO,{label:e.label}),e.children)}function N8e(t){var e=E.useRef(null);return E.createElement(C8e,{previousRectanglesRef:e,props:t})}var yJ=0,R8e=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Yn(t,e)}};class P8e extends E.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 u=An("recharts-bar",r),f=c;return E.createElement(Li,{className:u,id:c},o&&E.createElement("defs",null,E.createElement(vJ,{clipPathId:f,xAxisId:a,yAxisId:s})),E.createElement(Li,{className:"recharts-bar-rectangles",clipPath:o?"url(#clipPath-".concat(f,")"):void 0},E.createElement(w8e,{data:n,dataKey:i,background:l,allOtherBarProps:this.props}),E.createElement(N8e,this.props)))}}var k8e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:yJ,xAxisId:0,yAxisId:0,zIndex:qi.bar};function D8e(t){var{xAxisId:e,yAxisId:n,hide:i,legendType:r,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u}=t,{needClip:f}=nL(e,n),m=Dm(),g=oa(),y=KO(t.children,yv),_=At(M=>o6e(M,e,n,g,t.id,y));if(m!=="vertical"&&m!=="horizontal")return null;var v,x=_?.[0];return x==null||x.height==null||x.width==null?v=0:v=m==="vertical"?x.height/2:x.width/2,E.createElement(GBe,{xAxisId:e,yAxisId:n,data:_,dataPointFormatter:R8e,errorBarOffset:v},E.createElement(P8e,Mc({},t,{layout:m,needClip:f,data:_,xAxisId:e,yAxisId:n,hide:i,legendType:r,minPointSize:a,activeBar:s,animationBegin:o,animationDuration:l,animationEasing:c,isAnimationActive:u})))}function O8e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:i},pos:r,bandSize:a,xAxis:s,yAxis:o,xAxisTicks:l,yAxisTicks:c,stackedData:u,displayedData:f,offset:m,cells:g,parentViewBox:y,dataStartIndex:_}=t,v=e==="horizontal"?o:s,x=u?v.scale.domain():null,M=JPe({numericAxis:v}),w=v.scale(M);return f.map((C,T)=>{var P,A,j,N,k,F;u?P=XPe(u[T+_],x):(P=Yn(C,n),Array.isArray(P)||(P=[M,P]));var I=jBe(i,yJ)(P[1],T);if(e==="horizontal"){var W,[D,B]=[o.scale(P[0]),o.scale(P[1])];A=tH({axis:s,ticks:l,bandSize:a,offset:r.offset,entry:C,index:T}),j=(W=B??D)!==null&&W!==void 0?W:void 0,N=r.size;var $=D-B;if(k=qs($)?0:$,F={x:A,y:m.top,width:N,height:m.height},Math.abs(I)>0&&Math.abs(k)<Math.abs(I)){var K=Tr(k||I)*(Math.abs(I)-Math.abs(k));j-=K,k+=K}}else{var[X,Y]=[s.scale(P[0]),s.scale(P[1])];if(A=X,j=tH({axis:o,ticks:c,bandSize:a,offset:r.offset,entry:C,index:T}),N=Y-X,k=r.size,F={x:m.left,y:j,width:m.width,height:k},Math.abs(I)>0&&Math.abs(N)<Math.abs(I)){var ee=Tr(N||I)*(Math.abs(I)-Math.abs(N));N+=ee}}if(A==null||j==null||N==null||k==null)return null;var z=ha(ha({},C),{},{stackedBarStart:w,x:A,y:j,width:N,height:k,value:u?P:P[1],payload:C,background:F,tooltipPosition:{x:A+N/2,y:j+k/2},parentViewBox:y},g&&g[T]&&g[T].props);return z}).filter(Boolean)}function L8e(t){var e=Zi(t,k8e),n=oa();return E.createElement(eL,{id:e.id,type:"bar"},i=>E.createElement(E.Fragment,null,E.createElement(dJ,{legendPayload:_8e(e)}),E.createElement(S8e,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),E.createElement(pJ,{type:"bar",id:i,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:uY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),E.createElement(Ga,{zIndex:e.zIndex},E.createElement(D8e,Mc({},e,{id:i})))))}var bJ=E.memo(L8e,bM);bJ.displayName="Bar";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 l_(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){I8e(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 I8e(t,e,n){return(e=j8e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j8e(t){var e=U8e(t,"string");return typeof e=="symbol"?e:e+""}function U8e(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 F8e=(t,e)=>e,z8e=(t,e,n)=>n,B8e=(t,e,n,i)=>i,H8e=(t,e,n,i,r)=>r,bv=He([dM,H8e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),$8e=He([bv],t=>t?.maxBarSize),V8e=(t,e,n,i,r,a)=>a,BV=(t,e,n)=>{var i=n??t;if(!gi(i))return ra(i,e,0)},G8e=He([_n,dM,F8e,z8e,B8e],(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")),W8e=(t,e,n,i)=>{var r=_n(t);return r==="horizontal"?P0(t,"yAxis",n,i):P0(t,"xAxis",e,i)},q8e=(t,e,n)=>{var i=_n(t);return i==="horizontal"?O$(t,"xAxis",e):O$(t,"yAxis",n)},X8e=(t,e,n)=>{var i={},r=t.filter(lM),a=t.filter(c=>c.stackId==null),s=r.reduce((c,u)=>(c[u.stackId]||(c[u.stackId]=[]),c[u.stackId].push(u),c),i),o=Object.entries(s).map(c=>{var[u,f]=c,m=f.map(y=>y.dataKey),g=BV(e,n,f[0].barSize);return{stackId:u,dataKeys:m,barSize:g}}),l=a.map(c=>{var u=[c.dataKey].filter(m=>m!=null),f=BV(e,n,c.barSize);return{stackId:void 0,dataKeys:u,barSize:f}});return[...o,...l]},K8e=He([G8e,gje,q8e],X8e),Y8e=(t,e,n,i,r)=>{var a,s,o=bv(t,e,n,i,r);if(o!=null){var l=_n(t),c=LZ(t),{maxBarSize:u}=o,f=gi(u)?c:u,m,g;return l==="horizontal"?(m=td(t,"xAxis",e,i),g=ed(t,"xAxis",e,i)):(m=td(t,"yAxis",n,i),g=ed(t,"yAxis",n,i)),(a=(s=dm(m,g,!0))!==null&&s!==void 0?s:f)!==null&&a!==void 0?a:0}},_J=(t,e,n,i)=>{var r=_n(t),a,s;return r==="horizontal"?(a=td(t,"xAxis",e,i),s=ed(t,"xAxis",e,i)):(a=td(t,"yAxis",n,i),s=ed(t,"yAxis",n,i)),dm(a,s)};function Z8e(t,e,n,i,r){var a=i.length;if(!(a<1)){var s=ra(t,n,0,!0),o,l=[];if(oi(i[0].barSize)){var c=!1,u=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&&u>0&&(c=!0,u*=.9,f=a*u);var m=(n-f)/2>>0,g={offset:m-s,size:0};o=i.reduce((x,M)=>{var w,C={stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:g.offset+g.size+s,size:c?u:(w=M.barSize)!==null&&w!==void 0?w:0}},T=[...x,C];return g=T[T.length-1].position,T},l)}else{var y=ra(e,n,0,!0);n-2*y-(a-1)*s<=0&&(s=0);var _=(n-2*y-(a-1)*s)/a;_>1&&(_>>=0);var v=oi(r)?Math.min(_,r):_;o=i.reduce((x,M,w)=>[...x,{stackId:M.stackId,dataKeys:M.dataKeys,position:{offset:y+(_+s)*w+(_-v)/2,size:v}}],l)}return o}}var Q8e=(t,e,n,i,r,a,s)=>{var o=gi(s)?e:s,l=Z8e(n,i,r!==a?r:a,t,o);return r!==a&&l!=null&&(l=l.map(c=>l_(l_({},c),{},{position:l_(l_({},c.position),{},{offset:c.position.offset-r/2})}))),l},J8e=He([K8e,LZ,mje,IZ,Y8e,_J,$8e],Q8e),e6e=(t,e,n,i)=>td(t,"xAxis",e,i),t6e=(t,e,n,i)=>td(t,"yAxis",n,i),n6e=(t,e,n,i)=>ed(t,"xAxis",e,i),i6e=(t,e,n,i)=>ed(t,"yAxis",n,i),r6e=He([J8e,bv],(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}}),a6e=(t,e)=>{var n=oM(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)}}}},s6e=He([W8e,bv],a6e),o6e=He([dr,ND,e6e,t6e,n6e,i6e,r6e,_n,rM,_J,s6e,bv,V8e],(t,e,n,i,r,a,s,o,l,c,u,f,m)=>{var{chartData:g,dataStartIndex:y,dataEndIndex:_}=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=g?.slice(y,_+1),x!=null)return O8e({layout:o,barSettings:f,pos:s,parentViewBox:e,bandSize:c,xAxis:n,yAxis:i,xAxisTicks:r,yAxisTicks:a,stackedData:u,displayedData:x,offset:t,cells:m,dataStartIndex:y})}}),SJ=t=>{var{chartData:e}=t,n=ei(),i=oa();return E.useEffect(()=>i?()=>{}:(n(q$(e)),()=>{n(q$(void 0))}),[e,n,i]),null},HV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},wJ=Va({name:"brush",initialState:HV,reducers:{setBrushSettings(t,e){return e.payload==null?HV:e.payload}}}),{setBrushSettings:$Ge}=wJ.actions,l6e=wJ.reducer;function c6e(t,e,n){return(e=u6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u6e(t){var e=d6e(t,"string");return typeof e=="symbol"?e:e+""}function d6e(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 iL{static create(e){return new iL(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}}c6e(iL,"EPS",1e-4);function f6e(t){return(t%180+180)%180}var h6e=function(e){var{width:n,height:i}=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=f6e(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)},p6e={dots:[],areas:[],lines:[]},MJ=Va({name:"referenceElements",initialState:p6e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=bo(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=bo(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=bo(t).lines.findIndex(i=>i===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:VGe,removeDot:GGe,addArea:WGe,removeArea:qGe,addLine:XGe,removeLine:KGe}=MJ.actions,m6e=MJ.reducer,g6e=E.createContext(void 0),x6e=t=>{var{children:e}=t,[n]=E.useState("".concat(v0("recharts"),"-clip")),i=tL();if(i==null)return null;var{x:r,y:a,width:s,height:o}=i;return E.createElement(g6e.Provider,{value:n},E.createElement("defs",null,E.createElement("clipPath",{id:n},E.createElement("rect",{x:r,y:a,height:o,width:s}))),e)};function EJ(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 v6e(t,e,n){var i={width:t.width+e.width,height:t.height+e.height};return h6e(i,n)}function y6e(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 zS(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 b6e(t,e){return EJ(t,e+1)}function _6e(t,e,n,i,r){for(var a=(i||[]).slice(),{start:s,end:o}=e,l=0,c=1,u=s,f=function(){var y=i?.[l];if(y===void 0)return{v:EJ(i,c)};var _=l,v,x=()=>(v===void 0&&(v=n(y,_)),v),M=y.coordinate,w=l===0||zS(t,M,x,u,o);w||(l=0,u=s,c+=1),w&&(u=M+t*(x()/2+r),l+=c)},m;c<=a.length;)if(m=f(),m)return m.v;return[]}function $V(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 ta(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$V(Object(n),!0).forEach(function(i){S6e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$V(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function S6e(t,e,n){return(e=w6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function w6e(t){var e=M6e(t,"string");return typeof e=="symbol"?e:e+""}function M6e(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 E6e(t,e,n,i,r){for(var a=(i||[]).slice(),s=a.length,{start:o}=e,{end:l}=e,c=function(m){var g=a[m],y,_=()=>(y===void 0&&(y=n(g,m)),y);if(m===s-1){var v=t*(g.coordinate+t*_()/2-l);a[m]=g=ta(ta({},g),{},{tickCoord:v>0?g.coordinate-v*t:g.coordinate})}else a[m]=g=ta(ta({},g),{},{tickCoord:g.coordinate});if(g.tickCoord!=null){var x=zS(t,g.tickCoord,_,o,l);x&&(l=g.tickCoord-t*(_()/2+r),a[m]=ta(ta({},g),{},{isShow:!0}))}},u=s-1;u>=0;u--)c(u);return a}function A6e(t,e,n,i,r,a){var s=(i||[]).slice(),o=s.length,{start:l,end:c}=e;if(a){var u=i[o-1],f=n(u,o-1),m=t*(u.coordinate+t*f/2-c);if(s[o-1]=u=ta(ta({},u),{},{tickCoord:m>0?u.coordinate-m*t:u.coordinate}),u.tickCoord!=null){var g=zS(t,u.tickCoord,()=>f,l,c);g&&(c=u.tickCoord-t*(f/2+r),s[o-1]=ta(ta({},u),{},{isShow:!0}))}}for(var y=a?o-1:o,_=function(M){var w=s[M],C,T=()=>(C===void 0&&(C=n(w,M)),C);if(M===0){var P=t*(w.coordinate-t*T()/2-l);s[M]=w=ta(ta({},w),{},{tickCoord:P<0?w.coordinate-P*t:w.coordinate})}else s[M]=w=ta(ta({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var A=zS(t,w.tickCoord,T,l,c);A&&(l=w.tickCoord+t*(T()/2+r),s[M]=ta(ta({},w),{},{isShow:!0}))}},v=0;v<y;v++)_(v);return s}function rL(t,e,n){var{tick:i,ticks:r,viewBox:a,minTickGap:s,orientation:o,interval:l,tickFormatter:c,unit:u,angle:f}=t;if(!r||!r.length||!i)return[];if(Et(l)||Om.isSsr){var m;return(m=b6e(r,Et(l)?l:0))!==null&&m!==void 0?m:[]}var g=[],y=o==="top"||o==="bottom"?"width":"height",_=u&&y==="width"?Fx(u,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(w,C)=>{var T=typeof c=="function"?c(w.value,C):w.value;return y==="width"?v6e(Fx(T,{fontSize:e,letterSpacing:n}),_,f):Fx(T,{fontSize:e,letterSpacing:n})[y]},x=r.length>=2?Tr(r[1].coordinate-r[0].coordinate):1,M=y6e(a,x,y);return l==="equidistantPreserveStart"?_6e(x,M,v,r,s):(l==="preserveStart"||l==="preserveStartEnd"?g=A6e(x,M,v,r,s,l==="preserveStartEnd"):g=E6e(x,M,v,r,s),g.filter(w=>w.isShow))}var T6e=t=>{var{ticks:e,label:n,labelGapWithTick:i=5,tickSize:r=0,tickMargin:a=0}=t,s=0;if(e){Array.from(e).forEach(u=>{if(u){var f=u.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},C6e=["axisLine","width","height","className","hide","ticks","axisType"];function N6e(t,e){if(t==null)return{};var n,i,r=R6e(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 R6e(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 Ff(){return Ff=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},Ff.apply(null,arguments)}function VV(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 $i(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?VV(Object(n),!0).forEach(function(i){P6e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function P6e(t,e,n){return(e=k6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function k6e(t){var e=D6e(t,"string");return typeof e=="symbol"?e:e+""}function D6e(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 dc={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:qi.axis};function O6e(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=$i($i($i({},l),Ba(o)),{},{fill:"none"});if(a==="top"||a==="bottom"){var u=+(a==="top"&&!s||a==="bottom"&&s);c=$i($i({},c),{},{x1:e,y1:n+u*r,x2:e+i,y2:n+u*r})}else{var f=+(a==="left"&&!s||a==="right"&&s);c=$i($i({},c),{},{x1:e+f*i,y1:n,x2:e+f*i,y2:n+r})}return E.createElement("line",Ff({},c,{className:An("recharts-cartesian-axis-line",Lf(o,"className"))}))}function L6e(t,e,n,i,r,a,s,o,l){var c,u,f,m,g,y,_=o?-1:1,v=t.tickSize||s,x=Et(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":c=u=t.coordinate,m=n+ +!o*r,f=m-_*v,y=f-_*l,g=x;break;case"left":f=m=t.coordinate,u=e+ +!o*i,c=u-_*v,g=c-_*l,y=x;break;case"right":f=m=t.coordinate,u=e+ +o*i,c=u+_*v,g=c+_*l,y=x;break;default:c=u=t.coordinate,m=n+ +o*r,f=m+_*v,y=f+_*l,g=x;break}return{line:{x1:c,y1:f,x2:u,y2:m},tick:{x:g,y}}}function I6e(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function j6e(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function U6e(t){var{option:e,tickProps:n,value:i}=t,r,a=An(n.className,"recharts-cartesian-axis-tick-value");if(E.isValidElement(e))r=E.cloneElement(e,$i($i({},n),{},{className:a}));else if(typeof e=="function")r=e($i($i({},n),{},{className:a}));else{var s="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(s=An(s,e?.className)),r=E.createElement(gM,Ff({},n,{className:s}),i)}return r}var F6e=E.forwardRef((t,e)=>{var{ticks:n=[],tick:i,tickLine:r,stroke:a,tickFormatter:s,unit:o,padding:l,tickTextProps:c,orientation:u,mirror:f,x:m,y:g,width:y,height:_,tickSize:v,tickMargin:x,fontSize:M,letterSpacing:w,getTicksConfig:C,events:T,axisType:P}=t,A=rL($i($i({},C),{},{ticks:n}),M,w),j=I6e(u,f),N=j6e(u,f),k=Ba(C),F=Of(i),I={};typeof r=="object"&&(I=r);var W=$i($i({},k),{},{fill:"none"},I),D=A.map(K=>$i({entry:K},L6e(K,m,g,y,_,u,v,f,x))),B=D.map(K=>{var{entry:X,line:Y}=K;return E.createElement(Li,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(X.value,"-").concat(X.coordinate,"-").concat(X.tickCoord)},r&&E.createElement("line",Ff({},W,Y,{className:An("recharts-cartesian-axis-tick-line",Lf(r,"className"))})))}),$=D.map((K,X)=>{var{entry:Y,tick:ee}=K,z=$i($i($i($i({textAnchor:j,verticalAnchor:N},k),{},{stroke:"none",fill:a},F),ee),{},{index:X,payload:Y,visibleTicksCount:A.length,tickFormatter:s,padding:l},c);return E.createElement(Li,Ff({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},Z0(T,Y,X)),i&&E.createElement(U6e,{option:i,tickProps:z,value:"".concat(typeof s=="function"?s(Y.value,X):Y.value).concat(o||"")}))});return E.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(P,"-ticks")},$.length>0&&E.createElement(Ga,{zIndex:qi.label},E.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(P,"-tick-labels"),ref:e},$)),B.length>0&&E.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(P,"-tick-lines")},B))}),z6e=E.forwardRef((t,e)=>{var{axisLine:n,width:i,height:r,className:a,hide:s,ticks:o,axisType:l}=t,c=N6e(t,C6e),[u,f]=E.useState(""),[m,g]=E.useState(""),y=E.useRef(null);E.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return T6e({ticks:y.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var _=E.useCallback(v=>{if(v){var x=v.getElementsByClassName("recharts-cartesian-axis-tick-value");y.current=x;var M=x[0];if(M){var w=window.getComputedStyle(M),C=w.fontSize,T=w.letterSpacing;(C!==u||T!==m)&&(f(C),g(T))}}},[u,m]);return s||i!=null&&i<=0||r!=null&&r<=0?null:E.createElement(Ga,{zIndex:t.zIndex},E.createElement(Li,{className:An("recharts-cartesian-axis",a)},E.createElement(O6e,{x:t.x,y:t.y,width:i,height:r,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ba(t)}),E.createElement(F6e,{ref:_,axisType:l,events:c,fontSize:u,getTicksConfig:t,height:t.height,letterSpacing:m,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}),E.createElement(uze,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},E.createElement(bze,{label:t.label,labelRef:t.labelRef}),t.children)))}),aL=E.forwardRef((t,e)=>{var n=Zi(t,dc);return E.createElement(z6e,Ff({},n,{ref:e}))});aL.displayName="CartesianAxis";var B6e=["x1","y1","x2","y2","key"],H6e=["offset"],$6e=["xAxisId","yAxisId"],V6e=["xAxisId","yAxisId"];function GV(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 na(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GV(Object(n),!0).forEach(function(i){G6e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GV(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function G6e(t,e,n){return(e=W6e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W6e(t){var e=q6e(t,"string");return typeof e=="symbol"?e:e+""}function q6e(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 rf(){return rf=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},rf.apply(null,arguments)}function BS(t,e){if(t==null)return{};var n,i,r=X6e(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 X6e(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 K6e=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 E.createElement("rect",{x:i,y:r,ry:o,width:a,height:s,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function AJ(t){var{option:e,lineItemProps:n}=t,i;if(E.isValidElement(e))i=E.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,u=BS(n,B6e),f=(r=Ba(u))!==null&&r!==void 0?r:{},{offset:m}=f,g=BS(f,H6e);i=E.createElement("line",rf({},g,{x1:a,y1:s,x2:o,y2:l,fill:"none",key:c}))}return i}function Y6e(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=BS(t,$6e),l=r.map((c,u)=>{var f=na(na({},o),{},{x1:e,y1:c,x2:e+n,y2:c,key:"line-".concat(u),index:u});return E.createElement(AJ,{key:"line-".concat(u),option:i,lineItemProps:f})});return E.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function Z6e(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=BS(t,V6e),l=r.map((c,u)=>{var f=na(na({},o),{},{x1:c,y1:e,x2:c,y2:e+n,key:"line-".concat(u),index:u});return E.createElement(AJ,{option:i,lineItemProps:f,key:"line-".concat(u)})});return E.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function Q6e(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,m)=>f-m);r!==c[0]&&c.unshift(0);var u=c.map((f,m)=>{var g=!c[m+1],y=g?r+s-f:c[m+1]-f;if(y<=0)return null;var _=m%e.length;return E.createElement("rect",{key:"react-".concat(m),y:f,x:i,height:y,width:a,stroke:"none",fill:e[_],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function J6e(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,m)=>f-m);r!==c[0]&&c.unshift(0);var u=c.map((f,m)=>{var g=!c[m+1],y=g?r+s-f:c[m+1]-f;if(y<=0)return null;var _=m%n.length;return E.createElement("rect",{key:"react-".concat(m),x:f,y:a,width:y,height:o,stroke:"none",fill:n[_],fillOpacity:i,className:"recharts-cartesian-grid-bg"})});return E.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var eHe=(t,e)=>{var{xAxis:n,width:i,height:r,offset:a}=t;return lY(rL(na(na(na({},dc),n),{},{ticks:cY(n),viewBox:{x:0,y:0,width:i,height:r}})),a.left,a.left+a.width,e)},tHe=(t,e)=>{var{yAxis:n,width:i,height:r,offset:a}=t;return lY(rL(na(na(na({},dc),n),{},{ticks:cY(n),viewBox:{x:0,y:0,width:i,height:r}})),a.top,a.top+a.height,e)},nHe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:qi.grid};function pP(t){var e=PD(),n=kD(),i=vY(),r=na(na({},Zi(t,nHe)),{},{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:u,syncWithTicks:f,horizontalValues:m,verticalValues:g}=r,y=oa(),_=At(N=>L$(N,"xAxis",a,y)),v=At(N=>L$(N,"yAxis",s,y));if(!sl(c)||!sl(u)||!Et(o)||!Et(l))return null;var x=r.verticalCoordinatesGenerator||eHe,M=r.horizontalCoordinatesGenerator||tHe,{horizontalPoints:w,verticalPoints:C}=r;if((!w||!w.length)&&typeof M=="function"){var T=m&&m.length,P=M({yAxis:v?na(na({},v),{},{ticks:T?m:v.ticks}):void 0,width:e??c,height:n??u,offset:i},T?!0:f);fS(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(w=P)}if((!C||!C.length)&&typeof x=="function"){var A=g&&g.length,j=x({xAxis:_?na(na({},_),{},{ticks:A?g:_.ticks}):void 0,width:e??c,height:n??u,offset:i},A?!0:f);fS(Array.isArray(j),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof j,"]")),Array.isArray(j)&&(C=j)}return E.createElement(Ga,{zIndex:r.zIndex},E.createElement("g",{className:"recharts-cartesian-grid"},E.createElement(K6e,{fill:r.fill,fillOpacity:r.fillOpacity,x:r.x,y:r.y,width:r.width,height:r.height,ry:r.ry}),E.createElement(Q6e,rf({},r,{horizontalPoints:w})),E.createElement(J6e,rf({},r,{verticalPoints:C})),E.createElement(Y6e,rf({},r,{offset:i,horizontalPoints:w,xAxis:_,yAxis:v})),E.createElement(Z6e,rf({},r,{offset:i,verticalPoints:C,xAxis:_,yAxis:v}))))}pP.displayName="CartesianGrid";function iHe(t){var e=Of(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 TJ=(t,e,n,i)=>td(t,"xAxis",e,i),CJ=(t,e,n,i)=>ed(t,"xAxis",e,i),NJ=(t,e,n,i)=>td(t,"yAxis",n,i),RJ=(t,e,n,i)=>ed(t,"yAxis",n,i),rHe=He([_n,TJ,NJ,CJ,RJ],(t,e,n,i,r)=>Tc(t,"xAxis")?dm(e,i,!1):dm(n,r,!1)),aHe=(t,e,n,i,r)=>r,PJ=He([dM,aHe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),sHe=(t,e,n,i,r)=>{var a,s=PJ(t,e,n,i,r);if(s!=null){var o=_n(t),l=Tc(o,"xAxis"),c;if(l?c=P0(t,"yAxis",n,i):c=P0(t,"xAxis",e,i),c!=null){var{stackId:u}=s,f=oM(s);if(!(u==null||f==null)){var m=(a=c[u])===null||a===void 0?void 0:a.stackedData;return m?.find(g=>g.key===f)}}}},oHe=He([_n,TJ,NJ,CJ,RJ,sHe,rM,rHe,PJ,xje],(t,e,n,i,r,a,s,o,l,c)=>{var{chartData:u,dataStartIndex:f,dataEndIndex:m}=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:g}=l,y;if(g&&g.length>0?y=g:y=u?.slice(f,m+1),y!=null)return AHe({layout:t,xAxis:e,yAxis:n,xAxisTicks:i,yAxisTicks:r,dataStartIndex:f,areaSettings:l,stackedData:a,displayedData:y,chartBaseValue:c,bandSize:o})}}),lHe=["id"],cHe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function xf(){return xf=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},xf.apply(null,arguments)}function kJ(t,e){if(t==null)return{};var n,i,r=uHe(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 uHe(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 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 wp(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){dHe(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 dHe(t,e,n){return(e=fHe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fHe(t){var e=hHe(t,"string");return typeof e=="symbol"?e:e+""}function hHe(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 HS(t,e){return t&&t!=="none"?t:e}var pHe=t=>{var{dataKey:e,name:n,stroke:i,fill:r,legendType:a,hide:s}=t;return[{inactive:s,dataKey:e,type:a,color:HS(i,r),value:km(n,e),payload:t}]},mHe=E.memo(t=>{var{dataKey:e,data:n,stroke:i,strokeWidth:r,fill:a,name:s,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:n,positions:void 0,settings:{stroke:i,strokeWidth:r,fill:a,dataKey:e,nameKey:void 0,name:km(s,e),hide:o,type:c,color:HS(i,a),unit:l}};return E.createElement(JO,{tooltipEntrySettings:u})});function gHe(t){var{clipPathId:e,points:n,props:i}=t,{needClip:r,dot:a,dataKey:s}=i,o=Ba(i);return E.createElement(lBe,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:s,baseProps:o,needClip:r,clipPathId:e})}function xHe(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 wp(wp({},l),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:l,fill:void 0})});return E.createElement(tJ,{value:e?r:void 0},n)}function qV(t){var{points:e,baseLine:n,needClip:i,clipPathId:r,props:a}=t,{layout:s,type:o,stroke:l,connectNulls:c,isRange:u}=a,{id:f}=a,m=kJ(a,lHe),g=Ba(m),y=ba(m);return E.createElement(E.Fragment,null,e?.length>1&&E.createElement(Li,{clipPath:i?"url(#clipPath-".concat(r,")"):void 0},E.createElement(Lp,xf({},y,{id:f,points:e,connectNulls:c,type:o,baseLine:n,layout:s,stroke:"none",className:"recharts-area-area"})),l!=="none"&&E.createElement(Lp,xf({},g,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:e})),l!=="none"&&u&&E.createElement(Lp,xf({},g,{className:"recharts-area-curve",layout:s,type:o,connectNulls:c,fill:"none",points:n}))),E.createElement(gHe,{points:e,props:m,clipPathId:r}))}function vHe(t){var{alpha:e,baseLine:n,points:i,strokeWidth:r}=t,a=i[0].y,s=i[i.length-1].y;if(!oi(a)||!oi(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)?E.createElement("rect",{x:0,y:a<s?a:a-o,width:l+(r?parseInt("".concat(r),10):1),height:Math.floor(o)}):null}function yHe(t){var{alpha:e,baseLine:n,points:i,strokeWidth:r}=t,a=i[0].x,s=i[i.length-1].x;if(!oi(a)||!oi(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)?E.createElement("rect",{x:a<s?a:a-o,y:0,width:o,height:Math.floor(l+(r?parseInt("".concat(r),10):1))}):null}function bHe(t){var{alpha:e,layout:n,points:i,baseLine:r,strokeWidth:a}=t;return n==="vertical"?E.createElement(vHe,{alpha:e,points:i,baseLine:r,strokeWidth:a}):E.createElement(yHe,{alpha:e,points:i,baseLine:r,strokeWidth:a})}function _He(t){var{needClip:e,clipPathId:n,props:i,previousPointsRef:r,previousBaselineRef:a}=t,{points:s,baseLine:o,isAnimationActive:l,animationBegin:c,animationDuration:u,animationEasing:f,onAnimationStart:m,onAnimationEnd:g}=i,y=E.useMemo(()=>({points:s,baseLine:o}),[s,o]),_=rv(y,"recharts-area-"),v=Lke(),[x,M]=E.useState(!1),w=!x,C=E.useCallback(()=>{typeof g=="function"&&g(),M(!1)},[g]),T=E.useCallback(()=>{typeof m=="function"&&m(),M(!0)},[m]);if(v==null)return null;var P=r.current,A=a.current;return E.createElement(xHe,{showLabels:w,points:s},i.children,E.createElement(iv,{animationId:_,begin:c,duration:u,isActive:l,easing:f,onAnimationEnd:C,onAnimationStart:T,key:_},j=>{if(P){var N=P.length/s.length,k=j===1?s:s.map((I,W)=>{var D=Math.floor(W*N);if(P[D]){var B=P[D];return wp(wp({},I),{},{x:si(B.x,I.x,j),y:si(B.y,I.y,j)})}return I}),F;return Et(o)?F=si(A,o,j):gi(o)||qs(o)?F=si(A,0,j):F=o.map((I,W)=>{var D=Math.floor(W*N);if(Array.isArray(A)&&A[D]){var B=A[D];return wp(wp({},I),{},{x:si(B.x,I.x,j),y:si(B.y,I.y,j)})}return I}),j>0&&(r.current=k,a.current=F),E.createElement(qV,{points:k,baseLine:F,needClip:e,clipPathId:n,props:i})}return j>0&&(r.current=s,a.current=o),E.createElement(Li,null,l&&E.createElement("defs",null,E.createElement("clipPath",{id:"animationClipPath-".concat(n)},E.createElement(bHe,{alpha:j,points:s,baseLine:o,layout:v,strokeWidth:i.strokeWidth}))),E.createElement(Li,{clipPath:"url(#animationClipPath-".concat(n,")")},E.createElement(qV,{points:s,baseLine:o,needClip:e,clipPathId:n,props:i})))}),E.createElement(WO,{label:i.label}))}function SHe(t){var{needClip:e,clipPathId:n,props:i}=t,r=E.useRef(null),a=E.useRef();return E.createElement(_He,{needClip:e,clipPathId:n,props:i,previousPointsRef:r,previousBaselineRef:a})}class wHe extends E.PureComponent{render(){var{hide:e,dot:n,points:i,className:r,top:a,left:s,needClip:o,xAxisId:l,yAxisId:c,width:u,height:f,id:m,baseLine:g,zIndex:y}=this.props;if(e)return null;var _=An("recharts-area",r),v=m,{r:x,strokeWidth:M}=iHe(n),w=cJ(n),C=x*2+M,T=o?"url(#clipPath-".concat(w?"":"dots-").concat(v,")"):void 0;return E.createElement(Ga,{zIndex:y},E.createElement(Li,{className:_},o&&E.createElement("defs",null,E.createElement(vJ,{clipPathId:v,xAxisId:l,yAxisId:c}),!w&&E.createElement("clipPath",{id:"clipPath-dots-".concat(v)},E.createElement("rect",{x:s-C/2,y:a-C/2,width:u+C,height:f+C}))),E.createElement(SHe,{needClip:o,clipPathId:v,props:this.props})),E.createElement(DV,{points:i,mainColor:HS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}),this.props.isRange&&Array.isArray(g)&&E.createElement(DV,{points:g,mainColor:HS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:T}))}}var DJ={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:qi.area};function MHe(t){var e,n=Zi(t,DJ),{activeDot:i,animationBegin:r,animationDuration:a,animationEasing:s,connectNulls:o,dot:l,fill:c,fillOpacity:u,hide:f,isAnimationActive:m,legendType:g,stroke:y,xAxisId:_,yAxisId:v}=n,x=kJ(n,cHe),M=Dm(),w=IQ(),{needClip:C}=nL(_,v),T=oa(),{points:P,isRange:A,baseLine:j}=(e=At(D=>oHe(D,_,v,T,t.id)))!==null&&e!==void 0?e:{},N=tL();if(M!=="horizontal"&&M!=="vertical"||N==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:k,width:F,x:I,y:W}=N;return!P||!P.length?null:E.createElement(wHe,xf({},x,{activeDot:i,animationBegin:r,animationDuration:a,animationEasing:s,baseLine:j,connectNulls:o,dot:l,fill:c,fillOpacity:u,height:k,hide:f,layout:M,isAnimationActive:m==="auto"?!Om.isSsr:m,isRange:A,legendType:g,needClip:C,points:P,stroke:y,width:F,left:I,top:W,xAxisId:_,yAxisId:v}))}var EHe=(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 AHe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:i},stackedData:r,layout:a,chartBaseValue:s,xAxis:o,yAxis:l,displayedData:c,dataStartIndex:u,xAxisTicks:f,yAxisTicks:m,bandSize:g}=t,y=r&&r.length,_=EHe(a,s,n,o,l),v=a==="horizontal",x=!1,M=c.map((C,T)=>{var P;y?P=r[u+T]:(P=Yn(C,i),Array.isArray(P)?x=!0:P=[_,P]);var A=P[1]==null||y&&!e&&Yn(C,i)==null;return v?{x:eH({axis:o,ticks:f,bandSize:g,entry:C,index:T}),y:A?null:l.scale(P[1]),value:P,payload:C}:{x:A?null:o.scale(P[1]),y:eH({axis:l,ticks:m,bandSize:g,entry:C,index:T}),value:P,payload:C}}),w;return y||x?w=M.map(C=>{var T=Array.isArray(C.value)?C.value[0]:null;return v?{x:C.x,y:T!=null&&C.y!=null?l.scale(T):null,payload:C.payload}:{x:T!=null?o.scale(T):null,y:C.y,payload:C.payload}}):w=v?l.scale(_):o.scale(_),{points:M,baseLine:w,isRange:x}}function THe(t){var e=Zi(t,DJ),n=oa();return E.createElement(eL,{id:e.id,type:"area"},i=>E.createElement(E.Fragment,null,E.createElement(dJ,{legendPayload:pHe(e)}),E.createElement(mHe,{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}),E.createElement(pJ,{type:"area",id:i,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:uY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),E.createElement(MHe,xf({},e,{id:i}))))}var OJ=E.memo(THe,bM);OJ.displayName="Area";var CHe=["domain","range"],NHe=["domain","range"];function XV(t,e){if(t==null)return{};var n,i,r=RHe(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 RHe(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 KV(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 LJ(t,e){if(t===e)return!0;var{domain:n,range:i}=t,r=XV(t,CHe),{domain:a,range:s}=e,o=XV(e,NHe);return!KV(n,a)||!KV(i,s)?!1:bM(r,o)}var PHe=["dangerouslySetInnerHTML","ticks"],kHe=["id"];function mP(){return mP=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},mP.apply(null,arguments)}function YV(t,e){if(t==null)return{};var n,i,r=DHe(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 DHe(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 OHe(t){var e=ei(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(hBe(t)):n.current!==t&&e(pBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(mBe(n.current)),n.current=null)},[e]),null}var LHe=t=>{var{xAxisId:e,className:n}=t,i=At(ND),r=oa(),a="xAxis",s=At(v=>Bm(v,a,e,r)),o=At(v=>pQ(v,a,e,r)),l=At(v=>uQ(v,e)),c=At(v=>p4e(v,e)),u=At(v=>GZ(v,e));if(l==null||c==null||u==null)return null;var{dangerouslySetInnerHTML:f,ticks:m}=t,g=YV(t,PHe),{id:y}=u,_=YV(u,kHe);return E.createElement(aL,mP({},g,_,{scale:s,x:c.x,y:c.y,width:l.width,height:l.height,className:An("recharts-".concat(a," ").concat(a),n),viewBox:i,ticks:o,axisType:a}))},IHe={allowDataOverflow:Sr.allowDataOverflow,allowDecimals:Sr.allowDecimals,allowDuplicatedCategory:Sr.allowDuplicatedCategory,angle:Sr.angle,axisLine:dc.axisLine,height:Sr.height,hide:!1,includeHidden:Sr.includeHidden,interval:Sr.interval,minTickGap:Sr.minTickGap,mirror:Sr.mirror,orientation:Sr.orientation,padding:Sr.padding,reversed:Sr.reversed,scale:Sr.scale,tick:Sr.tick,tickCount:Sr.tickCount,tickLine:dc.tickLine,tickSize:dc.tickSize,type:Sr.type,xAxisId:0},jHe=t=>{var e=Zi(t,IHe);return E.createElement(E.Fragment,null,E.createElement(OHe,{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}),E.createElement(LHe,e))},gP=E.memo(jHe,LJ);gP.displayName="XAxis";var UHe=["dangerouslySetInnerHTML","ticks"],FHe=["id"];function xP(){return xP=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},xP.apply(null,arguments)}function ZV(t,e){if(t==null)return{};var n,i,r=zHe(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 zHe(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 BHe(t){var e=ei(),n=E.useRef(null);return E.useLayoutEffect(()=>{n.current===null?e(gBe(t)):n.current!==t&&e(xBe({prev:n.current,next:t})),n.current=t},[t,e]),E.useLayoutEffect(()=>()=>{n.current&&(e(vBe(n.current)),n.current=null)},[e]),null}var HHe=t=>{var{yAxisId:e,className:n,width:i,label:r}=t,a=E.useRef(null),s=E.useRef(null),o=At(ND),l=oa(),c=ei(),u="yAxis",f=At(T=>Bm(T,u,e,l)),m=At(T=>dQ(T,e)),g=At(T=>g4e(T,e)),y=At(T=>pQ(T,u,e,l)),_=At(T=>WZ(T,e));if(E.useLayoutEffect(()=>{if(!(i!=="auto"||!m||GO(r)||E.isValidElement(r)||_==null)){var T=a.current;if(T){var P=T.getCalculatedWidth();Math.round(m.width)!==Math.round(P)&&c(yBe({id:e,width:P}))}}},[y,m,c,r,e,i,_]),m==null||g==null||_==null)return null;var{dangerouslySetInnerHTML:v,ticks:x}=t,M=ZV(t,UHe),{id:w}=_,C=ZV(_,FHe);return E.createElement(aL,xP({},M,C,{ref:a,labelRef:s,scale:f,x:g.x,y:g.y,tickTextProps:i==="auto"?{width:void 0}:{width:i},width:m.width,height:m.height,className:An("recharts-".concat(u," ").concat(u),n),viewBox:o,ticks:y,axisType:u}))},$He={allowDataOverflow:wr.allowDataOverflow,allowDecimals:wr.allowDecimals,allowDuplicatedCategory:wr.allowDuplicatedCategory,angle:wr.angle,axisLine:dc.axisLine,hide:!1,includeHidden:wr.includeHidden,interval:wr.interval,minTickGap:wr.minTickGap,mirror:wr.mirror,orientation:wr.orientation,padding:wr.padding,reversed:wr.reversed,scale:wr.scale,tick:wr.tick,tickCount:wr.tickCount,tickLine:dc.tickLine,tickSize:dc.tickSize,type:wr.type,width:wr.width,yAxisId:0},VHe=t=>{var e=Zi(t,$He);return E.createElement(E.Fragment,null,E.createElement(BHe,{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}),E.createElement(HHe,e))},vP=E.memo(VHe,LJ);vP.displayName="YAxis";var GHe=(t,e)=>e,sL=He([GHe,_n,$Z,hr,RQ,Dc,PUe,dr],UUe),oL=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)}},IJ=Xs("mouseClick"),jJ=ev();jJ.startListening({actionCreator:IJ,effect:(t,e)=>{var n=t.payload,i=sL(e.getState(),oL(n));i?.activeIndex!=null&&e.dispatch(R4e({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}});var yP=Xs("mouseMove"),UJ=ev(),c_=null;UJ.startListening({actionCreator:yP,effect:(t,e)=>{var n=t.payload;c_!==null&&cancelAnimationFrame(c_);var i=oL(n);c_=requestAnimationFrame(()=>{var r=e.getState(),a=DO(r,r.tooltip.settings.shared);if(a==="axis"){var s=sL(r,i);s?.activeIndex!=null?e.dispatch(SQ({activeIndex:s.activeIndex,activeDataKey:void 0,activeCoordinate:s.activeCoordinate})):e.dispatch(_Q())}c_=null})}});var QV={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},FJ=Va({name:"rootProps",initialState:QV,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:QV.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}}}),WHe=FJ.reducer,{updateOptions:qHe}=FJ.actions,zJ=Va({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:XHe}=zJ.actions,KHe=zJ.reducer,BJ=Xs("keyDown"),HJ=Xs("focus"),lL=ev();lL.startListening({actionCreator:BJ,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=OO(r,$m(n),hv(n),xv(n)),o=s==null?-1:Number(s);if(!(!Number.isFinite(o)||o<0)){var l=Dc(n);if(a==="Enter"){var c=DS(n,"axis","hover",String(r.index));e.dispatch(oP({active:!r.active,activeIndex:r.index,activeDataKey:r.dataKey,activeCoordinate:c}));return}var u=b4e(n),f=u==="left-to-right"?1:-1,m=a==="ArrowRight"?1:-1,g=o+m*f;if(!(l==null||g>=l.length||g<0)){var y=DS(n,"axis","hover",String(g));e.dispatch(oP({active:!0,activeIndex:g.toString(),activeDataKey:void 0,activeCoordinate:y}))}}}}}});lL.startListening({actionCreator:HJ,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=DS(n,"axis","hover",String(a));e.dispatch(oP({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:s}))}}}});var Ns=Xs("externalEvent"),$J=ev(),pN=new Map;$J.startListening({actionCreator:Ns,effect:(t,e)=>{var{handler:n,reactEvent:i}=t.payload;if(n!=null){i.persist();var r=i.type,a=pN.get(r);a!==void 0&&cancelAnimationFrame(a);var s=requestAnimationFrame(()=>{try{var o=e.getState(),l={activeCoordinate:gUe(o),activeDataKey:FO(o),activeIndex:nd(o),activeLabel:DQ(o),activeTooltipIndex:nd(o),isTooltipActive:xUe(o)};n(l,i)}finally{pN.delete(r)}});pN.set(r,s)}}});var YHe=He([Hm],t=>t.tooltipItemPayloads),ZHe=He([YHe,mv,(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}}}),VJ=Xs("touchMove"),GJ=ev();GJ.startListening({actionCreator:VJ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var i=e.getState(),r=DO(i,i.tooltip.settings.shared);if(r==="axis"){var a=sL(i,oL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(SQ({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(fY),u=(s=l.getAttribute(hY))!==null&&s!==void 0?s:void 0,f=ZHe(e.getState(),c,u);e.dispatch(bQ({activeDataKey:u,activeIndex:c,activeCoordinate:f}))}}}});var QHe=DK({brush:l6e,cartesianAxis:bBe,chartData:mFe,errorBars:FBe,graphicalItems:A5e,layout:HPe,legend:Yke,options:uFe,polarAxis:Bze,polarOptions:KHe,referenceElements:m6e,rootProps:WHe,tooltip:P4e,zIndex:QUe}),JHe=function(e){return hPe({reducer:QHe,preloadedState:e,middleware:n=>{var i;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((i="es6")!==null&&i!==void 0?i:"")}).concat([jJ.middleware,UJ.middleware,lL.middleware,$J.middleware,GJ.middleware])},enhancers:n=>{var i=n;return typeof n=="function"&&(i=n()),i.concat(XK({type:"raf"}))},devTools:Om.devToolsEnabled})};function WJ(t){var{preloadedState:e,children:n,reduxStoreName:i}=t,r=oa(),a=E.useRef(null);if(r)return n;a.current==null&&(a.current=JHe(e));var s=bD;return E.createElement(u8e,{context:s,store:a.current},n)}function e$e(t){var{layout:e,margin:n}=t,i=ei(),r=oa();return E.useEffect(()=>{r||(i(FPe(e)),i(UPe(n)))},[i,r,e,n]),null}var qJ=E.memo(e$e,bM);function XJ(t){var e=ei();return E.useEffect(()=>{e(qHe(t))},[e,t]),null}function JV(t){var{zIndex:e,isPanorama:n}=t,i=n?"recharts-zindex-panorama-":"recharts-zindex-",r=fJ("".concat(i).concat(e)),a=ei();return E.useLayoutEffect(()=>(a(YUe({zIndex:e,elementId:r,isPanorama:n})),()=>{a(ZUe({zIndex:e,isPanorama:n}))}),[a,e,r,n]),E.createElement("g",{tabIndex:-1,id:r})}function eG(t){var{children:e,isPanorama:n}=t,i=At(zUe);if(!i||i.length===0)return e;var r=i.filter(s=>s<0),a=i.filter(s=>s>0);return E.createElement(E.Fragment,null,r.map(s=>E.createElement(JV,{key:s,zIndex:s,isPanorama:n})),e,a.map(s=>E.createElement(JV,{key:s,zIndex:s,isPanorama:n})))}var t$e=["children"];function n$e(t,e){if(t==null)return{};var n,i,r=i$e(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 i$e(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 $S(){return $S=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},$S.apply(null,arguments)}var r$e={width:"100%",height:"100%",display:"block"},a$e=E.forwardRef((t,e)=>{var n=PD(),i=kD(),r=RY();if(!sl(n)||!sl(i))return null;var{children:a,otherAttributes:s,title:o,desc:l}=t,c,u;return s!=null&&(typeof s.tabIndex=="number"?c=s.tabIndex:c=r?0:void 0,typeof s.role=="string"?u=s.role:u=r?"application":void 0),E.createElement(uD,$S({},s,{title:o,desc:l,role:u,tabIndex:c,width:n,height:i,style:r$e,ref:e}),a)}),s$e=t=>{var{children:e}=t,n=At(Ww);if(!n)return null;var{width:i,height:r,y:a,x:s}=n;return E.createElement(uD,{width:i,height:r,x:s,y:a},e)},tG=E.forwardRef((t,e)=>{var{children:n}=t,i=n$e(t,t$e),r=oa();return r?E.createElement(s$e,null,E.createElement(eG,{isPanorama:!0},n)):E.createElement(a$e,$S({ref:e},i),E.createElement(eG,{isPanorama:!1},n))});function o$e(){var t=ei(),[e,n]=E.useState(null),i=At(ake);return E.useEffect(()=>{if(e!=null){var r=e.getBoundingClientRect(),a=r.width/e.offsetWidth;oi(a)&&a!==i&&t(BPe(a))}},[e,t,i]),n}function nG(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 l$e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nG(Object(n),!0).forEach(function(i){c$e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nG(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function c$e(t,e,n){return(e=u$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u$e(t){var e=d$e(t,"string");return typeof e=="symbol"?e:e+""}function d$e(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 zf(){return zf=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},zf.apply(null,arguments)}var f$e=()=>(MFe(),null);function VS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var h$e=E.forwardRef((t,e)=>{var n,i,r=E.useRef(null),[a,s]=E.useState({containerWidth:VS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:VS((i=t.style)===null||i===void 0?void 0:i.height)}),o=E.useCallback((c,u)=>{s(f=>{var m=Math.round(c),g=Math.round(u);return f.containerWidth===m&&f.containerHeight===g?f:{containerWidth:m,containerHeight:g}})},[]),l=E.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null&&typeof ResizeObserver<"u"){var{width:u,height:f}=c.getBoundingClientRect();o(u,f);var m=y=>{var{width:_,height:v}=y[0].contentRect;o(_,v)},g=new ResizeObserver(m);g.observe(c),r.current=g}},[e,o]);return E.useEffect(()=>()=>{var c=r.current;c?.disconnect()},[o]),E.createElement(E.Fragment,null,E.createElement(Xw,{width:a.containerWidth,height:a.containerHeight}),E.createElement("div",zf({ref:l},t)))}),p$e=E.forwardRef((t,e)=>{var{width:n,height:i}=t,[r,a]=E.useState({containerWidth:VS(n),containerHeight:VS(i)}),s=E.useCallback((l,c)=>{a(u=>{var f=Math.round(l),m=Math.round(c);return u.containerWidth===f&&u.containerHeight===m?u:{containerWidth:f,containerHeight:m}})},[]),o=E.useCallback(l=>{if(typeof e=="function"&&e(l),l!=null){var{width:c,height:u}=l.getBoundingClientRect();s(c,u)}},[e,s]);return E.createElement(E.Fragment,null,E.createElement(Xw,{width:r.containerWidth,height:r.containerHeight}),E.createElement("div",zf({ref:o},t)))}),m$e=E.forwardRef((t,e)=>{var{width:n,height:i}=t;return E.createElement(E.Fragment,null,E.createElement(Xw,{width:n,height:i}),E.createElement("div",zf({ref:e},t)))}),g$e=E.forwardRef((t,e)=>{var{width:n,height:i}=t;return vc(n)||vc(i)?E.createElement(p$e,zf({},t,{ref:e})):E.createElement(m$e,zf({},t,{ref:e}))});function x$e(t){return t===!0?h$e:g$e}var v$e=E.forwardRef((t,e)=>{var{children:n,className:i,height:r,onClick:a,onContextMenu:s,onDoubleClick:o,onMouseDown:l,onMouseEnter:c,onMouseLeave:u,onMouseMove:f,onMouseUp:m,onTouchEnd:g,onTouchMove:y,onTouchStart:_,style:v,width:x,responsive:M,dispatchTouchEvents:w=!0}=t,C=E.useRef(null),T=ei(),[P,A]=E.useState(null),[j,N]=E.useState(null),k=o$e(),F=RD(),I=F?.width>0?F.width:x,W=F?.height>0?F.height:r,D=E.useCallback(he=>{k(he),typeof e=="function"&&e(he),A(he),N(he),he!=null&&(C.current=he)},[k,e,A,N]),B=E.useCallback(he=>{T(IJ(he)),T(Ns({handler:a,reactEvent:he}))},[T,a]),$=E.useCallback(he=>{T(yP(he)),T(Ns({handler:c,reactEvent:he}))},[T,c]),K=E.useCallback(he=>{T(_Q()),T(Ns({handler:u,reactEvent:he}))},[T,u]),X=E.useCallback(he=>{T(yP(he)),T(Ns({handler:f,reactEvent:he}))},[T,f]),Y=E.useCallback(()=>{T(HJ())},[T]),ee=E.useCallback(he=>{T(BJ(he.key))},[T]),z=E.useCallback(he=>{T(Ns({handler:s,reactEvent:he}))},[T,s]),V=E.useCallback(he=>{T(Ns({handler:o,reactEvent:he}))},[T,o]),re=E.useCallback(he=>{T(Ns({handler:l,reactEvent:he}))},[T,l]),le=E.useCallback(he=>{T(Ns({handler:m,reactEvent:he}))},[T,m]),ge=E.useCallback(he=>{T(Ns({handler:_,reactEvent:he}))},[T,_]),ie=E.useCallback(he=>{w&&T(VJ(he)),T(Ns({handler:y,reactEvent:he}))},[T,w,y]),xe=E.useCallback(he=>{T(Ns({handler:g,reactEvent:he}))},[T,g]),ke=x$e(M);return E.createElement(BQ.Provider,{value:P},E.createElement(KX.Provider,{value:j},E.createElement(ke,{width:I??v?.width,height:W??v?.height,className:An("recharts-wrapper",i),style:l$e({position:"relative",cursor:"default",width:I,height:W},v),onClick:B,onContextMenu:z,onDoubleClick:V,onFocus:Y,onKeyDown:ee,onMouseDown:re,onMouseEnter:$,onMouseLeave:K,onMouseMove:X,onMouseUp:le,onTouchEnd:xe,onTouchMove:ie,onTouchStart:ge,ref:D},E.createElement(f$e,null),n)))}),y$e=["width","height","responsive","children","className","style","compact","title","desc"];function b$e(t,e){if(t==null)return{};var n,i,r=_$e(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 _$e(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 KJ=E.forwardRef((t,e)=>{var{width:n,height:i,responsive:r,children:a,className:s,style:o,compact:l,title:c,desc:u}=t,f=b$e(t,y$e),m=Ba(f);return l?E.createElement(E.Fragment,null,E.createElement(Xw,{width:n,height:i}),E.createElement(tG,{otherAttributes:m,title:c,desc:u},a)):E.createElement(v$e,{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},E.createElement(tG,{otherAttributes:m,title:c,desc:u,ref:e},E.createElement(x6e,null,a)))});function bP(){return bP=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},bP.apply(null,arguments)}var S$e={top:5,right:5,bottom:5,left:5},w$e={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:S$e,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},YJ=E.forwardRef(function(e,n){var i,r=Zi(e.categoricalChartProps,w$e),{chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,categoricalChartProps:c}=e,u={chartName:a,defaultTooltipEventType:s,validateTooltipEventTypes:o,tooltipPayloadSearcher:l,eventEmitter:void 0};return E.createElement(WJ,{preloadedState:{options:u},reduxStoreName:(i=c.id)!==null&&i!==void 0?i:a},E.createElement(SJ,{chartData:c.data}),E.createElement(qJ,{layout:r.layout,margin:r.margin}),E.createElement(XJ,{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}),E.createElement(KJ,bP({},r,{ref:n})))}),M$e=["axis","item"],E$e=E.forwardRef((t,e)=>E.createElement(YJ,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:M$e,tooltipPayloadSearcher:VO,categoricalChartProps:t,ref:e}));function A$e(t){var e=ei();return E.useEffect(()=>{e(XHe(t))},[e,t]),null}var T$e=["layout"];function _P(){return _P=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},_P.apply(null,arguments)}function C$e(t,e){if(t==null)return{};var n,i,r=N$e(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 N$e(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 R$e={top:5,right:5,bottom:5,left:5},ZJ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:R$e,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},P$e=E.forwardRef(function(e,n){var i,r=Zi(e.categoricalChartProps,ZJ),{layout:a}=r,s=C$e(r,T$e),{chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u}=e,f={chartName:o,defaultTooltipEventType:l,validateTooltipEventTypes:c,tooltipPayloadSearcher:u,eventEmitter:void 0};return E.createElement(WJ,{preloadedState:{options:f},reduxStoreName:(i=r.id)!==null&&i!==void 0?i:o},E.createElement(SJ,{chartData:r.data}),E.createElement(qJ,{layout:a,margin:r.margin}),E.createElement(XJ,{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}),E.createElement(A$e,{cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius}),E.createElement(KJ,_P({},s,{ref:n})))});function iG(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 rG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?iG(Object(n),!0).forEach(function(i){k$e(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iG(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function k$e(t,e,n){return(e=D$e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D$e(t){var e=O$e(t,"string");return typeof e=="symbol"?e:e+""}function O$e(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 L$e=["item"],I$e=rG(rG({},ZJ),{},{layout:"centric",startAngle:0,endAngle:360}),j$e=E.forwardRef((t,e)=>{var n=Zi(t,I$e);return E.createElement(P$e,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:L$e,tooltipPayloadSearcher:VO,categoricalChartProps:n,ref:e})}),U$e=["axis"],F$e=E.forwardRef((t,e)=>E.createElement(YJ,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:U$e,tooltipPayloadSearcher:VO,categoricalChartProps:t,ref:e}));const u_=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function z$e(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 B$e({archives:t,currency:e="$"}){const[n,i]=E.useState("30d"),r=E.useMemo(()=>{const m=z$e(n);return t.filter(g=>new Date(g.completed_at||g.created_at)>=m)},[t,n]),a=E.useMemo(()=>{const m=new Map;return r.forEach(g=>{const _=new Date(g.completed_at||g.created_at).toISOString().split("T")[0],v=m.get(_)||{date:_,filament:0,cost:0,prints:0};v.filament+=g.filament_used_grams||0,v.cost+=g.cost||0,v.prints+=1,m.set(_,v)}),Array.from(m.values()).sort((g,y)=>g.date.localeCompare(y.date)).map(g=>({...g,dateLabel:new Date(g.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[r]),s=E.useMemo(()=>{if(n==="7d"||n==="30d")return a;const m=new Map;return r.forEach(g=>{const y=new Date(g.completed_at||g.created_at),_=new Date(y);_.setDate(y.getDate()-y.getDay());const v=_.toISOString().split("T")[0],x=m.get(v)||{week:v,filament:0,cost:0,prints:0};x.filament+=g.filament_used_grams||0,x.cost+=g.cost||0,x.prints+=1,m.set(v,x)}),Array.from(m.values()).sort((g,y)=>g.week.localeCompare(y.week)).map(g=>({date:g.week,dateLabel:`Week of ${new Date(g.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...g}))},[r,a,n]),o=E.useMemo(()=>{const m=new Map;return r.forEach(g=>{const _=(g.filament_type||"Unknown").split(", ");_.forEach(v=>{const x=(g.filament_used_grams||0)/_.length;m.set(v,(m.get(v)||0)+x)})}),Array.from(m.entries()).map(([g,y])=>({name:g,value:Math.round(y)})).sort((g,y)=>y.value-g.value)},[r]),l=E.useMemo(()=>{const m=new Date,g=[];for(let y=5;y>=0;y--){const _=new Date(m.getFullYear(),m.getMonth()-y,1),v=new Date(m.getFullYear(),m.getMonth()-y+1,0),x=_.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),M=t.filter(w=>{const C=new Date(w.completed_at||w.created_at);return C>=_&&C<=v});g.push({month:x,filament:Math.round(M.reduce((w,C)=>w+(C.filament_used_grams||0),0)),cost:M.reduce((w,C)=>w+(C.cost||0),0),prints:M.length})}return g},[t]),c=n==="7d"||n==="30d"?a:s,u=r.reduce((m,g)=>m+(g.filament_used_grams||0),0),f=r.reduce((m,g)=>m+(g.cost||0),0);return h.jsxs("div",{className:"space-y-6",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),h.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>h.jsx("button",{onClick:()=>i(m),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===m?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:m==="all"?"All":m.replace("d","D")},m))})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),h.jsxs("p",{className:"text-2xl font-bold text-white",children:[(u/1e3).toFixed(2),"kg"]}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[u.toFixed(0),"g total"]})]}),h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),h.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[r.length," prints"]})]}),h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),h.jsxs("p",{className:"text-2xl font-bold text-white",children:[r.length>0?(u/r.length).toFixed(0):0,"g"]}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,r.length>0?(f/r.length).toFixed(2):"0.00"," avg"]})]})]}),c.length>0?h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),h.jsx(LC,{width:"100%",height:250,children:h.jsxs(F$e,{data:c,children:[h.jsx("defs",{children:h.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[h.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),h.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),h.jsx(pP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),h.jsx(gP,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),h.jsx(vP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),h.jsx(JC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${m.toFixed(0)}g`,"Filament"]}),h.jsx(OJ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):h.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),h.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),o.length>0?h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx(LC,{width:160,height:160,children:h.jsxs(j$e,{children:[h.jsx(mJ,{data:o,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:o.map((m,g)=>h.jsx(yv,{fill:u_[g%u_.length]},`cell-${g}`))}),h.jsx(JC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m}g`,"Usage"]})]})}),h.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:o.map((m,g)=>{const y=o.reduce((v,x)=>v+x.value,0),_=y>0?(m.value/y*100).toFixed(0):0;return h.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[h.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:u_[g%u_.length]}}),h.jsx("span",{className:"text-white truncate flex-1",children:m.name}),h.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[_,"%"]})]},m.name)})})]}):h.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),h.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[h.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),h.jsx(LC,{width:"100%",height:200,children:h.jsxs(E$e,{data:l,children:[h.jsx(pP,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),h.jsx(gP,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),h.jsx(vP,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),h.jsx(JC,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,g)=>[g==="filament"?`${m}g`:g==="cost"?`${e}${m.toFixed(2)}`:m,g==="filament"?"Filament":g==="cost"?"Cost":"Prints"]}),h.jsx(NY,{}),h.jsx(bJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function H$e({id:t,title:e,children:n,isHidden:i,size:r,onToggleVisibility:a,onToggleSize:s}){const{attributes:o,listeners:l,setNodeRef:c,transform:u,transition:f,isDragging:m}=HX({id:t}),g={transform:om.Transform.toString(u),transition:f,opacity:m?.5:1};return i?null:h.jsxs("div",{ref:c,style:{...g,gridColumn:`span ${r}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${m?"ring-2 ring-bambu-green shadow-lg":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.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:h.jsx(FP,{className:"w-4 h-4 text-bambu-gray"})}),h.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.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?h.jsx(voe,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):h.jsx(poe,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),h.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:h.jsx(wse,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),h.jsx("div",{className:"p-4",children:n})]})}function $$e({widgets:t,storageKey:e,columns:n=4}){const i=()=>{const v={};return t.forEach(x=>{v[x.id]=x.defaultSize||4}),v},[r,a]=E.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]=E.useState(!1);E.useEffect(()=>{localStorage.setItem(e,JSON.stringify(r))},[r,e]),E.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=bX(K1(Tw,{activationConstraint:{distance:8}}),K1(Aw,{coordinateGetter:$X})),c=v=>{const{active:x,over:M}=v;M&&x.id!==M.id&&a(w=>{const C=w.order.indexOf(x.id),T=w.order.indexOf(M.id);return{...w,order:Rw(w.order,C,T)}})},u=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}}})},m=()=>{const v={order:t.map(x=>x.id),hidden:t.filter(x=>x.defaultVisible===!1).map(x=>x.id),sizes:i()};a(v)},g=r.order.map(v=>t.find(x=>x.id===v)).filter(Boolean),y=g.filter(v=>!r.hidden.includes(v.id)),_=g.filter(v=>r.hidden.includes(v.id));return h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[_.length>0&&h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>o(!s),children:[h.jsx($U,{className:"w-4 h-4"}),_.length," Hidden"]}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:m,children:[h.jsx(ZS,{className:"w-4 h-4"}),"Reset Layout"]})]}),s&&_.length>0&&h.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),h.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(v=>h.jsxs("button",{onClick:()=>u(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:[h.jsx($U,{className:"w-3 h-3"}),v.title]},v.id))})]}),h.jsx(jX,{sensors:l,collisionDetection:MX,onDragEnd:c,children:h.jsx(zX,{items:y.map(v=>v.id),strategy:lD,children:h.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:y.map(v=>h.jsx(H$e,{id:v.id,title:v.title,isHidden:r.hidden.includes(v.id),size:r.sizes[v.id]||2,onToggleVisibility:()=>u(v.id),onToggleSize:()=>f(v.id),children:v.component},v.id))})})}),y.length===0&&h.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[h.jsx("p",{children:"All widgets are hidden."}),h.jsx(Ye,{className:"mt-4",onClick:m,children:"Reset Layout"})]})]})}function V$e({stats:t,currency:e}){return h.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:h.jsx(G_,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),h.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:h.jsx(ar,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:h.jsx(G_,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:h.jsx(HU,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:h.jsx(c9,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:h.jsx(HU,{className:"w-5 h-5"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),h.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function G$e({stats:t}){const e=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0;return h.jsxs("div",{className:"flex items-center gap-6",children:[h.jsxs("div",{className:"relative w-28 h-28",children:[h.jsxs("svg",{className:"w-full h-full -rotate-90",children:[h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${e*3.02} 302`})]}),h.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:h.jsxs("span",{className:"text-xl font-bold text-white",children:[e,"%"]})})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(hc,{className:"w-4 h-4 text-bambu-green"}),h.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),h.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(j0,{className:"w-4 h-4 text-red-400"}),h.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),h.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]})]})}function W$e({stats:t,printerMap:e}){const n=t?.average_time_accuracy;if(n==null)return h.jsx("div",{className:"flex items-center justify-center h-full",children:h.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 h.jsxs("div",{className:"flex items-center gap-6",children:[h.jsxs("div",{className:"relative w-28 h-28",children:[h.jsxs("svg",{className:"w-full h-full -rotate-90",children:[h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),h.jsx("circle",{cx:"56",cy:"56",r:"48",fill:"none",stroke:s,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r*3.02} 302`})]}),h.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[h.jsxs("span",{className:"text-xl font-bold text-white",children:[n.toFixed(0),"%"]}),h.jsxs("span",{className:`text-xs ${o>=0?"text-blue-400":"text-orange-400"}`,children:[o>=0?"+":"",o.toFixed(0),"%"]})]})]}),h.jsxs("div",{className:"space-y-2 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[h.jsx(lle,{className:"w-3 h-3"}),h.jsx("span",{children:"100% = perfect estimate"})]}),t?.time_accuracy_by_printer&&Object.keys(t.time_accuracy_by_printer).length>0&&h.jsx("div",{className:"space-y-1 mt-2",children:Object.entries(t.time_accuracy_by_printer).slice(0,3).map(([l,c])=>h.jsxs("div",{className:"flex items-center justify-between text-xs",children:[h.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(l)||`Printer ${l}`}),h.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 q$e({stats:t}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return h.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 h.jsx("div",{className:"space-y-3",children:e.map(([n,i])=>{const r=Math.round(i/(t.total_prints||1)*100);return h.jsxs("div",{children:[h.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[h.jsx("span",{className:"text-white",children:n}),h.jsxs("span",{className:"text-bambu-gray",children:[i," prints"]})]}),h.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:h.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${r}%`}})})]},n)})})}function X$e({printDates:t}){return h.jsx(ONe,{printDates:t,months:4})}function K$e({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?h.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):h.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,i])=>h.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[h.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:h.jsx(Qo,{className:"w-4 h-4 text-bambu-green"})}),h.jsxs("div",{children:[h.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),h.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," prints"]})]})]},n))})}function Y$e({archives:t,currency:e}){return!t||t.length===0?h.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):h.jsx(B$e,{archives:t,currency:e})}function Z$e(){const{data:t,isLoading:e}=Dt({queryKey:["archiveStats"],queryFn:$e.getArchiveStats}),{data:n}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),{data:i}=Dt({queryKey:["archives"],queryFn:()=>$e.getArchives(void 0,1e3,0)}),{data:r}=Dt({queryKey:["settings"],queryFn:$e.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 h.jsx("div",{className:"p-8",children:h.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const l=[{id:"quick-stats",title:"Quick Stats",component:h.jsx(V$e,{stats:t,currency:a}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:h.jsx(G$e,{stats:t}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:h.jsx(W$e,{stats:t,printerMap:s}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:h.jsx(q$e,{stats:t}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:h.jsx(X$e,{printDates:o}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:h.jsx(K$e,{stats:t,printerMap:s}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:h.jsx(Y$e,{archives:i||[],currency:a}),defaultSize:4}];return h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"mb-6",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),h.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),h.jsx($$e,{widgets:l,storageKey:"bambusy-dashboard-layout"})]})}function Q$e({plug:t,onEdit:e}){const n=In(),[i,r]=E.useState(!1),[a,s]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),{data:f,isLoading:m,refetch:g}=Dt({queryKey:["smart-plug-status",t.id],queryFn:()=>$e.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:y}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),_=y?.find(P=>P.id===t.printer_id),v=Nt({mutationFn:P=>$e.controlSmartPlug(t.id,P),onSuccess:()=>{g()}}),x=Nt({mutationFn:P=>$e.updateSmartPlug(t.id,P),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),M=Nt({mutationFn:()=>$e.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=f?.state==="ON",C=f?.reachable??!1,T=v.isPending;return h.jsxs(h.Fragment,{children:[h.jsx($t,{className:"relative",children:h.jsxs(Qt,{className:"p-4",children:[h.jsxs("div",{className:"flex items-start justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:`p-2 rounded-lg ${C?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:h.jsx(PN,{className:`w-5 h-5 ${C?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),h.jsxs("div",{children:[h.jsx("h3",{className:"font-medium text-white",children:t.name}),h.jsx("p",{className:"text-sm text-bambu-gray",children:t.ip_address})]})]}),h.jsx("div",{className:"flex items-center gap-2",children:m?h.jsx(Ht,{className:"w-4 h-4 text-bambu-gray animate-spin"}):C?h.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[h.jsx(l9,{className:"w-4 h-4 text-bambu-green"}),h.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:f?.state||"Unknown"})]}):h.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[h.jsx(BP,{className:"w-4 h-4"}),h.jsx("span",{children:"Offline"})]})})]}),_&&h.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),h.jsx("span",{className:"text-sm text-white",children:_.name})]}),h.jsxs("div",{className:"flex gap-2 mb-3",children:[h.jsxs(Ye,{size:"sm",variant:w?"primary":"secondary",disabled:!C||T,onClick:()=>s(!0),className:"flex-1",children:[T?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Bf,{className:"w-4 h-4"}),"On"]}),h.jsxs(Ye,{size:"sm",variant:w?"secondary":"primary",disabled:!C||T,onClick:()=>l(!0),className:"flex-1",children:[T?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(n9,{className:"w-4 h-4"}),"Off"]})]}),h.jsxs("button",{onClick:()=>u(!c),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(QS,{className:"w-4 h-4"}),"Automation Settings"]}),h.jsx("span",{children:c?"-":"+"})]}),c&&h.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Enabled"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:t.enabled,onChange:P=>x.mutate({enabled:P.target.checked}),className:"sr-only peer"}),h.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"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Auto On"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:P=>x.mutate({auto_on:P.target.checked}),className:"sr-only peer"}),h.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"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:P=>x.mutate({auto_off:P.target.checked}),className:"sr-only peer"}),h.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&&h.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),h.jsxs("div",{className:"flex gap-2",children:[h.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:[h.jsx(ar,{className:"w-4 h-4"}),"Time"]}),h.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:[h.jsx(yx,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),h.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"})]}):h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),h.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"}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),h.jsxs("div",{className:"flex gap-2 pt-2",children:[h.jsxs(Ye,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[h.jsx(t9,{className:"w-4 h-4"}),"Edit"]}),h.jsx(Ye,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:h.jsx(Ei,{className:"w-4 h-4"})})]})]})]})}),i&&h.jsx(Ia,{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&&h.jsx(Ia,{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&&h.jsx(Ia,{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 J$e({plug:t,onClose:e}){const n=In(),i=!!t,[r,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.ip_address||""),[l,c]=E.useState(t?.username||""),[u,f]=E.useState(t?.password||""),[m,g]=E.useState(t?.printer_id||null),[y,_]=E.useState(null),[v,x]=E.useState(null),{data:M}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),{data:w}=Dt({queryKey:["smart-plugs"],queryFn:$e.getSmartPlugs});E.useEffect(()=>{const k=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const C=Nt({mutationFn:()=>$e.testSmartPlugConnection(s,l||null,u||null),onSuccess:k=>{_(k),x(null),!r&&k.device_name&&a(k.device_name)},onError:k=>{_(null),x(k.message)}}),T=Nt({mutationFn:k=>$e.createSmartPlug(k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),P=Nt({mutationFn:k=>$e.updateSmartPlug(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:k=>{x(k.message)}}),A=M?.filter(k=>!w?.some(I=>I.printer_id===k.id&&I.id!==t?.id)),j=k=>{if(k.preventDefault(),x(null),!r.trim()){x("Name is required");return}if(!s.trim()){x("IP address is required");return}const F={name:r.trim(),ip_address:s.trim(),username:l.trim()||null,password:u.trim()||null,printer_id:m};i?P.mutate(F):T.mutate(F)},N=T.isPending||P.isPending;return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:h.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:k=>k.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Smart Plug":"Add Smart Plug"}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:j,className:"p-6 space-y-4",children:[v&&h.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:v}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("input",{type:"text",value:s,onChange:k=>{o(k.target.value),_(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"}),h.jsxs(Ye,{type:"button",variant:"secondary",onClick:()=>C.mutate(),disabled:!s.trim()||C.isPending,children:[C.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(l9,{className:"w-4 h-4"}),"Test"]})]})]}),y&&h.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${y.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:y.success?h.jsxs(h.Fragment,{children:[h.jsx(hc,{className:"w-5 h-5"}),h.jsxs("div",{children:[h.jsx("p",{className:"font-medium",children:"Connected!"}),h.jsxs("p",{className:"text-sm opacity-80",children:[y.device_name&&`Device: ${y.device_name} - `,"State: ",y.state]})]})]}):h.jsxs(h.Fragment,{children:[h.jsx(BP,{className:"w-5 h-5"}),h.jsx("span",{children:"Connection failed"})]})}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),h.jsx("input",{type:"text",value:r,onChange:k=>a(k.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"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),h.jsx("input",{type:"text",value:l,onChange:k=>c(k.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),h.jsx("input",{type:"password",value:u,onChange:k=>f(k.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"})]})]}),h.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),h.jsxs("select",{value:m??"",onChange:k=>g(k.target.value?Number(k.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:[h.jsx("option",{value:"",children:"No printer (manual control only)"}),A?.map(k=>h.jsx("option",{value:k.id,children:k.name},k.id))]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(Ye,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{type:"submit",disabled:N,className:"flex-1",children:[N?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Sm,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function is({checked:t,onChange:e,disabled:n}){const i=r=>{r.preventDefault(),r.stopPropagation(),n||e(!t)};return h.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:h.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 eVe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email"};function tVe({provider:t,onEdit:e}){const n=In(),[i,r]=E.useState(!1),[a,s]=E.useState(!1),[o,l]=E.useState(null),{data:c}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),u=c?.find(_=>_.id===t.printer_id),f=Nt({mutationFn:_=>$e.updateNotificationProvider(t.id,_),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=Nt({mutationFn:()=>$e.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=Nt({mutationFn:()=>$e.testNotificationProvider(t.id),onSuccess:_=>{l(_),n.invalidateQueries({queryKey:["notification-providers"]})},onError:_=>{l({success:!1,message:_.message})}}),y=_=>_||"";return h.jsxs(h.Fragment,{children:[h.jsx($t,{className:"relative",children:h.jsxs(Qt,{className:"p-4",children:[h.jsxs("div",{className:"flex items-start justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:h.jsx(NN,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),h.jsxs("div",{children:[h.jsx("h3",{className:"font-medium text-white",children:t.name}),h.jsx("p",{className:"text-sm text-bambu-gray",children:eVe[t.provider_type]||t.provider_type})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[t.last_success&&h.jsxs("span",{className:"text-xs text-bambu-green",children:["Last sent: ",new Date(t.last_success).toLocaleDateString()]}),t.last_error&&h.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"})]})]}),u&&h.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[h.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),h.jsx("span",{className:"text-sm text-white",children:u.name})]}),!u&&!t.printer_id&&h.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:h.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),h.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&h.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&h.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&h.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&h.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&h.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&h.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&h.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Error"}),t.on_filament_low&&h.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&&h.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.quiet_hours_enabled&&h.jsxs("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded flex items-center gap-1",children:[h.jsx(V_,{className:"w-3 h-3"}),"Quiet"]})]}),h.jsx("div",{className:"mb-3",children:h.jsxs(Ye,{size:"sm",variant:"secondary",disabled:g.isPending,onClick:()=>{l(null),g.mutate()},className:"w-full",children:[g.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(i9,{className:"w-4 h-4"}),"Send Test Notification"]})}),o&&h.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?h.jsx(hc,{className:"w-4 h-4"}):h.jsx(j0,{className:"w-4 h-4"}),h.jsx("span",{children:o.message})]}),h.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:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsx(QS,{className:"w-4 h-4"}),"Event Settings"]}),a?h.jsx(WG,{className:"w-4 h-4"}):h.jsx(I0,{className:"w-4 h-4"})]}),a&&h.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Enabled"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),h.jsx(is,{checked:t.enabled,onChange:_=>f.mutate({enabled:_})})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Started"}),h.jsx(is,{checked:t.on_print_start,onChange:_=>f.mutate({on_print_start:_})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),h.jsx(is,{checked:t.on_print_complete,onChange:_=>f.mutate({on_print_complete:_})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),h.jsx(is,{checked:t.on_print_failed,onChange:_=>f.mutate({on_print_failed:_})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),h.jsx(is,{checked:t.on_print_stopped,onChange:_=>f.mutate({on_print_stopped:_})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),h.jsx(is,{checked:t.on_print_progress,onChange:_=>f.mutate({on_print_progress:_})})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),h.jsx(is,{checked:t.on_printer_offline,onChange:_=>f.mutate({on_printer_offline:_})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),h.jsx(is,{checked:t.on_printer_error,onChange:_=>f.mutate({on_printer_error:_})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),h.jsx(is,{checked:t.on_filament_low,onChange:_=>f.mutate({on_filament_low:_})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),h.jsx(is,{checked:t.on_maintenance_due??!1,onChange:_=>f.mutate({on_maintenance_due:_})})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(V_,{className:"w-4 h-4 text-purple-400"}),h.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),h.jsx(is,{checked:t.quiet_hours_enabled,onChange:_=>f.mutate({quiet_hours_enabled:_})})]}),t.quiet_hours_enabled&&h.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[h.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ar,{className:"w-4 h-4 text-bambu-gray"}),h.jsxs("span",{className:"text-sm text-white",children:[y(t.quiet_hours_start)||"22:00"," - ",y(t.quiet_hours_end)||"07:00"]})]}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),h.jsxs("div",{className:"flex gap-2 pt-2",children:[h.jsxs(Ye,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[h.jsx(t9,{className:"w-4 h-4"}),"Edit"]}),h.jsx(Ye,{size:"sm",variant:"secondary",onClick:()=>r(!0),className:"text-red-400 hover:text-red-300",children:h.jsx(Ei,{className:"w-4 h-4"})})]})]})]})}),i&&h.jsx(Ia,{title:"Delete Notification Provider",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)})]})}const aG=[{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 nVe({provider:t,onClose:e}){const n=In(),i=!!t,[r,a]=E.useState(t?.name||""),[s,o]=E.useState(t?.provider_type||"ntfy"),[l,c]=E.useState(t?.printer_id||null),[u,f]=E.useState(t?.quiet_hours_enabled||!1),[m,g]=E.useState(t?.quiet_hours_start||"22:00"),[y,_]=E.useState(t?.quiet_hours_end||"07:00"),[v,x]=E.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,$])=>[B,String($)])):{}),[M,w]=E.useState(null),[C,T]=E.useState(null),{data:P}=Dt({queryKey:["printers"],queryFn:$e.getPrinters});E.useEffect(()=>{const B=$=>{$.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const A=Nt({mutationFn:()=>$e.testNotificationConfig({provider_type:s,config:v}),onSuccess:B=>{w(B),T(null)},onError:B=>{w({success:!1,message:B.message})}}),j=Nt({mutationFn:B=>$e.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),N=Nt({mutationFn:B=>$e.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{T(B.message)}}),k=B=>{if(B.preventDefault(),T(null),!r.trim()){T("Name is required");return}const $=W(s);for(const X of $)if(!v[X.key]?.trim()){T(`${X.label} is required`);return}const K={name:r.trim(),provider_type:s,config:v,printer_id:l,quiet_hours_enabled:u,quiet_hours_start:u?m:null,quiet_hours_end:u?y:null};i?N.mutate(K):j.mutate(K)},F=j.isPending||N.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[]}},W=B=>I(B).filter($=>$.required),D=I(s);return h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:h.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:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Notification Provider":"Add Notification Provider"}),h.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:k,className:"p-6 space-y-4",children:[C&&h.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:C}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),h.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),h.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:aG.map(B=>h.jsx("option",{value:B.value,children:B.label},B.value))}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:aG.find(B=>B.value===s)?.description})]}),h.jsxs("div",{className:"space-y-3",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),D.map(B=>h.jsxs("div",{children:[h.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&B.options?h.jsx("select",{value:v[B.key]||B.options[0]?.value||"",onChange:$=>{x({...v,[B.key]:$.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($=>h.jsx("option",{value:$.value,children:$.label},$.value))}):h.jsx("input",{type:B.type,value:v[B.key]||"",onChange:$=>{x({...v,[B.key]:$.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))]}),h.jsx("div",{className:"flex gap-2",children:h.jsxs(Ye,{type:"button",variant:"secondary",onClick:()=>{w(null),A.mutate()},disabled:A.isPending||!v[W(s)[0]?.key],className:"flex-1",children:[A.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(i9,{className:"w-4 h-4"}),"Test Configuration"]})}),M&&h.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?h.jsxs(h.Fragment,{children:[h.jsx(hc,{className:"w-5 h-5"}),h.jsx("span",{children:M.message})]}):h.jsxs(h.Fragment,{children:[h.jsx(j0,{className:"w-5 h-5"}),h.jsx("span",{children:M.message})]})}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),h.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:[h.jsx("option",{value:"",children:"All printers"}),P?.map(B=>h.jsx("option",{value:B.id,children:B.name},B.id))]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),h.jsx(is,{checked:u,onChange:f})]}),u&&h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),h.jsx("input",{type:"time",value:m,onChange:B=>g(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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),h.jsx("input",{type:"time",value:y,onChange: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"})]})]})]}),h.jsxs("div",{className:"flex gap-3 pt-2",children:[h.jsx(Ye,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{type:"submit",disabled:F,className:"flex-1",children:[F?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Sm,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}async function iVe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function rVe(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 aVe(){const t=In(),[e,n]=E.useState(!1),[i,r]=E.useState(""),[a,s]=E.useState("auto"),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,m]=E.useState("all"),{data:g,isLoading:y}=Dt({queryKey:["spoolman-settings"],queryFn:iVe}),{data:_,isLoading:v,refetch:x}=Dt({queryKey:["spoolman-status"],queryFn:$e.getSpoolmanStatus,refetchInterval:3e4}),{data:M}=Dt({queryKey:["printers"],queryFn:$e.getPrinters});E.useEffect(()=>{g&&(n(g.spoolman_enabled==="true"),r(g.spoolman_url||""),s(g.spoolman_sync_mode||"auto"))},[g]),E.useEffect(()=>{if(g){const I=g.spoolman_enabled==="true"!==e||(g.spoolman_url||"")!==i||(g.spoolman_sync_mode||"auto")!==a;l(I)}},[g,e,i,a]);const w=Nt({mutationFn:()=>rVe({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),u(!0),setTimeout(()=>u(!1),2e3)}}),C=Nt({mutationFn:$e.connectSpoolman,onSuccess:()=>{x()}}),T=Nt({mutationFn:$e.disconnectSpoolman,onSuccess:()=>{x()}}),P=Nt({mutationFn:$e.syncAllPrintersAms,onSuccess:I=>{I.success}}),A=Nt({mutationFn:I=>$e.syncPrinterAms(I),onSuccess:I=>{I.success}}),j=()=>{f==="all"?P.mutate():A.mutate(f)},N=P.isPending||A.isPending,k=f==="all"?P.data:A.data,F=f==="all"?P.isSuccess:A.isSuccess;return y?h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(BU,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),h.jsx(Qt,{children:h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ht,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(BU,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),o&&h.jsx(Ye,{size:"sm",onClick:()=>w.mutate(),disabled:w.isPending,children:w.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):c?h.jsx(Wx,{className:"w-4 h-4"}):"Save"})]})}),h.jsxs(Qt,{className:"space-y-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Enable Spoolman"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:e,onChange:I=>n(I.target.checked),className:"sr-only peer"}),h.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"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),h.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"}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),h.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:[h.jsx("option",{value:"auto",children:"Automatic"}),h.jsx("option",{value:"manual",children:"Manual Only"})]}),h.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&&h.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),v?h.jsx(Ht,{className:"w-4 h-4 text-bambu-gray animate-spin"}):_?.connected?h.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[h.jsx(Wx,{className:"w-4 h-4"}),"Connected"]}):h.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[h.jsx(Sn,{className:"w-4 h-4"}),"Disconnected"]})]}),h.jsx("div",{className:"flex gap-2",children:_?.connected?h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(ioe,{className:"w-4 h-4"}),"Disconnect"]}):h.jsxs(Ye,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!i,children:[C.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(aoe,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&h.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:C.error.message}),_?.connected&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("div",{className:"relative flex-1",children:[h.jsxs("select",{value:f,onChange:I=>m(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:[h.jsx("option",{value:"all",children:"All Printers"}),M?.map(I=>h.jsx("option",{value:I.id,children:I.name},I.id))]}),h.jsx(I0,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:j,disabled:N,children:[N?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(wo,{className:"w-4 h-4"}),"Sync"]})]})]}),F&&k&&h.jsx("div",{className:`mt-2 p-2 rounded text-sm ${k.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:k.success?`Synced ${k.synced_count} trays successfully`:`Synced ${k.synced_count} trays with ${k.errors.length} errors`})]})]})]})}function sVe(){const t=In(),{t:e,i18n:n}=EP(),[i,r]=E.useState(null),[a,s]=E.useState(!1),[o,l]=E.useState(!1),[c,u]=E.useState(!1),[f,m]=E.useState(null),[g,y]=E.useState(!1),[_,v]=E.useState(null),[x,M]=E.useState(f9()),w=V=>{M(V),Hle(V)},C=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:T,isLoading:P}=Dt({queryKey:["settings"],queryFn:$e.getSettings}),{data:A,isLoading:j}=Dt({queryKey:["smart-plugs"],queryFn:$e.getSmartPlugs}),{data:N,isLoading:k}=Dt({queryKey:["notification-providers"],queryFn:$e.getNotificationProviders}),{data:F}=Dt({queryKey:["ffmpeg-status"],queryFn:$e.checkFfmpeg}),{data:I}=Dt({queryKey:["version"],queryFn:$e.getVersion}),{data:W,refetch:D,isRefetching:B}=Dt({queryKey:["updateCheck"],queryFn:$e.checkForUpdates,staleTime:300*1e3}),{data:$,refetch:K}=Dt({queryKey:["updateStatus"],queryFn:$e.getUpdateStatus,refetchInterval:V=>{const re=V.state.data;return re?.status==="downloading"||re?.status==="installing"?1e3:!1}}),X=Nt({mutationFn:$e.applyUpdate,onSuccess:()=>{K()}});E.useEffect(()=>{T&&!i&&r(T)},[T,i]),E.useEffect(()=>{if(T&&i){const V=T.auto_archive!==i.auto_archive||T.save_thumbnails!==i.save_thumbnails||T.capture_finish_photo!==i.capture_finish_photo||T.default_filament_cost!==i.default_filament_cost||T.currency!==i.currency||T.energy_cost_per_kwh!==i.energy_cost_per_kwh||T.energy_tracking_mode!==i.energy_tracking_mode||T.check_updates!==i.check_updates||T.notification_language!==i.notification_language||T.ams_humidity_good!==i.ams_humidity_good||T.ams_humidity_fair!==i.ams_humidity_fair||T.ams_temp_good!==i.ams_temp_good||T.ams_temp_fair!==i.ams_temp_fair;s(V)}},[T,i]);const Y=Nt({mutationFn:$e.updateSettings,onSuccess:V=>{t.setQueryData(["settings"],V),r(V),s(!1),l(!0),setTimeout(()=>l(!1),2e3),t.invalidateQueries({queryKey:["archiveStats"]})}}),ee=()=>{i&&Y.mutate(i)},z=(V,re)=>{i&&r({...i,[V]:re})};return P||!i?h.jsx("div",{className:"p-8 flex justify-center",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),h.jsx("p",{className:"text-bambu-gray",children:"Configure Bambusy"})]}),h.jsxs(Ye,{onClick:ee,disabled:!a||Y.isPending,children:[Y.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):o?h.jsx(Wx,{className:"w-4 h-4"}):h.jsx(Sm,{className:"w-4 h-4"}),o?"Saved!":"Save"]})]}),Y.isError&&h.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: ",Y.error.message]}),h.jsxs("div",{className:"flex gap-8",children:[h.jsxs("div",{className:"space-y-6 flex-1 max-w-xl",children:[h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),h.jsxs(Qt,{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Auto-archive prints"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.auto_archive,onChange:V=>z("auto_archive",V.target.checked),className:"sr-only peer"}),h.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"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Save thumbnails"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.save_thumbnails,onChange:V=>z("save_thumbnails",V.target.checked),className:"sr-only peer"}),h.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"})]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Capture finish photo"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.capture_finish_photo,onChange:V=>z("capture_finish_photo",V.target.checked),className:"sr-only peer"}),h.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"})]})]}),i.capture_finish_photo&&F&&!F.installed&&h.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[h.jsx(Jo,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),h.jsxs("div",{className:"text-sm",children:[h.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),h.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",h.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",h.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]}),h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),h.jsxs(Qt,{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),h.jsx("input",{type:"number",step:"0.01",min:"0",value:i.default_filament_cost,onChange:V=>z("default_filament_cost",parseFloat(V.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),h.jsxs("select",{value:i.currency,onChange:V=>z("currency",V.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:[h.jsx("option",{value:"USD",children:"USD ($)"}),h.jsx("option",{value:"EUR",children:"EUR (€)"}),h.jsx("option",{value:"GBP",children:"GBP (£)"}),h.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),h.jsx("option",{value:"JPY",children:"JPY (¥)"}),h.jsx("option",{value:"CNY",children:"CNY (¥)"}),h.jsx("option",{value:"CAD",children:"CAD ($)"}),h.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),h.jsx("input",{type:"number",step:"0.01",min:"0",value:i.energy_cost_per_kwh,onChange:V=>z("energy_cost_per_kwh",parseFloat(V.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),h.jsxs("select",{value:i.energy_tracking_mode||"total",onChange:V=>z("energy_tracking_mode",V.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:[h.jsx("option",{value:"print",children:"Prints Only"}),h.jsx("option",{value:"total",children:"Total Consumption"})]}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),h.jsxs(Qt,{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[h.jsx($_,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),h.jsx("select",{value:n.language,onChange:V=>n.changeLanguage(V.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:_U.map(V=>h.jsxs("option",{value:V.code,children:[V.nativeName," (",V.name,")"]},V.code))}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),h.jsx("select",{value:x,onChange:V=>w(V.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(V=>h.jsx("option",{value:V.to,children:e(V.labelKey)},V.id))}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Sidebar order"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:C,children:[h.jsx(ZS,{className:"w-4 h-4"}),"Reset"]})]})]})]}),h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),h.jsxs(Qt,{className:"space-y-4",children:[h.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{className:"flex items-center gap-2 text-white",children:[h.jsx(vse,{className:"w-4 h-4 text-blue-400"}),h.jsx("span",{className:"font-medium",children:"Humidity"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_good??40,onChange:V=>z("ams_humidity_good",parseInt(V.target.value)||40),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"}),h.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",min:"0",max:"100",value:i.ams_humidity_fair??60,onChange:V=>z("ams_humidity_fair",parseInt(V.target.value)||60),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"}),h.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),h.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-2 text-white",children:[h.jsx(yx,{className:"w-4 h-4 text-orange-400"}),h.jsx("span",{className:"font-medium",children:"Temperature"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_good??28,onChange:V=>z("ams_temp_good",parseFloat(V.target.value)||28),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"}),h.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:i.ams_temp_fair??35,onChange:V=>z("ams_temp_fair",parseFloat(V.target.value)||35),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"}),h.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),h.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]})]})]})]}),h.jsxs("div",{className:"space-y-6 flex-1 max-w-md",children:[h.jsx(aVe,{}),h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),h.jsxs(Qt,{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Check for updates"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),h.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.check_updates,onChange:V=>z("check_updates",V.target.checked),className:"sr-only peer"}),h.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"})]})]}),h.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[h.jsxs("div",{className:"flex items-center justify-between mb-2",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:"Current version"}),h.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",I?.version||"..."]})]}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>D(),disabled:B,children:[B?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(wo,{className:"w-4 h-4"}),"Check now"]})]}),W?.update_available?h.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[h.jsxs("div",{className:"flex items-start justify-between",children:[h.jsxs("div",{children:[h.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",W.latest_version]}),W.release_name&&W.release_name!==W.latest_version&&h.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:W.release_name}),W.release_notes&&h.jsx("p",{className:"text-sm text-bambu-gray mt-2 whitespace-pre-line line-clamp-3",children:W.release_notes})]}),W.release_url&&h.jsx("a",{href:W.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:h.jsx(mc,{className:"w-4 h-4"})})]}),$?.status==="downloading"||$?.status==="installing"?h.jsxs("div",{className:"mt-3",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[h.jsx(Ht,{className:"w-4 h-4 animate-spin"}),h.jsx("span",{children:$.message})]}),h.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:h.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${$.progress}%`}})})]}):$?.status==="complete"?h.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:$.message}):$?.status==="error"?h.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:$.error||$.message}):h.jsxs(Ye,{className:"mt-3",onClick:()=>X.mutate(),disabled:X.isPending,children:[X.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(pc,{className:"w-4 h-4"}),"Install Update"]})]}):W?.error?h.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: ",W.error]}):W&&!W.update_available?h.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]})]}),h.jsx("div",{className:"w-80 flex-shrink-0",children:h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(PN,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Smart Plugs"})]}),h.jsxs(Ye,{size:"sm",onClick:()=>{m(null),u(!0)},children:[h.jsx(So,{className:"w-4 h-4"}),"Add"]})]})}),h.jsxs(Qt,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Connect Tasmota-based smart plugs to automate power control for your printers."}),j?h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):A&&A.length>0?h.jsx("div",{className:"space-y-4",children:A.map(V=>h.jsx(Q$e,{plug:V,onEdit:re=>{m(re),u(!0)}},V.id))}):h.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[h.jsx(PN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),h.jsx("p",{children:"No smart plugs configured"}),h.jsx("p",{className:"text-sm mt-1",children:"Add a Tasmota plug to get started"})]})]})]})}),h.jsx("div",{className:"w-80 flex-shrink-0",children:h.jsxs($t,{children:[h.jsx(Gl,{children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(NN,{className:"w-5 h-5 text-bambu-green"}),h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notifications"})]}),h.jsxs(Ye,{size:"sm",onClick:()=>{v(null),y(!0)},children:[h.jsx(So,{className:"w-4 h-4"}),"Add"]})]})}),h.jsxs(Qt,{children:[h.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Get notified about print events via WhatsApp, Telegram, Email, and more."}),h.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary mb-4",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-white",children:e("settings.notificationLanguage")}),h.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),h.jsx("select",{value:i.notification_language||"en",onChange:V=>z("notification_language",V.target.value),className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-bambu-green",children:_U.map(V=>h.jsx("option",{value:V.code,children:V.nativeName},V.code))})]}),k?h.jsx("div",{className:"flex justify-center py-8",children:h.jsx(Ht,{className:"w-6 h-6 text-bambu-green animate-spin"})}):N&&N.length>0?h.jsx("div",{className:"space-y-4",children:N.map(V=>h.jsx(tVe,{provider:V,onEdit:re=>{v(re),y(!0)}},V.id))}):h.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[h.jsx(NN,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),h.jsx("p",{children:"No notification providers configured"}),h.jsx("p",{className:"text-sm mt-1",children:"Add a provider to get started"})]})]})]})})]}),c&&h.jsx(J$e,{plug:f,onClose:()=>{u(!1),m(null)}}),g&&h.jsx(nVe,{provider:_,onClose:()=>{y(!1),v(null)}})]})}const QJ=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},oVe=t=>t.startsWith("HH")?"HF":"S",lVe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},SP=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 mN({profile:t,onEdit:e,onCopy:n,selectionMode:i,isSelected:r,onToggleSelect:a,note:s}){const o=oVe(t.nozzle_id),l=t.nozzle_diameter,c=()=>{i&&a?a():e()};return h.jsxs("div",{className:"flex items-center gap-2",children:[i&&h.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:r?h.jsx(Sf,{className:"w-4 h-4 text-bambu-green"}):h.jsx(Hp,{className:"w-4 h-4"})}),h.jsxs("button",{onClick:c,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${r?"ring-1 ring-bambu-green":""}`,children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:QJ(t.k_value)}),h.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),s&&h.jsx("span",{title:"Has note",children:h.jsx(a9,{className:"w-3 h-3 text-yellow-500"})}),h.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[o," ",l]})]}),s&&h.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:s,children:["Note: ",s.length>50?s.substring(0,50)+"...":s]})]}),!i&&n&&h.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:h.jsx(Up,{className:"w-4 h-4"})})]})}function gN({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:i=[],isDualNozzle:r=!1,initialNote:a="",initialNoteKey:s=null,onClose:o,onSave:l,onSaveNote:c}){const{showToast:u}=wa(),[f,m]=E.useState(t?.name||""),[g,y]=E.useState(t?.k_value?QJ(t.k_value):"0.020"),[_,v]=E.useState(t?.filament_id||""),[x,M]=E.useState(t?.nozzle_id?lVe(t.nozzle_id):"HH00"),[w,C]=E.useState(t?.nozzle_diameter||n),[T,P]=E.useState(t?[t.extruder_id]:r?[0,1]:[0]),[A,j]=E.useState(!1),[N,k]=E.useState({current:0,total:0}),[F,I]=E.useState(a),W=ui.useMemo(()=>{const ee=new Map;for(const z of i)if(z.filament_id&&!ee.has(z.filament_id)){const V=SP(z.name||"");ee.set(z.filament_id,{id:z.filament_id,name:V||z.filament_id})}return Array.from(ee.values()).sort((z,V)=>z.name.localeCompare(V.name))},[i]),D=Nt({mutationFn:ee=>(console.log("[KProfile] Calling API..."),$e.setKProfile(e,ee)),onSuccess:ee=>{if(console.log("[KProfile] Save success:",ee),u("K-profile saved"),c&&F!==a){let z;F===""&&s?z=s:t&&t.slot_id>0?z=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:z=`name_${f}_${_}`,c(z,F)}j(!0),setTimeout(()=>{j(!1),l()},2500)},onError:ee=>{console.error("[KProfile] Save error:",ee),u(ee.message,"error"),j(!1)}}),B=Nt({mutationFn:ee=>(console.log("[KProfile] Deleting profile..."),$e.deleteKProfile(e,ee)),onSuccess:ee=>{console.log("[KProfile] Delete success:",ee),u("K-profile deleted"),j(!0),setTimeout(()=>{j(!1),o()},4e3)},onError:ee=>{console.error("[KProfile] Delete error:",ee),u(ee.message,"error"),j(!1)}}),[$,K]=E.useState(!1),X=()=>{t&&B.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,setting_id:t.setting_id})},Y=async ee=>{if(ee.preventDefault(),r&&!t&&T.length===0){u("Please select at least one extruder","error");return}const z=parseFloat(g).toFixed(6),V=`${x}-${w}`;if(t||T.length===1){const le={name:f,k_value:z,filament_id:_,nozzle_id:V,nozzle_diameter:w,extruder_id:t?t.extruder_id:T[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",le),D.mutate(le);return}j(!0),k({current:1,total:T.length});const re=T.map(le=>({name:f,k_value:z,filament_id:_,nozzle_id:V,nozzle_diameter:w,extruder_id:le,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${re.length} profiles in batch:`,re);try{if(await $e.setKProfilesBatch(e,re),u(`K-profile saved to ${T.length} extruders`),c&&F){const le=`name_${f}_${_}`;c(le,F)}}catch(le){console.error("[KProfile] Failed to save batch:",le),u("Failed to save K-profiles","error"),j(!1),k({current:0,total:0});return}k({current:T.length,total:T.length}),setTimeout(()=>{j(!1),k({current:0,total:0}),l()},3e3)};return h.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[h.jsxs($t,{className:"w-full max-w-md relative",children:[A&&h.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),h.jsx("p",{className:"text-white font-medium",children:N.total>1?`Saving to extruder ${N.current}/${N.total}...`:"Syncing with printer..."}),h.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),h.jsxs(Qt,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),h.jsx("button",{onClick:o,className:"text-bambu-gray hover:text-white transition-colors",disabled:A,children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("form",{onSubmit:Y,className:"p-4 space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),h.jsx("input",{type:"text",value:f,onChange:ee=>m(ee.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:!t})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),h.jsx("input",{type:"text",inputMode:"decimal",value:g,onChange:ee=>{const z=ee.target.value;(z===""||/^\d*\.?\d*$/.test(z))&&y(z)},onBlur:ee=>{const z=parseFloat(ee.target.value);isNaN(z)||y((Math.trunc(z*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}),h.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"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),h.jsxs("select",{value:_,onChange:ee=>{const z=ee.target.value;if(v(z),!t&&z&&!f){const V=W.find(re=>re.id===z);V&&m(`${x==="HH00"?"HF":"S"} ${V.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:!t,children:[h.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&h.jsx("option",{value:t.filament_id,children:W.find(ee=>ee.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&W.map(ee=>h.jsx("option",{value:ee.id,children:ee.name},ee.id))]}),!t&&W.length===0&&h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),h.jsxs("select",{value:x,onChange:ee=>{const z=ee.target.value;if(M(z),!t&&_&&!f){const V=W.find(re=>re.id===_);V&&m(`${z==="HS00"?"HF":"S"} ${V.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:[h.jsx("option",{value:"HH00",children:"High Flow"}),h.jsx("option",{value:"HS00",children:"Standard"})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),h.jsxs("select",{value:w,onChange:ee=>C(ee.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:[h.jsx("option",{value:"0.2",children:"0.2mm"}),h.jsx("option",{value:"0.4",children:"0.4mm"}),h.jsx("option",{value:"0.6",children:"0.6mm"}),h.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),r&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?h.jsx("div",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60",children:t.extruder_id===1?"Left":"Right"}):h.jsxs("div",{className:"flex gap-4",children:[h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:T.includes(1),onChange:ee=>{ee.target.checked?P([...T,1]):P(T.filter(z=>z!==1))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),h.jsx("span",{className:"text-white",children:"Left"})]}),h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:T.includes(0),onChange:ee=>{ee.target.checked?P([...T,0]):P(T.filter(z=>z!==0))},className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green"}),h.jsx("span",{className:"text-white",children:"Right"})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),h.jsx("textarea",{value:F,onChange:ee=>I(ee.target.value),placeholder:"Add notes about this profile...",rows:2,className:"w-full px-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 resize-none"}),h.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambusy, not on the printer"})]}),h.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&h.jsx(Ye,{type:"button",variant:"secondary",onClick:()=>K(!0),disabled:B.isPending||A,className:"text-red-500 hover:bg-red-500/10",children:B.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Ei,{className:"w-4 h-4"})}),h.jsx(Ye,{type:"button",variant:"secondary",onClick:o,disabled:A,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{type:"submit",disabled:D.isPending||A,className:"flex-1",children:[D.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(UP,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),$&&h.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:h.jsx($t,{className:"w-full max-w-sm",children:h.jsxs(Qt,{className:"p-6",children:[h.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[h.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:h.jsx(Ei,{className:"w-5 h-5 text-red-500"})}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),h.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",h.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),h.jsxs("div",{className:"flex gap-3",children:[h.jsx(Ye,{variant:"secondary",onClick:()=>K(!1),className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{onClick:()=>{K(!1),X()},disabled:B.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[B.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Ei,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const d_={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function cVe(){const{showToast:t}=wa(),[e,n]=E.useState(null),[i,r]=E.useState(()=>localStorage.getItem(d_.NOZZLE_DIAMETER)||"0.4"),[a,s]=E.useState(null),[o,l]=E.useState(!1),[c,u]=E.useState(null),[f,m]=E.useState(""),[g,y]=E.useState("all"),[_,v]=E.useState("all"),[x,M]=E.useState(()=>localStorage.getItem(d_.SORT_OPTION)||"name"),[w,C]=E.useState(!1),[T,P]=E.useState(new Set),[A,j]=E.useState(!1),[N,k]=E.useState(!1),F=Z=>`${Z.slot_id}_${Z.extruder_id}`;E.useEffect(()=>{localStorage.setItem(d_.NOZZLE_DIAMETER,i)},[i]),E.useEffect(()=>{localStorage.setItem(d_.SORT_OPTION,x)},[x]);const{data:I,isLoading:W}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),{data:D,isLoading:B,isFetching:$,error:K,refetch:X}=Dt({queryKey:["kprofiles",e,i],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",i);const Z=await $e.getKProfiles(e,i);return console.log("[KProfiles] Received profiles:",Z?.profiles?.length||0,"profiles"),Z},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:Y}=Dt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>$e.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:ee,refetch:z}=Dt({queryKey:["kprofile-notes",e],queryFn:()=>$e.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),V=K?.message?.includes("not connected");E.useEffect(()=>{if(!e&&I&&I.length>0){const Z=I.find(Q=>Q.is_active);Z&&n(Z.id)}},[e,I]),E.useEffect(()=>{if(e){const Z=setTimeout(()=>{X()},150);return()=>clearTimeout(Z)}},[e,i]);const re=I?.filter(Z=>Z.is_active)||[],le=ui.useMemo(()=>D?.profiles?D.profiles.filter(Q=>{const se=f.toLowerCase(),Ce=!se||Q.name.toLowerCase().includes(se)||Q.filament_id.toLowerCase().includes(se),Ee=g==="all"||g==="left"&&Q.extruder_id===1||g==="right"&&Q.extruder_id===0,ne=_==="all"||_==="hf"&&Q.nozzle_id.startsWith("HH")||_==="s"&&Q.nozzle_id.startsWith("HS");return Ce&&Ee&&ne}).sort((Q,se)=>{switch(x){case"k_value":return parseFloat(Q.k_value)-parseFloat(se.k_value);case"filament":return SP(Q.name).localeCompare(SP(se.name));case"name":default:return Q.name.localeCompare(se.name)}}):[],[D?.profiles,f,g,_,x]),ge=I?.find(Z=>Z.id===e),ie=ge?.nozzle_count===2;E.useEffect(()=>{const Z=Q=>{Q.target instanceof HTMLInputElement||Q.target instanceof HTMLTextAreaElement||Q.target instanceof HTMLSelectElement||a||o||c||(Q.key==="r"||Q.key==="R"?(Q.preventDefault(),X()):Q.key==="n"||Q.key==="N"?(Q.preventDefault(),l(!0)):Q.key==="Escape"&&w&&(Q.preventDefault(),C(!1),P(new Set)))};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[a,o,c,w,X]);const xe=E.useCallback(()=>{if(!D?.profiles||D.profiles.length===0){t("No profiles to export","error");return}const Z={version:1,exported_at:new Date().toISOString(),printer:ge?.name||"Unknown",nozzle_diameter:i,profiles:D.profiles.map(Ee=>({name:Ee.name,k_value:Ee.k_value,filament_id:Ee.filament_id,nozzle_id:Ee.nozzle_id,nozzle_diameter:Ee.nozzle_diameter,extruder_id:Ee.extruder_id}))},Q=new Blob([JSON.stringify(Z,null,2)],{type:"application/json"}),se=URL.createObjectURL(Q),Ce=document.createElement("a");Ce.href=se,Ce.download=`kprofiles_${ge?.name||"printer"}_${i}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),URL.revokeObjectURL(se),t(`Exported ${D.profiles.length} profiles`)},[D?.profiles,ge,i,t]),ke=E.useCallback(()=>{const Z=document.createElement("input");Z.type="file",Z.accept=".json",Z.onchange=async Q=>{const se=Q.target.files?.[0];if(se)try{const Ce=await se.text(),Ee=JSON.parse(Ce);if(!Ee.profiles||!Array.isArray(Ee.profiles)){t("Invalid file format","error");return}let ne=0;for(const U of Ee.profiles)if(!(!U.name||!U.k_value||!U.filament_id))try{await $e.setKProfile(e,{name:U.name,k_value:parseFloat(U.k_value).toFixed(6),filament_id:U.filament_id,nozzle_id:U.nozzle_id||`HH00-${i}`,nozzle_diameter:U.nozzle_diameter||i,extruder_id:U.extruder_id??0,slot_id:0}),ne++,await new Promise(L=>setTimeout(L,500))}catch(L){console.error("Failed to import profile:",U.name,L)}t(`Imported ${ne} of ${Ee.profiles.length} profiles`),X()}catch(Ce){console.error("Import error:",Ce),t("Failed to parse import file","error")}},Z.click()},[e,i,t,X]),he=E.useCallback(Z=>{P(Q=>{const se=new Set(Q);return se.has(Z)?se.delete(Z):se.add(Z),se})},[]),we=E.useCallback(()=>{P(new Set(le.map(Z=>F(Z))))},[le,F]),Ue=E.useCallback(()=>{T.size!==0&&j(!0)},[T.size]),ue=E.useCallback(async()=>{const Z=le.filter(se=>T.has(F(se)));k(!0);let Q=0;for(const se of Z)try{await $e.deleteKProfile(e,{slot_id:se.slot_id,extruder_id:se.extruder_id,nozzle_id:se.nozzle_id,nozzle_diameter:se.nozzle_diameter,filament_id:se.filament_id,setting_id:se.setting_id}),Q++,await new Promise(Ce=>setTimeout(Ce,300))}catch(Ce){console.error("Failed to delete profile:",se.name,Ce)}t(`Deleted ${Q} profiles`),k(!1),j(!1),C(!1),P(new Set),X()},[e,T,le,t,X,F]),lt=E.useCallback(Z=>{const Q=[];return Z.setting_id&&Q.push(Z.setting_id),Q.push(`slot_${Z.slot_id}_${Z.filament_id}_${Z.extruder_id}`),Q.push(`name_${Z.name}_${Z.filament_id}`),Q},[]),H=E.useCallback(async(Z,Q)=>{if(e)try{await $e.setKProfileNote(e,Z,Q),z()}catch(se){console.error("Failed to save note:",se),t("Failed to save note","error")}},[e,z,t]),q=E.useCallback(Z=>{if(!ee?.notes)return{note:"",key:null};const Q=lt(Z);for(const se of Q)if(ee.notes[se])return{note:ee.notes[se],key:se};return{note:"",key:null}},[ee,lt]),oe=E.useCallback(Z=>q(Z).note,[q]);return W?h.jsx("div",{className:"flex justify-center py-12",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!I||I.length===0?h.jsx($t,{children:h.jsxs(Qt,{className:"py-12 text-center",children:[h.jsx(Ec,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),h.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):re.length===0?h.jsx($t,{children:h.jsxs(Qt,{className:"py-12 text-center",children:[h.jsx(Qo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),h.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):h.jsxs(h.Fragment,{children:[$&&!B&&h.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[h.jsx(Ht,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),h.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),h.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[h.jsxs("div",{className:"flex-1 min-w-48",children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),h.jsx("select",{value:e||"",onChange:Z=>n(parseInt(Z.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:re.map(Z=>h.jsx("option",{value:Z.id,children:Z.name},Z.id))})]}),h.jsxs("div",{className:"w-32",children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),h.jsxs("select",{value:i,onChange:Z=>r(Z.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:[h.jsx("option",{value:"0.2",children:"0.2mm"}),h.jsx("option",{value:"0.4",children:"0.4mm"}),h.jsx("option",{value:"0.6",children:"0.6mm"}),h.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),h.jsxs("div",{className:"flex items-end gap-2",children:[h.jsxs(Ye,{variant:"secondary",onClick:()=>X(),disabled:$,children:[h.jsx(wo,{className:`w-4 h-4 ${$?"animate-spin":""}`}),"Refresh"]}),h.jsxs(Ye,{onClick:()=>l(!0),children:[h.jsx(So,{className:"w-4 h-4"}),"Add Profile"]})]})]}),h.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[h.jsxs("div",{className:"flex-1 min-w-48 relative",children:[h.jsx(Bp,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",value:f,onChange:Z=>m(Z.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"})]}),ie&&h.jsx("div",{className:"w-36",children:h.jsxs("select",{value:g,onChange:Z=>y(Z.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:[h.jsx("option",{value:"all",children:"All Extruders"}),h.jsx("option",{value:"left",children:"Left Only"}),h.jsx("option",{value:"right",children:"Right Only"})]})}),h.jsx("div",{className:"w-32",children:h.jsxs("select",{value:_,onChange:Z=>v(Z.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:[h.jsx("option",{value:"all",children:"All Flow"}),h.jsx("option",{value:"hf",children:"HF Only"}),h.jsx("option",{value:"s",children:"S Only"})]})}),h.jsx("div",{className:"w-32",children:h.jsxs("select",{value:x,onChange:Z=>M(Z.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:[h.jsx("option",{value:"name",children:"Sort: Name"}),h.jsx("option",{value:"k_value",children:"Sort: K-Value"}),h.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),h.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[h.jsxs(Ye,{variant:"secondary",onClick:xe,disabled:!D?.profiles?.length,title:"Export profiles to JSON",children:[h.jsx(pc,{className:"w-4 h-4"}),"Export"]}),h.jsxs(Ye,{variant:"secondary",onClick:ke,title:"Import profiles from JSON",children:[h.jsx($p,{className:"w-4 h-4"}),"Import"]}),h.jsx("div",{className:"flex-1"}),w?h.jsxs(h.Fragment,{children:[h.jsxs(Ye,{variant:"secondary",onClick:we,title:"Select all visible profiles",children:[h.jsx(Sf,{className:"w-4 h-4"}),"Select All"]}),h.jsxs(Ye,{variant:"secondary",onClick:Ue,disabled:T.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${T.size} selected profiles`,children:[h.jsx(Ei,{className:"w-4 h-4"}),"Delete (",T.size,")"]}),h.jsxs(Ye,{variant:"secondary",onClick:()=>{C(!1),P(new Set)},children:[h.jsx(Sn,{className:"w-4 h-4"}),"Cancel"]})]}):h.jsxs(Ye,{variant:"secondary",onClick:()=>C(!0),disabled:!le.length,title:"Enter selection mode for bulk delete",children:[h.jsx(Sf,{className:"w-4 h-4"}),"Select"]})]}),B?h.jsx("div",{className:"flex justify-center py-12",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):V?h.jsx($t,{children:h.jsxs(Qt,{className:"py-12 text-center",children:[h.jsx(BP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),h.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),h.jsxs(Ye,{variant:"secondary",onClick:()=>X(),children:[h.jsx(wo,{className:"w-4 h-4"}),"Retry"]})]})}):le.length>0?ie?h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),h.jsx("div",{className:"space-y-1",children:le.filter(Z=>Z.extruder_id===1).map(Z=>h.jsx(mN,{profile:Z,onEdit:()=>s(Z),onCopy:()=>u(Z),selectionMode:w,isSelected:T.has(F(Z)),onToggleSelect:()=>he(F(Z)),note:oe(Z)},F(Z)))})]}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),h.jsx("div",{className:"space-y-1",children:le.filter(Z=>Z.extruder_id===0).map(Z=>h.jsx(mN,{profile:Z,onEdit:()=>s(Z),onCopy:()=>u(Z),selectionMode:w,isSelected:T.has(F(Z)),onToggleSelect:()=>he(F(Z)),note:oe(Z)},F(Z)))})]})]}):h.jsx("div",{className:"space-y-1",children:le.map(Z=>h.jsx(mN,{profile:Z,onEdit:()=>s(Z),onCopy:()=>u(Z),selectionMode:w,isSelected:T.has(F(Z)),onToggleSelect:()=>he(F(Z)),note:oe(Z)},F(Z)))}):f||g!=="all"||_!=="all"?h.jsx($t,{children:h.jsxs(Qt,{className:"py-12 text-center",children:[h.jsx(Bp,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),h.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):h.jsx($t,{children:h.jsxs(Qt,{className:"py-12 text-center",children:[h.jsx(UP,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),h.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),h.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",i,"mm nozzle"]}),h.jsxs(Ye,{onClick:()=>l(!0),children:[h.jsx(So,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:Z,key:Q}=q(a);return h.jsx(gN,{profile:a,printerId:e,nozzleDiameter:i,existingProfiles:Y?.profiles||D?.profiles,isDualNozzle:ie,initialNote:Z,initialNoteKey:Q,onSaveNote:H,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),s(null),X()},onSave:()=>{s(null),X()}})})(),o&&e&&h.jsx(gN,{printerId:e,nozzleDiameter:i,existingProfiles:Y?.profiles||D?.profiles,isDualNozzle:ie,onSaveNote:H,onClose:()=>{l(!1),X()},onSave:()=>{l(!1),X()}}),c&&e&&h.jsx(gN,{printerId:e,nozzleDiameter:i,existingProfiles:Y?.profiles||D?.profiles,isDualNozzle:ie,onSaveNote:H,profile:{...c,slot_id:0,name:`${c.name} (Copy)`},onClose:()=>{u(null),X()},onSave:()=>{u(null),X()}}),A&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx($t,{className:"w-full max-w-sm",children:h.jsxs(Qt,{className:"p-6",children:[h.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[h.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:h.jsx(Ei,{className:"w-5 h-5 text-red-500"})}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),h.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",h.jsx("span",{className:"text-white font-medium",children:T.size})," selected profiles from the printer?"]}),h.jsxs("div",{className:"flex gap-3",children:[h.jsx(Ye,{variant:"secondary",onClick:()=>j(!1),disabled:N,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{onClick:ue,disabled:N,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[N?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Ei,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function cL(t,e){const n=`${t} ${e||""}`,i=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),r=i?i[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),s=a?(a[1]||a[2])+"mm":null,o=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),l=o?o[1]+"mm":null,c=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),u=c?c[1].toUpperCase():null;return{printer:r,nozzle:s,layerHeight:l,filamentType:u}}function JJ(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function eee(t){const e=new Date(t),i=new Date().getTime()-e.getTime(),r=Math.floor(i/6e4),a=Math.floor(i/36e5),s=Math.floor(i/864e5);return r<1?"Just now":r<60?`${r}m ago`:a<24?`${a}h ago`:s<7?`${s}d ago`:e.toLocaleDateString()}function uVe({onSuccess:t}){const{showToast:e}=wa(),[n,i]=E.useState("email"),[r,a]=E.useState(""),[s,o]=E.useState(""),[l,c]=E.useState(""),[u,f]=E.useState(""),[m,g]=E.useState("global"),y=Nt({mutationFn:()=>$e.cloudLogin(r,s,m),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")}),_=Nt({mutationFn:()=>$e.cloudVerify(r,l),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=Nt({mutationFn:()=>$e.cloudSetToken(u),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),x=w=>{w.preventDefault(),n==="email"?y.mutate():n==="code"?_.mutate():n==="token"&&v.mutate()},M=y.isPending||_.isPending||v.isPending;return h.jsx($t,{className:"max-w-md mx-auto",children:h.jsxs(Qt,{children:[h.jsxs("div",{className:"text-center mb-6",children:[h.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:h.jsx(IP,{className:"w-6 h-6 text-bambu-green"})}),h.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),h.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),h.jsxs("form",{onSubmit:x,className:"space-y-4",children:[n==="email"&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),h.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 placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"your@email.com",required:!0})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),h.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 placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",placeholder:"••••••••",required:!0})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),h.jsxs("select",{value:m,onChange:w=>g(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:[h.jsx("option",{value:"global",children:"Global"}),h.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),h.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",r,") for a 6-digit code"]}),h.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none",placeholder:"000000",maxLength:6,required:!0})]}),n==="token"&&h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),h.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),h.jsx("textarea",{value:u,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 placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),h.jsxs("div",{className:"flex gap-2",children:[n==="code"&&h.jsx(Ye,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:"Back"}),h.jsxs(Ye,{type:"submit",disabled:M,className:"flex-1",children:[M?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(WU,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&h.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[h.jsx(Yse,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&h.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:h.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[h.jsx(WU,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function sx({label:t,value:e,options:n,onChange:i}){const[r,a]=E.useState(!1),s=n.find(o=>o.value===e);return h.jsxs("div",{className:"relative",children:[h.jsxs("button",{onClick:()=>a(!r),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[h.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),h.jsx("span",{children:s?.label||"All"}),h.jsx(I0,{className:`w-4 h-4 text-bambu-gray transition-transform ${r?"rotate-180":""}`})]}),r&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),h.jsx("div",{className:"absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto",children:n.map(o=>h.jsxs("button",{onClick:()=>{i(o.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===o.value?"text-bambu-green":"text-white"}`,children:[h.jsx("span",{children:o.label}),o.count!==void 0&&h.jsx("span",{className:"text-bambu-gray text-xs",children:o.count})]},o.value))})]})]})}function dVe(){const[t,e]=E.useState(!1);E.useEffect(()=>{const i=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",i),()=>window.removeEventListener("scroll",i)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?h.jsx("button",{onClick:n,className:"fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40","aria-label":"Scroll to top",children:h.jsx(jp,{className:"w-5 h-5"})}):null}function fVe({setting:t,onClick:e,onDuplicate:n}){const i=cL(t.name),r=JJ(t.setting_id),a={filament:{icon:jP,color:"text-amber-400",bg:"bg-amber-500/10"},printer:{icon:Qo,color:"text-purple-400",bg:"bg-purple-500/10"},process:{icon:QS,color:"text-blue-400",bg:"bg-blue-500/10"}},s=a[t.type]||a.process,o=s.icon;return h.jsxs("div",{className:"group relative",children:[h.jsx("button",{onClick:e,className:"w-full text-left p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark shadow-md shadow-black/20 hover:shadow-lg hover:shadow-black/30 transition-all",children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:`p-2 rounded-lg ${s.bg}`,children:h.jsx(o,{className:`w-4 h-4 ${s.color}`})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"text-white font-medium truncate",children:t.name}),r&&h.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"Editable"})]}),h.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[i.printer&&h.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-bambu-dark-tertiary text-bambu-gray-light rounded",children:i.printer}),i.nozzle&&h.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-bambu-dark-tertiary text-bambu-gray-light rounded",children:i.nozzle}),i.layerHeight&&t.type==="process"&&h.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-bambu-dark-tertiary text-bambu-gray-light rounded",children:i.layerHeight}),i.filamentType&&t.type==="filament"&&h.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-bambu-dark-tertiary text-bambu-gray-light rounded",children:i.filamentType})]}),t.updated_time&&h.jsxs("div",{className:"flex items-center gap-1 mt-2 text-xs text-bambu-gray",children:[h.jsx(ar,{className:"w-3 h-3"}),eee(t.updated_time)]})]})]})}),h.jsx("button",{onClick:l=>{l.stopPropagation(),n()},className:"absolute top-2 right-2 p-1.5 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-all",title:"Duplicate",children:h.jsx(Up,{className:"w-3.5 h-3.5"})})]})}function hVe({setting:t,onClose:e,onDeleted:n,onDuplicate:i}){const{showToast:r}=wa(),a=In(),[s,o]=E.useState(!1),[l,c]=E.useState(""),[u,f]=E.useState(!1),{data:m,isLoading:g}=Dt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>$e.getCloudSettingDetail(t.setting_id)});E.useEffect(()=>{m&&l===""&&c(JSON.stringify(m.setting||{},null,2))},[m,l]);const y=Nt({mutationFn:()=>{let M;try{M=JSON.parse(l)}catch{throw new Error("Invalid JSON in settings")}return $e.updateCloudSetting(t.setting_id,{setting:M})},onSuccess:()=>{r("Preset updated successfully"),a.removeQueries({queryKey:["cloudSettingDetail",t.setting_id]}),a.invalidateQueries({queryKey:["cloudSettings"]}),e()},onError:M=>r(M.message,"error")}),_=Nt({mutationFn:()=>$e.deleteCloudSetting(t.setting_id),onSuccess:()=>{r("Preset deleted"),a.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:M=>r(M.message,"error")}),v=JJ(t.setting_id),x=cL(t.name,m?.setting?.inherits);return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx($t,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col",children:h.jsxs(Qt,{className:"p-0 flex flex-col h-full",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),v&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),h.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[h.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),x.printer&&h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"•"}),h.jsx("span",{children:x.printer})]})]})]}),h.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:g?h.jsx("div",{className:"flex items-center justify-center py-16",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):m?s?h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Settings (JSON)"}),h.jsx("textarea",{value:l,onChange:M=>c(M.target.value),className:"w-full h-[400px] 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",spellCheck:!1})]}),m.base_id&&h.jsxs("p",{className:"text-xs text-bambu-gray",children:["Base preset: ",h.jsx("span",{className:"text-white font-mono",children:m.base_id})]})]}):h.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto",children:JSON.stringify(m,null,2)}):h.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),u?h.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[h.jsx(Jo,{className:"w-5 h-5"}),h.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),h.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Ye,{variant:"secondary",onClick:()=>f(!1),disabled:_.isPending,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{variant:"danger",onClick:()=>_.mutate(),disabled:_.isPending,className:"flex-1",children:[_.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Ei,{className:"w-4 h-4"}),"Delete"]})]})]}):h.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s?h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Ye,{variant:"secondary",onClick:()=>{o(!1),m&&c(JSON.stringify(m.setting||{},null,2))},disabled:y.isPending,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{onClick:()=>y.mutate(),disabled:y.isPending,className:"flex-1",children:[y.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(Sm,{className:"w-4 h-4"}),"Save"]})]}):h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Ye,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),h.jsxs(Ye,{variant:"secondary",onClick:i,children:[h.jsx(Up,{className:"w-4 h-4"}),"Duplicate"]}),v&&h.jsxs(h.Fragment,{children:[h.jsxs(Ye,{variant:"secondary",onClick:()=>o(!0),disabled:g||!m,children:[h.jsx(zp,{className:"w-4 h-4"}),"Edit"]}),h.jsx(Ye,{variant:"danger",onClick:()=>f(!0),children:h.jsx(Ei,{className:"w-4 h-4"})})]})]})})]})})})}function pVe({onClose:t,initialData:e,allPresets:n}){const{showToast:i}=wa(),r=In(),[a,s]=E.useState(e?.type||"filament"),[o,l]=E.useState(e?.name?`${e.name} (Copy)`:""),[c,u]=E.useState(e?.base_id||""),[f,m]=E.useState(e?.setting?JSON.stringify(e.setting,null,2):`{
- "inherits": ""
- }`),g=E.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[a]||[]).sort((v,x)=>v.name.localeCompare(x.name)),[n,a]),y=Nt({mutationFn:()=>{let _;try{_=JSON.parse(f)}catch{throw new Error("Invalid JSON in settings")}const v=a==="filament"?"filament_settings_id":a==="print"?"print_settings_id":"printer_settings_id";_[v]=`"${o}"`;const x={type:a,name:o,base_id:c,setting:_};return $e.createCloudSetting(x)},onSuccess:()=>{i("Preset created successfully"),r.invalidateQueries({queryKey:["cloudSettings"]}),t()},onError:_=>i(_.message,"error")});return h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:h.jsx($t,{className:"w-full max-w-2xl",children:h.jsxs(Qt,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-xl font-semibold text-white",children:e?"Duplicate Preset":"Create New Preset"}),h.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Add a new preset to your Bambu Cloud"})]}),h.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:h.jsx(Sn,{className:"w-5 h-5"})})]}),h.jsxs("div",{className:"p-4 space-y-4",children:[h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),h.jsxs("select",{value:a,onChange:_=>s(_.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:[h.jsx("option",{value:"filament",children:"Filament"}),h.jsx("option",{value:"print",children:"Process"}),h.jsx("option",{value:"printer",children:"Printer"})]})]}),h.jsxs("div",{children:[h.jsxs("label",{className:"block text-sm text-bambu-gray mb-1 flex items-center gap-1.5",children:["Base Preset",h.jsxs("span",{className:"relative group/tooltip",children:[h.jsx(rse,{className:"w-3.5 h-3.5 text-bambu-gray-dark hover:text-bambu-gray cursor-help"}),h.jsxs("span",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-xs text-bambu-gray-light whitespace-nowrap opacity-0 group-hover/tooltip:opacity-100 pointer-events-none transition-opacity shadow-lg z-10",children:["The parent preset this new preset",h.jsx("br",{}),"will inherit settings from."]})]})]}),h.jsxs("select",{value:c,onChange:_=>u(_.target.value),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",children:[h.jsx("option",{value:"",children:"Select a base preset..."}),g.map(_=>h.jsx("option",{value:_.setting_id,children:_.name},_.setting_id))]})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),h.jsx("input",{type:"text",value:o,onChange:_=>l(_.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:"My Custom Preset"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Settings (JSON)"}),h.jsx("textarea",{value:f,onChange:_=>m(_.target.value),className:"w-full h-48 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",spellCheck:!1})]})]}),h.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[h.jsx(Ye,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),h.jsxs(Ye,{onClick:()=>y.mutate(),disabled:y.isPending||!o.trim()||!c,className:"flex-1",children:[y.isPending?h.jsx(Ht,{className:"w-4 h-4 animate-spin"}):h.jsx(So,{className:"w-4 h-4"}),e?"Duplicate":"Create"]})]})]})})})}function mVe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:i,printers:r}){const[a,s]=E.useState(""),[o,l]=E.useState("all"),[c,u]=E.useState("all"),[f,m]=E.useState("all"),[g,y]=E.useState("all"),[_,v]=E.useState("all"),[x,M]=E.useState(null),[w,C]=E.useState(!1),[T,P]=E.useState(null),A=In(),j=E.useMemo(()=>[...t.filament.map(Y=>({...Y,type:"filament"})),...t.printer.map(Y=>({...Y,type:"printer"})),...t.process.map(Y=>({...Y,type:"process"}))].map(Y=>({...Y,meta:cL(Y.name)})),[t]),N=E.useMemo(()=>{const X=new Set,Y=new Set,ee=new Set;return j.forEach(z=>{z.meta.nozzle&&X.add(z.meta.nozzle),z.meta.filamentType&&Y.add(z.meta.filamentType),z.meta.layerHeight&&ee.add(z.meta.layerHeight)}),{printers:r.map(z=>({id:z.id.toString(),name:z.name})),nozzles:Array.from(X).sort((z,V)=>parseFloat(z)-parseFloat(V)),filaments:Array.from(Y).sort(),layerHeights:Array.from(ee).sort((z,V)=>parseFloat(z)-parseFloat(V))}},[j,r]),k=E.useMemo(()=>c==="all"?null:r.find(Y=>Y.id.toString()===c)?.model||null,[c,r]),F=E.useMemo(()=>j.filter(X=>o==="all"||X.type===o).filter(X=>{if(c==="all"||!k)return!0;const Y=X.meta.printer?.toLowerCase()||"",ee=k.toLowerCase();return Y.includes(ee)||ee.includes(Y)}).filter(X=>f==="all"||X.meta.nozzle===f).filter(X=>g==="all"||X.meta.filamentType===g).filter(X=>_==="all"||X.meta.layerHeight===_).filter(X=>a===""||X.name.toLowerCase().includes(a.toLowerCase())).sort((X,Y)=>X.name.localeCompare(Y.name)),[j,o,c,k,f,g,_,a]),I=E.useMemo(()=>o!=="all"?{[o]:F}:{filament:F.filter(X=>X.type==="filament"),printer:F.filter(X=>X.type==="printer"),process:F.filter(X=>X.type==="process")},[F,o]),W=async X=>{try{const Y=await A.fetchQuery({queryKey:["cloudSettingDetail",X.setting_id],queryFn:()=>$e.getCloudSettingDetail(X.setting_id)}),ee=X.type==="process"?"print":X.type;P({type:ee,name:X.name,base_id:Y.base_id||"GFSA00",setting:Y.setting||{}}),M(null)}catch(Y){console.error("Failed to fetch preset details for duplication:",Y)}},D=()=>{l("all"),u("all"),m("all"),y("all"),v("all"),s("")},B=o!=="all"||c!=="all"||f!=="all"||g!=="all"||_!=="all"||a!=="",$={filament:{label:"Filament",icon:jP,color:"text-amber-400"},printer:{label:"Printer",icon:Qo,color:"text-purple-400"},process:{label:"Process",icon:QS,color:"text-blue-400"}},K=t.filament.length+t.printer.length+t.process.length;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"space-y-4 mb-6",children:[h.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[h.jsxs("div",{className:"relative flex-1",children:[h.jsx(Bp,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),h.jsx("input",{type:"text",value:a,onChange:X=>s(X.target.value),placeholder:"Search presets...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs(Ye,{variant:"secondary",onClick:n,disabled:i,children:[h.jsx(wo,{className:`w-4 h-4 ${i?"animate-spin":""}`}),"Refresh"]}),h.jsxs(Ye,{onClick:()=>C(!0),children:[h.jsx(So,{className:"w-4 h-4"}),"New Preset"]})]})]}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(XG,{className:"w-4 h-4 text-bambu-gray"}),h.jsx(sx,{label:"Type",value:o,options:[{value:"all",label:"All",count:K},{value:"filament",label:"Filament",count:t.filament.length},{value:"printer",label:"Printer",count:t.printer.length},{value:"process",label:"Process",count:t.process.length}],onChange:X=>l(X)}),N.printers.length>0&&h.jsx(sx,{label:"Printer",value:c,options:[{value:"all",label:"All"},...N.printers.map(X=>({value:X.id,label:X.name}))],onChange:u}),N.nozzles.length>0&&h.jsx(sx,{label:"Nozzle",value:f,options:[{value:"all",label:"All"},...N.nozzles.map(X=>({value:X,label:X}))],onChange:m}),N.filaments.length>0&&(o==="all"||o==="filament")&&h.jsx(sx,{label:"Filament",value:g,options:[{value:"all",label:"All"},...N.filaments.map(X=>({value:X,label:X}))],onChange:y}),N.layerHeights.length>0&&(o==="all"||o==="process")&&h.jsx(sx,{label:"Layer",value:_,options:[{value:"all",label:"All"},...N.layerHeights.map(X=>({value:X,label:X}))],onChange:v}),B&&h.jsx("button",{onClick:D,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),e&&h.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray mb-4",children:[h.jsx(ar,{className:"w-3 h-3"}),"Last synced: ",eee(e.toISOString())]}),h.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Showing ",F.length," of ",K," presets"]}),F.length===0?h.jsxs("div",{className:"text-center py-16",children:[h.jsx(Fp,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),h.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),B&&h.jsx("button",{onClick:D,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):h.jsx("div",{className:"space-y-8",children:Object.entries(I).map(([X,Y])=>{if(Y.length===0)return null;const{label:ee,icon:z,color:V}=$[X];return h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[h.jsx(z,{className:`w-5 h-5 ${V}`}),h.jsx("h3",{className:"text-lg font-semibold text-white",children:ee}),h.jsxs("span",{className:"text-sm text-bambu-gray",children:["(",Y.length,")"]})]}),h.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:Y.map(re=>h.jsx(fVe,{setting:re,onClick:()=>M(re),onDuplicate:()=>W(re)},re.setting_id))})]},X)})}),x&&h.jsx(hVe,{setting:x,onClose:()=>M(null),onDeleted:()=>M(null),onDuplicate:()=>W(x)}),(w||T)&&h.jsx(pVe,{onClose:()=>{C(!1),P(null)},initialData:T||void 0,allPresets:t})]})}function gVe(){const t=In(),{showToast:e}=wa(),[n,i]=E.useState("cloud"),[r,a]=E.useState(),{data:s,isLoading:o}=Dt({queryKey:["cloudStatus"],queryFn:$e.getCloudStatus}),{data:l=[]}=Dt({queryKey:["printers"],queryFn:$e.getPrinters}),{data:c,isLoading:u,refetch:f,dataUpdatedAt:m}=Dt({queryKey:["cloudSettings"],queryFn:()=>$e.getCloudSettings(),enabled:!!s?.is_authenticated,retry:!1,staleTime:1e3*60*5});E.useEffect(()=>{m&&a(new Date(m))},[m]);const g=Nt({mutationFn:$e.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),y=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return o?h.jsx("div",{className:"p-8 flex items-center justify-center min-h-[400px]",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h.jsxs("div",{className:"p-6 lg:p-8",children:[h.jsxs("div",{className:"mb-6",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),h.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),h.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[h.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:[h.jsx(IP,{className:"w-4 h-4"}),"Cloud Profiles"]}),h.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:[h.jsx(UP,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&h.jsxs(h.Fragment,{children:[s?.is_authenticated&&h.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),h.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",h.jsx("span",{className:"text-white",children:s.email})]})]}),h.jsxs(Ye,{variant:"secondary",size:"sm",onClick:()=>g.mutate(),disabled:g.isPending,children:[h.jsx(foe,{className:"w-4 h-4"}),"Logout"]})]}),s?.is_authenticated?u?h.jsx("div",{className:"flex items-center justify-center py-16",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})}):c?h.jsx(mVe,{settings:c,lastSyncTime:r,onRefresh:()=>f(),isRefreshing:u,printers:l}):h.jsxs("div",{className:"text-center py-16",children:[h.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),h.jsx(Ye,{onClick:()=>f(),children:"Retry"})]}):h.jsx(uVe,{onSuccess:y})]}),n==="kprofiles"&&h.jsx(cVe,{}),h.jsx(dVe,{})]})}const wP={Droplet:jP,Flame:Ose,Ruler:Foe,Sparkles:ele,Square:Hp,Cable:Hae,Wrench:Vp};function L_(t){return t&&wP[t]||Vp}function zx(t){return t<1?`${Math.round(t*60)}m`:`${t.toFixed(1)}h`}function xVe(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 vVe({item:t,onPerform:e,onToggle:n}){const i=L_(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 ${zx(Math.abs(t.hours_until_due))}`:t.is_warning?`Due in ${zx(t.hours_until_due)}`:`${zx(t.hours_until_due)} left`:"Disabled";return h.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:[h.jsxs("div",{className:"flex items-center gap-3 min-w-[180px]",children:[h.jsx(i,{className:`w-4 h-4 ${a()}`}),h.jsx("span",{className:`text-sm ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name})]}),h.jsx("div",{className:"flex-1 max-w-[200px]",children:h.jsx("div",{className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:h.jsx("div",{className:`h-full transition-all ${s()}`,style:{width:`${r}%`}})})}),h.jsxs("div",{className:`text-xs min-w-[120px] ${a()}`,children:[t.is_due&&h.jsx(Jo,{className:"w-3 h-3 inline mr-1"}),t.is_warning&&h.jsx(ar,{className:"w-3 h-3 inline mr-1"}),!t.is_due&&!t.is_warning&&t.enabled&&h.jsx(Wx,{className:"w-3 h-3 inline mr-1"}),o()]}),h.jsx(is,{checked:t.enabled,onChange:l=>n(t.id,l)}),h.jsxs(Ye,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"min-w-[70px]",children:[h.jsx(ZS,{className:"w-3 h-3"}),"Done"]})]})}function yVe({overview:t,onPerform:e,onToggle:n,onSetHours:i}){const[r,a]=E.useState(!1),[s,o]=E.useState(!1),[l,c]=E.useState(t.total_print_hours.toFixed(1)),u=[...t.maintenance_items].sort((g,y)=>g.maintenance_type_id-y.maintenance_type_id),f=[...t.maintenance_items].filter(g=>g.enabled).sort((g,y)=>g.is_due&&!y.is_due?-1:!g.is_due&&y.is_due?1:g.is_warning&&!y.is_warning?-1:!g.is_warning&&y.is_warning?1:g.hours_until_due-y.hours_until_due)[0],m=()=>{const g=parseFloat(l);!isNaN(g)&&g>=0&&(i(t.printer_id,g),o(!1))};return h.jsxs($t,{children:[h.jsxs("div",{className:"p-4",children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:t.printer_name}),t.due_count>0&&h.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:[h.jsx(Jo,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&h.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:[h.jsx(ar,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&h.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:[h.jsx(Wx,{className:"w-3 h-3"}),"All good"]})]}),h.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?h.jsxs(h.Fragment,{children:[h.jsx(WG,{className:"w-4 h-4"}),"Hide"]}):h.jsxs(h.Fragment,{children:[h.jsx(I0,{className:"w-4 h-4"}),"Details"]})})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[h.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[h.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Total Print Time"}),s?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"number",value:l,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&m(),g.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}),h.jsx("span",{className:"text-sm text-bambu-gray",children:"hours"}),h.jsxs("div",{className:"flex gap-1 ml-auto",children:[h.jsx(Ye,{size:"sm",onClick:m,children:"Save"}),h.jsx(Ye,{size:"sm",variant:"secondary",onClick:()=>o(!1),children:"✕"})]})]}):h.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:[h.jsx("span",{className:"text-xl font-semibold text-white group-hover:text-bambu-green transition-colors",children:xVe(t.total_print_hours)}),h.jsx(zP,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})]})]}),h.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:[h.jsx("div",{className:"text-xs text-bambu-gray mb-1 uppercase tracking-wide",children:"Next Maintenance"}),f?h.jsxs("div",{children:[h.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}),h.jsx("div",{className:`text-sm ${f.is_due?"text-red-400":f.is_warning?"text-yellow-400":"text-bambu-gray"}`,children:f.is_due?h.jsxs(h.Fragment,{children:["Overdue by ",zx(Math.abs(f.hours_until_due))]}):h.jsxs(h.Fragment,{children:["Due in ",zx(f.hours_until_due)]})})]}):h.jsx("div",{className:"text-white",children:"No tasks enabled"})]})]})]}),r&&h.jsx(Qt,{className:"pt-0 space-y-2 border-t border-bambu-dark-tertiary mt-4",children:h.jsx("div",{className:"pt-4",children:u.map(g=>h.jsx(vVe,{item:g,onPerform:e,onToggle:n},g.id))})})]})}function bVe({overview:t,types:e,onUpdateInterval:n,onAddType:i,onDeleteType:r}){const[a,s]=E.useState(null),[o,l]=E.useState(""),[c,u]=E.useState(!1),[f,m]=E.useState(""),[g,y]=E.useState("100"),[_,v]=E.useState("Wrench"),x=(P,A)=>{const j=parseFloat(o);if(!isNaN(j)&&j>0){const N=Math.abs(j-A)<.01?null:j;n(P,N)}s(null)},M=P=>{P.preventDefault(),f.trim()&&parseFloat(g)>0&&(i({name:f.trim(),default_interval_hours:parseFloat(g),icon:_}),m(""),y("100"),u(!1))},w=t?.map(P=>({printerId:P.printer_id,printerName:P.printer_name,items:P.maintenance_items.sort((A,j)=>A.maintenance_type_id-j.maintenance_type_id)})).sort((P,A)=>P.printerName.localeCompare(A.printerName))||[],C=e.filter(P=>P.is_system),T=e.filter(P=>!P.is_system);return h.jsxs("div",{className:"space-y-8",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-4",children:[h.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),h.jsxs(Ye,{size:"sm",variant:"secondary",onClick:()=>u(!c),children:[h.jsx(So,{className:"w-4 h-4"}),"Add Custom Type"]})]}),c&&h.jsx($t,{className:"mb-4",children:h.jsx("div",{className:"p-4",children:h.jsx("form",{onSubmit:M,children:h.jsxs("div",{className:"flex gap-3 items-end",children:[h.jsxs("div",{className:"flex-1",children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Name"}),h.jsx("input",{type:"text",value:f,onChange:P=>m(P.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),h.jsxs("div",{className:"w-28",children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Interval (hours)"}),h.jsx("input",{type:"number",value:g,onChange:P=>y(P.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"1"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Icon"}),h.jsx("div",{className:"flex gap-1",children:Object.keys(wP).map(P=>{const A=wP[P];return h.jsx("button",{type:"button",onClick:()=>v(P),className:`p-2 rounded ${_===P?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:h.jsx(A,{className:"w-4 h-4"})},P)})})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(Ye,{type:"submit",size:"sm",disabled:!f.trim(),children:"Add"}),h.jsx(Ye,{type:"button",size:"sm",variant:"secondary",onClick:()=>u(!1),children:"Cancel"})]})]})})})}),h.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[C.map(P=>{const A=L_(P.icon);return h.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-dark-tertiary",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"p-2 bg-bambu-dark rounded-lg",children:h.jsx(A,{className:"w-5 h-5 text-bambu-gray"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-sm font-medium text-white truncate",children:P.name}),h.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[P.default_interval_hours,"h interval"]})]})]})},P.id)}),T.map(P=>{const A=L_(P.icon);return h.jsx("div",{className:"bg-bambu-dark-secondary rounded-lg p-4 border border-bambu-green/30",children:h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx("div",{className:"p-2 bg-bambu-green/20 rounded-lg",children:h.jsx(A,{className:"w-5 h-5 text-bambu-green"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-medium text-white truncate",children:P.name}),h.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),h.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5",children:[P.default_interval_hours,"h interval"]})]}),h.jsx("button",{onClick:()=>{confirm(`Delete "${P.name}"?`)&&r(P.id)},className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:h.jsx(Ei,{className:"w-4 h-4"})})]})},P.id)})]})]}),w.length>0&&h.jsxs("div",{children:[h.jsx("h2",{className:"text-lg font-semibold text-white mb-2",children:"Interval Overrides"}),h.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Set custom intervals per printer."}),h.jsx("div",{className:"space-y-3",children:w.map(P=>h.jsx($t,{children:h.jsxs("div",{className:"p-4",children:[h.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:P.printerName}),h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:P.items.map(A=>{const j=L_(A.maintenance_type_icon),k=e.find(I=>I.id===A.maintenance_type_id)?.default_interval_hours||A.interval_hours,F=a===A.id;return h.jsxs("div",{className:"flex items-center gap-2 p-2 bg-bambu-dark rounded-lg",children:[h.jsx(j,{className:"w-4 h-4 text-bambu-gray shrink-0"}),h.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:A.maintenance_type_name}),F?h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("input",{type:"number",value:o,onChange:I=>l(I.target.value),onKeyDown:I=>{I.key==="Enter"&&x(A.id,k),I.key==="Escape"&&s(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1",autoFocus:!0}),h.jsx(Ye,{size:"sm",onClick:()=>x(A.id,k),children:"OK"})]}):h.jsxs("button",{onClick:()=>{s(A.id),l(A.interval_hours.toString())},className:"px-2 py-1 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green rounded text-xs font-medium text-white transition-colors",children:[A.interval_hours,"h",h.jsx(zP,{className:"w-3 h-3 inline ml-1.5 text-bambu-gray"})]})]},A.id)})})]})},P.printerId))})]}),w.length===0&&h.jsx($t,{children:h.jsxs(Qt,{className:"text-center py-12",children:[h.jsx(ar,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),h.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),h.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function _Ve(){const t=In(),{showToast:e}=wa(),[n,i]=E.useState("status"),{data:r,isLoading:a}=Dt({queryKey:["maintenanceOverview"],queryFn:$e.getMaintenanceOverview}),{data:s}=Dt({queryKey:["maintenanceTypes"],queryFn:$e.getMaintenanceTypes}),o=Nt({mutationFn:({id:x,notes:M})=>$e.performMaintenance(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as done")},onError:x=>{e(x.message,"error")}}),l=Nt({mutationFn:({id:x,data:M})=>$e.updateMaintenanceItem(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:x=>{e(x.message,"error")}}),c=Nt({mutationFn:$e.createMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onError:x=>{e(x.message,"error")}}),u=Nt({mutationFn:$e.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:x=>{e(x.message,"error")}}),f=Nt({mutationFn:({printerId:x,hours:M})=>$e.setPrinterHours(x,M),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:x=>{e(x.message,"error")}}),m=x=>{o.mutate({id:x})},g=(x,M)=>{l.mutate({id:x,data:{enabled:M}})},y=(x,M)=>{f.mutate({printerId:x,hours:M})};if(a)return h.jsx("div",{className:"p-8 flex justify-center",children:h.jsx(Ht,{className:"w-8 h-8 text-bambu-green animate-spin"})});const _=r?.reduce((x,M)=>x+M.due_count,0)||0,v=r?.reduce((x,M)=>x+M.warning_count,0)||0;return h.jsxs("div",{className:"p-8",children:[h.jsxs("div",{className:"mb-6",children:[h.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),h.jsx("p",{className:"text-bambu-gray text-sm",children:n==="status"?h.jsxs(h.Fragment,{children:[_>0&&h.jsxs("span",{className:"text-red-400",children:[_," tasks overdue"]}),_>0&&v>0&&" · ",v>0&&h.jsxs("span",{className:"text-yellow-400",children:[v," due soon"]}),_===0&&v===0&&"All maintenance up to date"]}):"Configure maintenance types and intervals"})]}),h.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[h.jsx("button",{onClick:()=>i("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Status"}),h.jsx("button",{onClick:()=>i("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${n==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:"Settings"})]}),n==="status"?h.jsx("div",{className:"space-y-4",children:r&&r.length>0?[...r].sort((x,M)=>x.printer_name.localeCompare(M.printer_name)).map(x=>h.jsx(yVe,{overview:x,onPerform:m,onToggle:g,onSetHours:y},x.printer_id)):h.jsx($t,{children:h.jsxs(Qt,{className:"text-center py-12",children:[h.jsx(Vp,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),h.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),h.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to start tracking maintenance"})]})})}):h.jsx(bVe,{overview:r,types:s||[],onUpdateInterval:(x,M)=>l.mutate({id:x,data:{custom_interval_hours:M}}),onAddType:x=>c.mutate(x),onDeleteType:x=>u.mutate(x)})]})}function SVe(){const{printerId:t}=Yie(),e=parseInt(t||"0",10),[n,i]=E.useState("stream"),[r,a]=E.useState(!1),[s,o]=E.useState(!0),[l,c]=E.useState(Date.now()),[u,f]=E.useState(!1),[m,g]=E.useState(!1),y=E.useRef(null),_=E.useRef(null),{data:v}=Dt({queryKey:["printer",e],queryFn:()=>$e.getPrinter(e),enabled:e>0});E.useEffect(()=>(v&&(document.title=`${v.name} - Camera`),()=>{document.title="Bambusy"}),[v]),E.useEffect(()=>()=>{y.current&&(y.current.src="")},[]),E.useEffect(()=>{if(s&&!u){const N=setTimeout(()=>{o(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(N)}},[n,s,l,u]),E.useEffect(()=>{const j=()=>{g(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",j),()=>document.removeEventListener("fullscreenchange",j)},[]);const x=()=>{a(!0),o(!1)},M=()=>{o(!1),a(!1)},w=j=>{n===j||u||(f(!0),o(!0),a(!1),y.current&&(y.current.src=""),setTimeout(()=>{i(j),c(Date.now()),f(!1)},100))},C=()=>{u||(f(!0),o(!0),a(!1),y.current&&(y.current.src=""),setTimeout(()=>{c(Date.now()),f(!1)},100))},T=()=>{_.current&&(document.fullscreenElement?document.exitFullscreen():_.current.requestFullscreen())},P=u?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${l}`:`/api/v1/printers/${e}/camera/snapshot?t=${l}`,A=s||u;return e?h.jsxs("div",{ref:_,className:"min-h-screen bg-black flex flex-col",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[h.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[h.jsx(H_,{className:"w-4 h-4"}),v?.name||`Printer ${e}`]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[h.jsx("button",{onClick:()=>w("stream"),disabled:A,className:`px-3 py-1 text-xs rounded transition-colors ${n==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Live"}),h.jsx("button",{onClick:()=>w("snapshot"),disabled:A,className:`px-3 py-1 text-xs rounded transition-colors ${n==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:"Snapshot"})]}),h.jsx("button",{onClick:C,disabled:A,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:h.jsx(wo,{className:`w-4 h-4 text-bambu-gray ${A?"animate-spin":""}`})}),h.jsx("button",{onClick:T,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:m?"Exit fullscreen":"Fullscreen",children:m?h.jsx(boe,{className:"w-4 h-4 text-bambu-gray"}):h.jsx(goe,{className:"w-4 h-4 text-bambu-gray"})})]})]}),h.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:h.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(s||u)&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:h.jsxs("div",{className:"text-center",children:[h.jsx(wo,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),h.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),r&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:h.jsxs("div",{className:"text-center p-4",children:[h.jsx(Jo,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),h.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),h.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),h.jsx("button",{onClick:C,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),h.jsx("img",{ref:y,src:P,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:P?x:void 0,onLoad:P?M:void 0},l)]})})]}):h.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:h.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function wVe(){const t=E.useRef(null),e=E.useRef(null),n=In(),[i,r]=E.useState(!1),a=E.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const c=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,u=new WebSocket(c);let f=null;u.onopen=()=>{console.log("[WebSocket] Connected"),r(!0),f=window.setInterval(()=>{u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({type:"ping"}))},3e4)},u.onmessage=m=>{try{const g=JSON.parse(m.data);s(g)}catch{}},u.onclose=m=>{console.log("[WebSocket] Closed",m.code,m.reason),f&&(clearInterval(f),f=null),r(!1),t.current=null,e.current=window.setTimeout(()=>{a()},3e3)},u.onerror=m=>{console.error("[WebSocket] Error",m),u.close()},t.current=u},[]),s=E.useCallback(l=>{switch(l.type){case"printer_status":l.printer_id!==void 0&&n.setQueryData(["printerStatus",l.printer_id],c=>{const u={...c,...l.data};return u.wifi_signal==null&&c?.wifi_signal!=null&&(u.wifi_signal=c.wifi_signal),u});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]);E.useEffect(()=>(a(),()=>{e.current&&clearTimeout(e.current),t.current&&t.current.close()}),[a]);const o=E.useCallback(l=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(l))},[]);return{isConnected:i,sendMessage:o}}const MVe=new hae({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function EVe({children:t}){return wVe(),h.jsx(h.Fragment,{children:t})}function AVe(){return h.jsx(jle,{children:h.jsx(Wle,{children:h.jsx(pae,{client:MVe,children:h.jsx(EVe,{children:h.jsx(Lre,{children:h.jsxs(fre,{children:[h.jsx(jo,{path:"/camera/:printerId",element:h.jsx(SVe,{})}),h.jsxs(jo,{path:"/",element:h.jsx($le,{}),children:[h.jsx(jo,{index:!0,element:h.jsx(Sce,{})}),h.jsx(jo,{path:"archives",element:h.jsx(X2e,{})}),h.jsx(jo,{path:"queue",element:h.jsx(DNe,{})}),h.jsx(jo,{path:"stats",element:h.jsx(Z$e,{})}),h.jsx(jo,{path:"profiles",element:h.jsx(gVe,{})}),h.jsx(jo,{path:"maintenance",element:h.jsx(_Ve,{})}),h.jsx(jo,{path:"settings",element:h.jsx(sVe,{})})]})]})})})})})})}mne.createRoot(document.getElementById("root")).render(h.jsx(E.StrictMode,{children:h.jsx(AVe,{})}));
|