| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663 |
- function Rie(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}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 i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Fv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Co(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rA={exports:{}},kx={};var HF;function Die(){if(HF)return kx;HF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:a}}return kx.Fragment=e,kx.jsx=n,kx.jsxs=n,kx}var VF;function Oie(){return VF||(VF=1,rA.exports=Die()),rA.exports}var s=Oie(),iA={exports:{}},on={};var GF;function Lie(){if(GF)return on;GF=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),p=Symbol.iterator;function g(F){return F===null||typeof F!="object"?null:(F=p&&F[p]||F["@@iterator"],typeof F=="function"?F:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,x={};function y(F,q,ne){this.props=F,this.context=q,this.refs=x,this.updater=ne||b}y.prototype.isReactComponent={},y.prototype.setState=function(F,q){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,q,"setState")},y.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function E(){}E.prototype=y.prototype;function w(F,q,ne){this.props=F,this.context=q,this.refs=x,this.updater=ne||b}var A=w.prototype=new E;A.constructor=w,v(A,y.prototype),A.isPureReactComponent=!0;var N=Array.isArray;function C(){}var T={H:null,A:null,T:null,S:null},D=Object.prototype.hasOwnProperty;function k(F,q,ne){var re=ne.ref;return{$$typeof:t,type:F,key:q,ref:re!==void 0?re:null,props:ne}}function P(F,q){return k(F.type,q,F.props)}function z(F){return typeof F=="object"&&F!==null&&F.$$typeof===t}function L(F){var q={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(ne){return q[ne]})}var X=/\/+/g;function R(F,q){return typeof F=="object"&&F!==null&&F.key!=null?L(""+F.key):q.toString(36)}function Y(F){switch(F.status){case"fulfilled":return F.value;case"rejected":throw F.reason;default:switch(typeof F.status=="string"?F.then(C,C):(F.status="pending",F.then(function(q){F.status==="pending"&&(F.status="fulfilled",F.value=q)},function(q){F.status==="pending"&&(F.status="rejected",F.reason=q)})),F.status){case"fulfilled":return F.value;case"rejected":throw F.reason}}throw F}function J(F,q,ne,re,se){var de=typeof F;(de==="undefined"||de==="boolean")&&(F=null);var pe=!1;if(F===null)pe=!0;else switch(de){case"bigint":case"string":case"number":pe=!0;break;case"object":switch(F.$$typeof){case t:case e:pe=!0;break;case d:return pe=F._init,J(pe(F._payload),q,ne,re,se)}}if(pe)return se=se(F),pe=re===""?"."+R(F,0):re,N(se)?(ne="",pe!=null&&(ne=pe.replace(X,"$&/")+"/"),J(se,q,ne,"",function(ae){return ae})):se!=null&&(z(se)&&(se=P(se,ne+(se.key==null||F&&F.key===se.key?"":(""+se.key).replace(X,"$&/")+"/")+pe)),q.push(se)),1;pe=0;var Ce=re===""?".":re+":";if(N(F))for(var oe=0;oe<F.length;oe++)re=F[oe],de=Ce+R(re,oe),pe+=J(re,q,ne,de,se);else if(oe=g(F),typeof oe=="function")for(F=oe.call(F),oe=0;!(re=F.next()).done;)re=re.value,de=Ce+R(re,oe++),pe+=J(re,q,ne,de,se);else if(de==="object"){if(typeof F.then=="function")return J(Y(F),q,ne,re,se);throw q=String(F),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return pe}function G(F,q,ne){if(F==null)return F;var re=[],se=0;return J(F,re,"","",function(de){return q.call(ne,de,se++)}),re}function W(F){if(F._status===-1){var q=F._result;q=q(),q.then(function(ne){(F._status===0||F._status===-1)&&(F._status=1,F._result=ne)},function(ne){(F._status===0||F._status===-1)&&(F._status=2,F._result=ne)}),F._status===-1&&(F._status=0,F._result=q)}if(F._status===1)return F._result.default;throw F._result}var ee=typeof reportError=="function"?reportError:function(F){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof F=="object"&&F!==null&&typeof F.message=="string"?String(F.message):String(F),error:F});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",F);return}console.error(F)},K={map:G,forEach:function(F,q,ne){G(F,function(){q.apply(this,arguments)},ne)},count:function(F){var q=0;return G(F,function(){q++}),q},toArray:function(F){return G(F,function(q){return q})||[]},only:function(F){if(!z(F))throw Error("React.Children.only expected to receive a single React element child.");return F}};return on.Activity=f,on.Children=K,on.Component=y,on.Fragment=n,on.Profiler=i,on.PureComponent=w,on.StrictMode=r,on.Suspense=c,on.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,on.__COMPILER_RUNTIME={__proto__:null,c:function(F){return T.H.useMemoCache(F)}},on.cache=function(F){return function(){return F.apply(null,arguments)}},on.cacheSignal=function(){return null},on.cloneElement=function(F,q,ne){if(F==null)throw Error("The argument must be a React element, but you passed "+F+".");var re=v({},F.props),se=F.key;if(q!=null)for(de in q.key!==void 0&&(se=""+q.key),q)!D.call(q,de)||de==="key"||de==="__self"||de==="__source"||de==="ref"&&q.ref===void 0||(re[de]=q[de]);var de=arguments.length-2;if(de===1)re.children=ne;else if(1<de){for(var pe=Array(de),Ce=0;Ce<de;Ce++)pe[Ce]=arguments[Ce+2];re.children=pe}return k(F.type,se,re)},on.createContext=function(F){return F={$$typeof:o,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null},F.Provider=F,F.Consumer={$$typeof:a,_context:F},F},on.createElement=function(F,q,ne){var re,se={},de=null;if(q!=null)for(re in q.key!==void 0&&(de=""+q.key),q)D.call(q,re)&&re!=="key"&&re!=="__self"&&re!=="__source"&&(se[re]=q[re]);var pe=arguments.length-2;if(pe===1)se.children=ne;else if(1<pe){for(var Ce=Array(pe),oe=0;oe<pe;oe++)Ce[oe]=arguments[oe+2];se.children=Ce}if(F&&F.defaultProps)for(re in pe=F.defaultProps,pe)se[re]===void 0&&(se[re]=pe[re]);return k(F,de,se)},on.createRef=function(){return{current:null}},on.forwardRef=function(F){return{$$typeof:l,render:F}},on.isValidElement=z,on.lazy=function(F){return{$$typeof:d,_payload:{_status:-1,_result:F},_init:W}},on.memo=function(F,q){return{$$typeof:u,type:F,compare:q===void 0?null:q}},on.startTransition=function(F){var q=T.T,ne={};T.T=ne;try{var re=F(),se=T.S;se!==null&&se(ne,re),typeof re=="object"&&re!==null&&typeof re.then=="function"&&re.then(C,ee)}catch(de){ee(de)}finally{q!==null&&ne.types!==null&&(q.types=ne.types),T.T=q}},on.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},on.use=function(F){return T.H.use(F)},on.useActionState=function(F,q,ne){return T.H.useActionState(F,q,ne)},on.useCallback=function(F,q){return T.H.useCallback(F,q)},on.useContext=function(F){return T.H.useContext(F)},on.useDebugValue=function(){},on.useDeferredValue=function(F,q){return T.H.useDeferredValue(F,q)},on.useEffect=function(F,q){return T.H.useEffect(F,q)},on.useEffectEvent=function(F){return T.H.useEffectEvent(F)},on.useId=function(){return T.H.useId()},on.useImperativeHandle=function(F,q,ne){return T.H.useImperativeHandle(F,q,ne)},on.useInsertionEffect=function(F,q){return T.H.useInsertionEffect(F,q)},on.useLayoutEffect=function(F,q){return T.H.useLayoutEffect(F,q)},on.useMemo=function(F,q){return T.H.useMemo(F,q)},on.useOptimistic=function(F,q){return T.H.useOptimistic(F,q)},on.useReducer=function(F,q,ne){return T.H.useReducer(F,q,ne)},on.useRef=function(F){return T.H.useRef(F)},on.useState=function(F){return T.H.useState(F)},on.useSyncExternalStore=function(F,q,ne){return T.H.useSyncExternalStore(F,q,ne)},on.useTransition=function(){return T.H.useTransition()},on.version="19.2.0",on}var WF;function gg(){return WF||(WF=1,iA.exports=Lie()),iA.exports}var S=gg();const Cr=Co(S),Iie=Rie({__proto__:null,default:Cr},[S]);var aA={exports:{}},jx={},sA={exports:{}},oA={};var qF;function Fie(){return qF||(qF=1,(function(t){function e(J,G){var W=J.length;J.push(G);e:for(;0<W;){var ee=W-1>>>1,K=J[ee];if(0<i(K,G))J[ee]=G,J[W]=K,W=ee;else break e}}function n(J){return J.length===0?null:J[0]}function r(J){if(J.length===0)return null;var G=J[0],W=J.pop();if(W!==G){J[0]=W;e:for(var ee=0,K=J.length,F=K>>>1;ee<F;){var q=2*(ee+1)-1,ne=J[q],re=q+1,se=J[re];if(0>i(ne,W))re<K&&0>i(se,ne)?(J[ee]=se,J[re]=W,ee=re):(J[ee]=ne,J[q]=W,ee=q);else if(re<K&&0>i(se,W))J[ee]=se,J[re]=W,ee=re;else break e}}return G}function i(J,G){var W=J.sortIndex-G.sortIndex;return W!==0?W:J.id-G.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 o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,p=3,g=!1,b=!1,v=!1,x=!1,y=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;function A(J){for(var G=n(u);G!==null;){if(G.callback===null)r(u);else if(G.startTime<=J)r(u),G.sortIndex=G.expirationTime,e(c,G);else break;G=n(u)}}function N(J){if(v=!1,A(J),!b)if(n(c)!==null)b=!0,C||(C=!0,L());else{var G=n(u);G!==null&&Y(N,G.startTime-J)}}var C=!1,T=-1,D=5,k=-1;function P(){return x?!0:!(t.unstable_now()-k<D)}function z(){if(x=!1,C){var J=t.unstable_now();k=J;var G=!0;try{e:{b=!1,v&&(v=!1,E(T),T=-1),g=!0;var W=p;try{t:{for(A(J),f=n(c);f!==null&&!(f.expirationTime>J&&P());){var ee=f.callback;if(typeof ee=="function"){f.callback=null,p=f.priorityLevel;var K=ee(f.expirationTime<=J);if(J=t.unstable_now(),typeof K=="function"){f.callback=K,A(J),G=!0;break t}f===n(c)&&r(c),A(J)}else r(c);f=n(c)}if(f!==null)G=!0;else{var F=n(u);F!==null&&Y(N,F.startTime-J),G=!1}}break e}finally{f=null,p=W,g=!1}G=void 0}}finally{G?L():C=!1}}}var L;if(typeof w=="function")L=function(){w(z)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,R=X.port2;X.port1.onmessage=z,L=function(){R.postMessage(null)}}else L=function(){y(z,0)};function Y(J,G){T=y(function(){J(t.unstable_now())},G)}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(J){J.callback=null},t.unstable_forceFrameRate=function(J){0>J||125<J?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<J?Math.floor(1e3/J):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(J){switch(p){case 1:case 2:case 3:var G=3;break;default:G=p}var W=p;p=G;try{return J()}finally{p=W}},t.unstable_requestPaint=function(){x=!0},t.unstable_runWithPriority=function(J,G){switch(J){case 1:case 2:case 3:case 4:case 5:break;default:J=3}var W=p;p=J;try{return G()}finally{p=W}},t.unstable_scheduleCallback=function(J,G,W){var ee=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?ee+W:ee):W=ee,J){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=W+K,J={id:d++,callback:G,priorityLevel:J,startTime:W,expirationTime:K,sortIndex:-1},W>ee?(J.sortIndex=W,e(u,J),n(c)===null&&J===n(u)&&(v?(E(T),T=-1):v=!0,Y(N,W-ee))):(J.sortIndex=K,e(c,J),b||g||(b=!0,C||(C=!0,L()))),J},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(J){var G=p;return function(){var W=p;p=G;try{return J.apply(this,arguments)}finally{p=W}}}})(oA)),oA}var KF;function Uie(){return KF||(KF=1,sA.exports=Fie()),sA.exports}var lA={exports:{}},xa={};var XF;function zie(){if(XF)return xa;XF=1;var t=gg();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={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},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return xa.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,xa.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},xa.flushSync=function(c){var u=o.T,d=r.p;try{if(o.T=null,r.p=2,c)return c()}finally{o.T=u,r.p=d,r.d.f()}},xa.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},xa.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},xa.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),p=typeof u.integrity=="string"?u.integrity:void 0,g=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:p,fetchPriority:g}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:p,fetchPriority:g,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},xa.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},xa.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},xa.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},xa.requestFormReset=function(c){r.d.r(c)},xa.unstable_batchedUpdates=function(c,u){return c(u)},xa.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},xa.useFormStatus=function(){return o.H.useHostTransitionStatus()},xa.version="19.2.0",xa}var YF;function yG(){if(YF)return lA.exports;YF=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(),lA.exports=zie(),lA.exports}var QF;function Bie(){if(QF)return jx;QF=1;var t=Uie(),e=gg(),n=yG();function r(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)m+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var m=h,_=h;if(h.alternate)for(;m.return;)m=m.return;else{h=m;do m=h,(m.flags&4098)!==0&&(_=m.return),h=m.return;while(h)}return m.tag===3?_:null}function o(h){if(h.tag===13){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function l(h){if(h.tag===31){var m=h.memoizedState;if(m===null&&(h=h.alternate,h!==null&&(m=h.memoizedState)),m!==null)return m.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var m=h.alternate;if(!m){if(m=a(h),m===null)throw Error(r(188));return m!==h?null:h}for(var _=h,M=m;;){var j=_.return;if(j===null)break;var O=j.alternate;if(O===null){if(M=j.return,M!==null){_=M;continue}break}if(j.child===O.child){for(O=j.child;O;){if(O===_)return c(j),h;if(O===M)return c(j),m;O=O.sibling}throw Error(r(188))}if(_.return!==M.return)_=j,M=O;else{for(var te=!1,he=j.child;he;){if(he===_){te=!0,_=j,M=O;break}if(he===M){te=!0,M=j,_=O;break}he=he.sibling}if(!te){for(he=O.child;he;){if(he===_){te=!0,_=O,M=j;break}if(he===M){te=!0,M=O,_=j;break}he=he.sibling}if(!te)throw Error(r(189))}}if(_.alternate!==M)throw Error(r(190))}if(_.tag!==3)throw Error(r(188));return _.stateNode.current===_?h:m}function d(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h;for(h=h.child;h!==null;){if(m=d(h),m!==null)return m;h=h.sibling}return null}var f=Object.assign,p=Symbol.for("react.element"),g=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),w=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),z=Symbol.iterator;function L(h){return h===null||typeof h!="object"?null:(h=z&&h[z]||h["@@iterator"],typeof h=="function"?h:null)}var X=Symbol.for("react.client.reference");function R(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===X?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case v:return"Fragment";case y:return"Profiler";case x:return"StrictMode";case N:return"Suspense";case C:return"SuspenseList";case k:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case b:return"Portal";case w:return h.displayName||"Context";case E:return(h._context.displayName||"Context")+".Consumer";case A:var m=h.render;return h=h.displayName,h||(h=m.displayName||m.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case T:return m=h.displayName||null,m!==null?m:R(h.type)||"Memo";case D:m=h._payload,h=h._init;try{return R(h(m))}catch{}}return null}var Y=Array.isArray,J=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W={pending:!1,data:null,method:null,action:null},ee=[],K=-1;function F(h){return{current:h}}function q(h){0>K||(h.current=ee[K],ee[K]=null,K--)}function ne(h,m){K++,ee[K]=h.current,h.current=m}var re=F(null),se=F(null),de=F(null),pe=F(null);function Ce(h,m){switch(ne(de,m),ne(se,h),ne(re,null),m.nodeType){case 9:case 11:h=(h=m.documentElement)&&(h=h.namespaceURI)?hF(h):0;break;default:if(h=m.tagName,m=m.namespaceURI)m=hF(m),h=fF(m,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}q(re),ne(re,h)}function oe(){q(re),q(se),q(de)}function ae(h){h.memoizedState!==null&&ne(pe,h);var m=re.current,_=fF(m,h.type);m!==_&&(ne(se,h),ne(re,_))}function ge(h){se.current===h&&(q(re),q(se)),pe.current===h&&(q(pe),Nx._currentValue=W)}var ue,Le;function V(h){if(ue===void 0)try{throw Error()}catch(_){var m=_.stack.trim().match(/\n( *(at )?)/);ue=m&&m[1]||"",Le=-1<_.stack.indexOf(`
- at`)?" (<anonymous>)":-1<_.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+ue+h+Le}var $=!1;function Z(h,m){if(!h||$)return"";$=!0;var _=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(m){var bt=function(){throw Error()};if(Object.defineProperty(bt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(bt,[])}catch(ot){var rt=ot}Reflect.construct(h,[],bt)}else{try{bt.call()}catch(ot){rt=ot}h.call(bt.prototype)}}else{try{throw Error()}catch(ot){rt=ot}(bt=h())&&typeof bt.catch=="function"&&bt.catch(function(){})}}catch(ot){if(ot&&rt&&typeof ot.stack=="string")return[ot.stack,rt.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var O=M.DetermineComponentFrameRoot(),te=O[0],he=O[1];if(te&&he){var Pe=te.split(`
- `),tt=he.split(`
- `);for(j=M=0;M<Pe.length&&!Pe[M].includes("DetermineComponentFrameRoot");)M++;for(;j<tt.length&&!tt[j].includes("DetermineComponentFrameRoot");)j++;if(M===Pe.length||j===tt.length)for(M=Pe.length-1,j=tt.length-1;1<=M&&0<=j&&Pe[M]!==tt[j];)j--;for(;1<=M&&0<=j;M--,j--)if(Pe[M]!==tt[j]){if(M!==1||j!==1)do if(M--,j--,0>j||Pe[M]!==tt[j]){var dt=`
- `+Pe[M].replace(" at new "," at ");return h.displayName&&dt.includes("<anonymous>")&&(dt=dt.replace("<anonymous>",h.displayName)),dt}while(1<=M&&0<=j);break}}}finally{$=!1,Error.prepareStackTrace=_}return(_=h?h.displayName||h.name:"")?V(_):""}function B(h,m){switch(h.tag){case 26:case 27:case 5:return V(h.type);case 16:return V("Lazy");case 13:return h.child!==m&&m!==null?V("Suspense Fallback"):V("Suspense");case 19:return V("SuspenseList");case 0:case 15:return Z(h.type,!1);case 11:return Z(h.type.render,!1);case 1:return Z(h.type,!0);case 31:return V("Activity");default:return""}}function U(h){try{var m="",_=null;do m+=B(h,_),_=h,h=h.return;while(h);return m}catch(M){return`
- Error generating stack: `+M.message+`
- `+M.stack}}var Q=Object.prototype.hasOwnProperty,Me=t.unstable_scheduleCallback,Te=t.unstable_cancelCallback,fe=t.unstable_shouldYield,H=t.unstable_requestPaint,I=t.unstable_now,ce=t.unstable_getCurrentPriorityLevel,we=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,_e=t.unstable_NormalPriority,st=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,it=t.log,ct=t.unstable_setDisableYieldValue,Fe=null,me=null;function Ke(h){if(typeof it=="function"&&ct(h),me&&typeof me.setStrictMode=="function")try{me.setStrictMode(Fe,h)}catch{}}var qe=Math.clz32?Math.clz32:ie,Qe=Math.log,ut=Math.LN2;function ie(h){return h>>>=0,h===0?32:31-(Qe(h)/ut|0)|0}var He=256,ve=262144,Be=4194304;function je(h){var m=h&42;if(m!==0)return m;switch(h&-h){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 h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function Ne(h,m,_){var M=h.pendingLanes;if(M===0)return 0;var j=0,O=h.suspendedLanes,te=h.pingedLanes;h=h.warmLanes;var he=M&134217727;return he!==0?(M=he&~O,M!==0?j=je(M):(te&=he,te!==0?j=je(te):_||(_=he&~h,_!==0&&(j=je(_))))):(he=M&~O,he!==0?j=je(he):te!==0?j=je(te):_||(_=M&~h,_!==0&&(j=je(_)))),j===0?0:m!==0&&m!==j&&(m&O)===0&&(O=j&-j,_=m&-m,O>=_||O===32&&(_&4194048)!==0)?m:j}function Xe(h,m){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&m)===0}function mt(h,m){switch(h){case 1:case 2:case 4:case 8:case 64:return m+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 m+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 At(){var h=Be;return Be<<=1,(Be&62914560)===0&&(Be=4194304),h}function Rt(h){for(var m=[],_=0;31>_;_++)m.push(h);return m}function Xt(h,m){h.pendingLanes|=m,m!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Lt(h,m,_,M,j,O){var te=h.pendingLanes;h.pendingLanes=_,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=_,h.entangledLanes&=_,h.errorRecoveryDisabledLanes&=_,h.shellSuspendCounter=0;var he=h.entanglements,Pe=h.expirationTimes,tt=h.hiddenUpdates;for(_=te&~_;0<_;){var dt=31-qe(_),bt=1<<dt;he[dt]=0,Pe[dt]=-1;var rt=tt[dt];if(rt!==null)for(tt[dt]=null,dt=0;dt<rt.length;dt++){var ot=rt[dt];ot!==null&&(ot.lane&=-536870913)}_&=~bt}M!==0&&Sn(h,M,0),O!==0&&j===0&&h.tag!==0&&(h.suspendedLanes|=O&~(te&~m))}function Sn(h,m,_){h.pendingLanes|=m,h.suspendedLanes&=~m;var M=31-qe(m);h.entangledLanes|=m,h.entanglements[M]=h.entanglements[M]|1073741824|_&261930}function $t(h,m){var _=h.entangledLanes|=m;for(h=h.entanglements;_;){var M=31-qe(_),j=1<<M;j&m|h[M]&m&&(h[M]|=m),_&=~j}}function Cn(h,m){var _=m&-m;return _=(_&42)!==0?1:nr(_),(_&(h.suspendedLanes|m))!==0?0:_}function nr(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=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:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Hn(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function Jr(){var h=G.p;return h!==0?h:(h=window.event,h===void 0?32:LF(h.type))}function qn(h,m){var _=G.p;try{return G.p=h,m()}finally{G.p=_}}var yt=Math.random().toString(36).slice(2),Ft="__reactFiber$"+yt,qt="__reactProps$"+yt,gt="__reactContainer$"+yt,en="__reactEvents$"+yt,ye="__reactListeners$"+yt,$e="__reactHandles$"+yt,Ye="__reactResources$"+yt,nt="__reactMarker$"+yt;function ke(h){delete h[Ft],delete h[qt],delete h[en],delete h[ye],delete h[$e]}function xe(h){var m=h[Ft];if(m)return m;for(var _=h.parentNode;_;){if(m=_[gt]||_[Ft]){if(_=m.alternate,m.child!==null||_!==null&&_.child!==null)for(h=vF(h);h!==null;){if(_=h[Ft])return _;h=vF(h)}return m}h=_,_=h.parentNode}return null}function le(h){if(h=h[Ft]||h[gt]){var m=h.tag;if(m===5||m===6||m===13||m===31||m===26||m===27||m===3)return h}return null}function Ae(h){var m=h.tag;if(m===5||m===26||m===27||m===6)return h.stateNode;throw Error(r(33))}function Oe(h){var m=h[Ye];return m||(m=h[Ye]={hoistableStyles:new Map,hoistableScripts:new Map}),m}function Ie(h){h[nt]=!0}var Re=new Set,Je={};function xt(h,m){Nt(h,m),Nt(h+"Capture",m)}function Nt(h,m){for(Je[h]=m,h=0;h<m.length;h++)Re.add(m[h])}var Et=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]*$"),Ct={},jt={};function wt(h){return Q.call(jt,h)?!0:Q.call(Ct,h)?!1:Et.test(h)?jt[h]=!0:(Ct[h]=!0,!1)}function tn(h,m,_){if(wt(m))if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":h.removeAttribute(m);return;case"boolean":var M=m.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){h.removeAttribute(m);return}}h.setAttribute(m,""+_)}}function Vt(h,m,_){if(_===null)h.removeAttribute(m);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(m);return}h.setAttribute(m,""+_)}}function hn(h,m,_,M){if(M===null)h.removeAttribute(_);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(_);return}h.setAttributeNS(m,_,""+M)}}function _n(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function kn(h){var m=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function Ht(h,m,_){var M=Object.getOwnPropertyDescriptor(h.constructor.prototype,m);if(!h.hasOwnProperty(m)&&typeof M<"u"&&typeof M.get=="function"&&typeof M.set=="function"){var j=M.get,O=M.set;return Object.defineProperty(h,m,{configurable:!0,get:function(){return j.call(this)},set:function(te){_=""+te,O.call(this,te)}}),Object.defineProperty(h,m,{enumerable:M.enumerable}),{getValue:function(){return _},setValue:function(te){_=""+te},stopTracking:function(){h._valueTracker=null,delete h[m]}}}}function sn(h){if(!h._valueTracker){var m=kn(h)?"checked":"value";h._valueTracker=Ht(h,m,""+h[m])}}function cn(h){if(!h)return!1;var m=h._valueTracker;if(!m)return!0;var _=m.getValue(),M="";return h&&(M=kn(h)?h.checked?"true":"false":h.value),h=M,h!==_?(m.setValue(h),!0):!1}function Ur(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var ei=/[\n"\\]/g;function Vn(h){return h.replace(ei,function(m){return"\\"+m.charCodeAt(0).toString(16)+" "})}function jo(h,m,_,M,j,O,te,he){h.name="",te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"?h.type=te:h.removeAttribute("type"),m!=null?te==="number"?(m===0&&h.value===""||h.value!=m)&&(h.value=""+_n(m)):h.value!==""+_n(m)&&(h.value=""+_n(m)):te!=="submit"&&te!=="reset"||h.removeAttribute("value"),m!=null?Ii(h,te,_n(m)):_!=null?Ii(h,te,_n(_)):M!=null&&h.removeAttribute("value"),j==null&&O!=null&&(h.defaultChecked=!!O),j!=null&&(h.checked=j&&typeof j!="function"&&typeof j!="symbol"),he!=null&&typeof he!="function"&&typeof he!="symbol"&&typeof he!="boolean"?h.name=""+_n(he):h.removeAttribute("name")}function Kn(h,m,_,M,j,O,te,he){if(O!=null&&typeof O!="function"&&typeof O!="symbol"&&typeof O!="boolean"&&(h.type=O),m!=null||_!=null){if(!(O!=="submit"&&O!=="reset"||m!=null)){sn(h);return}_=_!=null?""+_n(_):"",m=m!=null?""+_n(m):_,he||m===h.value||(h.value=m),h.defaultValue=m}M=M??j,M=typeof M!="function"&&typeof M!="symbol"&&!!M,h.checked=he?h.checked:!!M,h.defaultChecked=!!M,te!=null&&typeof te!="function"&&typeof te!="symbol"&&typeof te!="boolean"&&(h.name=te),sn(h)}function Ii(h,m,_){m==="number"&&Ur(h.ownerDocument)===h||h.defaultValue===""+_||(h.defaultValue=""+_)}function _i(h,m,_,M){if(h=h.options,m){m={};for(var j=0;j<_.length;j++)m["$"+_[j]]=!0;for(_=0;_<h.length;_++)j=m.hasOwnProperty("$"+h[_].value),h[_].selected!==j&&(h[_].selected=j),j&&M&&(h[_].defaultSelected=!0)}else{for(_=""+_n(_),m=null,j=0;j<h.length;j++){if(h[j].value===_){h[j].selected=!0,M&&(h[j].defaultSelected=!0);return}m!==null||h[j].disabled||(m=h[j])}m!==null&&(m.selected=!0)}}function Fi(h,m,_){if(m!=null&&(m=""+_n(m),m!==h.value&&(h.value=m),_==null)){h.defaultValue!==m&&(h.defaultValue=m);return}h.defaultValue=_!=null?""+_n(_):""}function Ji(h,m,_,M){if(m==null){if(M!=null){if(_!=null)throw Error(r(92));if(Y(M)){if(1<M.length)throw Error(r(93));M=M[0]}_=M}_==null&&(_=""),m=_}_=_n(m),h.defaultValue=_,M=h.textContent,M===_&&M!==""&&M!==null&&(h.value=M),sn(h)}function al(h,m){if(m){var _=h.firstChild;if(_&&_===h.lastChild&&_.nodeType===3){_.nodeValue=m;return}}h.textContent=m}var Gl=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 cL(h,m,_){var M=m.indexOf("--")===0;_==null||typeof _=="boolean"||_===""?M?h.setProperty(m,""):m==="float"?h.cssFloat="":h[m]="":M?h.setProperty(m,_):typeof _!="number"||_===0||Gl.has(m)?m==="float"?h.cssFloat=_:h[m]=(""+_).trim():h[m]=_+"px"}function uL(h,m,_){if(m!=null&&typeof m!="object")throw Error(r(62));if(h=h.style,_!=null){for(var M in _)!_.hasOwnProperty(M)||m!=null&&m.hasOwnProperty(M)||(M.indexOf("--")===0?h.setProperty(M,""):M==="float"?h.cssFloat="":h[M]="");for(var j in m)M=m[j],m.hasOwnProperty(j)&&_[j]!==M&&cL(h,j,M)}else for(var O in m)m.hasOwnProperty(O)&&cL(h,O,m[O])}function JM(h){if(h.indexOf("-")===-1)return!1;switch(h){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 Cne=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"]]),kne=/^[\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 Cy(h){return kne.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Wl(){}var eE=null;function tE(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var Vf=null,Gf=null;function dL(h){var m=le(h);if(m&&(h=m.stateNode)){var _=h[qt]||null;e:switch(h=m.stateNode,m.type){case"input":if(jo(h,_.value,_.defaultValue,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name),m=_.name,_.type==="radio"&&m!=null){for(_=h;_.parentNode;)_=_.parentNode;for(_=_.querySelectorAll('input[name="'+Vn(""+m)+'"][type="radio"]'),m=0;m<_.length;m++){var M=_[m];if(M!==h&&M.form===h.form){var j=M[qt]||null;if(!j)throw Error(r(90));jo(M,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(m=0;m<_.length;m++)M=_[m],M.form===h.form&&cn(M)}break e;case"textarea":Fi(h,_.value,_.defaultValue);break e;case"select":m=_.value,m!=null&&_i(h,!!_.multiple,m,!1)}}}var nE=!1;function hL(h,m,_){if(nE)return h(m,_);nE=!0;try{var M=h(m);return M}finally{if(nE=!1,(Vf!==null||Gf!==null)&&(gv(),Vf&&(m=Vf,h=Gf,Gf=Vf=null,dL(m),h)))for(m=0;m<h.length;m++)dL(h[m])}}function Hg(h,m){var _=h.stateNode;if(_===null)return null;var M=_[qt]||null;if(M===null)return null;_=M[m];e:switch(m){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(h=h.type,M=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!M;break e;default:h=!1}if(h)return null;if(_&&typeof _!="function")throw Error(r(231,m,typeof _));return _}var ql=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rE=!1;if(ql)try{var Vg={};Object.defineProperty(Vg,"passive",{get:function(){rE=!0}}),window.addEventListener("test",Vg,Vg),window.removeEventListener("test",Vg,Vg)}catch{rE=!1}var mu=null,iE=null,ky=null;function fL(){if(ky)return ky;var h,m=iE,_=m.length,M,j="value"in mu?mu.value:mu.textContent,O=j.length;for(h=0;h<_&&m[h]===j[h];h++);var te=_-h;for(M=1;M<=te&&m[_-M]===j[O-M];M++);return ky=j.slice(h,1<M?1-M:void 0)}function jy(h){var m=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&m===13&&(h=13)):h=m,h===10&&(h=13),32<=h||h===13?h:0}function Py(){return!0}function mL(){return!1}function Xa(h){function m(_,M,j,O,te){this._reactName=_,this._targetInst=j,this.type=M,this.nativeEvent=O,this.target=te,this.currentTarget=null;for(var he in h)h.hasOwnProperty(he)&&(_=h[he],this[he]=_?_(O):O[he]);return this.isDefaultPrevented=(O.defaultPrevented!=null?O.defaultPrevented:O.returnValue===!1)?Py:mL,this.isPropagationStopped=mL,this}return f(m.prototype,{preventDefault:function(){this.defaultPrevented=!0;var _=this.nativeEvent;_&&(_.preventDefault?_.preventDefault():typeof _.returnValue!="unknown"&&(_.returnValue=!1),this.isDefaultPrevented=Py)},stopPropagation:function(){var _=this.nativeEvent;_&&(_.stopPropagation?_.stopPropagation():typeof _.cancelBubble!="unknown"&&(_.cancelBubble=!0),this.isPropagationStopped=Py)},persist:function(){},isPersistent:Py}),m}var Zd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ry=Xa(Zd),Gg=f({},Zd,{view:0,detail:0}),jne=Xa(Gg),aE,sE,Wg,Dy=f({},Gg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:lE,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==Wg&&(Wg&&h.type==="mousemove"?(aE=h.screenX-Wg.screenX,sE=h.screenY-Wg.screenY):sE=aE=0,Wg=h),aE)},movementY:function(h){return"movementY"in h?h.movementY:sE}}),pL=Xa(Dy),Pne=f({},Dy,{dataTransfer:0}),Rne=Xa(Pne),Dne=f({},Gg,{relatedTarget:0}),oE=Xa(Dne),One=f({},Zd,{animationName:0,elapsedTime:0,pseudoElement:0}),Lne=Xa(One),Ine=f({},Zd,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),Fne=Xa(Ine),Une=f({},Zd,{data:0}),gL=Xa(Une),zne={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Bne={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"},$ne={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Hne(h){var m=this.nativeEvent;return m.getModifierState?m.getModifierState(h):(h=$ne[h])?!!m[h]:!1}function lE(){return Hne}var Vne=f({},Gg,{key:function(h){if(h.key){var m=zne[h.key]||h.key;if(m!=="Unidentified")return m}return h.type==="keypress"?(h=jy(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Bne[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:lE,charCode:function(h){return h.type==="keypress"?jy(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?jy(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Gne=Xa(Vne),Wne=f({},Dy,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xL=Xa(Wne),qne=f({},Gg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:lE}),Kne=Xa(qne),Xne=f({},Zd,{propertyName:0,elapsedTime:0,pseudoElement:0}),Yne=Xa(Xne),Qne=f({},Dy,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),Zne=Xa(Qne),Jne=f({},Zd,{newState:0,oldState:0}),ere=Xa(Jne),tre=[9,13,27,32],cE=ql&&"CompositionEvent"in window,qg=null;ql&&"documentMode"in document&&(qg=document.documentMode);var nre=ql&&"TextEvent"in window&&!qg,bL=ql&&(!cE||qg&&8<qg&&11>=qg),yL=" ",vL=!1;function _L(h,m){switch(h){case"keyup":return tre.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wL(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Wf=!1;function rre(h,m){switch(h){case"compositionend":return wL(m);case"keypress":return m.which!==32?null:(vL=!0,yL);case"textInput":return h=m.data,h===yL&&vL?null:h;default:return null}}function ire(h,m){if(Wf)return h==="compositionend"||!cE&&_L(h,m)?(h=fL(),ky=iE=mu=null,Wf=!1,h):null;switch(h){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1<m.char.length)return m.char;if(m.which)return String.fromCharCode(m.which)}return null;case"compositionend":return bL&&m.locale!=="ko"?null:m.data;default:return null}}var are={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 SL(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m==="input"?!!are[h.type]:m==="textarea"}function ML(h,m,_,M){Vf?Gf?Gf.push(M):Gf=[M]:Vf=M,m=Sv(m,"onChange"),0<m.length&&(_=new Ry("onChange","change",null,_,M),h.push({event:_,listeners:m}))}var Kg=null,Xg=null;function sre(h){sF(h,0)}function Oy(h){var m=Ae(h);if(cn(m))return h}function EL(h,m){if(h==="change")return m}var NL=!1;if(ql){var uE;if(ql){var dE="oninput"in document;if(!dE){var AL=document.createElement("div");AL.setAttribute("oninput","return;"),dE=typeof AL.oninput=="function"}uE=dE}else uE=!1;NL=uE&&(!document.documentMode||9<document.documentMode)}function TL(){Kg&&(Kg.detachEvent("onpropertychange",CL),Xg=Kg=null)}function CL(h){if(h.propertyName==="value"&&Oy(Xg)){var m=[];ML(m,Xg,h,tE(h)),hL(sre,m)}}function ore(h,m,_){h==="focusin"?(TL(),Kg=m,Xg=_,Kg.attachEvent("onpropertychange",CL)):h==="focusout"&&TL()}function lre(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Oy(Xg)}function cre(h,m){if(h==="click")return Oy(m)}function ure(h,m){if(h==="input"||h==="change")return Oy(m)}function dre(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var gs=typeof Object.is=="function"?Object.is:dre;function Yg(h,m){if(gs(h,m))return!0;if(typeof h!="object"||h===null||typeof m!="object"||m===null)return!1;var _=Object.keys(h),M=Object.keys(m);if(_.length!==M.length)return!1;for(M=0;M<_.length;M++){var j=_[M];if(!Q.call(m,j)||!gs(h[j],m[j]))return!1}return!0}function kL(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function jL(h,m){var _=kL(h);h=0;for(var M;_;){if(_.nodeType===3){if(M=h+_.textContent.length,h<=m&&M>=m)return{node:_,offset:m-h};h=M}e:{for(;_;){if(_.nextSibling){_=_.nextSibling;break e}_=_.parentNode}_=void 0}_=kL(_)}}function PL(h,m){return h&&m?h===m?!0:h&&h.nodeType===3?!1:m&&m.nodeType===3?PL(h,m.parentNode):"contains"in h?h.contains(m):h.compareDocumentPosition?!!(h.compareDocumentPosition(m)&16):!1:!1}function RL(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var m=Ur(h.document);m instanceof h.HTMLIFrameElement;){try{var _=typeof m.contentWindow.location.href=="string"}catch{_=!1}if(_)h=m.contentWindow;else break;m=Ur(h.document)}return m}function hE(h){var m=h&&h.nodeName&&h.nodeName.toLowerCase();return m&&(m==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||m==="textarea"||h.contentEditable==="true")}var hre=ql&&"documentMode"in document&&11>=document.documentMode,qf=null,fE=null,Qg=null,mE=!1;function DL(h,m,_){var M=_.window===_?_.document:_.nodeType===9?_:_.ownerDocument;mE||qf==null||qf!==Ur(M)||(M=qf,"selectionStart"in M&&hE(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),Qg&&Yg(Qg,M)||(Qg=M,M=Sv(fE,"onSelect"),0<M.length&&(m=new Ry("onSelect","select",null,m,_),h.push({event:m,listeners:M}),m.target=qf)))}function Jd(h,m){var _={};return _[h.toLowerCase()]=m.toLowerCase(),_["Webkit"+h]="webkit"+m,_["Moz"+h]="moz"+m,_}var Kf={animationend:Jd("Animation","AnimationEnd"),animationiteration:Jd("Animation","AnimationIteration"),animationstart:Jd("Animation","AnimationStart"),transitionrun:Jd("Transition","TransitionRun"),transitionstart:Jd("Transition","TransitionStart"),transitioncancel:Jd("Transition","TransitionCancel"),transitionend:Jd("Transition","TransitionEnd")},pE={},OL={};ql&&(OL=document.createElement("div").style,"AnimationEvent"in window||(delete Kf.animationend.animation,delete Kf.animationiteration.animation,delete Kf.animationstart.animation),"TransitionEvent"in window||delete Kf.transitionend.transition);function eh(h){if(pE[h])return pE[h];if(!Kf[h])return h;var m=Kf[h],_;for(_ in m)if(m.hasOwnProperty(_)&&_ in OL)return pE[h]=m[_];return h}var LL=eh("animationend"),IL=eh("animationiteration"),FL=eh("animationstart"),fre=eh("transitionrun"),mre=eh("transitionstart"),pre=eh("transitioncancel"),UL=eh("transitionend"),zL=new Map,gE="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(" ");gE.push("scrollEnd");function Po(h,m){zL.set(h,m),xt(m,[h])}var Ly=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var m=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(m))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},Ws=[],Xf=0,xE=0;function Iy(){for(var h=Xf,m=xE=Xf=0;m<h;){var _=Ws[m];Ws[m++]=null;var M=Ws[m];Ws[m++]=null;var j=Ws[m];Ws[m++]=null;var O=Ws[m];if(Ws[m++]=null,M!==null&&j!==null){var te=M.pending;te===null?j.next=j:(j.next=te.next,te.next=j),M.pending=j}O!==0&&BL(_,j,O)}}function Fy(h,m,_,M){Ws[Xf++]=h,Ws[Xf++]=m,Ws[Xf++]=_,Ws[Xf++]=M,xE|=M,h.lanes|=M,h=h.alternate,h!==null&&(h.lanes|=M)}function bE(h,m,_,M){return Fy(h,m,_,M),Uy(h)}function th(h,m){return Fy(h,null,null,m),Uy(h)}function BL(h,m,_){h.lanes|=_;var M=h.alternate;M!==null&&(M.lanes|=_);for(var j=!1,O=h.return;O!==null;)O.childLanes|=_,M=O.alternate,M!==null&&(M.childLanes|=_),O.tag===22&&(h=O.stateNode,h===null||h._visibility&1||(j=!0)),h=O,O=O.return;return h.tag===3?(O=h.stateNode,j&&m!==null&&(j=31-qe(_),h=O.hiddenUpdates,M=h[j],M===null?h[j]=[m]:M.push(m),m.lane=_|536870912),O):null}function Uy(h){if(50<yx)throw yx=0,AN=null,Error(r(185));for(var m=h.return;m!==null;)h=m,m=h.return;return h.tag===3?h.stateNode:null}var Yf={};function gre(h,m,_,M){this.tag=h,this.key=_,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function xs(h,m,_,M){return new gre(h,m,_,M)}function yE(h){return h=h.prototype,!(!h||!h.isReactComponent)}function Kl(h,m){var _=h.alternate;return _===null?(_=xs(h.tag,m,h.key,h.mode),_.elementType=h.elementType,_.type=h.type,_.stateNode=h.stateNode,_.alternate=h,h.alternate=_):(_.pendingProps=m,_.type=h.type,_.flags=0,_.subtreeFlags=0,_.deletions=null),_.flags=h.flags&65011712,_.childLanes=h.childLanes,_.lanes=h.lanes,_.child=h.child,_.memoizedProps=h.memoizedProps,_.memoizedState=h.memoizedState,_.updateQueue=h.updateQueue,m=h.dependencies,_.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},_.sibling=h.sibling,_.index=h.index,_.ref=h.ref,_.refCleanup=h.refCleanup,_}function $L(h,m){h.flags&=65011714;var _=h.alternate;return _===null?(h.childLanes=0,h.lanes=m,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=_.childLanes,h.lanes=_.lanes,h.child=_.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=_.memoizedProps,h.memoizedState=_.memoizedState,h.updateQueue=_.updateQueue,h.type=_.type,m=_.dependencies,h.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext}),h}function zy(h,m,_,M,j,O){var te=0;if(M=h,typeof h=="function")yE(h)&&(te=1);else if(typeof h=="string")te=_ie(h,_,re.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case k:return h=xs(31,_,m,j),h.elementType=k,h.lanes=O,h;case v:return nh(_.children,j,O,m);case x:te=8,j|=24;break;case y:return h=xs(12,_,m,j|2),h.elementType=y,h.lanes=O,h;case N:return h=xs(13,_,m,j),h.elementType=N,h.lanes=O,h;case C:return h=xs(19,_,m,j),h.elementType=C,h.lanes=O,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case w:te=10;break e;case E:te=9;break e;case A:te=11;break e;case T:te=14;break e;case D:te=16,M=null;break e}te=29,_=Error(r(130,h===null?"null":typeof h,"")),M=null}return m=xs(te,_,m,j),m.elementType=h,m.type=M,m.lanes=O,m}function nh(h,m,_,M){return h=xs(7,h,M,m),h.lanes=_,h}function vE(h,m,_){return h=xs(6,h,null,m),h.lanes=_,h}function HL(h){var m=xs(18,null,null,0);return m.stateNode=h,m}function _E(h,m,_){return m=xs(4,h.children!==null?h.children:[],h.key,m),m.lanes=_,m.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},m}var VL=new WeakMap;function qs(h,m){if(typeof h=="object"&&h!==null){var _=VL.get(h);return _!==void 0?_:(m={value:h,source:m,stack:U(m)},VL.set(h,m),m)}return{value:h,source:m,stack:U(m)}}var Qf=[],Zf=0,By=null,Zg=0,Ks=[],Xs=0,pu=null,sl=1,ol="";function Xl(h,m){Qf[Zf++]=Zg,Qf[Zf++]=By,By=h,Zg=m}function GL(h,m,_){Ks[Xs++]=sl,Ks[Xs++]=ol,Ks[Xs++]=pu,pu=h;var M=sl;h=ol;var j=32-qe(M)-1;M&=~(1<<j),_+=1;var O=32-qe(m)+j;if(30<O){var te=j-j%5;O=(M&(1<<te)-1).toString(32),M>>=te,j-=te,sl=1<<32-qe(m)+j|_<<j|M,ol=O+h}else sl=1<<O|_<<j|M,ol=h}function wE(h){h.return!==null&&(Xl(h,1),GL(h,1,0))}function SE(h){for(;h===By;)By=Qf[--Zf],Qf[Zf]=null,Zg=Qf[--Zf],Qf[Zf]=null;for(;h===pu;)pu=Ks[--Xs],Ks[Xs]=null,ol=Ks[--Xs],Ks[Xs]=null,sl=Ks[--Xs],Ks[Xs]=null}function WL(h,m){Ks[Xs++]=sl,Ks[Xs++]=ol,Ks[Xs++]=pu,sl=m.id,ol=m.overflow,pu=h}var ea=null,_r=null,Rn=!1,gu=null,Ys=!1,ME=Error(r(519));function xu(h){var m=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Jg(qs(m,h)),ME}function qL(h){var m=h.stateNode,_=h.type,M=h.memoizedProps;switch(m[Ft]=h,m[qt]=M,_){case"dialog":En("cancel",m),En("close",m);break;case"iframe":case"object":case"embed":En("load",m);break;case"video":case"audio":for(_=0;_<_x.length;_++)En(_x[_],m);break;case"source":En("error",m);break;case"img":case"image":case"link":En("error",m),En("load",m);break;case"details":En("toggle",m);break;case"input":En("invalid",m),Kn(m,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":En("invalid",m);break;case"textarea":En("invalid",m),Ji(m,M.value,M.defaultValue,M.children)}_=M.children,typeof _!="string"&&typeof _!="number"&&typeof _!="bigint"||m.textContent===""+_||M.suppressHydrationWarning===!0||uF(m.textContent,_)?(M.popover!=null&&(En("beforetoggle",m),En("toggle",m)),M.onScroll!=null&&En("scroll",m),M.onScrollEnd!=null&&En("scrollend",m),M.onClick!=null&&(m.onclick=Wl),m=!0):m=!1,m||xu(h,!0)}function KL(h){for(ea=h.return;ea;)switch(ea.tag){case 5:case 31:case 13:Ys=!1;return;case 27:case 3:Ys=!0;return;default:ea=ea.return}}function Jf(h){if(h!==ea)return!1;if(!Rn)return KL(h),Rn=!0,!1;var m=h.tag,_;if((_=m!==3&&m!==27)&&((_=m===5)&&(_=h.type,_=!(_!=="form"&&_!=="button")||$N(h.type,h.memoizedProps)),_=!_),_&&_r&&xu(h),KL(h),m===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=yF(h)}else if(m===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));_r=yF(h)}else m===27?(m=_r,ju(h.type)?(h=qN,qN=null,_r=h):_r=m):_r=ea?Zs(h.stateNode.nextSibling):null;return!0}function rh(){_r=ea=null,Rn=!1}function EE(){var h=gu;return h!==null&&(Ja===null?Ja=h:Ja.push.apply(Ja,h),gu=null),h}function Jg(h){gu===null?gu=[h]:gu.push(h)}var NE=F(null),ih=null,Yl=null;function bu(h,m,_){ne(NE,m._currentValue),m._currentValue=_}function Ql(h){h._currentValue=NE.current,q(NE)}function AE(h,m,_){for(;h!==null;){var M=h.alternate;if((h.childLanes&m)!==m?(h.childLanes|=m,M!==null&&(M.childLanes|=m)):M!==null&&(M.childLanes&m)!==m&&(M.childLanes|=m),h===_)break;h=h.return}}function TE(h,m,_,M){var j=h.child;for(j!==null&&(j.return=h);j!==null;){var O=j.dependencies;if(O!==null){var te=j.child;O=O.firstContext;e:for(;O!==null;){var he=O;O=j;for(var Pe=0;Pe<m.length;Pe++)if(he.context===m[Pe]){O.lanes|=_,he=O.alternate,he!==null&&(he.lanes|=_),AE(O.return,_,h),M||(te=null);break e}O=he.next}}else if(j.tag===18){if(te=j.return,te===null)throw Error(r(341));te.lanes|=_,O=te.alternate,O!==null&&(O.lanes|=_),AE(te,_,h),te=null}else te=j.child;if(te!==null)te.return=j;else for(te=j;te!==null;){if(te===h){te=null;break}if(j=te.sibling,j!==null){j.return=te.return,te=j;break}te=te.return}j=te}}function em(h,m,_,M){h=null;for(var j=m,O=!1;j!==null;){if(!O){if((j.flags&524288)!==0)O=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var te=j.alternate;if(te===null)throw Error(r(387));if(te=te.memoizedProps,te!==null){var he=j.type;gs(j.pendingProps.value,te.value)||(h!==null?h.push(he):h=[he])}}else if(j===pe.current){if(te=j.alternate,te===null)throw Error(r(387));te.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(h!==null?h.push(Nx):h=[Nx])}j=j.return}h!==null&&TE(m,h,_,M),m.flags|=262144}function $y(h){for(h=h.firstContext;h!==null;){if(!gs(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function ah(h){ih=h,Yl=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function ta(h){return XL(ih,h)}function Hy(h,m){return ih===null&&ah(h),XL(h,m)}function XL(h,m){var _=m._currentValue;if(m={context:m,memoizedValue:_,next:null},Yl===null){if(h===null)throw Error(r(308));Yl=m,h.dependencies={lanes:0,firstContext:m},h.flags|=524288}else Yl=Yl.next=m;return _}var xre=typeof AbortController<"u"?AbortController:function(){var h=[],m=this.signal={aborted:!1,addEventListener:function(_,M){h.push(M)}};this.abort=function(){m.aborted=!0,h.forEach(function(_){return _()})}},bre=t.unstable_scheduleCallback,yre=t.unstable_NormalPriority,si={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function CE(){return{controller:new xre,data:new Map,refCount:0}}function ex(h){h.refCount--,h.refCount===0&&bre(yre,function(){h.controller.abort()})}var tx=null,kE=0,tm=0,nm=null;function vre(h,m){if(tx===null){var _=tx=[];kE=0,tm=RN(),nm={status:"pending",value:void 0,then:function(M){_.push(M)}}}return kE++,m.then(YL,YL),m}function YL(){if(--kE===0&&tx!==null){nm!==null&&(nm.status="fulfilled");var h=tx;tx=null,tm=0,nm=null;for(var m=0;m<h.length;m++)(0,h[m])()}}function _re(h,m){var _=[],M={status:"pending",value:null,reason:null,then:function(j){_.push(j)}};return h.then(function(){M.status="fulfilled",M.value=m;for(var j=0;j<_.length;j++)(0,_[j])(m)},function(j){for(M.status="rejected",M.reason=j,j=0;j<_.length;j++)(0,_[j])(void 0)}),M}var QL=J.S;J.S=function(h,m){D5=I(),typeof m=="object"&&m!==null&&typeof m.then=="function"&&vre(h,m),QL!==null&&QL(h,m)};var sh=F(null);function jE(){var h=sh.current;return h!==null?h:mr.pooledCache}function Vy(h,m){m===null?ne(sh,sh.current):ne(sh,m.pool)}function ZL(){var h=jE();return h===null?null:{parent:si._currentValue,pool:h}}var rm=Error(r(460)),PE=Error(r(474)),Gy=Error(r(542)),Wy={then:function(){}};function JL(h){return h=h.status,h==="fulfilled"||h==="rejected"}function eI(h,m,_){switch(_=h[_],_===void 0?h.push(m):_!==m&&(m.then(Wl,Wl),m=_),m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,nI(h),h;default:if(typeof m.status=="string")m.then(Wl,Wl);else{if(h=mr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=m,h.status="pending",h.then(function(M){if(m.status==="pending"){var j=m;j.status="fulfilled",j.value=M}},function(M){if(m.status==="pending"){var j=m;j.status="rejected",j.reason=M}})}switch(m.status){case"fulfilled":return m.value;case"rejected":throw h=m.reason,nI(h),h}throw lh=m,rm}}function oh(h){try{var m=h._init;return m(h._payload)}catch(_){throw _!==null&&typeof _=="object"&&typeof _.then=="function"?(lh=_,rm):_}}var lh=null;function tI(){if(lh===null)throw Error(r(459));var h=lh;return lh=null,h}function nI(h){if(h===rm||h===Gy)throw Error(r(483))}var im=null,nx=0;function qy(h){var m=nx;return nx+=1,im===null&&(im=[]),eI(im,h,m)}function rx(h,m){m=m.props.ref,h.ref=m!==void 0?m:null}function Ky(h,m){throw m.$$typeof===p?Error(r(525)):(h=Object.prototype.toString.call(m),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(m).join(", ")+"}":h)))}function rI(h){function m(Ge,Ue){if(h){var et=Ge.deletions;et===null?(Ge.deletions=[Ue],Ge.flags|=16):et.push(Ue)}}function _(Ge,Ue){if(!h)return null;for(;Ue!==null;)m(Ge,Ue),Ue=Ue.sibling;return null}function M(Ge){for(var Ue=new Map;Ge!==null;)Ge.key!==null?Ue.set(Ge.key,Ge):Ue.set(Ge.index,Ge),Ge=Ge.sibling;return Ue}function j(Ge,Ue){return Ge=Kl(Ge,Ue),Ge.index=0,Ge.sibling=null,Ge}function O(Ge,Ue,et){return Ge.index=et,h?(et=Ge.alternate,et!==null?(et=et.index,et<Ue?(Ge.flags|=67108866,Ue):et):(Ge.flags|=67108866,Ue)):(Ge.flags|=1048576,Ue)}function te(Ge){return h&&Ge.alternate===null&&(Ge.flags|=67108866),Ge}function he(Ge,Ue,et,pt){return Ue===null||Ue.tag!==6?(Ue=vE(et,Ge.mode,pt),Ue.return=Ge,Ue):(Ue=j(Ue,et),Ue.return=Ge,Ue)}function Pe(Ge,Ue,et,pt){var Gt=et.type;return Gt===v?dt(Ge,Ue,et.props.children,pt,et.key):Ue!==null&&(Ue.elementType===Gt||typeof Gt=="object"&&Gt!==null&&Gt.$$typeof===D&&oh(Gt)===Ue.type)?(Ue=j(Ue,et.props),rx(Ue,et),Ue.return=Ge,Ue):(Ue=zy(et.type,et.key,et.props,null,Ge.mode,pt),rx(Ue,et),Ue.return=Ge,Ue)}function tt(Ge,Ue,et,pt){return Ue===null||Ue.tag!==4||Ue.stateNode.containerInfo!==et.containerInfo||Ue.stateNode.implementation!==et.implementation?(Ue=_E(et,Ge.mode,pt),Ue.return=Ge,Ue):(Ue=j(Ue,et.children||[]),Ue.return=Ge,Ue)}function dt(Ge,Ue,et,pt,Gt){return Ue===null||Ue.tag!==7?(Ue=nh(et,Ge.mode,pt,Gt),Ue.return=Ge,Ue):(Ue=j(Ue,et),Ue.return=Ge,Ue)}function bt(Ge,Ue,et){if(typeof Ue=="string"&&Ue!==""||typeof Ue=="number"||typeof Ue=="bigint")return Ue=vE(""+Ue,Ge.mode,et),Ue.return=Ge,Ue;if(typeof Ue=="object"&&Ue!==null){switch(Ue.$$typeof){case g:return et=zy(Ue.type,Ue.key,Ue.props,null,Ge.mode,et),rx(et,Ue),et.return=Ge,et;case b:return Ue=_E(Ue,Ge.mode,et),Ue.return=Ge,Ue;case D:return Ue=oh(Ue),bt(Ge,Ue,et)}if(Y(Ue)||L(Ue))return Ue=nh(Ue,Ge.mode,et,null),Ue.return=Ge,Ue;if(typeof Ue.then=="function")return bt(Ge,qy(Ue),et);if(Ue.$$typeof===w)return bt(Ge,Hy(Ge,Ue),et);Ky(Ge,Ue)}return null}function rt(Ge,Ue,et,pt){var Gt=Ue!==null?Ue.key:null;if(typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint")return Gt!==null?null:he(Ge,Ue,""+et,pt);if(typeof et=="object"&&et!==null){switch(et.$$typeof){case g:return et.key===Gt?Pe(Ge,Ue,et,pt):null;case b:return et.key===Gt?tt(Ge,Ue,et,pt):null;case D:return et=oh(et),rt(Ge,Ue,et,pt)}if(Y(et)||L(et))return Gt!==null?null:dt(Ge,Ue,et,pt,null);if(typeof et.then=="function")return rt(Ge,Ue,qy(et),pt);if(et.$$typeof===w)return rt(Ge,Ue,Hy(Ge,et),pt);Ky(Ge,et)}return null}function ot(Ge,Ue,et,pt,Gt){if(typeof pt=="string"&&pt!==""||typeof pt=="number"||typeof pt=="bigint")return Ge=Ge.get(et)||null,he(Ue,Ge,""+pt,Gt);if(typeof pt=="object"&&pt!==null){switch(pt.$$typeof){case g:return Ge=Ge.get(pt.key===null?et:pt.key)||null,Pe(Ue,Ge,pt,Gt);case b:return Ge=Ge.get(pt.key===null?et:pt.key)||null,tt(Ue,Ge,pt,Gt);case D:return pt=oh(pt),ot(Ge,Ue,et,pt,Gt)}if(Y(pt)||L(pt))return Ge=Ge.get(et)||null,dt(Ue,Ge,pt,Gt,null);if(typeof pt.then=="function")return ot(Ge,Ue,et,qy(pt),Gt);if(pt.$$typeof===w)return ot(Ge,Ue,et,Hy(Ue,pt),Gt);Ky(Ue,pt)}return null}function Ut(Ge,Ue,et,pt){for(var Gt=null,Ln=null,Bt=Ue,dn=Ue=0,Pn=null;Bt!==null&&dn<et.length;dn++){Bt.index>dn?(Pn=Bt,Bt=null):Pn=Bt.sibling;var In=rt(Ge,Bt,et[dn],pt);if(In===null){Bt===null&&(Bt=Pn);break}h&&Bt&&In.alternate===null&&m(Ge,Bt),Ue=O(In,Ue,dn),Ln===null?Gt=In:Ln.sibling=In,Ln=In,Bt=Pn}if(dn===et.length)return _(Ge,Bt),Rn&&Xl(Ge,dn),Gt;if(Bt===null){for(;dn<et.length;dn++)Bt=bt(Ge,et[dn],pt),Bt!==null&&(Ue=O(Bt,Ue,dn),Ln===null?Gt=Bt:Ln.sibling=Bt,Ln=Bt);return Rn&&Xl(Ge,dn),Gt}for(Bt=M(Bt);dn<et.length;dn++)Pn=ot(Bt,Ge,dn,et[dn],pt),Pn!==null&&(h&&Pn.alternate!==null&&Bt.delete(Pn.key===null?dn:Pn.key),Ue=O(Pn,Ue,dn),Ln===null?Gt=Pn:Ln.sibling=Pn,Ln=Pn);return h&&Bt.forEach(function(Lu){return m(Ge,Lu)}),Rn&&Xl(Ge,dn),Gt}function Qt(Ge,Ue,et,pt){if(et==null)throw Error(r(151));for(var Gt=null,Ln=null,Bt=Ue,dn=Ue=0,Pn=null,In=et.next();Bt!==null&&!In.done;dn++,In=et.next()){Bt.index>dn?(Pn=Bt,Bt=null):Pn=Bt.sibling;var Lu=rt(Ge,Bt,In.value,pt);if(Lu===null){Bt===null&&(Bt=Pn);break}h&&Bt&&Lu.alternate===null&&m(Ge,Bt),Ue=O(Lu,Ue,dn),Ln===null?Gt=Lu:Ln.sibling=Lu,Ln=Lu,Bt=Pn}if(In.done)return _(Ge,Bt),Rn&&Xl(Ge,dn),Gt;if(Bt===null){for(;!In.done;dn++,In=et.next())In=bt(Ge,In.value,pt),In!==null&&(Ue=O(In,Ue,dn),Ln===null?Gt=In:Ln.sibling=In,Ln=In);return Rn&&Xl(Ge,dn),Gt}for(Bt=M(Bt);!In.done;dn++,In=et.next())In=ot(Bt,Ge,dn,In.value,pt),In!==null&&(h&&In.alternate!==null&&Bt.delete(In.key===null?dn:In.key),Ue=O(In,Ue,dn),Ln===null?Gt=In:Ln.sibling=In,Ln=In);return h&&Bt.forEach(function(Pie){return m(Ge,Pie)}),Rn&&Xl(Ge,dn),Gt}function ar(Ge,Ue,et,pt){if(typeof et=="object"&&et!==null&&et.type===v&&et.key===null&&(et=et.props.children),typeof et=="object"&&et!==null){switch(et.$$typeof){case g:e:{for(var Gt=et.key;Ue!==null;){if(Ue.key===Gt){if(Gt=et.type,Gt===v){if(Ue.tag===7){_(Ge,Ue.sibling),pt=j(Ue,et.props.children),pt.return=Ge,Ge=pt;break e}}else if(Ue.elementType===Gt||typeof Gt=="object"&&Gt!==null&&Gt.$$typeof===D&&oh(Gt)===Ue.type){_(Ge,Ue.sibling),pt=j(Ue,et.props),rx(pt,et),pt.return=Ge,Ge=pt;break e}_(Ge,Ue);break}else m(Ge,Ue);Ue=Ue.sibling}et.type===v?(pt=nh(et.props.children,Ge.mode,pt,et.key),pt.return=Ge,Ge=pt):(pt=zy(et.type,et.key,et.props,null,Ge.mode,pt),rx(pt,et),pt.return=Ge,Ge=pt)}return te(Ge);case b:e:{for(Gt=et.key;Ue!==null;){if(Ue.key===Gt)if(Ue.tag===4&&Ue.stateNode.containerInfo===et.containerInfo&&Ue.stateNode.implementation===et.implementation){_(Ge,Ue.sibling),pt=j(Ue,et.children||[]),pt.return=Ge,Ge=pt;break e}else{_(Ge,Ue);break}else m(Ge,Ue);Ue=Ue.sibling}pt=_E(et,Ge.mode,pt),pt.return=Ge,Ge=pt}return te(Ge);case D:return et=oh(et),ar(Ge,Ue,et,pt)}if(Y(et))return Ut(Ge,Ue,et,pt);if(L(et)){if(Gt=L(et),typeof Gt!="function")throw Error(r(150));return et=Gt.call(et),Qt(Ge,Ue,et,pt)}if(typeof et.then=="function")return ar(Ge,Ue,qy(et),pt);if(et.$$typeof===w)return ar(Ge,Ue,Hy(Ge,et),pt);Ky(Ge,et)}return typeof et=="string"&&et!==""||typeof et=="number"||typeof et=="bigint"?(et=""+et,Ue!==null&&Ue.tag===6?(_(Ge,Ue.sibling),pt=j(Ue,et),pt.return=Ge,Ge=pt):(_(Ge,Ue),pt=vE(et,Ge.mode,pt),pt.return=Ge,Ge=pt),te(Ge)):_(Ge,Ue)}return function(Ge,Ue,et,pt){try{nx=0;var Gt=ar(Ge,Ue,et,pt);return im=null,Gt}catch(Bt){if(Bt===rm||Bt===Gy)throw Bt;var Ln=xs(29,Bt,null,Ge.mode);return Ln.lanes=pt,Ln.return=Ge,Ln}finally{}}}var ch=rI(!0),iI=rI(!1),yu=!1;function RE(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function DE(h,m){h=h.updateQueue,m.updateQueue===h&&(m.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function vu(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function _u(h,m,_){var M=h.updateQueue;if(M===null)return null;if(M=M.shared,(Bn&2)!==0){var j=M.pending;return j===null?m.next=m:(m.next=j.next,j.next=m),M.pending=m,m=Uy(h),BL(h,null,_),m}return Fy(h,M,m,_),Uy(h)}function ix(h,m,_){if(m=m.updateQueue,m!==null&&(m=m.shared,(_&4194048)!==0)){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,$t(h,_)}}function OE(h,m){var _=h.updateQueue,M=h.alternate;if(M!==null&&(M=M.updateQueue,_===M)){var j=null,O=null;if(_=_.firstBaseUpdate,_!==null){do{var te={lane:_.lane,tag:_.tag,payload:_.payload,callback:null,next:null};O===null?j=O=te:O=O.next=te,_=_.next}while(_!==null);O===null?j=O=m:O=O.next=m}else j=O=m;_={baseState:M.baseState,firstBaseUpdate:j,lastBaseUpdate:O,shared:M.shared,callbacks:M.callbacks},h.updateQueue=_;return}h=_.lastBaseUpdate,h===null?_.firstBaseUpdate=m:h.next=m,_.lastBaseUpdate=m}var LE=!1;function ax(){if(LE){var h=nm;if(h!==null)throw h}}function sx(h,m,_,M){LE=!1;var j=h.updateQueue;yu=!1;var O=j.firstBaseUpdate,te=j.lastBaseUpdate,he=j.shared.pending;if(he!==null){j.shared.pending=null;var Pe=he,tt=Pe.next;Pe.next=null,te===null?O=tt:te.next=tt,te=Pe;var dt=h.alternate;dt!==null&&(dt=dt.updateQueue,he=dt.lastBaseUpdate,he!==te&&(he===null?dt.firstBaseUpdate=tt:he.next=tt,dt.lastBaseUpdate=Pe))}if(O!==null){var bt=j.baseState;te=0,dt=tt=Pe=null,he=O;do{var rt=he.lane&-536870913,ot=rt!==he.lane;if(ot?(jn&rt)===rt:(M&rt)===rt){rt!==0&&rt===tm&&(LE=!0),dt!==null&&(dt=dt.next={lane:0,tag:he.tag,payload:he.payload,callback:null,next:null});e:{var Ut=h,Qt=he;rt=m;var ar=_;switch(Qt.tag){case 1:if(Ut=Qt.payload,typeof Ut=="function"){bt=Ut.call(ar,bt,rt);break e}bt=Ut;break e;case 3:Ut.flags=Ut.flags&-65537|128;case 0:if(Ut=Qt.payload,rt=typeof Ut=="function"?Ut.call(ar,bt,rt):Ut,rt==null)break e;bt=f({},bt,rt);break e;case 2:yu=!0}}rt=he.callback,rt!==null&&(h.flags|=64,ot&&(h.flags|=8192),ot=j.callbacks,ot===null?j.callbacks=[rt]:ot.push(rt))}else ot={lane:rt,tag:he.tag,payload:he.payload,callback:he.callback,next:null},dt===null?(tt=dt=ot,Pe=bt):dt=dt.next=ot,te|=rt;if(he=he.next,he===null){if(he=j.shared.pending,he===null)break;ot=he,he=ot.next,ot.next=null,j.lastBaseUpdate=ot,j.shared.pending=null}}while(!0);dt===null&&(Pe=bt),j.baseState=Pe,j.firstBaseUpdate=tt,j.lastBaseUpdate=dt,O===null&&(j.shared.lanes=0),Nu|=te,h.lanes=te,h.memoizedState=bt}}function aI(h,m){if(typeof h!="function")throw Error(r(191,h));h.call(m)}function sI(h,m){var _=h.callbacks;if(_!==null)for(h.callbacks=null,h=0;h<_.length;h++)aI(_[h],m)}var am=F(null),Xy=F(0);function oI(h,m){h=sc,ne(Xy,h),ne(am,m),sc=h|m.baseLanes}function IE(){ne(Xy,sc),ne(am,am.current)}function FE(){sc=Xy.current,q(am),q(Xy)}var bs=F(null),Qs=null;function wu(h){var m=h.alternate;ne(ti,ti.current&1),ne(bs,h),Qs===null&&(m===null||am.current!==null||m.memoizedState!==null)&&(Qs=h)}function UE(h){ne(ti,ti.current),ne(bs,h),Qs===null&&(Qs=h)}function lI(h){h.tag===22?(ne(ti,ti.current),ne(bs,h),Qs===null&&(Qs=h)):Su()}function Su(){ne(ti,ti.current),ne(bs,bs.current)}function ys(h){q(bs),Qs===h&&(Qs=null),q(ti)}var ti=F(0);function Yy(h){for(var m=h;m!==null;){if(m.tag===13){var _=m.memoizedState;if(_!==null&&(_=_.dehydrated,_===null||GN(_)||WN(_)))return m}else if(m.tag===19&&(m.memoizedProps.revealOrder==="forwards"||m.memoizedProps.revealOrder==="backwards"||m.memoizedProps.revealOrder==="unstable_legacy-backwards"||m.memoizedProps.revealOrder==="together")){if((m.flags&128)!==0)return m}else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return null;m=m.return}m.sibling.return=m.return,m=m.sibling}return null}var Zl=0,un=null,rr=null,oi=null,Qy=!1,sm=!1,uh=!1,Zy=0,ox=0,om=null,wre=0;function zr(){throw Error(r(321))}function zE(h,m){if(m===null)return!1;for(var _=0;_<m.length&&_<h.length;_++)if(!gs(h[_],m[_]))return!1;return!0}function BE(h,m,_,M,j,O){return Zl=O,un=m,m.memoizedState=null,m.updateQueue=null,m.lanes=0,J.H=h===null||h.memoizedState===null?GI:nN,uh=!1,O=_(M,j),uh=!1,sm&&(O=uI(m,_,M,j)),cI(h),O}function cI(h){J.H=ux;var m=rr!==null&&rr.next!==null;if(Zl=0,oi=rr=un=null,Qy=!1,ox=0,om=null,m)throw Error(r(300));h===null||li||(h=h.dependencies,h!==null&&$y(h)&&(li=!0))}function uI(h,m,_,M){un=h;var j=0;do{if(sm&&(om=null),ox=0,sm=!1,25<=j)throw Error(r(301));if(j+=1,oi=rr=null,h.updateQueue!=null){var O=h.updateQueue;O.lastEffect=null,O.events=null,O.stores=null,O.memoCache!=null&&(O.memoCache.index=0)}J.H=WI,O=m(_,M)}while(sm);return O}function Sre(){var h=J.H,m=h.useState()[0];return m=typeof m.then=="function"?lx(m):m,h=h.useState()[0],(rr!==null?rr.memoizedState:null)!==h&&(un.flags|=1024),m}function $E(){var h=Zy!==0;return Zy=0,h}function HE(h,m,_){m.updateQueue=h.updateQueue,m.flags&=-2053,h.lanes&=~_}function VE(h){if(Qy){for(h=h.memoizedState;h!==null;){var m=h.queue;m!==null&&(m.pending=null),h=h.next}Qy=!1}Zl=0,oi=rr=un=null,sm=!1,ox=Zy=0,om=null}function Pa(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return oi===null?un.memoizedState=oi=h:oi=oi.next=h,oi}function ni(){if(rr===null){var h=un.alternate;h=h!==null?h.memoizedState:null}else h=rr.next;var m=oi===null?un.memoizedState:oi.next;if(m!==null)oi=m,rr=h;else{if(h===null)throw un.alternate===null?Error(r(467)):Error(r(310));rr=h,h={memoizedState:rr.memoizedState,baseState:rr.baseState,baseQueue:rr.baseQueue,queue:rr.queue,next:null},oi===null?un.memoizedState=oi=h:oi=oi.next=h}return oi}function Jy(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function lx(h){var m=ox;return ox+=1,om===null&&(om=[]),h=eI(om,h,m),m=un,(oi===null?m.memoizedState:oi.next)===null&&(m=m.alternate,J.H=m===null||m.memoizedState===null?GI:nN),h}function ev(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return lx(h);if(h.$$typeof===w)return ta(h)}throw Error(r(438,String(h)))}function GE(h){var m=null,_=un.updateQueue;if(_!==null&&(m=_.memoCache),m==null){var M=un.alternate;M!==null&&(M=M.updateQueue,M!==null&&(M=M.memoCache,M!=null&&(m={data:M.data.map(function(j){return j.slice()}),index:0})))}if(m==null&&(m={data:[],index:0}),_===null&&(_=Jy(),un.updateQueue=_),_.memoCache=m,_=m.data[m.index],_===void 0)for(_=m.data[m.index]=Array(h),M=0;M<h;M++)_[M]=P;return m.index++,_}function Jl(h,m){return typeof m=="function"?m(h):m}function tv(h){var m=ni();return WE(m,rr,h)}function WE(h,m,_){var M=h.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=_;var j=h.baseQueue,O=M.pending;if(O!==null){if(j!==null){var te=j.next;j.next=O.next,O.next=te}m.baseQueue=j=O,M.pending=null}if(O=h.baseState,j===null)h.memoizedState=O;else{m=j.next;var he=te=null,Pe=null,tt=m,dt=!1;do{var bt=tt.lane&-536870913;if(bt!==tt.lane?(jn&bt)===bt:(Zl&bt)===bt){var rt=tt.revertLane;if(rt===0)Pe!==null&&(Pe=Pe.next={lane:0,revertLane:0,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null}),bt===tm&&(dt=!0);else if((Zl&rt)===rt){tt=tt.next,rt===tm&&(dt=!0);continue}else bt={lane:0,revertLane:tt.revertLane,gesture:null,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},Pe===null?(he=Pe=bt,te=O):Pe=Pe.next=bt,un.lanes|=rt,Nu|=rt;bt=tt.action,uh&&_(O,bt),O=tt.hasEagerState?tt.eagerState:_(O,bt)}else rt={lane:bt,revertLane:tt.revertLane,gesture:tt.gesture,action:tt.action,hasEagerState:tt.hasEagerState,eagerState:tt.eagerState,next:null},Pe===null?(he=Pe=rt,te=O):Pe=Pe.next=rt,un.lanes|=bt,Nu|=bt;tt=tt.next}while(tt!==null&&tt!==m);if(Pe===null?te=O:Pe.next=he,!gs(O,h.memoizedState)&&(li=!0,dt&&(_=nm,_!==null)))throw _;h.memoizedState=O,h.baseState=te,h.baseQueue=Pe,M.lastRenderedState=O}return j===null&&(M.lanes=0),[h.memoizedState,M.dispatch]}function qE(h){var m=ni(),_=m.queue;if(_===null)throw Error(r(311));_.lastRenderedReducer=h;var M=_.dispatch,j=_.pending,O=m.memoizedState;if(j!==null){_.pending=null;var te=j=j.next;do O=h(O,te.action),te=te.next;while(te!==j);gs(O,m.memoizedState)||(li=!0),m.memoizedState=O,m.baseQueue===null&&(m.baseState=O),_.lastRenderedState=O}return[O,M]}function dI(h,m,_){var M=un,j=ni(),O=Rn;if(O){if(_===void 0)throw Error(r(407));_=_()}else _=m();var te=!gs((rr||j).memoizedState,_);if(te&&(j.memoizedState=_,li=!0),j=j.queue,YE(mI.bind(null,M,j,h),[h]),j.getSnapshot!==m||te||oi!==null&&oi.memoizedState.tag&1){if(M.flags|=2048,lm(9,{destroy:void 0},fI.bind(null,M,j,_,m),null),mr===null)throw Error(r(349));O||(Zl&127)!==0||hI(M,m,_)}return _}function hI(h,m,_){h.flags|=16384,h={getSnapshot:m,value:_},m=un.updateQueue,m===null?(m=Jy(),un.updateQueue=m,m.stores=[h]):(_=m.stores,_===null?m.stores=[h]:_.push(h))}function fI(h,m,_,M){m.value=_,m.getSnapshot=M,pI(m)&&gI(h)}function mI(h,m,_){return _(function(){pI(m)&&gI(h)})}function pI(h){var m=h.getSnapshot;h=h.value;try{var _=m();return!gs(h,_)}catch{return!0}}function gI(h){var m=th(h,2);m!==null&&es(m,h,2)}function KE(h){var m=Pa();if(typeof h=="function"){var _=h;if(h=_(),uh){Ke(!0);try{_()}finally{Ke(!1)}}}return m.memoizedState=m.baseState=h,m.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jl,lastRenderedState:h},m}function xI(h,m,_,M){return h.baseState=_,WE(h,rr,typeof M=="function"?M:Jl)}function Mre(h,m,_,M,j){if(iv(h))throw Error(r(485));if(h=m.action,h!==null){var O={payload:j,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(te){O.listeners.push(te)}};J.T!==null?_(!0):O.isTransition=!1,M(O),_=m.pending,_===null?(O.next=m.pending=O,bI(m,O)):(O.next=_.next,m.pending=_.next=O)}}function bI(h,m){var _=m.action,M=m.payload,j=h.state;if(m.isTransition){var O=J.T,te={};J.T=te;try{var he=_(j,M),Pe=J.S;Pe!==null&&Pe(te,he),yI(h,m,he)}catch(tt){XE(h,m,tt)}finally{O!==null&&te.types!==null&&(O.types=te.types),J.T=O}}else try{O=_(j,M),yI(h,m,O)}catch(tt){XE(h,m,tt)}}function yI(h,m,_){_!==null&&typeof _=="object"&&typeof _.then=="function"?_.then(function(M){vI(h,m,M)},function(M){return XE(h,m,M)}):vI(h,m,_)}function vI(h,m,_){m.status="fulfilled",m.value=_,_I(m),h.state=_,m=h.pending,m!==null&&(_=m.next,_===m?h.pending=null:(_=_.next,m.next=_,bI(h,_)))}function XE(h,m,_){var M=h.pending;if(h.pending=null,M!==null){M=M.next;do m.status="rejected",m.reason=_,_I(m),m=m.next;while(m!==M)}h.action=null}function _I(h){h=h.listeners;for(var m=0;m<h.length;m++)(0,h[m])()}function wI(h,m){return m}function SI(h,m){if(Rn){var _=mr.formState;if(_!==null){e:{var M=un;if(Rn){if(_r){t:{for(var j=_r,O=Ys;j.nodeType!==8;){if(!O){j=null;break t}if(j=Zs(j.nextSibling),j===null){j=null;break t}}O=j.data,j=O==="F!"||O==="F"?j:null}if(j){_r=Zs(j.nextSibling),M=j.data==="F!";break e}}xu(M)}M=!1}M&&(m=_[0])}}return _=Pa(),_.memoizedState=_.baseState=m,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:wI,lastRenderedState:m},_.queue=M,_=$I.bind(null,un,M),M.dispatch=_,M=KE(!1),O=tN.bind(null,un,!1,M.queue),M=Pa(),j={state:m,dispatch:null,action:h,pending:null},M.queue=j,_=Mre.bind(null,un,j,O,_),j.dispatch=_,M.memoizedState=h,[m,_,!1]}function MI(h){var m=ni();return EI(m,rr,h)}function EI(h,m,_){if(m=WE(h,m,wI)[0],h=tv(Jl)[0],typeof m=="object"&&m!==null&&typeof m.then=="function")try{var M=lx(m)}catch(te){throw te===rm?Gy:te}else M=m;m=ni();var j=m.queue,O=j.dispatch;return _!==m.memoizedState&&(un.flags|=2048,lm(9,{destroy:void 0},Ere.bind(null,j,_),null)),[M,O,h]}function Ere(h,m){h.action=m}function NI(h){var m=ni(),_=rr;if(_!==null)return EI(m,_,h);ni(),m=m.memoizedState,_=ni();var M=_.queue.dispatch;return _.memoizedState=h,[m,M,!1]}function lm(h,m,_,M){return h={tag:h,create:_,deps:M,inst:m,next:null},m=un.updateQueue,m===null&&(m=Jy(),un.updateQueue=m),_=m.lastEffect,_===null?m.lastEffect=h.next=h:(M=_.next,_.next=h,h.next=M,m.lastEffect=h),h}function AI(){return ni().memoizedState}function nv(h,m,_,M){var j=Pa();un.flags|=h,j.memoizedState=lm(1|m,{destroy:void 0},_,M===void 0?null:M)}function rv(h,m,_,M){var j=ni();M=M===void 0?null:M;var O=j.memoizedState.inst;rr!==null&&M!==null&&zE(M,rr.memoizedState.deps)?j.memoizedState=lm(m,O,_,M):(un.flags|=h,j.memoizedState=lm(1|m,O,_,M))}function TI(h,m){nv(8390656,8,h,m)}function YE(h,m){rv(2048,8,h,m)}function Nre(h){un.flags|=4;var m=un.updateQueue;if(m===null)m=Jy(),un.updateQueue=m,m.events=[h];else{var _=m.events;_===null?m.events=[h]:_.push(h)}}function CI(h){var m=ni().memoizedState;return Nre({ref:m,nextImpl:h}),function(){if((Bn&2)!==0)throw Error(r(440));return m.impl.apply(void 0,arguments)}}function kI(h,m){return rv(4,2,h,m)}function jI(h,m){return rv(4,4,h,m)}function PI(h,m){if(typeof m=="function"){h=h();var _=m(h);return function(){typeof _=="function"?_():m(null)}}if(m!=null)return h=h(),m.current=h,function(){m.current=null}}function RI(h,m,_){_=_!=null?_.concat([h]):null,rv(4,4,PI.bind(null,m,h),_)}function QE(){}function DI(h,m){var _=ni();m=m===void 0?null:m;var M=_.memoizedState;return m!==null&&zE(m,M[1])?M[0]:(_.memoizedState=[h,m],h)}function OI(h,m){var _=ni();m=m===void 0?null:m;var M=_.memoizedState;if(m!==null&&zE(m,M[1]))return M[0];if(M=h(),uh){Ke(!0);try{h()}finally{Ke(!1)}}return _.memoizedState=[M,m],M}function ZE(h,m,_){return _===void 0||(Zl&1073741824)!==0&&(jn&261930)===0?h.memoizedState=m:(h.memoizedState=_,h=L5(),un.lanes|=h,Nu|=h,_)}function LI(h,m,_,M){return gs(_,m)?_:am.current!==null?(h=ZE(h,_,M),gs(h,m)||(li=!0),h):(Zl&42)===0||(Zl&1073741824)!==0&&(jn&261930)===0?(li=!0,h.memoizedState=_):(h=L5(),un.lanes|=h,Nu|=h,m)}function II(h,m,_,M,j){var O=G.p;G.p=O!==0&&8>O?O:8;var te=J.T,he={};J.T=he,tN(h,!1,m,_);try{var Pe=j(),tt=J.S;if(tt!==null&&tt(he,Pe),Pe!==null&&typeof Pe=="object"&&typeof Pe.then=="function"){var dt=_re(Pe,M);cx(h,m,dt,ws(h))}else cx(h,m,M,ws(h))}catch(bt){cx(h,m,{then:function(){},status:"rejected",reason:bt},ws())}finally{G.p=O,te!==null&&he.types!==null&&(te.types=he.types),J.T=te}}function Are(){}function JE(h,m,_,M){if(h.tag!==5)throw Error(r(476));var j=FI(h).queue;II(h,j,m,W,_===null?Are:function(){return UI(h),_(M)})}function FI(h){var m=h.memoizedState;if(m!==null)return m;m={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jl,lastRenderedState:W},next:null};var _={};return m.next={memoizedState:_,baseState:_,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jl,lastRenderedState:_},next:null},h.memoizedState=m,h=h.alternate,h!==null&&(h.memoizedState=m),m}function UI(h){var m=FI(h);m.next===null&&(m=h.alternate.memoizedState),cx(h,m.next.queue,{},ws())}function eN(){return ta(Nx)}function zI(){return ni().memoizedState}function BI(){return ni().memoizedState}function Tre(h){for(var m=h.return;m!==null;){switch(m.tag){case 24:case 3:var _=ws();h=vu(_);var M=_u(m,h,_);M!==null&&(es(M,m,_),ix(M,m,_)),m={cache:CE()},h.payload=m;return}m=m.return}}function Cre(h,m,_){var M=ws();_={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},iv(h)?HI(m,_):(_=bE(h,m,_,M),_!==null&&(es(_,h,M),VI(_,m,M)))}function $I(h,m,_){var M=ws();cx(h,m,_,M)}function cx(h,m,_,M){var j={lane:M,revertLane:0,gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null};if(iv(h))HI(m,j);else{var O=h.alternate;if(h.lanes===0&&(O===null||O.lanes===0)&&(O=m.lastRenderedReducer,O!==null))try{var te=m.lastRenderedState,he=O(te,_);if(j.hasEagerState=!0,j.eagerState=he,gs(he,te))return Fy(h,m,j,0),mr===null&&Iy(),!1}catch{}finally{}if(_=bE(h,m,j,M),_!==null)return es(_,h,M),VI(_,m,M),!0}return!1}function tN(h,m,_,M){if(M={lane:2,revertLane:RN(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},iv(h)){if(m)throw Error(r(479))}else m=bE(h,_,M,2),m!==null&&es(m,h,2)}function iv(h){var m=h.alternate;return h===un||m!==null&&m===un}function HI(h,m){sm=Qy=!0;var _=h.pending;_===null?m.next=m:(m.next=_.next,_.next=m),h.pending=m}function VI(h,m,_){if((_&4194048)!==0){var M=m.lanes;M&=h.pendingLanes,_|=M,m.lanes=_,$t(h,_)}}var ux={readContext:ta,use:ev,useCallback:zr,useContext:zr,useEffect:zr,useImperativeHandle:zr,useLayoutEffect:zr,useInsertionEffect:zr,useMemo:zr,useReducer:zr,useRef:zr,useState:zr,useDebugValue:zr,useDeferredValue:zr,useTransition:zr,useSyncExternalStore:zr,useId:zr,useHostTransitionStatus:zr,useFormState:zr,useActionState:zr,useOptimistic:zr,useMemoCache:zr,useCacheRefresh:zr};ux.useEffectEvent=zr;var GI={readContext:ta,use:ev,useCallback:function(h,m){return Pa().memoizedState=[h,m===void 0?null:m],h},useContext:ta,useEffect:TI,useImperativeHandle:function(h,m,_){_=_!=null?_.concat([h]):null,nv(4194308,4,PI.bind(null,m,h),_)},useLayoutEffect:function(h,m){return nv(4194308,4,h,m)},useInsertionEffect:function(h,m){nv(4,2,h,m)},useMemo:function(h,m){var _=Pa();m=m===void 0?null:m;var M=h();if(uh){Ke(!0);try{h()}finally{Ke(!1)}}return _.memoizedState=[M,m],M},useReducer:function(h,m,_){var M=Pa();if(_!==void 0){var j=_(m);if(uh){Ke(!0);try{_(m)}finally{Ke(!1)}}}else j=m;return M.memoizedState=M.baseState=j,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:j},M.queue=h,h=h.dispatch=Cre.bind(null,un,h),[M.memoizedState,h]},useRef:function(h){var m=Pa();return h={current:h},m.memoizedState=h},useState:function(h){h=KE(h);var m=h.queue,_=$I.bind(null,un,m);return m.dispatch=_,[h.memoizedState,_]},useDebugValue:QE,useDeferredValue:function(h,m){var _=Pa();return ZE(_,h,m)},useTransition:function(){var h=KE(!1);return h=II.bind(null,un,h.queue,!0,!1),Pa().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,m,_){var M=un,j=Pa();if(Rn){if(_===void 0)throw Error(r(407));_=_()}else{if(_=m(),mr===null)throw Error(r(349));(jn&127)!==0||hI(M,m,_)}j.memoizedState=_;var O={value:_,getSnapshot:m};return j.queue=O,TI(mI.bind(null,M,O,h),[h]),M.flags|=2048,lm(9,{destroy:void 0},fI.bind(null,M,O,_,m),null),_},useId:function(){var h=Pa(),m=mr.identifierPrefix;if(Rn){var _=ol,M=sl;_=(M&~(1<<32-qe(M)-1)).toString(32)+_,m="_"+m+"R_"+_,_=Zy++,0<_&&(m+="H"+_.toString(32)),m+="_"}else _=wre++,m="_"+m+"r_"+_.toString(32)+"_";return h.memoizedState=m},useHostTransitionStatus:eN,useFormState:SI,useActionState:SI,useOptimistic:function(h){var m=Pa();m.memoizedState=m.baseState=h;var _={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return m.queue=_,m=tN.bind(null,un,!0,_),_.dispatch=m,[h,m]},useMemoCache:GE,useCacheRefresh:function(){return Pa().memoizedState=Tre.bind(null,un)},useEffectEvent:function(h){var m=Pa(),_={impl:h};return m.memoizedState=_,function(){if((Bn&2)!==0)throw Error(r(440));return _.impl.apply(void 0,arguments)}}},nN={readContext:ta,use:ev,useCallback:DI,useContext:ta,useEffect:YE,useImperativeHandle:RI,useInsertionEffect:kI,useLayoutEffect:jI,useMemo:OI,useReducer:tv,useRef:AI,useState:function(){return tv(Jl)},useDebugValue:QE,useDeferredValue:function(h,m){var _=ni();return LI(_,rr.memoizedState,h,m)},useTransition:function(){var h=tv(Jl)[0],m=ni().memoizedState;return[typeof h=="boolean"?h:lx(h),m]},useSyncExternalStore:dI,useId:zI,useHostTransitionStatus:eN,useFormState:MI,useActionState:MI,useOptimistic:function(h,m){var _=ni();return xI(_,rr,h,m)},useMemoCache:GE,useCacheRefresh:BI};nN.useEffectEvent=CI;var WI={readContext:ta,use:ev,useCallback:DI,useContext:ta,useEffect:YE,useImperativeHandle:RI,useInsertionEffect:kI,useLayoutEffect:jI,useMemo:OI,useReducer:qE,useRef:AI,useState:function(){return qE(Jl)},useDebugValue:QE,useDeferredValue:function(h,m){var _=ni();return rr===null?ZE(_,h,m):LI(_,rr.memoizedState,h,m)},useTransition:function(){var h=qE(Jl)[0],m=ni().memoizedState;return[typeof h=="boolean"?h:lx(h),m]},useSyncExternalStore:dI,useId:zI,useHostTransitionStatus:eN,useFormState:NI,useActionState:NI,useOptimistic:function(h,m){var _=ni();return rr!==null?xI(_,rr,h,m):(_.baseState=h,[h,_.queue.dispatch])},useMemoCache:GE,useCacheRefresh:BI};WI.useEffectEvent=CI;function rN(h,m,_,M){m=h.memoizedState,_=_(M,m),_=_==null?m:f({},m,_),h.memoizedState=_,h.lanes===0&&(h.updateQueue.baseState=_)}var iN={enqueueSetState:function(h,m,_){h=h._reactInternals;var M=ws(),j=vu(M);j.payload=m,_!=null&&(j.callback=_),m=_u(h,j,M),m!==null&&(es(m,h,M),ix(m,h,M))},enqueueReplaceState:function(h,m,_){h=h._reactInternals;var M=ws(),j=vu(M);j.tag=1,j.payload=m,_!=null&&(j.callback=_),m=_u(h,j,M),m!==null&&(es(m,h,M),ix(m,h,M))},enqueueForceUpdate:function(h,m){h=h._reactInternals;var _=ws(),M=vu(_);M.tag=2,m!=null&&(M.callback=m),m=_u(h,M,_),m!==null&&(es(m,h,_),ix(m,h,_))}};function qI(h,m,_,M,j,O,te){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(M,O,te):m.prototype&&m.prototype.isPureReactComponent?!Yg(_,M)||!Yg(j,O):!0}function KI(h,m,_,M){h=m.state,typeof m.componentWillReceiveProps=="function"&&m.componentWillReceiveProps(_,M),typeof m.UNSAFE_componentWillReceiveProps=="function"&&m.UNSAFE_componentWillReceiveProps(_,M),m.state!==h&&iN.enqueueReplaceState(m,m.state,null)}function dh(h,m){var _=m;if("ref"in m){_={};for(var M in m)M!=="ref"&&(_[M]=m[M])}if(h=h.defaultProps){_===m&&(_=f({},_));for(var j in h)_[j]===void 0&&(_[j]=h[j])}return _}function XI(h){Ly(h)}function YI(h){console.error(h)}function QI(h){Ly(h)}function av(h,m){try{var _=h.onUncaughtError;_(m.value,{componentStack:m.stack})}catch(M){setTimeout(function(){throw M})}}function ZI(h,m,_){try{var M=h.onCaughtError;M(_.value,{componentStack:_.stack,errorBoundary:m.tag===1?m.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function aN(h,m,_){return _=vu(_),_.tag=3,_.payload={element:null},_.callback=function(){av(h,m)},_}function JI(h){return h=vu(h),h.tag=3,h}function e5(h,m,_,M){var j=_.type.getDerivedStateFromError;if(typeof j=="function"){var O=M.value;h.payload=function(){return j(O)},h.callback=function(){ZI(m,_,M)}}var te=_.stateNode;te!==null&&typeof te.componentDidCatch=="function"&&(h.callback=function(){ZI(m,_,M),typeof j!="function"&&(Au===null?Au=new Set([this]):Au.add(this));var he=M.stack;this.componentDidCatch(M.value,{componentStack:he!==null?he:""})})}function kre(h,m,_,M,j){if(_.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(m=_.alternate,m!==null&&em(m,_,j,!0),_=bs.current,_!==null){switch(_.tag){case 31:case 13:return Qs===null?xv():_.alternate===null&&Br===0&&(Br=3),_.flags&=-257,_.flags|=65536,_.lanes=j,M===Wy?_.flags|=16384:(m=_.updateQueue,m===null?_.updateQueue=new Set([M]):m.add(M),kN(h,M,j)),!1;case 22:return _.flags|=65536,M===Wy?_.flags|=16384:(m=_.updateQueue,m===null?(m={transitions:null,markerInstances:null,retryQueue:new Set([M])},_.updateQueue=m):(_=m.retryQueue,_===null?m.retryQueue=new Set([M]):_.add(M)),kN(h,M,j)),!1}throw Error(r(435,_.tag))}return kN(h,M,j),xv(),!1}if(Rn)return m=bs.current,m!==null?((m.flags&65536)===0&&(m.flags|=256),m.flags|=65536,m.lanes=j,M!==ME&&(h=Error(r(422),{cause:M}),Jg(qs(h,_)))):(M!==ME&&(m=Error(r(423),{cause:M}),Jg(qs(m,_))),h=h.current.alternate,h.flags|=65536,j&=-j,h.lanes|=j,M=qs(M,_),j=aN(h.stateNode,M,j),OE(h,j),Br!==4&&(Br=2)),!1;var O=Error(r(520),{cause:M});if(O=qs(O,_),bx===null?bx=[O]:bx.push(O),Br!==4&&(Br=2),m===null)return!0;M=qs(M,_),_=m;do{switch(_.tag){case 3:return _.flags|=65536,h=j&-j,_.lanes|=h,h=aN(_.stateNode,M,h),OE(_,h),!1;case 1:if(m=_.type,O=_.stateNode,(_.flags&128)===0&&(typeof m.getDerivedStateFromError=="function"||O!==null&&typeof O.componentDidCatch=="function"&&(Au===null||!Au.has(O))))return _.flags|=65536,j&=-j,_.lanes|=j,j=JI(j),e5(j,h,_,M),OE(_,j),!1}_=_.return}while(_!==null);return!1}var sN=Error(r(461)),li=!1;function na(h,m,_,M){m.child=h===null?iI(m,null,_,M):ch(m,h.child,_,M)}function t5(h,m,_,M,j){_=_.render;var O=m.ref;if("ref"in M){var te={};for(var he in M)he!=="ref"&&(te[he]=M[he])}else te=M;return ah(m),M=BE(h,m,_,te,O,j),he=$E(),h!==null&&!li?(HE(h,m,j),ec(h,m,j)):(Rn&&he&&wE(m),m.flags|=1,na(h,m,M,j),m.child)}function n5(h,m,_,M,j){if(h===null){var O=_.type;return typeof O=="function"&&!yE(O)&&O.defaultProps===void 0&&_.compare===null?(m.tag=15,m.type=O,r5(h,m,O,M,j)):(h=zy(_.type,null,M,m,m.mode,j),h.ref=m.ref,h.return=m,m.child=h)}if(O=h.child,!mN(h,j)){var te=O.memoizedProps;if(_=_.compare,_=_!==null?_:Yg,_(te,M)&&h.ref===m.ref)return ec(h,m,j)}return m.flags|=1,h=Kl(O,M),h.ref=m.ref,h.return=m,m.child=h}function r5(h,m,_,M,j){if(h!==null){var O=h.memoizedProps;if(Yg(O,M)&&h.ref===m.ref)if(li=!1,m.pendingProps=M=O,mN(h,j))(h.flags&131072)!==0&&(li=!0);else return m.lanes=h.lanes,ec(h,m,j)}return oN(h,m,_,M,j)}function i5(h,m,_,M){var j=M.children,O=h!==null?h.memoizedState:null;if(h===null&&m.stateNode===null&&(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((m.flags&128)!==0){if(O=O!==null?O.baseLanes|_:_,h!==null){for(M=m.child=h.child,j=0;M!==null;)j=j|M.lanes|M.childLanes,M=M.sibling;M=j&~O}else M=0,m.child=null;return a5(h,m,O,_,M)}if((_&536870912)!==0)m.memoizedState={baseLanes:0,cachePool:null},h!==null&&Vy(m,O!==null?O.cachePool:null),O!==null?oI(m,O):IE(),lI(m);else return M=m.lanes=536870912,a5(h,m,O!==null?O.baseLanes|_:_,_,M)}else O!==null?(Vy(m,O.cachePool),oI(m,O),Su(),m.memoizedState=null):(h!==null&&Vy(m,null),IE(),Su());return na(h,m,j,_),m.child}function dx(h,m){return h!==null&&h.tag===22||m.stateNode!==null||(m.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),m.sibling}function a5(h,m,_,M,j){var O=jE();return O=O===null?null:{parent:si._currentValue,pool:O},m.memoizedState={baseLanes:_,cachePool:O},h!==null&&Vy(m,null),IE(),lI(m),h!==null&&em(h,m,M,!0),m.childLanes=j,null}function sv(h,m){return m=lv({mode:m.mode,children:m.children},h.mode),m.ref=h.ref,h.child=m,m.return=h,m}function s5(h,m,_){return ch(m,h.child,null,_),h=sv(m,m.pendingProps),h.flags|=2,ys(m),m.memoizedState=null,h}function jre(h,m,_){var M=m.pendingProps,j=(m.flags&128)!==0;if(m.flags&=-129,h===null){if(Rn){if(M.mode==="hidden")return h=sv(m,M),m.lanes=536870912,dx(null,h);if(UE(m),(h=_r)?(h=bF(h,Ys),h=h!==null&&h.data==="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:pu!==null?{id:sl,overflow:ol}:null,retryLane:536870912,hydrationErrors:null},_=HL(h),_.return=m,m.child=_,ea=m,_r=null)):h=null,h===null)throw xu(m);return m.lanes=536870912,null}return sv(m,M)}var O=h.memoizedState;if(O!==null){var te=O.dehydrated;if(UE(m),j)if(m.flags&256)m.flags&=-257,m=s5(h,m,_);else if(m.memoizedState!==null)m.child=h.child,m.flags|=128,m=null;else throw Error(r(558));else if(li||em(h,m,_,!1),j=(_&h.childLanes)!==0,li||j){if(M=mr,M!==null&&(te=Cn(M,_),te!==0&&te!==O.retryLane))throw O.retryLane=te,th(h,te),es(M,h,te),sN;xv(),m=s5(h,m,_)}else h=O.treeContext,_r=Zs(te.nextSibling),ea=m,Rn=!0,gu=null,Ys=!1,h!==null&&WL(m,h),m=sv(m,M),m.flags|=4096;return m}return h=Kl(h.child,{mode:M.mode,children:M.children}),h.ref=m.ref,m.child=h,h.return=m,h}function ov(h,m){var _=m.ref;if(_===null)h!==null&&h.ref!==null&&(m.flags|=4194816);else{if(typeof _!="function"&&typeof _!="object")throw Error(r(284));(h===null||h.ref!==_)&&(m.flags|=4194816)}}function oN(h,m,_,M,j){return ah(m),_=BE(h,m,_,M,void 0,j),M=$E(),h!==null&&!li?(HE(h,m,j),ec(h,m,j)):(Rn&&M&&wE(m),m.flags|=1,na(h,m,_,j),m.child)}function o5(h,m,_,M,j,O){return ah(m),m.updateQueue=null,_=uI(m,M,_,j),cI(h),M=$E(),h!==null&&!li?(HE(h,m,O),ec(h,m,O)):(Rn&&M&&wE(m),m.flags|=1,na(h,m,_,O),m.child)}function l5(h,m,_,M,j){if(ah(m),m.stateNode===null){var O=Yf,te=_.contextType;typeof te=="object"&&te!==null&&(O=ta(te)),O=new _(M,O),m.memoizedState=O.state!==null&&O.state!==void 0?O.state:null,O.updater=iN,m.stateNode=O,O._reactInternals=m,O=m.stateNode,O.props=M,O.state=m.memoizedState,O.refs={},RE(m),te=_.contextType,O.context=typeof te=="object"&&te!==null?ta(te):Yf,O.state=m.memoizedState,te=_.getDerivedStateFromProps,typeof te=="function"&&(rN(m,_,te,M),O.state=m.memoizedState),typeof _.getDerivedStateFromProps=="function"||typeof O.getSnapshotBeforeUpdate=="function"||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(te=O.state,typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount(),te!==O.state&&iN.enqueueReplaceState(O,O.state,null),sx(m,M,O,j),ax(),O.state=m.memoizedState),typeof O.componentDidMount=="function"&&(m.flags|=4194308),M=!0}else if(h===null){O=m.stateNode;var he=m.memoizedProps,Pe=dh(_,he);O.props=Pe;var tt=O.context,dt=_.contextType;te=Yf,typeof dt=="object"&&dt!==null&&(te=ta(dt));var bt=_.getDerivedStateFromProps;dt=typeof bt=="function"||typeof O.getSnapshotBeforeUpdate=="function",he=m.pendingProps!==he,dt||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(he||tt!==te)&&KI(m,O,M,te),yu=!1;var rt=m.memoizedState;O.state=rt,sx(m,M,O,j),ax(),tt=m.memoizedState,he||rt!==tt||yu?(typeof bt=="function"&&(rN(m,_,bt,M),tt=m.memoizedState),(Pe=yu||qI(m,_,Pe,M,rt,tt,te))?(dt||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"&&(m.flags|=4194308)):(typeof O.componentDidMount=="function"&&(m.flags|=4194308),m.memoizedProps=M,m.memoizedState=tt),O.props=M,O.state=tt,O.context=te,M=Pe):(typeof O.componentDidMount=="function"&&(m.flags|=4194308),M=!1)}else{O=m.stateNode,DE(h,m),te=m.memoizedProps,dt=dh(_,te),O.props=dt,bt=m.pendingProps,rt=O.context,tt=_.contextType,Pe=Yf,typeof tt=="object"&&tt!==null&&(Pe=ta(tt)),he=_.getDerivedStateFromProps,(tt=typeof he=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(te!==bt||rt!==Pe)&&KI(m,O,M,Pe),yu=!1,rt=m.memoizedState,O.state=rt,sx(m,M,O,j),ax();var ot=m.memoizedState;te!==bt||rt!==ot||yu||h!==null&&h.dependencies!==null&&$y(h.dependencies)?(typeof he=="function"&&(rN(m,_,he,M),ot=m.memoizedState),(dt=yu||qI(m,_,dt,M,rt,ot,Pe)||h!==null&&h.dependencies!==null&&$y(h.dependencies))?(tt||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(M,ot,Pe),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(M,ot,Pe)),typeof O.componentDidUpdate=="function"&&(m.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(m.flags|=1024)):(typeof O.componentDidUpdate!="function"||te===h.memoizedProps&&rt===h.memoizedState||(m.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||te===h.memoizedProps&&rt===h.memoizedState||(m.flags|=1024),m.memoizedProps=M,m.memoizedState=ot),O.props=M,O.state=ot,O.context=Pe,M=dt):(typeof O.componentDidUpdate!="function"||te===h.memoizedProps&&rt===h.memoizedState||(m.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||te===h.memoizedProps&&rt===h.memoizedState||(m.flags|=1024),M=!1)}return O=M,ov(h,m),M=(m.flags&128)!==0,O||M?(O=m.stateNode,_=M&&typeof _.getDerivedStateFromError!="function"?null:O.render(),m.flags|=1,h!==null&&M?(m.child=ch(m,h.child,null,j),m.child=ch(m,null,_,j)):na(h,m,_,j),m.memoizedState=O.state,h=m.child):h=ec(h,m,j),h}function c5(h,m,_,M){return rh(),m.flags|=256,na(h,m,_,M),m.child}var lN={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function cN(h){return{baseLanes:h,cachePool:ZL()}}function uN(h,m,_){return h=h!==null?h.childLanes&~_:0,m&&(h|=_s),h}function u5(h,m,_){var M=m.pendingProps,j=!1,O=(m.flags&128)!==0,te;if((te=O)||(te=h!==null&&h.memoizedState===null?!1:(ti.current&2)!==0),te&&(j=!0,m.flags&=-129),te=(m.flags&32)!==0,m.flags&=-33,h===null){if(Rn){if(j?wu(m):Su(),(h=_r)?(h=bF(h,Ys),h=h!==null&&h.data!=="&"?h:null,h!==null&&(m.memoizedState={dehydrated:h,treeContext:pu!==null?{id:sl,overflow:ol}:null,retryLane:536870912,hydrationErrors:null},_=HL(h),_.return=m,m.child=_,ea=m,_r=null)):h=null,h===null)throw xu(m);return WN(h)?m.lanes=32:m.lanes=536870912,null}var he=M.children;return M=M.fallback,j?(Su(),j=m.mode,he=lv({mode:"hidden",children:he},j),M=nh(M,j,_,null),he.return=m,M.return=m,he.sibling=M,m.child=he,M=m.child,M.memoizedState=cN(_),M.childLanes=uN(h,te,_),m.memoizedState=lN,dx(null,M)):(wu(m),dN(m,he))}var Pe=h.memoizedState;if(Pe!==null&&(he=Pe.dehydrated,he!==null)){if(O)m.flags&256?(wu(m),m.flags&=-257,m=hN(h,m,_)):m.memoizedState!==null?(Su(),m.child=h.child,m.flags|=128,m=null):(Su(),he=M.fallback,j=m.mode,M=lv({mode:"visible",children:M.children},j),he=nh(he,j,_,null),he.flags|=2,M.return=m,he.return=m,M.sibling=he,m.child=M,ch(m,h.child,null,_),M=m.child,M.memoizedState=cN(_),M.childLanes=uN(h,te,_),m.memoizedState=lN,m=dx(null,M));else if(wu(m),WN(he)){if(te=he.nextSibling&&he.nextSibling.dataset,te)var tt=te.dgst;te=tt,M=Error(r(419)),M.stack="",M.digest=te,Jg({value:M,source:null,stack:null}),m=hN(h,m,_)}else if(li||em(h,m,_,!1),te=(_&h.childLanes)!==0,li||te){if(te=mr,te!==null&&(M=Cn(te,_),M!==0&&M!==Pe.retryLane))throw Pe.retryLane=M,th(h,M),es(te,h,M),sN;GN(he)||xv(),m=hN(h,m,_)}else GN(he)?(m.flags|=192,m.child=h.child,m=null):(h=Pe.treeContext,_r=Zs(he.nextSibling),ea=m,Rn=!0,gu=null,Ys=!1,h!==null&&WL(m,h),m=dN(m,M.children),m.flags|=4096);return m}return j?(Su(),he=M.fallback,j=m.mode,Pe=h.child,tt=Pe.sibling,M=Kl(Pe,{mode:"hidden",children:M.children}),M.subtreeFlags=Pe.subtreeFlags&65011712,tt!==null?he=Kl(tt,he):(he=nh(he,j,_,null),he.flags|=2),he.return=m,M.return=m,M.sibling=he,m.child=M,dx(null,M),M=m.child,he=h.child.memoizedState,he===null?he=cN(_):(j=he.cachePool,j!==null?(Pe=si._currentValue,j=j.parent!==Pe?{parent:Pe,pool:Pe}:j):j=ZL(),he={baseLanes:he.baseLanes|_,cachePool:j}),M.memoizedState=he,M.childLanes=uN(h,te,_),m.memoizedState=lN,dx(h.child,M)):(wu(m),_=h.child,h=_.sibling,_=Kl(_,{mode:"visible",children:M.children}),_.return=m,_.sibling=null,h!==null&&(te=m.deletions,te===null?(m.deletions=[h],m.flags|=16):te.push(h)),m.child=_,m.memoizedState=null,_)}function dN(h,m){return m=lv({mode:"visible",children:m},h.mode),m.return=h,h.child=m}function lv(h,m){return h=xs(22,h,null,m),h.lanes=0,h}function hN(h,m,_){return ch(m,h.child,null,_),h=dN(m,m.pendingProps.children),h.flags|=2,m.memoizedState=null,h}function d5(h,m,_){h.lanes|=m;var M=h.alternate;M!==null&&(M.lanes|=m),AE(h.return,m,_)}function fN(h,m,_,M,j,O){var te=h.memoizedState;te===null?h.memoizedState={isBackwards:m,rendering:null,renderingStartTime:0,last:M,tail:_,tailMode:j,treeForkCount:O}:(te.isBackwards=m,te.rendering=null,te.renderingStartTime=0,te.last=M,te.tail=_,te.tailMode=j,te.treeForkCount=O)}function h5(h,m,_){var M=m.pendingProps,j=M.revealOrder,O=M.tail;M=M.children;var te=ti.current,he=(te&2)!==0;if(he?(te=te&1|2,m.flags|=128):te&=1,ne(ti,te),na(h,m,M,_),M=Rn?Zg:0,!he&&h!==null&&(h.flags&128)!==0)e:for(h=m.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&d5(h,_,m);else if(h.tag===19)d5(h,_,m);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===m)break e;for(;h.sibling===null;){if(h.return===null||h.return===m)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(j){case"forwards":for(_=m.child,j=null;_!==null;)h=_.alternate,h!==null&&Yy(h)===null&&(j=_),_=_.sibling;_=j,_===null?(j=m.child,m.child=null):(j=_.sibling,_.sibling=null),fN(m,!1,j,_,O,M);break;case"backwards":case"unstable_legacy-backwards":for(_=null,j=m.child,m.child=null;j!==null;){if(h=j.alternate,h!==null&&Yy(h)===null){m.child=j;break}h=j.sibling,j.sibling=_,_=j,j=h}fN(m,!0,_,null,O,M);break;case"together":fN(m,!1,null,null,void 0,M);break;default:m.memoizedState=null}return m.child}function ec(h,m,_){if(h!==null&&(m.dependencies=h.dependencies),Nu|=m.lanes,(_&m.childLanes)===0)if(h!==null){if(em(h,m,_,!1),(_&m.childLanes)===0)return null}else return null;if(h!==null&&m.child!==h.child)throw Error(r(153));if(m.child!==null){for(h=m.child,_=Kl(h,h.pendingProps),m.child=_,_.return=m;h.sibling!==null;)h=h.sibling,_=_.sibling=Kl(h,h.pendingProps),_.return=m;_.sibling=null}return m.child}function mN(h,m){return(h.lanes&m)!==0?!0:(h=h.dependencies,!!(h!==null&&$y(h)))}function Pre(h,m,_){switch(m.tag){case 3:Ce(m,m.stateNode.containerInfo),bu(m,si,h.memoizedState.cache),rh();break;case 27:case 5:ae(m);break;case 4:Ce(m,m.stateNode.containerInfo);break;case 10:bu(m,m.type,m.memoizedProps.value);break;case 31:if(m.memoizedState!==null)return m.flags|=128,UE(m),null;break;case 13:var M=m.memoizedState;if(M!==null)return M.dehydrated!==null?(wu(m),m.flags|=128,null):(_&m.child.childLanes)!==0?u5(h,m,_):(wu(m),h=ec(h,m,_),h!==null?h.sibling:null);wu(m);break;case 19:var j=(h.flags&128)!==0;if(M=(_&m.childLanes)!==0,M||(em(h,m,_,!1),M=(_&m.childLanes)!==0),j){if(M)return h5(h,m,_);m.flags|=128}if(j=m.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),ne(ti,ti.current),M)break;return null;case 22:return m.lanes=0,i5(h,m,_,m.pendingProps);case 24:bu(m,si,h.memoizedState.cache)}return ec(h,m,_)}function f5(h,m,_){if(h!==null)if(h.memoizedProps!==m.pendingProps)li=!0;else{if(!mN(h,_)&&(m.flags&128)===0)return li=!1,Pre(h,m,_);li=(h.flags&131072)!==0}else li=!1,Rn&&(m.flags&1048576)!==0&&GL(m,Zg,m.index);switch(m.lanes=0,m.tag){case 16:e:{var M=m.pendingProps;if(h=oh(m.elementType),m.type=h,typeof h=="function")yE(h)?(M=dh(h,M),m.tag=1,m=l5(null,m,h,M,_)):(m.tag=0,m=oN(null,m,h,M,_));else{if(h!=null){var j=h.$$typeof;if(j===A){m.tag=11,m=t5(null,m,h,M,_);break e}else if(j===T){m.tag=14,m=n5(null,m,h,M,_);break e}}throw m=R(h)||h,Error(r(306,m,""))}}return m;case 0:return oN(h,m,m.type,m.pendingProps,_);case 1:return M=m.type,j=dh(M,m.pendingProps),l5(h,m,M,j,_);case 3:e:{if(Ce(m,m.stateNode.containerInfo),h===null)throw Error(r(387));M=m.pendingProps;var O=m.memoizedState;j=O.element,DE(h,m),sx(m,M,null,_);var te=m.memoizedState;if(M=te.cache,bu(m,si,M),M!==O.cache&&TE(m,[si],_,!0),ax(),M=te.element,O.isDehydrated)if(O={element:M,isDehydrated:!1,cache:te.cache},m.updateQueue.baseState=O,m.memoizedState=O,m.flags&256){m=c5(h,m,M,_);break e}else if(M!==j){j=qs(Error(r(424)),m),Jg(j),m=c5(h,m,M,_);break e}else{switch(h=m.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for(_r=Zs(h.firstChild),ea=m,Rn=!0,gu=null,Ys=!0,_=iI(m,null,M,_),m.child=_;_;)_.flags=_.flags&-3|4096,_=_.sibling}else{if(rh(),M===j){m=ec(h,m,_);break e}na(h,m,M,_)}m=m.child}return m;case 26:return ov(h,m),h===null?(_=MF(m.type,null,m.pendingProps,null))?m.memoizedState=_:Rn||(_=m.type,h=m.pendingProps,M=Mv(de.current).createElement(_),M[Ft]=m,M[qt]=h,ra(M,_,h),Ie(M),m.stateNode=M):m.memoizedState=MF(m.type,h.memoizedProps,m.pendingProps,h.memoizedState),null;case 27:return ae(m),h===null&&Rn&&(M=m.stateNode=_F(m.type,m.pendingProps,de.current),ea=m,Ys=!0,j=_r,ju(m.type)?(qN=j,_r=Zs(M.firstChild)):_r=j),na(h,m,m.pendingProps.children,_),ov(h,m),h===null&&(m.flags|=4194304),m.child;case 5:return h===null&&Rn&&((j=M=_r)&&(M=lie(M,m.type,m.pendingProps,Ys),M!==null?(m.stateNode=M,ea=m,_r=Zs(M.firstChild),Ys=!1,j=!0):j=!1),j||xu(m)),ae(m),j=m.type,O=m.pendingProps,te=h!==null?h.memoizedProps:null,M=O.children,$N(j,O)?M=null:te!==null&&$N(j,te)&&(m.flags|=32),m.memoizedState!==null&&(j=BE(h,m,Sre,null,null,_),Nx._currentValue=j),ov(h,m),na(h,m,M,_),m.child;case 6:return h===null&&Rn&&((h=_=_r)&&(_=cie(_,m.pendingProps,Ys),_!==null?(m.stateNode=_,ea=m,_r=null,h=!0):h=!1),h||xu(m)),null;case 13:return u5(h,m,_);case 4:return Ce(m,m.stateNode.containerInfo),M=m.pendingProps,h===null?m.child=ch(m,null,M,_):na(h,m,M,_),m.child;case 11:return t5(h,m,m.type,m.pendingProps,_);case 7:return na(h,m,m.pendingProps,_),m.child;case 8:return na(h,m,m.pendingProps.children,_),m.child;case 12:return na(h,m,m.pendingProps.children,_),m.child;case 10:return M=m.pendingProps,bu(m,m.type,M.value),na(h,m,M.children,_),m.child;case 9:return j=m.type._context,M=m.pendingProps.children,ah(m),j=ta(j),M=M(j),m.flags|=1,na(h,m,M,_),m.child;case 14:return n5(h,m,m.type,m.pendingProps,_);case 15:return r5(h,m,m.type,m.pendingProps,_);case 19:return h5(h,m,_);case 31:return jre(h,m,_);case 22:return i5(h,m,_,m.pendingProps);case 24:return ah(m),M=ta(si),h===null?(j=jE(),j===null&&(j=mr,O=CE(),j.pooledCache=O,O.refCount++,O!==null&&(j.pooledCacheLanes|=_),j=O),m.memoizedState={parent:M,cache:j},RE(m),bu(m,si,j)):((h.lanes&_)!==0&&(DE(h,m),sx(m,null,null,_),ax()),j=h.memoizedState,O=m.memoizedState,j.parent!==M?(j={parent:M,cache:M},m.memoizedState=j,m.lanes===0&&(m.memoizedState=m.updateQueue.baseState=j),bu(m,si,M)):(M=O.cache,bu(m,si,M),M!==j.cache&&TE(m,[si],_,!0))),na(h,m,m.pendingProps.children,_),m.child;case 29:throw m.pendingProps}throw Error(r(156,m.tag))}function tc(h){h.flags|=4}function pN(h,m,_,M,j){if((m=(h.mode&32)!==0)&&(m=!1),m){if(h.flags|=16777216,(j&335544128)===j)if(h.stateNode.complete)h.flags|=8192;else if(z5())h.flags|=8192;else throw lh=Wy,PE}else h.flags&=-16777217}function m5(h,m){if(m.type!=="stylesheet"||(m.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!CF(m))if(z5())h.flags|=8192;else throw lh=Wy,PE}function cv(h,m){m!==null&&(h.flags|=4),h.flags&16384&&(m=h.tag!==22?At():536870912,h.lanes|=m,hm|=m)}function hx(h,m){if(!Rn)switch(h.tailMode){case"hidden":m=h.tail;for(var _=null;m!==null;)m.alternate!==null&&(_=m),m=m.sibling;_===null?h.tail=null:_.sibling=null;break;case"collapsed":_=h.tail;for(var M=null;_!==null;)_.alternate!==null&&(M=_),_=_.sibling;M===null?m||h.tail===null?h.tail=null:h.tail.sibling=null:M.sibling=null}}function wr(h){var m=h.alternate!==null&&h.alternate.child===h.child,_=0,M=0;if(m)for(var j=h.child;j!==null;)_|=j.lanes|j.childLanes,M|=j.subtreeFlags&65011712,M|=j.flags&65011712,j.return=h,j=j.sibling;else for(j=h.child;j!==null;)_|=j.lanes|j.childLanes,M|=j.subtreeFlags,M|=j.flags,j.return=h,j=j.sibling;return h.subtreeFlags|=M,h.childLanes=_,m}function Rre(h,m,_){var M=m.pendingProps;switch(SE(m),m.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wr(m),null;case 1:return wr(m),null;case 3:return _=m.stateNode,M=null,h!==null&&(M=h.memoizedState.cache),m.memoizedState.cache!==M&&(m.flags|=2048),Ql(si),oe(),_.pendingContext&&(_.context=_.pendingContext,_.pendingContext=null),(h===null||h.child===null)&&(Jf(m)?tc(m):h===null||h.memoizedState.isDehydrated&&(m.flags&256)===0||(m.flags|=1024,EE())),wr(m),null;case 26:var j=m.type,O=m.memoizedState;return h===null?(tc(m),O!==null?(wr(m),m5(m,O)):(wr(m),pN(m,j,null,M,_))):O?O!==h.memoizedState?(tc(m),wr(m),m5(m,O)):(wr(m),m.flags&=-16777217):(h=h.memoizedProps,h!==M&&tc(m),wr(m),pN(m,j,h,M,_)),null;case 27:if(ge(m),_=de.current,j=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&tc(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return wr(m),null}h=re.current,Jf(m)?qL(m):(h=_F(j,M,_),m.stateNode=h,tc(m))}return wr(m),null;case 5:if(ge(m),j=m.type,h!==null&&m.stateNode!=null)h.memoizedProps!==M&&tc(m);else{if(!M){if(m.stateNode===null)throw Error(r(166));return wr(m),null}if(O=re.current,Jf(m))qL(m);else{var te=Mv(de.current);switch(O){case 1:O=te.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:O=te.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":O=te.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":O=te.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":O=te.createElement("div"),O.innerHTML="<script><\/script>",O=O.removeChild(O.firstChild);break;case"select":O=typeof M.is=="string"?te.createElement("select",{is:M.is}):te.createElement("select"),M.multiple?O.multiple=!0:M.size&&(O.size=M.size);break;default:O=typeof M.is=="string"?te.createElement(j,{is:M.is}):te.createElement(j)}}O[Ft]=m,O[qt]=M;e:for(te=m.child;te!==null;){if(te.tag===5||te.tag===6)O.appendChild(te.stateNode);else if(te.tag!==4&&te.tag!==27&&te.child!==null){te.child.return=te,te=te.child;continue}if(te===m)break e;for(;te.sibling===null;){if(te.return===null||te.return===m)break e;te=te.return}te.sibling.return=te.return,te=te.sibling}m.stateNode=O;e:switch(ra(O,j,M),j){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}M&&tc(m)}}return wr(m),pN(m,m.type,h===null?null:h.memoizedProps,m.pendingProps,_),null;case 6:if(h&&m.stateNode!=null)h.memoizedProps!==M&&tc(m);else{if(typeof M!="string"&&m.stateNode===null)throw Error(r(166));if(h=de.current,Jf(m)){if(h=m.stateNode,_=m.memoizedProps,M=null,j=ea,j!==null)switch(j.tag){case 27:case 5:M=j.memoizedProps}h[Ft]=m,h=!!(h.nodeValue===_||M!==null&&M.suppressHydrationWarning===!0||uF(h.nodeValue,_)),h||xu(m,!0)}else h=Mv(h).createTextNode(M),h[Ft]=m,m.stateNode=h}return wr(m),null;case 31:if(_=m.memoizedState,h===null||h.memoizedState!==null){if(M=Jf(m),_!==null){if(h===null){if(!M)throw Error(r(318));if(h=m.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Ft]=m}else rh(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),h=!1}else _=EE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=_),h=!0;if(!h)return m.flags&256?(ys(m),m):(ys(m),null);if((m.flags&128)!==0)throw Error(r(558))}return wr(m),null;case 13:if(M=m.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(j=Jf(m),M!==null&&M.dehydrated!==null){if(h===null){if(!j)throw Error(r(318));if(j=m.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[Ft]=m}else rh(),(m.flags&128)===0&&(m.memoizedState=null),m.flags|=4;wr(m),j=!1}else j=EE(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=j),j=!0;if(!j)return m.flags&256?(ys(m),m):(ys(m),null)}return ys(m),(m.flags&128)!==0?(m.lanes=_,m):(_=M!==null,h=h!==null&&h.memoizedState!==null,_&&(M=m.child,j=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(j=M.alternate.memoizedState.cachePool.pool),O=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(O=M.memoizedState.cachePool.pool),O!==j&&(M.flags|=2048)),_!==h&&_&&(m.child.flags|=8192),cv(m,m.updateQueue),wr(m),null);case 4:return oe(),h===null&&IN(m.stateNode.containerInfo),wr(m),null;case 10:return Ql(m.type),wr(m),null;case 19:if(q(ti),M=m.memoizedState,M===null)return wr(m),null;if(j=(m.flags&128)!==0,O=M.rendering,O===null)if(j)hx(M,!1);else{if(Br!==0||h!==null&&(h.flags&128)!==0)for(h=m.child;h!==null;){if(O=Yy(h),O!==null){for(m.flags|=128,hx(M,!1),h=O.updateQueue,m.updateQueue=h,cv(m,h),m.subtreeFlags=0,h=_,_=m.child;_!==null;)$L(_,h),_=_.sibling;return ne(ti,ti.current&1|2),Rn&&Xl(m,M.treeForkCount),m.child}h=h.sibling}M.tail!==null&&I()>mv&&(m.flags|=128,j=!0,hx(M,!1),m.lanes=4194304)}else{if(!j)if(h=Yy(O),h!==null){if(m.flags|=128,j=!0,h=h.updateQueue,m.updateQueue=h,cv(m,h),hx(M,!0),M.tail===null&&M.tailMode==="hidden"&&!O.alternate&&!Rn)return wr(m),null}else 2*I()-M.renderingStartTime>mv&&_!==536870912&&(m.flags|=128,j=!0,hx(M,!1),m.lanes=4194304);M.isBackwards?(O.sibling=m.child,m.child=O):(h=M.last,h!==null?h.sibling=O:m.child=O,M.last=O)}return M.tail!==null?(h=M.tail,M.rendering=h,M.tail=h.sibling,M.renderingStartTime=I(),h.sibling=null,_=ti.current,ne(ti,j?_&1|2:_&1),Rn&&Xl(m,M.treeForkCount),h):(wr(m),null);case 22:case 23:return ys(m),FE(),M=m.memoizedState!==null,h!==null?h.memoizedState!==null!==M&&(m.flags|=8192):M&&(m.flags|=8192),M?(_&536870912)!==0&&(m.flags&128)===0&&(wr(m),m.subtreeFlags&6&&(m.flags|=8192)):wr(m),_=m.updateQueue,_!==null&&cv(m,_.retryQueue),_=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),M=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(M=m.memoizedState.cachePool.pool),M!==_&&(m.flags|=2048),h!==null&&q(sh),null;case 24:return _=null,h!==null&&(_=h.memoizedState.cache),m.memoizedState.cache!==_&&(m.flags|=2048),Ql(si),wr(m),null;case 25:return null;case 30:return null}throw Error(r(156,m.tag))}function Dre(h,m){switch(SE(m),m.tag){case 1:return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 3:return Ql(si),oe(),h=m.flags,(h&65536)!==0&&(h&128)===0?(m.flags=h&-65537|128,m):null;case 26:case 27:case 5:return ge(m),null;case 31:if(m.memoizedState!==null){if(ys(m),m.alternate===null)throw Error(r(340));rh()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 13:if(ys(m),h=m.memoizedState,h!==null&&h.dehydrated!==null){if(m.alternate===null)throw Error(r(340));rh()}return h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 19:return q(ti),null;case 4:return oe(),null;case 10:return Ql(m.type),null;case 22:case 23:return ys(m),FE(),h!==null&&q(sh),h=m.flags,h&65536?(m.flags=h&-65537|128,m):null;case 24:return Ql(si),null;case 25:return null;default:return null}}function p5(h,m){switch(SE(m),m.tag){case 3:Ql(si),oe();break;case 26:case 27:case 5:ge(m);break;case 4:oe();break;case 31:m.memoizedState!==null&&ys(m);break;case 13:ys(m);break;case 19:q(ti);break;case 10:Ql(m.type);break;case 22:case 23:ys(m),FE(),h!==null&&q(sh);break;case 24:Ql(si)}}function fx(h,m){try{var _=m.updateQueue,M=_!==null?_.lastEffect:null;if(M!==null){var j=M.next;_=j;do{if((_.tag&h)===h){M=void 0;var O=_.create,te=_.inst;M=O(),te.destroy=M}_=_.next}while(_!==j)}}catch(he){Yn(m,m.return,he)}}function Mu(h,m,_){try{var M=m.updateQueue,j=M!==null?M.lastEffect:null;if(j!==null){var O=j.next;M=O;do{if((M.tag&h)===h){var te=M.inst,he=te.destroy;if(he!==void 0){te.destroy=void 0,j=m;var Pe=_,tt=he;try{tt()}catch(dt){Yn(j,Pe,dt)}}}M=M.next}while(M!==O)}}catch(dt){Yn(m,m.return,dt)}}function g5(h){var m=h.updateQueue;if(m!==null){var _=h.stateNode;try{sI(m,_)}catch(M){Yn(h,h.return,M)}}}function x5(h,m,_){_.props=dh(h.type,h.memoizedProps),_.state=h.memoizedState;try{_.componentWillUnmount()}catch(M){Yn(h,m,M)}}function mx(h,m){try{var _=h.ref;if(_!==null){switch(h.tag){case 26:case 27:case 5:var M=h.stateNode;break;case 30:M=h.stateNode;break;default:M=h.stateNode}typeof _=="function"?h.refCleanup=_(M):_.current=M}}catch(j){Yn(h,m,j)}}function ll(h,m){var _=h.ref,M=h.refCleanup;if(_!==null)if(typeof M=="function")try{M()}catch(j){Yn(h,m,j)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof _=="function")try{_(null)}catch(j){Yn(h,m,j)}else _.current=null}function b5(h){var m=h.type,_=h.memoizedProps,M=h.stateNode;try{e:switch(m){case"button":case"input":case"select":case"textarea":_.autoFocus&&M.focus();break e;case"img":_.src?M.src=_.src:_.srcSet&&(M.srcset=_.srcSet)}}catch(j){Yn(h,h.return,j)}}function gN(h,m,_){try{var M=h.stateNode;nie(M,h.type,_,m),M[qt]=m}catch(j){Yn(h,h.return,j)}}function y5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&ju(h.type)||h.tag===4}function xN(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||y5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&ju(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function bN(h,m,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,m?(_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_).insertBefore(h,m):(m=_.nodeType===9?_.body:_.nodeName==="HTML"?_.ownerDocument.body:_,m.appendChild(h),_=_._reactRootContainer,_!=null||m.onclick!==null||(m.onclick=Wl));else if(M!==4&&(M===27&&ju(h.type)&&(_=h.stateNode,m=null),h=h.child,h!==null))for(bN(h,m,_),h=h.sibling;h!==null;)bN(h,m,_),h=h.sibling}function uv(h,m,_){var M=h.tag;if(M===5||M===6)h=h.stateNode,m?_.insertBefore(h,m):_.appendChild(h);else if(M!==4&&(M===27&&ju(h.type)&&(_=h.stateNode),h=h.child,h!==null))for(uv(h,m,_),h=h.sibling;h!==null;)uv(h,m,_),h=h.sibling}function v5(h){var m=h.stateNode,_=h.memoizedProps;try{for(var M=h.type,j=m.attributes;j.length;)m.removeAttributeNode(j[0]);ra(m,M,_),m[Ft]=h,m[qt]=_}catch(O){Yn(h,h.return,O)}}var nc=!1,ci=!1,yN=!1,_5=typeof WeakSet=="function"?WeakSet:Set,Ui=null;function Ore(h,m){if(h=h.containerInfo,zN=jv,h=RL(h),hE(h)){if("selectionStart"in h)var _={start:h.selectionStart,end:h.selectionEnd};else e:{_=(_=h.ownerDocument)&&_.defaultView||window;var M=_.getSelection&&_.getSelection();if(M&&M.rangeCount!==0){_=M.anchorNode;var j=M.anchorOffset,O=M.focusNode;M=M.focusOffset;try{_.nodeType,O.nodeType}catch{_=null;break e}var te=0,he=-1,Pe=-1,tt=0,dt=0,bt=h,rt=null;t:for(;;){for(var ot;bt!==_||j!==0&&bt.nodeType!==3||(he=te+j),bt!==O||M!==0&&bt.nodeType!==3||(Pe=te+M),bt.nodeType===3&&(te+=bt.nodeValue.length),(ot=bt.firstChild)!==null;)rt=bt,bt=ot;for(;;){if(bt===h)break t;if(rt===_&&++tt===j&&(he=te),rt===O&&++dt===M&&(Pe=te),(ot=bt.nextSibling)!==null)break;bt=rt,rt=bt.parentNode}bt=ot}_=he===-1||Pe===-1?null:{start:he,end:Pe}}else _=null}_=_||{start:0,end:0}}else _=null;for(BN={focusedElem:h,selectionRange:_},jv=!1,Ui=m;Ui!==null;)if(m=Ui,h=m.child,(m.subtreeFlags&1028)!==0&&h!==null)h.return=m,Ui=h;else for(;Ui!==null;){switch(m=Ui,O=m.alternate,h=m.flags,m.tag){case 0:if((h&4)!==0&&(h=m.updateQueue,h=h!==null?h.events:null,h!==null))for(_=0;_<h.length;_++)j=h[_],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&O!==null){h=void 0,_=m,j=O.memoizedProps,O=O.memoizedState,M=_.stateNode;try{var Ut=dh(_.type,j);h=M.getSnapshotBeforeUpdate(Ut,O),M.__reactInternalSnapshotBeforeUpdate=h}catch(Qt){Yn(_,_.return,Qt)}}break;case 3:if((h&1024)!==0){if(h=m.stateNode.containerInfo,_=h.nodeType,_===9)VN(h);else if(_===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":VN(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=m.sibling,h!==null){h.return=m.return,Ui=h;break}Ui=m.return}}function w5(h,m,_){var M=_.flags;switch(_.tag){case 0:case 11:case 15:ic(h,_),M&4&&fx(5,_);break;case 1:if(ic(h,_),M&4)if(h=_.stateNode,m===null)try{h.componentDidMount()}catch(te){Yn(_,_.return,te)}else{var j=dh(_.type,m.memoizedProps);m=m.memoizedState;try{h.componentDidUpdate(j,m,h.__reactInternalSnapshotBeforeUpdate)}catch(te){Yn(_,_.return,te)}}M&64&&g5(_),M&512&&mx(_,_.return);break;case 3:if(ic(h,_),M&64&&(h=_.updateQueue,h!==null)){if(m=null,_.child!==null)switch(_.child.tag){case 27:case 5:m=_.child.stateNode;break;case 1:m=_.child.stateNode}try{sI(h,m)}catch(te){Yn(_,_.return,te)}}break;case 27:m===null&&M&4&&v5(_);case 26:case 5:ic(h,_),m===null&&M&4&&b5(_),M&512&&mx(_,_.return);break;case 12:ic(h,_);break;case 31:ic(h,_),M&4&&E5(h,_);break;case 13:ic(h,_),M&4&&N5(h,_),M&64&&(h=_.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(_=Vre.bind(null,_),uie(h,_))));break;case 22:if(M=_.memoizedState!==null||nc,!M){m=m!==null&&m.memoizedState!==null||ci,j=nc;var O=ci;nc=M,(ci=m)&&!O?ac(h,_,(_.subtreeFlags&8772)!==0):ic(h,_),nc=j,ci=O}break;case 30:break;default:ic(h,_)}}function S5(h){var m=h.alternate;m!==null&&(h.alternate=null,S5(m)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(m=h.stateNode,m!==null&&ke(m)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Ar=null,Ya=!1;function rc(h,m,_){for(_=_.child;_!==null;)M5(h,m,_),_=_.sibling}function M5(h,m,_){if(me&&typeof me.onCommitFiberUnmount=="function")try{me.onCommitFiberUnmount(Fe,_)}catch{}switch(_.tag){case 26:ci||ll(_,m),rc(h,m,_),_.memoizedState?_.memoizedState.count--:_.stateNode&&(_=_.stateNode,_.parentNode.removeChild(_));break;case 27:ci||ll(_,m);var M=Ar,j=Ya;ju(_.type)&&(Ar=_.stateNode,Ya=!1),rc(h,m,_),Sx(_.stateNode),Ar=M,Ya=j;break;case 5:ci||ll(_,m);case 6:if(M=Ar,j=Ya,Ar=null,rc(h,m,_),Ar=M,Ya=j,Ar!==null)if(Ya)try{(Ar.nodeType===9?Ar.body:Ar.nodeName==="HTML"?Ar.ownerDocument.body:Ar).removeChild(_.stateNode)}catch(O){Yn(_,m,O)}else try{Ar.removeChild(_.stateNode)}catch(O){Yn(_,m,O)}break;case 18:Ar!==null&&(Ya?(h=Ar,gF(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,_.stateNode),vm(h)):gF(Ar,_.stateNode));break;case 4:M=Ar,j=Ya,Ar=_.stateNode.containerInfo,Ya=!0,rc(h,m,_),Ar=M,Ya=j;break;case 0:case 11:case 14:case 15:Mu(2,_,m),ci||Mu(4,_,m),rc(h,m,_);break;case 1:ci||(ll(_,m),M=_.stateNode,typeof M.componentWillUnmount=="function"&&x5(_,m,M)),rc(h,m,_);break;case 21:rc(h,m,_);break;case 22:ci=(M=ci)||_.memoizedState!==null,rc(h,m,_),ci=M;break;default:rc(h,m,_)}}function E5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{vm(h)}catch(_){Yn(m,m.return,_)}}}function N5(h,m){if(m.memoizedState===null&&(h=m.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{vm(h)}catch(_){Yn(m,m.return,_)}}function Lre(h){switch(h.tag){case 31:case 13:case 19:var m=h.stateNode;return m===null&&(m=h.stateNode=new _5),m;case 22:return h=h.stateNode,m=h._retryCache,m===null&&(m=h._retryCache=new _5),m;default:throw Error(r(435,h.tag))}}function dv(h,m){var _=Lre(h);m.forEach(function(M){if(!_.has(M)){_.add(M);var j=Gre.bind(null,h,M);M.then(j,j)}})}function Qa(h,m){var _=m.deletions;if(_!==null)for(var M=0;M<_.length;M++){var j=_[M],O=h,te=m,he=te;e:for(;he!==null;){switch(he.tag){case 27:if(ju(he.type)){Ar=he.stateNode,Ya=!1;break e}break;case 5:Ar=he.stateNode,Ya=!1;break e;case 3:case 4:Ar=he.stateNode.containerInfo,Ya=!0;break e}he=he.return}if(Ar===null)throw Error(r(160));M5(O,te,j),Ar=null,Ya=!1,O=j.alternate,O!==null&&(O.return=null),j.return=null}if(m.subtreeFlags&13886)for(m=m.child;m!==null;)A5(m,h),m=m.sibling}var Ro=null;function A5(h,m){var _=h.alternate,M=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:Qa(m,h),Za(h),M&4&&(Mu(3,h,h.return),fx(3,h),Mu(5,h,h.return));break;case 1:Qa(m,h),Za(h),M&512&&(ci||_===null||ll(_,_.return)),M&64&&nc&&(h=h.updateQueue,h!==null&&(M=h.callbacks,M!==null&&(_=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=_===null?M:_.concat(M))));break;case 26:var j=Ro;if(Qa(m,h),Za(h),M&512&&(ci||_===null||ll(_,_.return)),M&4){var O=_!==null?_.memoizedState:null;if(M=h.memoizedState,_===null)if(M===null)if(h.stateNode===null){e:{M=h.type,_=h.memoizedProps,j=j.ownerDocument||j;t:switch(M){case"title":O=j.getElementsByTagName("title")[0],(!O||O[nt]||O[Ft]||O.namespaceURI==="http://www.w3.org/2000/svg"||O.hasAttribute("itemprop"))&&(O=j.createElement(M),j.head.insertBefore(O,j.querySelector("head > title"))),ra(O,M,_),O[Ft]=h,Ie(O),M=O;break e;case"link":var te=AF("link","href",j).get(M+(_.href||""));if(te){for(var he=0;he<te.length;he++)if(O=te[he],O.getAttribute("href")===(_.href==null||_.href===""?null:_.href)&&O.getAttribute("rel")===(_.rel==null?null:_.rel)&&O.getAttribute("title")===(_.title==null?null:_.title)&&O.getAttribute("crossorigin")===(_.crossOrigin==null?null:_.crossOrigin)){te.splice(he,1);break t}}O=j.createElement(M),ra(O,M,_),j.head.appendChild(O);break;case"meta":if(te=AF("meta","content",j).get(M+(_.content||""))){for(he=0;he<te.length;he++)if(O=te[he],O.getAttribute("content")===(_.content==null?null:""+_.content)&&O.getAttribute("name")===(_.name==null?null:_.name)&&O.getAttribute("property")===(_.property==null?null:_.property)&&O.getAttribute("http-equiv")===(_.httpEquiv==null?null:_.httpEquiv)&&O.getAttribute("charset")===(_.charSet==null?null:_.charSet)){te.splice(he,1);break t}}O=j.createElement(M),ra(O,M,_),j.head.appendChild(O);break;default:throw Error(r(468,M))}O[Ft]=h,Ie(O),M=O}h.stateNode=M}else TF(j,h.type,h.stateNode);else h.stateNode=NF(j,M,h.memoizedProps);else O!==M?(O===null?_.stateNode!==null&&(_=_.stateNode,_.parentNode.removeChild(_)):O.count--,M===null?TF(j,h.type,h.stateNode):NF(j,M,h.memoizedProps)):M===null&&h.stateNode!==null&&gN(h,h.memoizedProps,_.memoizedProps)}break;case 27:Qa(m,h),Za(h),M&512&&(ci||_===null||ll(_,_.return)),_!==null&&M&4&&gN(h,h.memoizedProps,_.memoizedProps);break;case 5:if(Qa(m,h),Za(h),M&512&&(ci||_===null||ll(_,_.return)),h.flags&32){j=h.stateNode;try{al(j,"")}catch(Ut){Yn(h,h.return,Ut)}}M&4&&h.stateNode!=null&&(j=h.memoizedProps,gN(h,j,_!==null?_.memoizedProps:j)),M&1024&&(yN=!0);break;case 6:if(Qa(m,h),Za(h),M&4){if(h.stateNode===null)throw Error(r(162));M=h.memoizedProps,_=h.stateNode;try{_.nodeValue=M}catch(Ut){Yn(h,h.return,Ut)}}break;case 3:if(Av=null,j=Ro,Ro=Ev(m.containerInfo),Qa(m,h),Ro=j,Za(h),M&4&&_!==null&&_.memoizedState.isDehydrated)try{vm(m.containerInfo)}catch(Ut){Yn(h,h.return,Ut)}yN&&(yN=!1,T5(h));break;case 4:M=Ro,Ro=Ev(h.stateNode.containerInfo),Qa(m,h),Za(h),Ro=M;break;case 12:Qa(m,h),Za(h);break;case 31:Qa(m,h),Za(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,dv(h,M)));break;case 13:Qa(m,h),Za(h),h.child.flags&8192&&h.memoizedState!==null!=(_!==null&&_.memoizedState!==null)&&(fv=I()),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,dv(h,M)));break;case 22:j=h.memoizedState!==null;var Pe=_!==null&&_.memoizedState!==null,tt=nc,dt=ci;if(nc=tt||j,ci=dt||Pe,Qa(m,h),ci=dt,nc=tt,Za(h),M&8192)e:for(m=h.stateNode,m._visibility=j?m._visibility&-2:m._visibility|1,j&&(_===null||Pe||nc||ci||hh(h)),_=null,m=h;;){if(m.tag===5||m.tag===26){if(_===null){Pe=_=m;try{if(O=Pe.stateNode,j)te=O.style,typeof te.setProperty=="function"?te.setProperty("display","none","important"):te.display="none";else{he=Pe.stateNode;var bt=Pe.memoizedProps.style,rt=bt!=null&&bt.hasOwnProperty("display")?bt.display:null;he.style.display=rt==null||typeof rt=="boolean"?"":(""+rt).trim()}}catch(Ut){Yn(Pe,Pe.return,Ut)}}}else if(m.tag===6){if(_===null){Pe=m;try{Pe.stateNode.nodeValue=j?"":Pe.memoizedProps}catch(Ut){Yn(Pe,Pe.return,Ut)}}}else if(m.tag===18){if(_===null){Pe=m;try{var ot=Pe.stateNode;j?xF(ot,!0):xF(Pe.stateNode,!1)}catch(Ut){Yn(Pe,Pe.return,Ut)}}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===h)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===h)break e;for(;m.sibling===null;){if(m.return===null||m.return===h)break e;_===m&&(_=null),m=m.return}_===m&&(_=null),m.sibling.return=m.return,m=m.sibling}M&4&&(M=h.updateQueue,M!==null&&(_=M.retryQueue,_!==null&&(M.retryQueue=null,dv(h,_))));break;case 19:Qa(m,h),Za(h),M&4&&(M=h.updateQueue,M!==null&&(h.updateQueue=null,dv(h,M)));break;case 30:break;case 21:break;default:Qa(m,h),Za(h)}}function Za(h){var m=h.flags;if(m&2){try{for(var _,M=h.return;M!==null;){if(y5(M)){_=M;break}M=M.return}if(_==null)throw Error(r(160));switch(_.tag){case 27:var j=_.stateNode,O=xN(h);uv(h,O,j);break;case 5:var te=_.stateNode;_.flags&32&&(al(te,""),_.flags&=-33);var he=xN(h);uv(h,he,te);break;case 3:case 4:var Pe=_.stateNode.containerInfo,tt=xN(h);bN(h,tt,Pe);break;default:throw Error(r(161))}}catch(dt){Yn(h,h.return,dt)}h.flags&=-3}m&4096&&(h.flags&=-4097)}function T5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var m=h;T5(m),m.tag===5&&m.flags&1024&&m.stateNode.reset(),h=h.sibling}}function ic(h,m){if(m.subtreeFlags&8772)for(m=m.child;m!==null;)w5(h,m.alternate,m),m=m.sibling}function hh(h){for(h=h.child;h!==null;){var m=h;switch(m.tag){case 0:case 11:case 14:case 15:Mu(4,m,m.return),hh(m);break;case 1:ll(m,m.return);var _=m.stateNode;typeof _.componentWillUnmount=="function"&&x5(m,m.return,_),hh(m);break;case 27:Sx(m.stateNode);case 26:case 5:ll(m,m.return),hh(m);break;case 22:m.memoizedState===null&&hh(m);break;case 30:hh(m);break;default:hh(m)}h=h.sibling}}function ac(h,m,_){for(_=_&&(m.subtreeFlags&8772)!==0,m=m.child;m!==null;){var M=m.alternate,j=h,O=m,te=O.flags;switch(O.tag){case 0:case 11:case 15:ac(j,O,_),fx(4,O);break;case 1:if(ac(j,O,_),M=O,j=M.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(tt){Yn(M,M.return,tt)}if(M=O,j=M.updateQueue,j!==null){var he=M.stateNode;try{var Pe=j.shared.hiddenCallbacks;if(Pe!==null)for(j.shared.hiddenCallbacks=null,j=0;j<Pe.length;j++)aI(Pe[j],he)}catch(tt){Yn(M,M.return,tt)}}_&&te&64&&g5(O),mx(O,O.return);break;case 27:v5(O);case 26:case 5:ac(j,O,_),_&&M===null&&te&4&&b5(O),mx(O,O.return);break;case 12:ac(j,O,_);break;case 31:ac(j,O,_),_&&te&4&&E5(j,O);break;case 13:ac(j,O,_),_&&te&4&&N5(j,O);break;case 22:O.memoizedState===null&&ac(j,O,_),mx(O,O.return);break;case 30:break;default:ac(j,O,_)}m=m.sibling}}function vN(h,m){var _=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),h=null,m.memoizedState!==null&&m.memoizedState.cachePool!==null&&(h=m.memoizedState.cachePool.pool),h!==_&&(h!=null&&h.refCount++,_!=null&&ex(_))}function _N(h,m){h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&ex(h))}function Do(h,m,_,M){if(m.subtreeFlags&10256)for(m=m.child;m!==null;)C5(h,m,_,M),m=m.sibling}function C5(h,m,_,M){var j=m.flags;switch(m.tag){case 0:case 11:case 15:Do(h,m,_,M),j&2048&&fx(9,m);break;case 1:Do(h,m,_,M);break;case 3:Do(h,m,_,M),j&2048&&(h=null,m.alternate!==null&&(h=m.alternate.memoizedState.cache),m=m.memoizedState.cache,m!==h&&(m.refCount++,h!=null&&ex(h)));break;case 12:if(j&2048){Do(h,m,_,M),h=m.stateNode;try{var O=m.memoizedProps,te=O.id,he=O.onPostCommit;typeof he=="function"&&he(te,m.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Pe){Yn(m,m.return,Pe)}}else Do(h,m,_,M);break;case 31:Do(h,m,_,M);break;case 13:Do(h,m,_,M);break;case 23:break;case 22:O=m.stateNode,te=m.alternate,m.memoizedState!==null?O._visibility&2?Do(h,m,_,M):px(h,m):O._visibility&2?Do(h,m,_,M):(O._visibility|=2,cm(h,m,_,M,(m.subtreeFlags&10256)!==0||!1)),j&2048&&vN(te,m);break;case 24:Do(h,m,_,M),j&2048&&_N(m.alternate,m);break;default:Do(h,m,_,M)}}function cm(h,m,_,M,j){for(j=j&&((m.subtreeFlags&10256)!==0||!1),m=m.child;m!==null;){var O=h,te=m,he=_,Pe=M,tt=te.flags;switch(te.tag){case 0:case 11:case 15:cm(O,te,he,Pe,j),fx(8,te);break;case 23:break;case 22:var dt=te.stateNode;te.memoizedState!==null?dt._visibility&2?cm(O,te,he,Pe,j):px(O,te):(dt._visibility|=2,cm(O,te,he,Pe,j)),j&&tt&2048&&vN(te.alternate,te);break;case 24:cm(O,te,he,Pe,j),j&&tt&2048&&_N(te.alternate,te);break;default:cm(O,te,he,Pe,j)}m=m.sibling}}function px(h,m){if(m.subtreeFlags&10256)for(m=m.child;m!==null;){var _=h,M=m,j=M.flags;switch(M.tag){case 22:px(_,M),j&2048&&vN(M.alternate,M);break;case 24:px(_,M),j&2048&&_N(M.alternate,M);break;default:px(_,M)}m=m.sibling}}var gx=8192;function um(h,m,_){if(h.subtreeFlags&gx)for(h=h.child;h!==null;)k5(h,m,_),h=h.sibling}function k5(h,m,_){switch(h.tag){case 26:um(h,m,_),h.flags&gx&&h.memoizedState!==null&&wie(_,Ro,h.memoizedState,h.memoizedProps);break;case 5:um(h,m,_);break;case 3:case 4:var M=Ro;Ro=Ev(h.stateNode.containerInfo),um(h,m,_),Ro=M;break;case 22:h.memoizedState===null&&(M=h.alternate,M!==null&&M.memoizedState!==null?(M=gx,gx=16777216,um(h,m,_),gx=M):um(h,m,_));break;default:um(h,m,_)}}function j5(h){var m=h.alternate;if(m!==null&&(h=m.child,h!==null)){m.child=null;do m=h.sibling,h.sibling=null,h=m;while(h!==null)}}function xx(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Ui=M,R5(M,h)}j5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)P5(h),h=h.sibling}function P5(h){switch(h.tag){case 0:case 11:case 15:xx(h),h.flags&2048&&Mu(9,h,h.return);break;case 3:xx(h);break;case 12:xx(h);break;case 22:var m=h.stateNode;h.memoizedState!==null&&m._visibility&2&&(h.return===null||h.return.tag!==13)?(m._visibility&=-3,hv(h)):xx(h);break;default:xx(h)}}function hv(h){var m=h.deletions;if((h.flags&16)!==0){if(m!==null)for(var _=0;_<m.length;_++){var M=m[_];Ui=M,R5(M,h)}j5(h)}for(h=h.child;h!==null;){switch(m=h,m.tag){case 0:case 11:case 15:Mu(8,m,m.return),hv(m);break;case 22:_=m.stateNode,_._visibility&2&&(_._visibility&=-3,hv(m));break;default:hv(m)}h=h.sibling}}function R5(h,m){for(;Ui!==null;){var _=Ui;switch(_.tag){case 0:case 11:case 15:Mu(8,_,m);break;case 23:case 22:if(_.memoizedState!==null&&_.memoizedState.cachePool!==null){var M=_.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:ex(_.memoizedState.cache)}if(M=_.child,M!==null)M.return=_,Ui=M;else e:for(_=h;Ui!==null;){M=Ui;var j=M.sibling,O=M.return;if(S5(M),M===_){Ui=null;break e}if(j!==null){j.return=O,Ui=j;break e}Ui=O}}}var Ire={getCacheForType:function(h){var m=ta(si),_=m.data.get(h);return _===void 0&&(_=h(),m.data.set(h,_)),_},cacheSignal:function(){return ta(si).controller.signal}},Fre=typeof WeakMap=="function"?WeakMap:Map,Bn=0,mr=null,Mn=null,jn=0,Xn=0,vs=null,Eu=!1,dm=!1,wN=!1,sc=0,Br=0,Nu=0,fh=0,SN=0,_s=0,hm=0,bx=null,Ja=null,MN=!1,fv=0,D5=0,mv=1/0,pv=null,Au=null,wi=0,Tu=null,fm=null,oc=0,EN=0,NN=null,O5=null,yx=0,AN=null;function ws(){return(Bn&2)!==0&&jn!==0?jn&-jn:J.T!==null?RN():Jr()}function L5(){if(_s===0)if((jn&536870912)===0||Rn){var h=ve;ve<<=1,(ve&3932160)===0&&(ve=262144),_s=h}else _s=536870912;return h=bs.current,h!==null&&(h.flags|=32),_s}function es(h,m,_){(h===mr&&(Xn===2||Xn===9)||h.cancelPendingCommit!==null)&&(mm(h,0),Cu(h,jn,_s,!1)),Xt(h,_),((Bn&2)===0||h!==mr)&&(h===mr&&((Bn&2)===0&&(fh|=_),Br===4&&Cu(h,jn,_s,!1)),cl(h))}function I5(h,m,_){if((Bn&6)!==0)throw Error(r(327));var M=!_&&(m&127)===0&&(m&h.expiredLanes)===0||Xe(h,m),j=M?Bre(h,m):CN(h,m,!0),O=M;do{if(j===0){dm&&!M&&Cu(h,m,0,!1);break}else{if(_=h.current.alternate,O&&!Ure(_)){j=CN(h,m,!1),O=!1;continue}if(j===2){if(O=m,h.errorRecoveryDisabledLanes&O)var te=0;else te=h.pendingLanes&-536870913,te=te!==0?te:te&536870912?536870912:0;if(te!==0){m=te;e:{var he=h;j=bx;var Pe=he.current.memoizedState.isDehydrated;if(Pe&&(mm(he,te).flags|=256),te=CN(he,te,!1),te!==2){if(wN&&!Pe){he.errorRecoveryDisabledLanes|=O,fh|=O,j=4;break e}O=Ja,Ja=j,O!==null&&(Ja===null?Ja=O:Ja.push.apply(Ja,O))}j=te}if(O=!1,j!==2)continue}}if(j===1){mm(h,0),Cu(h,m,0,!0);break}e:{switch(M=h,O=j,O){case 0:case 1:throw Error(r(345));case 4:if((m&4194048)!==m)break;case 6:Cu(M,m,_s,!Eu);break e;case 2:Ja=null;break;case 3:case 5:break;default:throw Error(r(329))}if((m&62914560)===m&&(j=fv+300-I(),10<j)){if(Cu(M,m,_s,!Eu),Ne(M,0,!0)!==0)break e;oc=m,M.timeoutHandle=mF(F5.bind(null,M,_,Ja,pv,MN,m,_s,fh,hm,Eu,O,"Throttled",-0,0),j);break e}F5(M,_,Ja,pv,MN,m,_s,fh,hm,Eu,O,null,-0,0)}}break}while(!0);cl(h)}function F5(h,m,_,M,j,O,te,he,Pe,tt,dt,bt,rt,ot){if(h.timeoutHandle=-1,bt=m.subtreeFlags,bt&8192||(bt&16785408)===16785408){bt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Wl},k5(m,O,bt);var Ut=(O&62914560)===O?fv-I():(O&4194048)===O?D5-I():0;if(Ut=Sie(bt,Ut),Ut!==null){oc=O,h.cancelPendingCommit=Ut(W5.bind(null,h,m,O,_,M,j,te,he,Pe,dt,bt,null,rt,ot)),Cu(h,O,te,!tt);return}}W5(h,m,O,_,M,j,te,he,Pe)}function Ure(h){for(var m=h;;){var _=m.tag;if((_===0||_===11||_===15)&&m.flags&16384&&(_=m.updateQueue,_!==null&&(_=_.stores,_!==null)))for(var M=0;M<_.length;M++){var j=_[M],O=j.getSnapshot;j=j.value;try{if(!gs(O(),j))return!1}catch{return!1}}if(_=m.child,m.subtreeFlags&16384&&_!==null)_.return=m,m=_;else{if(m===h)break;for(;m.sibling===null;){if(m.return===null||m.return===h)return!0;m=m.return}m.sibling.return=m.return,m=m.sibling}}return!0}function Cu(h,m,_,M){m&=~SN,m&=~fh,h.suspendedLanes|=m,h.pingedLanes&=~m,M&&(h.warmLanes|=m),M=h.expirationTimes;for(var j=m;0<j;){var O=31-qe(j),te=1<<O;M[O]=-1,j&=~te}_!==0&&Sn(h,_,m)}function gv(){return(Bn&6)===0?(vx(0),!1):!0}function TN(){if(Mn!==null){if(Xn===0)var h=Mn.return;else h=Mn,Yl=ih=null,VE(h),im=null,nx=0,h=Mn;for(;h!==null;)p5(h.alternate,h),h=h.return;Mn=null}}function mm(h,m){var _=h.timeoutHandle;_!==-1&&(h.timeoutHandle=-1,aie(_)),_=h.cancelPendingCommit,_!==null&&(h.cancelPendingCommit=null,_()),oc=0,TN(),mr=h,Mn=_=Kl(h.current,null),jn=m,Xn=0,vs=null,Eu=!1,dm=Xe(h,m),wN=!1,hm=_s=SN=fh=Nu=Br=0,Ja=bx=null,MN=!1,(m&8)!==0&&(m|=m&32);var M=h.entangledLanes;if(M!==0)for(h=h.entanglements,M&=m;0<M;){var j=31-qe(M),O=1<<j;m|=h[j],M&=~O}return sc=m,Iy(),_}function U5(h,m){un=null,J.H=ux,m===rm||m===Gy?(m=tI(),Xn=3):m===PE?(m=tI(),Xn=4):Xn=m===sN?8:m!==null&&typeof m=="object"&&typeof m.then=="function"?6:1,vs=m,Mn===null&&(Br=1,av(h,qs(m,h.current)))}function z5(){var h=bs.current;return h===null?!0:(jn&4194048)===jn?Qs===null:(jn&62914560)===jn||(jn&536870912)!==0?h===Qs:!1}function B5(){var h=J.H;return J.H=ux,h===null?ux:h}function $5(){var h=J.A;return J.A=Ire,h}function xv(){Br=4,Eu||(jn&4194048)!==jn&&bs.current!==null||(dm=!0),(Nu&134217727)===0&&(fh&134217727)===0||mr===null||Cu(mr,jn,_s,!1)}function CN(h,m,_){var M=Bn;Bn|=2;var j=B5(),O=$5();(mr!==h||jn!==m)&&(pv=null,mm(h,m)),m=!1;var te=Br;e:do try{if(Xn!==0&&Mn!==null){var he=Mn,Pe=vs;switch(Xn){case 8:TN(),te=6;break e;case 3:case 2:case 9:case 6:bs.current===null&&(m=!0);var tt=Xn;if(Xn=0,vs=null,pm(h,he,Pe,tt),_&&dm){te=0;break e}break;default:tt=Xn,Xn=0,vs=null,pm(h,he,Pe,tt)}}zre(),te=Br;break}catch(dt){U5(h,dt)}while(!0);return m&&h.shellSuspendCounter++,Yl=ih=null,Bn=M,J.H=j,J.A=O,Mn===null&&(mr=null,jn=0,Iy()),te}function zre(){for(;Mn!==null;)H5(Mn)}function Bre(h,m){var _=Bn;Bn|=2;var M=B5(),j=$5();mr!==h||jn!==m?(pv=null,mv=I()+500,mm(h,m)):dm=Xe(h,m);e:do try{if(Xn!==0&&Mn!==null){m=Mn;var O=vs;t:switch(Xn){case 1:Xn=0,vs=null,pm(h,m,O,1);break;case 2:case 9:if(JL(O)){Xn=0,vs=null,V5(m);break}m=function(){Xn!==2&&Xn!==9||mr!==h||(Xn=7),cl(h)},O.then(m,m);break e;case 3:Xn=7;break e;case 4:Xn=5;break e;case 7:JL(O)?(Xn=0,vs=null,V5(m)):(Xn=0,vs=null,pm(h,m,O,7));break;case 5:var te=null;switch(Mn.tag){case 26:te=Mn.memoizedState;case 5:case 27:var he=Mn;if(te?CF(te):he.stateNode.complete){Xn=0,vs=null;var Pe=he.sibling;if(Pe!==null)Mn=Pe;else{var tt=he.return;tt!==null?(Mn=tt,bv(tt)):Mn=null}break t}}Xn=0,vs=null,pm(h,m,O,5);break;case 6:Xn=0,vs=null,pm(h,m,O,6);break;case 8:TN(),Br=6;break e;default:throw Error(r(462))}}$re();break}catch(dt){U5(h,dt)}while(!0);return Yl=ih=null,J.H=M,J.A=j,Bn=_,Mn!==null?0:(mr=null,jn=0,Iy(),Br)}function $re(){for(;Mn!==null&&!fe();)H5(Mn)}function H5(h){var m=f5(h.alternate,h,sc);h.memoizedProps=h.pendingProps,m===null?bv(h):Mn=m}function V5(h){var m=h,_=m.alternate;switch(m.tag){case 15:case 0:m=o5(_,m,m.pendingProps,m.type,void 0,jn);break;case 11:m=o5(_,m,m.pendingProps,m.type.render,m.ref,jn);break;case 5:VE(m);default:p5(_,m),m=Mn=$L(m,sc),m=f5(_,m,sc)}h.memoizedProps=h.pendingProps,m===null?bv(h):Mn=m}function pm(h,m,_,M){Yl=ih=null,VE(m),im=null,nx=0;var j=m.return;try{if(kre(h,j,m,_,jn)){Br=1,av(h,qs(_,h.current)),Mn=null;return}}catch(O){if(j!==null)throw Mn=j,O;Br=1,av(h,qs(_,h.current)),Mn=null;return}m.flags&32768?(Rn||M===1?h=!0:dm||(jn&536870912)!==0?h=!1:(Eu=h=!0,(M===2||M===9||M===3||M===6)&&(M=bs.current,M!==null&&M.tag===13&&(M.flags|=16384))),G5(m,h)):bv(m)}function bv(h){var m=h;do{if((m.flags&32768)!==0){G5(m,Eu);return}h=m.return;var _=Rre(m.alternate,m,sc);if(_!==null){Mn=_;return}if(m=m.sibling,m!==null){Mn=m;return}Mn=m=h}while(m!==null);Br===0&&(Br=5)}function G5(h,m){do{var _=Dre(h.alternate,h);if(_!==null){_.flags&=32767,Mn=_;return}if(_=h.return,_!==null&&(_.flags|=32768,_.subtreeFlags=0,_.deletions=null),!m&&(h=h.sibling,h!==null)){Mn=h;return}Mn=h=_}while(h!==null);Br=6,Mn=null}function W5(h,m,_,M,j,O,te,he,Pe){h.cancelPendingCommit=null;do yv();while(wi!==0);if((Bn&6)!==0)throw Error(r(327));if(m!==null){if(m===h.current)throw Error(r(177));if(O=m.lanes|m.childLanes,O|=xE,Lt(h,_,O,te,he,Pe),h===mr&&(Mn=mr=null,jn=0),fm=m,Tu=h,oc=_,EN=O,NN=j,O5=M,(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,Wre(_e,function(){return Q5(),null})):(h.callbackNode=null,h.callbackPriority=0),M=(m.flags&13878)!==0,(m.subtreeFlags&13878)!==0||M){M=J.T,J.T=null,j=G.p,G.p=2,te=Bn,Bn|=4;try{Ore(h,m,_)}finally{Bn=te,G.p=j,J.T=M}}wi=1,q5(),K5(),X5()}}function q5(){if(wi===1){wi=0;var h=Tu,m=fm,_=(m.flags&13878)!==0;if((m.subtreeFlags&13878)!==0||_){_=J.T,J.T=null;var M=G.p;G.p=2;var j=Bn;Bn|=4;try{A5(m,h);var O=BN,te=RL(h.containerInfo),he=O.focusedElem,Pe=O.selectionRange;if(te!==he&&he&&he.ownerDocument&&PL(he.ownerDocument.documentElement,he)){if(Pe!==null&&hE(he)){var tt=Pe.start,dt=Pe.end;if(dt===void 0&&(dt=tt),"selectionStart"in he)he.selectionStart=tt,he.selectionEnd=Math.min(dt,he.value.length);else{var bt=he.ownerDocument||document,rt=bt&&bt.defaultView||window;if(rt.getSelection){var ot=rt.getSelection(),Ut=he.textContent.length,Qt=Math.min(Pe.start,Ut),ar=Pe.end===void 0?Qt:Math.min(Pe.end,Ut);!ot.extend&&Qt>ar&&(te=ar,ar=Qt,Qt=te);var Ge=jL(he,Qt),Ue=jL(he,ar);if(Ge&&Ue&&(ot.rangeCount!==1||ot.anchorNode!==Ge.node||ot.anchorOffset!==Ge.offset||ot.focusNode!==Ue.node||ot.focusOffset!==Ue.offset)){var et=bt.createRange();et.setStart(Ge.node,Ge.offset),ot.removeAllRanges(),Qt>ar?(ot.addRange(et),ot.extend(Ue.node,Ue.offset)):(et.setEnd(Ue.node,Ue.offset),ot.addRange(et))}}}}for(bt=[],ot=he;ot=ot.parentNode;)ot.nodeType===1&&bt.push({element:ot,left:ot.scrollLeft,top:ot.scrollTop});for(typeof he.focus=="function"&&he.focus(),he=0;he<bt.length;he++){var pt=bt[he];pt.element.scrollLeft=pt.left,pt.element.scrollTop=pt.top}}jv=!!zN,BN=zN=null}finally{Bn=j,G.p=M,J.T=_}}h.current=m,wi=2}}function K5(){if(wi===2){wi=0;var h=Tu,m=fm,_=(m.flags&8772)!==0;if((m.subtreeFlags&8772)!==0||_){_=J.T,J.T=null;var M=G.p;G.p=2;var j=Bn;Bn|=4;try{w5(h,m.alternate,m)}finally{Bn=j,G.p=M,J.T=_}}wi=3}}function X5(){if(wi===4||wi===3){wi=0,H();var h=Tu,m=fm,_=oc,M=O5;(m.subtreeFlags&10256)!==0||(m.flags&10256)!==0?wi=5:(wi=0,fm=Tu=null,Y5(h,h.pendingLanes));var j=h.pendingLanes;if(j===0&&(Au=null),Hn(_),m=m.stateNode,me&&typeof me.onCommitFiberRoot=="function")try{me.onCommitFiberRoot(Fe,m,void 0,(m.current.flags&128)===128)}catch{}if(M!==null){m=J.T,j=G.p,G.p=2,J.T=null;try{for(var O=h.onRecoverableError,te=0;te<M.length;te++){var he=M[te];O(he.value,{componentStack:he.stack})}}finally{J.T=m,G.p=j}}(oc&3)!==0&&yv(),cl(h),j=h.pendingLanes,(_&261930)!==0&&(j&42)!==0?h===AN?yx++:(yx=0,AN=h):yx=0,vx(0)}}function Y5(h,m){(h.pooledCacheLanes&=m)===0&&(m=h.pooledCache,m!=null&&(h.pooledCache=null,ex(m)))}function yv(){return q5(),K5(),X5(),Q5()}function Q5(){if(wi!==5)return!1;var h=Tu,m=EN;EN=0;var _=Hn(oc),M=J.T,j=G.p;try{G.p=32>_?32:_,J.T=null,_=NN,NN=null;var O=Tu,te=oc;if(wi=0,fm=Tu=null,oc=0,(Bn&6)!==0)throw Error(r(331));var he=Bn;if(Bn|=4,P5(O.current),C5(O,O.current,te,_),Bn=he,vx(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(Fe,O)}catch{}return!0}finally{G.p=j,J.T=M,Y5(h,m)}}function Z5(h,m,_){m=qs(_,m),m=aN(h.stateNode,m,2),h=_u(h,m,2),h!==null&&(Xt(h,2),cl(h))}function Yn(h,m,_){if(h.tag===3)Z5(h,h,_);else for(;m!==null;){if(m.tag===3){Z5(m,h,_);break}else if(m.tag===1){var M=m.stateNode;if(typeof m.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(Au===null||!Au.has(M))){h=qs(_,h),_=JI(2),M=_u(m,_,2),M!==null&&(e5(_,M,m,h),Xt(M,2),cl(M));break}}m=m.return}}function kN(h,m,_){var M=h.pingCache;if(M===null){M=h.pingCache=new Fre;var j=new Set;M.set(m,j)}else j=M.get(m),j===void 0&&(j=new Set,M.set(m,j));j.has(_)||(wN=!0,j.add(_),h=Hre.bind(null,h,m,_),m.then(h,h))}function Hre(h,m,_){var M=h.pingCache;M!==null&&M.delete(m),h.pingedLanes|=h.suspendedLanes&_,h.warmLanes&=~_,mr===h&&(jn&_)===_&&(Br===4||Br===3&&(jn&62914560)===jn&&300>I()-fv?(Bn&2)===0&&mm(h,0):SN|=_,hm===jn&&(hm=0)),cl(h)}function J5(h,m){m===0&&(m=At()),h=th(h,m),h!==null&&(Xt(h,m),cl(h))}function Vre(h){var m=h.memoizedState,_=0;m!==null&&(_=m.retryLane),J5(h,_)}function Gre(h,m){var _=0;switch(h.tag){case 31:case 13:var M=h.stateNode,j=h.memoizedState;j!==null&&(_=j.retryLane);break;case 19:M=h.stateNode;break;case 22:M=h.stateNode._retryCache;break;default:throw Error(r(314))}M!==null&&M.delete(m),J5(h,_)}function Wre(h,m){return Me(h,m)}var vv=null,gm=null,jN=!1,_v=!1,PN=!1,ku=0;function cl(h){h!==gm&&h.next===null&&(gm===null?vv=gm=h:gm=gm.next=h),_v=!0,jN||(jN=!0,Kre())}function vx(h,m){if(!PN&&_v){PN=!0;do for(var _=!1,M=vv;M!==null;){if(h!==0){var j=M.pendingLanes;if(j===0)var O=0;else{var te=M.suspendedLanes,he=M.pingedLanes;O=(1<<31-qe(42|h)+1)-1,O&=j&~(te&~he),O=O&201326741?O&201326741|1:O?O|2:0}O!==0&&(_=!0,rF(M,O))}else O=jn,O=Ne(M,M===mr?O:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(O&3)===0||Xe(M,O)||(_=!0,rF(M,O));M=M.next}while(_);PN=!1}}function qre(){eF()}function eF(){_v=jN=!1;var h=0;ku!==0&&iie()&&(h=ku);for(var m=I(),_=null,M=vv;M!==null;){var j=M.next,O=tF(M,m);O===0?(M.next=null,_===null?vv=j:_.next=j,j===null&&(gm=_)):(_=M,(h!==0||(O&3)!==0)&&(_v=!0)),M=j}wi!==0&&wi!==5||vx(h),ku!==0&&(ku=0)}function tF(h,m){for(var _=h.suspendedLanes,M=h.pingedLanes,j=h.expirationTimes,O=h.pendingLanes&-62914561;0<O;){var te=31-qe(O),he=1<<te,Pe=j[te];Pe===-1?((he&_)===0||(he&M)!==0)&&(j[te]=mt(he,m)):Pe<=m&&(h.expiredLanes|=he),O&=~he}if(m=mr,_=jn,_=Ne(h,h===m?_:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M=h.callbackNode,_===0||h===m&&(Xn===2||Xn===9)||h.cancelPendingCommit!==null)return M!==null&&M!==null&&Te(M),h.callbackNode=null,h.callbackPriority=0;if((_&3)===0||Xe(h,_)){if(m=_&-_,m===h.callbackPriority)return m;switch(M!==null&&Te(M),Hn(_)){case 2:case 8:_=Se;break;case 32:_=_e;break;case 268435456:_=Ve;break;default:_=_e}return M=nF.bind(null,h),_=Me(_,M),h.callbackPriority=m,h.callbackNode=_,m}return M!==null&&M!==null&&Te(M),h.callbackPriority=2,h.callbackNode=null,2}function nF(h,m){if(wi!==0&&wi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var _=h.callbackNode;if(yv()&&h.callbackNode!==_)return null;var M=jn;return M=Ne(h,h===mr?M:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),M===0?null:(I5(h,M,m),tF(h,I()),h.callbackNode!=null&&h.callbackNode===_?nF.bind(null,h):null)}function rF(h,m){if(yv())return null;I5(h,m,!0)}function Kre(){sie(function(){(Bn&6)!==0?Me(we,qre):eF()})}function RN(){if(ku===0){var h=tm;h===0&&(h=He,He<<=1,(He&261888)===0&&(He=256)),ku=h}return ku}function iF(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:Cy(""+h)}function aF(h,m){var _=m.ownerDocument.createElement("input");return _.name=m.name,_.value=m.value,h.id&&_.setAttribute("form",h.id),m.parentNode.insertBefore(_,m),h=new FormData(h),_.parentNode.removeChild(_),h}function Xre(h,m,_,M,j){if(m==="submit"&&_&&_.stateNode===j){var O=iF((j[qt]||null).action),te=M.submitter;te&&(m=(m=te[qt]||null)?iF(m.formAction):te.getAttribute("formAction"),m!==null&&(O=m,te=null));var he=new Ry("action","action",null,M,j);h.push({event:he,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(ku!==0){var Pe=te?aF(j,te):new FormData(j);JE(_,{pending:!0,data:Pe,method:j.method,action:O},null,Pe)}}else typeof O=="function"&&(he.preventDefault(),Pe=te?aF(j,te):new FormData(j),JE(_,{pending:!0,data:Pe,method:j.method,action:O},O,Pe))},currentTarget:j}]})}}for(var DN=0;DN<gE.length;DN++){var ON=gE[DN],Yre=ON.toLowerCase(),Qre=ON[0].toUpperCase()+ON.slice(1);Po(Yre,"on"+Qre)}Po(LL,"onAnimationEnd"),Po(IL,"onAnimationIteration"),Po(FL,"onAnimationStart"),Po("dblclick","onDoubleClick"),Po("focusin","onFocus"),Po("focusout","onBlur"),Po(fre,"onTransitionRun"),Po(mre,"onTransitionStart"),Po(pre,"onTransitionCancel"),Po(UL,"onTransitionEnd"),Nt("onMouseEnter",["mouseout","mouseover"]),Nt("onMouseLeave",["mouseout","mouseover"]),Nt("onPointerEnter",["pointerout","pointerover"]),Nt("onPointerLeave",["pointerout","pointerover"]),xt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),xt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),xt("onBeforeInput",["compositionend","keypress","textInput","paste"]),xt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),xt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),xt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _x="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(" "),Zre=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(_x));function sF(h,m){m=(m&4)!==0;for(var _=0;_<h.length;_++){var M=h[_],j=M.event;M=M.listeners;e:{var O=void 0;if(m)for(var te=M.length-1;0<=te;te--){var he=M[te],Pe=he.instance,tt=he.currentTarget;if(he=he.listener,Pe!==O&&j.isPropagationStopped())break e;O=he,j.currentTarget=tt;try{O(j)}catch(dt){Ly(dt)}j.currentTarget=null,O=Pe}else for(te=0;te<M.length;te++){if(he=M[te],Pe=he.instance,tt=he.currentTarget,he=he.listener,Pe!==O&&j.isPropagationStopped())break e;O=he,j.currentTarget=tt;try{O(j)}catch(dt){Ly(dt)}j.currentTarget=null,O=Pe}}}}function En(h,m){var _=m[en];_===void 0&&(_=m[en]=new Set);var M=h+"__bubble";_.has(M)||(oF(m,h,2,!1),_.add(M))}function LN(h,m,_){var M=0;m&&(M|=4),oF(_,h,M,m)}var wv="_reactListening"+Math.random().toString(36).slice(2);function IN(h){if(!h[wv]){h[wv]=!0,Re.forEach(function(_){_!=="selectionchange"&&(Zre.has(_)||LN(_,!1,h),LN(_,!0,h))});var m=h.nodeType===9?h:h.ownerDocument;m===null||m[wv]||(m[wv]=!0,LN("selectionchange",!1,m))}}function oF(h,m,_,M){switch(LF(m)){case 2:var j=Nie;break;case 8:j=Aie;break;default:j=ZN}_=j.bind(null,m,_,h),j=void 0,!rE||m!=="touchstart"&&m!=="touchmove"&&m!=="wheel"||(j=!0),M?j!==void 0?h.addEventListener(m,_,{capture:!0,passive:j}):h.addEventListener(m,_,!0):j!==void 0?h.addEventListener(m,_,{passive:j}):h.addEventListener(m,_,!1)}function FN(h,m,_,M,j){var O=M;if((m&1)===0&&(m&2)===0&&M!==null)e:for(;;){if(M===null)return;var te=M.tag;if(te===3||te===4){var he=M.stateNode.containerInfo;if(he===j)break;if(te===4)for(te=M.return;te!==null;){var Pe=te.tag;if((Pe===3||Pe===4)&&te.stateNode.containerInfo===j)return;te=te.return}for(;he!==null;){if(te=xe(he),te===null)return;if(Pe=te.tag,Pe===5||Pe===6||Pe===26||Pe===27){M=O=te;continue e}he=he.parentNode}}M=M.return}hL(function(){var tt=O,dt=tE(_),bt=[];e:{var rt=zL.get(h);if(rt!==void 0){var ot=Ry,Ut=h;switch(h){case"keypress":if(jy(_)===0)break e;case"keydown":case"keyup":ot=Gne;break;case"focusin":Ut="focus",ot=oE;break;case"focusout":Ut="blur",ot=oE;break;case"beforeblur":case"afterblur":ot=oE;break;case"click":if(_.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ot=pL;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ot=Rne;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ot=Kne;break;case LL:case IL:case FL:ot=Lne;break;case UL:ot=Yne;break;case"scroll":case"scrollend":ot=jne;break;case"wheel":ot=Zne;break;case"copy":case"cut":case"paste":ot=Fne;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ot=xL;break;case"toggle":case"beforetoggle":ot=ere}var Qt=(m&4)!==0,ar=!Qt&&(h==="scroll"||h==="scrollend"),Ge=Qt?rt!==null?rt+"Capture":null:rt;Qt=[];for(var Ue=tt,et;Ue!==null;){var pt=Ue;if(et=pt.stateNode,pt=pt.tag,pt!==5&&pt!==26&&pt!==27||et===null||Ge===null||(pt=Hg(Ue,Ge),pt!=null&&Qt.push(wx(Ue,pt,et))),ar)break;Ue=Ue.return}0<Qt.length&&(rt=new ot(rt,Ut,null,_,dt),bt.push({event:rt,listeners:Qt}))}}if((m&7)===0){e:{if(rt=h==="mouseover"||h==="pointerover",ot=h==="mouseout"||h==="pointerout",rt&&_!==eE&&(Ut=_.relatedTarget||_.fromElement)&&(xe(Ut)||Ut[gt]))break e;if((ot||rt)&&(rt=dt.window===dt?dt:(rt=dt.ownerDocument)?rt.defaultView||rt.parentWindow:window,ot?(Ut=_.relatedTarget||_.toElement,ot=tt,Ut=Ut?xe(Ut):null,Ut!==null&&(ar=a(Ut),Qt=Ut.tag,Ut!==ar||Qt!==5&&Qt!==27&&Qt!==6)&&(Ut=null)):(ot=null,Ut=tt),ot!==Ut)){if(Qt=pL,pt="onMouseLeave",Ge="onMouseEnter",Ue="mouse",(h==="pointerout"||h==="pointerover")&&(Qt=xL,pt="onPointerLeave",Ge="onPointerEnter",Ue="pointer"),ar=ot==null?rt:Ae(ot),et=Ut==null?rt:Ae(Ut),rt=new Qt(pt,Ue+"leave",ot,_,dt),rt.target=ar,rt.relatedTarget=et,pt=null,xe(dt)===tt&&(Qt=new Qt(Ge,Ue+"enter",Ut,_,dt),Qt.target=et,Qt.relatedTarget=ar,pt=Qt),ar=pt,ot&&Ut)t:{for(Qt=Jre,Ge=ot,Ue=Ut,et=0,pt=Ge;pt;pt=Qt(pt))et++;pt=0;for(var Gt=Ue;Gt;Gt=Qt(Gt))pt++;for(;0<et-pt;)Ge=Qt(Ge),et--;for(;0<pt-et;)Ue=Qt(Ue),pt--;for(;et--;){if(Ge===Ue||Ue!==null&&Ge===Ue.alternate){Qt=Ge;break t}Ge=Qt(Ge),Ue=Qt(Ue)}Qt=null}else Qt=null;ot!==null&&lF(bt,rt,ot,Qt,!1),Ut!==null&&ar!==null&&lF(bt,ar,Ut,Qt,!0)}}e:{if(rt=tt?Ae(tt):window,ot=rt.nodeName&&rt.nodeName.toLowerCase(),ot==="select"||ot==="input"&&rt.type==="file")var Ln=EL;else if(SL(rt))if(NL)Ln=ure;else{Ln=lre;var Bt=ore}else ot=rt.nodeName,!ot||ot.toLowerCase()!=="input"||rt.type!=="checkbox"&&rt.type!=="radio"?tt&&JM(tt.elementType)&&(Ln=EL):Ln=cre;if(Ln&&(Ln=Ln(h,tt))){ML(bt,Ln,_,dt);break e}Bt&&Bt(h,rt,tt),h==="focusout"&&tt&&rt.type==="number"&&tt.memoizedProps.value!=null&&Ii(rt,"number",rt.value)}switch(Bt=tt?Ae(tt):window,h){case"focusin":(SL(Bt)||Bt.contentEditable==="true")&&(qf=Bt,fE=tt,Qg=null);break;case"focusout":Qg=fE=qf=null;break;case"mousedown":mE=!0;break;case"contextmenu":case"mouseup":case"dragend":mE=!1,DL(bt,_,dt);break;case"selectionchange":if(hre)break;case"keydown":case"keyup":DL(bt,_,dt)}var dn;if(cE)e:{switch(h){case"compositionstart":var Pn="onCompositionStart";break e;case"compositionend":Pn="onCompositionEnd";break e;case"compositionupdate":Pn="onCompositionUpdate";break e}Pn=void 0}else Wf?_L(h,_)&&(Pn="onCompositionEnd"):h==="keydown"&&_.keyCode===229&&(Pn="onCompositionStart");Pn&&(bL&&_.locale!=="ko"&&(Wf||Pn!=="onCompositionStart"?Pn==="onCompositionEnd"&&Wf&&(dn=fL()):(mu=dt,iE="value"in mu?mu.value:mu.textContent,Wf=!0)),Bt=Sv(tt,Pn),0<Bt.length&&(Pn=new gL(Pn,h,null,_,dt),bt.push({event:Pn,listeners:Bt}),dn?Pn.data=dn:(dn=wL(_),dn!==null&&(Pn.data=dn)))),(dn=nre?rre(h,_):ire(h,_))&&(Pn=Sv(tt,"onBeforeInput"),0<Pn.length&&(Bt=new gL("onBeforeInput","beforeinput",null,_,dt),bt.push({event:Bt,listeners:Pn}),Bt.data=dn)),Xre(bt,h,tt,_,dt)}sF(bt,m)})}function wx(h,m,_){return{instance:h,listener:m,currentTarget:_}}function Sv(h,m){for(var _=m+"Capture",M=[];h!==null;){var j=h,O=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||O===null||(j=Hg(h,_),j!=null&&M.unshift(wx(h,j,O)),j=Hg(h,m),j!=null&&M.push(wx(h,j,O))),h.tag===3)return M;h=h.return}return[]}function Jre(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function lF(h,m,_,M,j){for(var O=m._reactName,te=[];_!==null&&_!==M;){var he=_,Pe=he.alternate,tt=he.stateNode;if(he=he.tag,Pe!==null&&Pe===M)break;he!==5&&he!==26&&he!==27||tt===null||(Pe=tt,j?(tt=Hg(_,O),tt!=null&&te.unshift(wx(_,tt,Pe))):j||(tt=Hg(_,O),tt!=null&&te.push(wx(_,tt,Pe)))),_=_.return}te.length!==0&&h.push({event:m,listeners:te})}var eie=/\r\n?/g,tie=/\u0000|\uFFFD/g;function cF(h){return(typeof h=="string"?h:""+h).replace(eie,`
- `).replace(tie,"")}function uF(h,m){return m=cF(m),cF(h)===m}function ir(h,m,_,M,j,O){switch(_){case"children":typeof M=="string"?m==="body"||m==="textarea"&&M===""||al(h,M):(typeof M=="number"||typeof M=="bigint")&&m!=="body"&&al(h,""+M);break;case"className":Vt(h,"class",M);break;case"tabIndex":Vt(h,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Vt(h,_,M);break;case"style":uL(h,M,O);break;case"data":if(m!=="object"){Vt(h,"data",M);break}case"src":case"href":if(M===""&&(m!=="a"||_!=="href")){h.removeAttribute(_);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=Cy(""+M),h.setAttribute(_,M);break;case"action":case"formAction":if(typeof M=="function"){h.setAttribute(_,"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"&&(_==="formAction"?(m!=="input"&&ir(h,m,"name",j.name,j,null),ir(h,m,"formEncType",j.formEncType,j,null),ir(h,m,"formMethod",j.formMethod,j,null),ir(h,m,"formTarget",j.formTarget,j,null)):(ir(h,m,"encType",j.encType,j,null),ir(h,m,"method",j.method,j,null),ir(h,m,"target",j.target,j,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){h.removeAttribute(_);break}M=Cy(""+M),h.setAttribute(_,M);break;case"onClick":M!=null&&(h.onclick=Wl);break;case"onScroll":M!=null&&En("scroll",h);break;case"onScrollEnd":M!=null&&En("scrollend",h);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"multiple":h.multiple=M&&typeof M!="function"&&typeof M!="symbol";break;case"muted":h.muted=M&&typeof M!="function"&&typeof M!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(M==null||typeof M=="function"||typeof M=="boolean"||typeof M=="symbol"){h.removeAttribute("xlink:href");break}_=Cy(""+M),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""+M):h.removeAttribute(_);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":M&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,""):h.removeAttribute(_);break;case"capture":case"download":M===!0?h.setAttribute(_,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?h.setAttribute(_,M):h.removeAttribute(_);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?h.setAttribute(_,M):h.removeAttribute(_);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?h.removeAttribute(_):h.setAttribute(_,M);break;case"popover":En("beforetoggle",h),En("toggle",h),tn(h,"popover",M);break;case"xlinkActuate":hn(h,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":hn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":hn(h,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":hn(h,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":hn(h,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":hn(h,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":hn(h,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":hn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":hn(h,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":tn(h,"is",M);break;case"innerText":case"textContent":break;default:(!(2<_.length)||_[0]!=="o"&&_[0]!=="O"||_[1]!=="n"&&_[1]!=="N")&&(_=Cne.get(_)||_,tn(h,_,M))}}function UN(h,m,_,M,j,O){switch(_){case"style":uL(h,M,O);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(_=M.__html,_!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=_}}break;case"children":typeof M=="string"?al(h,M):(typeof M=="number"||typeof M=="bigint")&&al(h,""+M);break;case"onScroll":M!=null&&En("scroll",h);break;case"onScrollEnd":M!=null&&En("scrollend",h);break;case"onClick":M!=null&&(h.onclick=Wl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Je.hasOwnProperty(_))e:{if(_[0]==="o"&&_[1]==="n"&&(j=_.endsWith("Capture"),m=_.slice(2,j?_.length-7:void 0),O=h[qt]||null,O=O!=null?O[_]:null,typeof O=="function"&&h.removeEventListener(m,O,j),typeof M=="function")){typeof O!="function"&&O!==null&&(_ in h?h[_]=null:h.hasAttribute(_)&&h.removeAttribute(_)),h.addEventListener(m,M,j);break e}_ in h?h[_]=M:M===!0?h.setAttribute(_,""):tn(h,_,M)}}}function ra(h,m,_){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":En("error",h),En("load",h);var M=!1,j=!1,O;for(O in _)if(_.hasOwnProperty(O)){var te=_[O];if(te!=null)switch(O){case"src":M=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:ir(h,m,O,te,_,null)}}j&&ir(h,m,"srcSet",_.srcSet,_,null),M&&ir(h,m,"src",_.src,_,null);return;case"input":En("invalid",h);var he=O=te=j=null,Pe=null,tt=null;for(M in _)if(_.hasOwnProperty(M)){var dt=_[M];if(dt!=null)switch(M){case"name":j=dt;break;case"type":te=dt;break;case"checked":Pe=dt;break;case"defaultChecked":tt=dt;break;case"value":O=dt;break;case"defaultValue":he=dt;break;case"children":case"dangerouslySetInnerHTML":if(dt!=null)throw Error(r(137,m));break;default:ir(h,m,M,dt,_,null)}}Kn(h,O,he,Pe,tt,te,j,!1);return;case"select":En("invalid",h),M=te=O=null;for(j in _)if(_.hasOwnProperty(j)&&(he=_[j],he!=null))switch(j){case"value":O=he;break;case"defaultValue":te=he;break;case"multiple":M=he;default:ir(h,m,j,he,_,null)}m=O,_=te,h.multiple=!!M,m!=null?_i(h,!!M,m,!1):_!=null&&_i(h,!!M,_,!0);return;case"textarea":En("invalid",h),O=j=M=null;for(te in _)if(_.hasOwnProperty(te)&&(he=_[te],he!=null))switch(te){case"value":M=he;break;case"defaultValue":j=he;break;case"children":O=he;break;case"dangerouslySetInnerHTML":if(he!=null)throw Error(r(91));break;default:ir(h,m,te,he,_,null)}Ji(h,M,j,O);return;case"option":for(Pe in _)if(_.hasOwnProperty(Pe)&&(M=_[Pe],M!=null))switch(Pe){case"selected":h.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:ir(h,m,Pe,M,_,null)}return;case"dialog":En("beforetoggle",h),En("toggle",h),En("cancel",h),En("close",h);break;case"iframe":case"object":En("load",h);break;case"video":case"audio":for(M=0;M<_x.length;M++)En(_x[M],h);break;case"image":En("error",h),En("load",h);break;case"details":En("toggle",h);break;case"embed":case"source":case"link":En("error",h),En("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(tt in _)if(_.hasOwnProperty(tt)&&(M=_[tt],M!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,m));default:ir(h,m,tt,M,_,null)}return;default:if(JM(m)){for(dt in _)_.hasOwnProperty(dt)&&(M=_[dt],M!==void 0&&UN(h,m,dt,M,_,void 0));return}}for(he in _)_.hasOwnProperty(he)&&(M=_[he],M!=null&&ir(h,m,he,M,_,null))}function nie(h,m,_,M){switch(m){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,O=null,te=null,he=null,Pe=null,tt=null,dt=null;for(ot in _){var bt=_[ot];if(_.hasOwnProperty(ot)&&bt!=null)switch(ot){case"checked":break;case"value":break;case"defaultValue":Pe=bt;default:M.hasOwnProperty(ot)||ir(h,m,ot,null,M,bt)}}for(var rt in M){var ot=M[rt];if(bt=_[rt],M.hasOwnProperty(rt)&&(ot!=null||bt!=null))switch(rt){case"type":O=ot;break;case"name":j=ot;break;case"checked":tt=ot;break;case"defaultChecked":dt=ot;break;case"value":te=ot;break;case"defaultValue":he=ot;break;case"children":case"dangerouslySetInnerHTML":if(ot!=null)throw Error(r(137,m));break;default:ot!==bt&&ir(h,m,rt,ot,M,bt)}}jo(h,te,he,Pe,tt,dt,O,j);return;case"select":ot=te=he=rt=null;for(O in _)if(Pe=_[O],_.hasOwnProperty(O)&&Pe!=null)switch(O){case"value":break;case"multiple":ot=Pe;default:M.hasOwnProperty(O)||ir(h,m,O,null,M,Pe)}for(j in M)if(O=M[j],Pe=_[j],M.hasOwnProperty(j)&&(O!=null||Pe!=null))switch(j){case"value":rt=O;break;case"defaultValue":he=O;break;case"multiple":te=O;default:O!==Pe&&ir(h,m,j,O,M,Pe)}m=he,_=te,M=ot,rt!=null?_i(h,!!_,rt,!1):!!M!=!!_&&(m!=null?_i(h,!!_,m,!0):_i(h,!!_,_?[]:"",!1));return;case"textarea":ot=rt=null;for(he in _)if(j=_[he],_.hasOwnProperty(he)&&j!=null&&!M.hasOwnProperty(he))switch(he){case"value":break;case"children":break;default:ir(h,m,he,null,M,j)}for(te in M)if(j=M[te],O=_[te],M.hasOwnProperty(te)&&(j!=null||O!=null))switch(te){case"value":rt=j;break;case"defaultValue":ot=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==O&&ir(h,m,te,j,M,O)}Fi(h,rt,ot);return;case"option":for(var Ut in _)if(rt=_[Ut],_.hasOwnProperty(Ut)&&rt!=null&&!M.hasOwnProperty(Ut))switch(Ut){case"selected":h.selected=!1;break;default:ir(h,m,Ut,null,M,rt)}for(Pe in M)if(rt=M[Pe],ot=_[Pe],M.hasOwnProperty(Pe)&&rt!==ot&&(rt!=null||ot!=null))switch(Pe){case"selected":h.selected=rt&&typeof rt!="function"&&typeof rt!="symbol";break;default:ir(h,m,Pe,rt,M,ot)}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 Qt in _)rt=_[Qt],_.hasOwnProperty(Qt)&&rt!=null&&!M.hasOwnProperty(Qt)&&ir(h,m,Qt,null,M,rt);for(tt in M)if(rt=M[tt],ot=_[tt],M.hasOwnProperty(tt)&&rt!==ot&&(rt!=null||ot!=null))switch(tt){case"children":case"dangerouslySetInnerHTML":if(rt!=null)throw Error(r(137,m));break;default:ir(h,m,tt,rt,M,ot)}return;default:if(JM(m)){for(var ar in _)rt=_[ar],_.hasOwnProperty(ar)&&rt!==void 0&&!M.hasOwnProperty(ar)&&UN(h,m,ar,void 0,M,rt);for(dt in M)rt=M[dt],ot=_[dt],!M.hasOwnProperty(dt)||rt===ot||rt===void 0&&ot===void 0||UN(h,m,dt,rt,M,ot);return}}for(var Ge in _)rt=_[Ge],_.hasOwnProperty(Ge)&&rt!=null&&!M.hasOwnProperty(Ge)&&ir(h,m,Ge,null,M,rt);for(bt in M)rt=M[bt],ot=_[bt],!M.hasOwnProperty(bt)||rt===ot||rt==null&&ot==null||ir(h,m,bt,rt,M,ot)}function dF(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function rie(){if(typeof performance.getEntriesByType=="function"){for(var h=0,m=0,_=performance.getEntriesByType("resource"),M=0;M<_.length;M++){var j=_[M],O=j.transferSize,te=j.initiatorType,he=j.duration;if(O&&he&&dF(te)){for(te=0,he=j.responseEnd,M+=1;M<_.length;M++){var Pe=_[M],tt=Pe.startTime;if(tt>he)break;var dt=Pe.transferSize,bt=Pe.initiatorType;dt&&dF(bt)&&(Pe=Pe.responseEnd,te+=dt*(Pe<he?1:(he-tt)/(Pe-tt)))}if(--M,m+=8*(O+te)/(j.duration/1e3),h++,10<h)break}}if(0<h)return m/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var zN=null,BN=null;function Mv(h){return h.nodeType===9?h:h.ownerDocument}function hF(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function fF(h,m){if(h===0)switch(m){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&m==="foreignObject"?0:h}function $N(h,m){return h==="textarea"||h==="noscript"||typeof m.children=="string"||typeof m.children=="number"||typeof m.children=="bigint"||typeof m.dangerouslySetInnerHTML=="object"&&m.dangerouslySetInnerHTML!==null&&m.dangerouslySetInnerHTML.__html!=null}var HN=null;function iie(){var h=window.event;return h&&h.type==="popstate"?h===HN?!1:(HN=h,!0):(HN=null,!1)}var mF=typeof setTimeout=="function"?setTimeout:void 0,aie=typeof clearTimeout=="function"?clearTimeout:void 0,pF=typeof Promise=="function"?Promise:void 0,sie=typeof queueMicrotask=="function"?queueMicrotask:typeof pF<"u"?function(h){return pF.resolve(null).then(h).catch(oie)}:mF;function oie(h){setTimeout(function(){throw h})}function ju(h){return h==="head"}function gF(h,m){var _=m,M=0;do{var j=_.nextSibling;if(h.removeChild(_),j&&j.nodeType===8)if(_=j.data,_==="/$"||_==="/&"){if(M===0){h.removeChild(j),vm(m);return}M--}else if(_==="$"||_==="$?"||_==="$~"||_==="$!"||_==="&")M++;else if(_==="html")Sx(h.ownerDocument.documentElement);else if(_==="head"){_=h.ownerDocument.head,Sx(_);for(var O=_.firstChild;O;){var te=O.nextSibling,he=O.nodeName;O[nt]||he==="SCRIPT"||he==="STYLE"||he==="LINK"&&O.rel.toLowerCase()==="stylesheet"||_.removeChild(O),O=te}}else _==="body"&&Sx(h.ownerDocument.body);_=j}while(_);vm(m)}function xF(h,m){var _=h;h=0;do{var M=_.nextSibling;if(_.nodeType===1?m?(_._stashedDisplay=_.style.display,_.style.display="none"):(_.style.display=_._stashedDisplay||"",_.getAttribute("style")===""&&_.removeAttribute("style")):_.nodeType===3&&(m?(_._stashedText=_.nodeValue,_.nodeValue=""):_.nodeValue=_._stashedText||""),M&&M.nodeType===8)if(_=M.data,_==="/$"){if(h===0)break;h--}else _!=="$"&&_!=="$?"&&_!=="$~"&&_!=="$!"||h++;_=M}while(_)}function VN(h){var m=h.firstChild;for(m&&m.nodeType===10&&(m=m.nextSibling);m;){var _=m;switch(m=m.nextSibling,_.nodeName){case"HTML":case"HEAD":case"BODY":VN(_),ke(_);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(_.rel.toLowerCase()==="stylesheet")continue}h.removeChild(_)}}function lie(h,m,_,M){for(;h.nodeType===1;){var j=_;if(h.nodeName.toLowerCase()!==m.toLowerCase()){if(!M&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(M){if(!h[nt])switch(m){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(O=h.getAttribute("rel"),O==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(O!==j.rel||h.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||h.getAttribute("title")!==(j.title==null?null:j.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(O=h.getAttribute("src"),(O!==(j.src==null?null:j.src)||h.getAttribute("type")!==(j.type==null?null:j.type)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&O&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(m==="input"&&h.type==="hidden"){var O=j.name==null?null:""+j.name;if(j.type==="hidden"&&h.getAttribute("name")===O)return h}else return h;if(h=Zs(h.nextSibling),h===null)break}return null}function cie(h,m,_){if(m==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!_||(h=Zs(h.nextSibling),h===null))return null;return h}function bF(h,m){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!m||(h=Zs(h.nextSibling),h===null))return null;return h}function GN(h){return h.data==="$?"||h.data==="$~"}function WN(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function uie(h,m){var _=h.ownerDocument;if(h.data==="$~")h._reactRetry=m;else if(h.data!=="$?"||_.readyState!=="loading")m();else{var M=function(){m(),_.removeEventListener("DOMContentLoaded",M)};_.addEventListener("DOMContentLoaded",M),h._reactRetry=M}}function Zs(h){for(;h!=null;h=h.nextSibling){var m=h.nodeType;if(m===1||m===3)break;if(m===8){if(m=h.data,m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"||m==="F!"||m==="F")break;if(m==="/$"||m==="/&")return null}}return h}var qN=null;function yF(h){h=h.nextSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="/$"||_==="/&"){if(m===0)return Zs(h.nextSibling);m--}else _!=="$"&&_!=="$!"&&_!=="$?"&&_!=="$~"&&_!=="&"||m++}h=h.nextSibling}return null}function vF(h){h=h.previousSibling;for(var m=0;h;){if(h.nodeType===8){var _=h.data;if(_==="$"||_==="$!"||_==="$?"||_==="$~"||_==="&"){if(m===0)return h;m--}else _!=="/$"&&_!=="/&"||m++}h=h.previousSibling}return null}function _F(h,m,_){switch(m=Mv(_),h){case"html":if(h=m.documentElement,!h)throw Error(r(452));return h;case"head":if(h=m.head,!h)throw Error(r(453));return h;case"body":if(h=m.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function Sx(h){for(var m=h.attributes;m.length;)h.removeAttributeNode(m[0]);ke(h)}var Js=new Map,wF=new Set;function Ev(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var lc=G.d;G.d={f:die,r:hie,D:fie,C:mie,L:pie,m:gie,X:bie,S:xie,M:yie};function die(){var h=lc.f(),m=gv();return h||m}function hie(h){var m=le(h);m!==null&&m.tag===5&&m.type==="form"?UI(m):lc.r(h)}var xm=typeof document>"u"?null:document;function SF(h,m,_){var M=xm;if(M&&typeof m=="string"&&m){var j=Vn(m);j='link[rel="'+h+'"][href="'+j+'"]',typeof _=="string"&&(j+='[crossorigin="'+_+'"]'),wF.has(j)||(wF.add(j),h={rel:h,crossOrigin:_,href:m},M.querySelector(j)===null&&(m=M.createElement("link"),ra(m,"link",h),Ie(m),M.head.appendChild(m)))}}function fie(h){lc.D(h),SF("dns-prefetch",h,null)}function mie(h,m){lc.C(h,m),SF("preconnect",h,m)}function pie(h,m,_){lc.L(h,m,_);var M=xm;if(M&&h&&m){var j='link[rel="preload"][as="'+Vn(m)+'"]';m==="image"&&_&&_.imageSrcSet?(j+='[imagesrcset="'+Vn(_.imageSrcSet)+'"]',typeof _.imageSizes=="string"&&(j+='[imagesizes="'+Vn(_.imageSizes)+'"]')):j+='[href="'+Vn(h)+'"]';var O=j;switch(m){case"style":O=bm(h);break;case"script":O=ym(h)}Js.has(O)||(h=f({rel:"preload",href:m==="image"&&_&&_.imageSrcSet?void 0:h,as:m},_),Js.set(O,h),M.querySelector(j)!==null||m==="style"&&M.querySelector(Mx(O))||m==="script"&&M.querySelector(Ex(O))||(m=M.createElement("link"),ra(m,"link",h),Ie(m),M.head.appendChild(m)))}}function gie(h,m){lc.m(h,m);var _=xm;if(_&&h){var M=m&&typeof m.as=="string"?m.as:"script",j='link[rel="modulepreload"][as="'+Vn(M)+'"][href="'+Vn(h)+'"]',O=j;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":O=ym(h)}if(!Js.has(O)&&(h=f({rel:"modulepreload",href:h},m),Js.set(O,h),_.querySelector(j)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(_.querySelector(Ex(O)))return}M=_.createElement("link"),ra(M,"link",h),Ie(M),_.head.appendChild(M)}}}function xie(h,m,_){lc.S(h,m,_);var M=xm;if(M&&h){var j=Oe(M).hoistableStyles,O=bm(h);m=m||"default";var te=j.get(O);if(!te){var he={loading:0,preload:null};if(te=M.querySelector(Mx(O)))he.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":m},_),(_=Js.get(O))&&KN(h,_);var Pe=te=M.createElement("link");Ie(Pe),ra(Pe,"link",h),Pe._p=new Promise(function(tt,dt){Pe.onload=tt,Pe.onerror=dt}),Pe.addEventListener("load",function(){he.loading|=1}),Pe.addEventListener("error",function(){he.loading|=2}),he.loading|=4,Nv(te,m,M)}te={type:"stylesheet",instance:te,count:1,state:he},j.set(O,te)}}}function bie(h,m){lc.X(h,m);var _=xm;if(_&&h){var M=Oe(_).hoistableScripts,j=ym(h),O=M.get(j);O||(O=_.querySelector(Ex(j)),O||(h=f({src:h,async:!0},m),(m=Js.get(j))&&XN(h,m),O=_.createElement("script"),Ie(O),ra(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},M.set(j,O))}}function yie(h,m){lc.M(h,m);var _=xm;if(_&&h){var M=Oe(_).hoistableScripts,j=ym(h),O=M.get(j);O||(O=_.querySelector(Ex(j)),O||(h=f({src:h,async:!0,type:"module"},m),(m=Js.get(j))&&XN(h,m),O=_.createElement("script"),Ie(O),ra(O,"link",h),_.head.appendChild(O)),O={type:"script",instance:O,count:1,state:null},M.set(j,O))}}function MF(h,m,_,M){var j=(j=de.current)?Ev(j):null;if(!j)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof _.precedence=="string"&&typeof _.href=="string"?(m=bm(_.href),_=Oe(j).hoistableStyles,M=_.get(m),M||(M={type:"style",instance:null,count:0,state:null},_.set(m,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(_.rel==="stylesheet"&&typeof _.href=="string"&&typeof _.precedence=="string"){h=bm(_.href);var O=Oe(j).hoistableStyles,te=O.get(h);if(te||(j=j.ownerDocument||j,te={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},O.set(h,te),(O=j.querySelector(Mx(h)))&&!O._p&&(te.instance=O,te.state.loading=5),Js.has(h)||(_={rel:"preload",as:"style",href:_.href,crossOrigin:_.crossOrigin,integrity:_.integrity,media:_.media,hrefLang:_.hrefLang,referrerPolicy:_.referrerPolicy},Js.set(h,_),O||vie(j,h,_,te.state))),m&&M===null)throw Error(r(528,""));return te}if(m&&M!==null)throw Error(r(529,""));return null;case"script":return m=_.async,_=_.src,typeof _=="string"&&m&&typeof m!="function"&&typeof m!="symbol"?(m=ym(_),_=Oe(j).hoistableScripts,M=_.get(m),M||(M={type:"script",instance:null,count:0,state:null},_.set(m,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function bm(h){return'href="'+Vn(h)+'"'}function Mx(h){return'link[rel="stylesheet"]['+h+"]"}function EF(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function vie(h,m,_,M){h.querySelector('link[rel="preload"][as="style"]['+m+"]")?M.loading=1:(m=h.createElement("link"),M.preload=m,m.addEventListener("load",function(){return M.loading|=1}),m.addEventListener("error",function(){return M.loading|=2}),ra(m,"link",_),Ie(m),h.head.appendChild(m))}function ym(h){return'[src="'+Vn(h)+'"]'}function Ex(h){return"script[async]"+h}function NF(h,m,_){if(m.count++,m.instance===null)switch(m.type){case"style":var M=h.querySelector('style[data-href~="'+Vn(_.href)+'"]');if(M)return m.instance=M,Ie(M),M;var j=f({},_,{"data-href":_.href,"data-precedence":_.precedence,href:null,precedence:null});return M=(h.ownerDocument||h).createElement("style"),Ie(M),ra(M,"style",j),Nv(M,_.precedence,h),m.instance=M;case"stylesheet":j=bm(_.href);var O=h.querySelector(Mx(j));if(O)return m.state.loading|=4,m.instance=O,Ie(O),O;M=EF(_),(j=Js.get(j))&&KN(M,j),O=(h.ownerDocument||h).createElement("link"),Ie(O);var te=O;return te._p=new Promise(function(he,Pe){te.onload=he,te.onerror=Pe}),ra(O,"link",M),m.state.loading|=4,Nv(O,_.precedence,h),m.instance=O;case"script":return O=ym(_.src),(j=h.querySelector(Ex(O)))?(m.instance=j,Ie(j),j):(M=_,(j=Js.get(O))&&(M=f({},_),XN(M,j)),h=h.ownerDocument||h,j=h.createElement("script"),Ie(j),ra(j,"link",M),h.head.appendChild(j),m.instance=j);case"void":return null;default:throw Error(r(443,m.type))}else m.type==="stylesheet"&&(m.state.loading&4)===0&&(M=m.instance,m.state.loading|=4,Nv(M,_.precedence,h));return m.instance}function Nv(h,m,_){for(var M=_.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=M.length?M[M.length-1]:null,O=j,te=0;te<M.length;te++){var he=M[te];if(he.dataset.precedence===m)O=he;else if(O!==j)break}O?O.parentNode.insertBefore(h,O.nextSibling):(m=_.nodeType===9?_.head:_,m.insertBefore(h,m.firstChild))}function KN(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.title==null&&(h.title=m.title)}function XN(h,m){h.crossOrigin==null&&(h.crossOrigin=m.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=m.referrerPolicy),h.integrity==null&&(h.integrity=m.integrity)}var Av=null;function AF(h,m,_){if(Av===null){var M=new Map,j=Av=new Map;j.set(_,M)}else j=Av,M=j.get(_),M||(M=new Map,j.set(_,M));if(M.has(h))return M;for(M.set(h,null),_=_.getElementsByTagName(h),j=0;j<_.length;j++){var O=_[j];if(!(O[nt]||O[Ft]||h==="link"&&O.getAttribute("rel")==="stylesheet")&&O.namespaceURI!=="http://www.w3.org/2000/svg"){var te=O.getAttribute(m)||"";te=h+te;var he=M.get(te);he?he.push(O):M.set(te,[O])}}return M}function TF(h,m,_){h=h.ownerDocument||h,h.head.insertBefore(_,m==="title"?h.querySelector("head > title"):null)}function _ie(h,m,_){if(_===1||m.itemProp!=null)return!1;switch(h){case"meta":case"title":return!0;case"style":if(typeof m.precedence!="string"||typeof m.href!="string"||m.href==="")break;return!0;case"link":if(typeof m.rel!="string"||typeof m.href!="string"||m.href===""||m.onLoad||m.onError)break;switch(m.rel){case"stylesheet":return h=m.disabled,typeof m.precedence=="string"&&h==null;default:return!0}case"script":if(m.async&&typeof m.async!="function"&&typeof m.async!="symbol"&&!m.onLoad&&!m.onError&&m.src&&typeof m.src=="string")return!0}return!1}function CF(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function wie(h,m,_,M){if(_.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(_.state.loading&4)===0){if(_.instance===null){var j=bm(M.href),O=m.querySelector(Mx(j));if(O){m=O._p,m!==null&&typeof m=="object"&&typeof m.then=="function"&&(h.count++,h=Tv.bind(h),m.then(h,h)),_.state.loading|=4,_.instance=O,Ie(O);return}O=m.ownerDocument||m,M=EF(M),(j=Js.get(j))&&KN(M,j),O=O.createElement("link"),Ie(O);var te=O;te._p=new Promise(function(he,Pe){te.onload=he,te.onerror=Pe}),ra(O,"link",M),_.instance=O}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(_,m),(m=_.state.preload)&&(_.state.loading&3)===0&&(h.count++,_=Tv.bind(h),m.addEventListener("load",_),m.addEventListener("error",_))}}var YN=0;function Sie(h,m){return h.stylesheets&&h.count===0&&kv(h,h.stylesheets),0<h.count||0<h.imgCount?function(_){var M=setTimeout(function(){if(h.stylesheets&&kv(h,h.stylesheets),h.unsuspend){var O=h.unsuspend;h.unsuspend=null,O()}},6e4+m);0<h.imgBytes&&YN===0&&(YN=62500*rie());var j=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&kv(h,h.stylesheets),h.unsuspend)){var O=h.unsuspend;h.unsuspend=null,O()}},(h.imgBytes>YN?50:800)+m);return h.unsuspend=_,function(){h.unsuspend=null,clearTimeout(M),clearTimeout(j)}}:null}function Tv(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)kv(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var Cv=null;function kv(h,m){h.stylesheets=null,h.unsuspend!==null&&(h.count++,Cv=new Map,m.forEach(Mie,h),Cv=null,Tv.call(h))}function Mie(h,m){if(!(m.state.loading&4)){var _=Cv.get(h);if(_)var M=_.get(null);else{_=new Map,Cv.set(h,_);for(var j=h.querySelectorAll("link[data-precedence],style[data-precedence]"),O=0;O<j.length;O++){var te=j[O];(te.nodeName==="LINK"||te.getAttribute("media")!=="not all")&&(_.set(te.dataset.precedence,te),M=te)}M&&_.set(null,M)}j=m.instance,te=j.getAttribute("data-precedence"),O=_.get(te)||M,O===M&&_.set(null,j),_.set(te,j),this.count++,M=Tv.bind(this),j.addEventListener("load",M),j.addEventListener("error",M),O?O.parentNode.insertBefore(j,O.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(j,h.firstChild)),m.state.loading|=4}}var Nx={$$typeof:w,Provider:null,Consumer:null,_currentValue:W,_currentValue2:W,_threadCount:0};function Eie(h,m,_,M,j,O,te,he,Pe){this.tag=1,this.containerInfo=h,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=M,this.onUncaughtError=j,this.onCaughtError=O,this.onRecoverableError=te,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Pe,this.incompleteTransitions=new Map}function kF(h,m,_,M,j,O,te,he,Pe,tt,dt,bt){return h=new Eie(h,m,_,te,Pe,tt,dt,bt,he),m=1,O===!0&&(m|=24),O=xs(3,null,null,m),h.current=O,O.stateNode=h,m=CE(),m.refCount++,h.pooledCache=m,m.refCount++,O.memoizedState={element:M,isDehydrated:_,cache:m},RE(O),h}function jF(h){return h?(h=Yf,h):Yf}function PF(h,m,_,M,j,O){j=jF(j),M.context===null?M.context=j:M.pendingContext=j,M=vu(m),M.payload={element:_},O=O===void 0?null:O,O!==null&&(M.callback=O),_=_u(h,M,m),_!==null&&(es(_,h,m),ix(_,h,m))}function RF(h,m){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var _=h.retryLane;h.retryLane=_!==0&&_<m?_:m}}function QN(h,m){RF(h,m),(h=h.alternate)&&RF(h,m)}function DF(h){if(h.tag===13||h.tag===31){var m=th(h,67108864);m!==null&&es(m,h,67108864),QN(h,67108864)}}function OF(h){if(h.tag===13||h.tag===31){var m=ws();m=nr(m);var _=th(h,m);_!==null&&es(_,h,m),QN(h,m)}}var jv=!0;function Nie(h,m,_,M){var j=J.T;J.T=null;var O=G.p;try{G.p=2,ZN(h,m,_,M)}finally{G.p=O,J.T=j}}function Aie(h,m,_,M){var j=J.T;J.T=null;var O=G.p;try{G.p=8,ZN(h,m,_,M)}finally{G.p=O,J.T=j}}function ZN(h,m,_,M){if(jv){var j=JN(M);if(j===null)FN(h,m,M,Pv,_),IF(h,M);else if(Cie(j,h,m,_,M))M.stopPropagation();else if(IF(h,M),m&4&&-1<Tie.indexOf(h)){for(;j!==null;){var O=le(j);if(O!==null)switch(O.tag){case 3:if(O=O.stateNode,O.current.memoizedState.isDehydrated){var te=je(O.pendingLanes);if(te!==0){var he=O;for(he.pendingLanes|=2,he.entangledLanes|=2;te;){var Pe=1<<31-qe(te);he.entanglements[1]|=Pe,te&=~Pe}cl(O),(Bn&6)===0&&(mv=I()+500,vx(0))}}break;case 31:case 13:he=th(O,2),he!==null&&es(he,O,2),gv(),QN(O,2)}if(O=JN(M),O===null&&FN(h,m,M,Pv,_),O===j)break;j=O}j!==null&&M.stopPropagation()}else FN(h,m,M,null,_)}}function JN(h){return h=tE(h),eA(h)}var Pv=null;function eA(h){if(Pv=null,h=xe(h),h!==null){var m=a(h);if(m===null)h=null;else{var _=m.tag;if(_===13){if(h=o(m),h!==null)return h;h=null}else if(_===31){if(h=l(m),h!==null)return h;h=null}else if(_===3){if(m.stateNode.current.memoizedState.isDehydrated)return m.tag===3?m.stateNode.containerInfo:null;h=null}else m!==h&&(h=null)}}return Pv=h,null}function LF(h){switch(h){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(ce()){case we:return 2;case Se:return 8;case _e:case st:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var tA=!1,Pu=null,Ru=null,Du=null,Ax=new Map,Tx=new Map,Ou=[],Tie="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 IF(h,m){switch(h){case"focusin":case"focusout":Pu=null;break;case"dragenter":case"dragleave":Ru=null;break;case"mouseover":case"mouseout":Du=null;break;case"pointerover":case"pointerout":Ax.delete(m.pointerId);break;case"gotpointercapture":case"lostpointercapture":Tx.delete(m.pointerId)}}function Cx(h,m,_,M,j,O){return h===null||h.nativeEvent!==O?(h={blockedOn:m,domEventName:_,eventSystemFlags:M,nativeEvent:O,targetContainers:[j]},m!==null&&(m=le(m),m!==null&&DF(m)),h):(h.eventSystemFlags|=M,m=h.targetContainers,j!==null&&m.indexOf(j)===-1&&m.push(j),h)}function Cie(h,m,_,M,j){switch(m){case"focusin":return Pu=Cx(Pu,h,m,_,M,j),!0;case"dragenter":return Ru=Cx(Ru,h,m,_,M,j),!0;case"mouseover":return Du=Cx(Du,h,m,_,M,j),!0;case"pointerover":var O=j.pointerId;return Ax.set(O,Cx(Ax.get(O)||null,h,m,_,M,j)),!0;case"gotpointercapture":return O=j.pointerId,Tx.set(O,Cx(Tx.get(O)||null,h,m,_,M,j)),!0}return!1}function FF(h){var m=xe(h.target);if(m!==null){var _=a(m);if(_!==null){if(m=_.tag,m===13){if(m=o(_),m!==null){h.blockedOn=m,qn(h.priority,function(){OF(_)});return}}else if(m===31){if(m=l(_),m!==null){h.blockedOn=m,qn(h.priority,function(){OF(_)});return}}else if(m===3&&_.stateNode.current.memoizedState.isDehydrated){h.blockedOn=_.tag===3?_.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Rv(h){if(h.blockedOn!==null)return!1;for(var m=h.targetContainers;0<m.length;){var _=JN(h.nativeEvent);if(_===null){_=h.nativeEvent;var M=new _.constructor(_.type,_);eE=M,_.target.dispatchEvent(M),eE=null}else return m=le(_),m!==null&&DF(m),h.blockedOn=_,!1;m.shift()}return!0}function UF(h,m,_){Rv(h)&&_.delete(m)}function kie(){tA=!1,Pu!==null&&Rv(Pu)&&(Pu=null),Ru!==null&&Rv(Ru)&&(Ru=null),Du!==null&&Rv(Du)&&(Du=null),Ax.forEach(UF),Tx.forEach(UF)}function Dv(h,m){h.blockedOn===m&&(h.blockedOn=null,tA||(tA=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kie)))}var Ov=null;function zF(h){Ov!==h&&(Ov=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Ov===h&&(Ov=null);for(var m=0;m<h.length;m+=3){var _=h[m],M=h[m+1],j=h[m+2];if(typeof M!="function"){if(eA(M||_)===null)continue;break}var O=le(_);O!==null&&(h.splice(m,3),m-=3,JE(O,{pending:!0,data:j,method:_.method,action:M},M,j))}}))}function vm(h){function m(Pe){return Dv(Pe,h)}Pu!==null&&Dv(Pu,h),Ru!==null&&Dv(Ru,h),Du!==null&&Dv(Du,h),Ax.forEach(m),Tx.forEach(m);for(var _=0;_<Ou.length;_++){var M=Ou[_];M.blockedOn===h&&(M.blockedOn=null)}for(;0<Ou.length&&(_=Ou[0],_.blockedOn===null);)FF(_),_.blockedOn===null&&Ou.shift();if(_=(h.ownerDocument||h).$$reactFormReplay,_!=null)for(M=0;M<_.length;M+=3){var j=_[M],O=_[M+1],te=j[qt]||null;if(typeof O=="function")te||zF(_);else if(te){var he=null;if(O&&O.hasAttribute("formAction")){if(j=O,te=O[qt]||null)he=te.formAction;else if(eA(j)!==null)continue}else he=te.action;typeof he=="function"?_[M+1]=he:(_.splice(M,3),M-=3),zF(_)}}}function BF(){function h(O){O.canIntercept&&O.info==="react-transition"&&O.intercept({handler:function(){return new Promise(function(te){return j=te})},focusReset:"manual",scroll:"manual"})}function m(){j!==null&&(j(),j=null),M||setTimeout(_,20)}function _(){if(!M&&!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 M=!1,j=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",m),navigation.addEventListener("navigateerror",m),setTimeout(_,100),function(){M=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",m),navigation.removeEventListener("navigateerror",m),j!==null&&(j(),j=null)}}}function nA(h){this._internalRoot=h}Lv.prototype.render=nA.prototype.render=function(h){var m=this._internalRoot;if(m===null)throw Error(r(409));var _=m.current,M=ws();PF(_,M,h,m,null,null)},Lv.prototype.unmount=nA.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var m=h.containerInfo;PF(h.current,2,null,h,null,null),gv(),m[gt]=null}};function Lv(h){this._internalRoot=h}Lv.prototype.unstable_scheduleHydration=function(h){if(h){var m=Jr();h={blockedOn:null,target:h,priority:m};for(var _=0;_<Ou.length&&m!==0&&m<Ou[_].priority;_++);Ou.splice(_,0,h),_===0&&FF(h)}};var $F=e.version;if($F!=="19.2.0")throw Error(r(527,$F,"19.2.0"));G.findDOMNode=function(h){var m=h._reactInternals;if(m===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(m),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var jie={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:J,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Iv=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Iv.isDisabled&&Iv.supportsFiber)try{Fe=Iv.inject(jie),me=Iv}catch{}}return jx.createRoot=function(h,m){if(!i(h))throw Error(r(299));var _=!1,M="",j=XI,O=YI,te=QI;return m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(M=m.identifierPrefix),m.onUncaughtError!==void 0&&(j=m.onUncaughtError),m.onCaughtError!==void 0&&(O=m.onCaughtError),m.onRecoverableError!==void 0&&(te=m.onRecoverableError)),m=kF(h,1,!1,null,null,_,M,null,j,O,te,BF),h[gt]=m.current,IN(h),new nA(m)},jx.hydrateRoot=function(h,m,_){if(!i(h))throw Error(r(299));var M=!1,j="",O=XI,te=YI,he=QI,Pe=null;return _!=null&&(_.unstable_strictMode===!0&&(M=!0),_.identifierPrefix!==void 0&&(j=_.identifierPrefix),_.onUncaughtError!==void 0&&(O=_.onUncaughtError),_.onCaughtError!==void 0&&(te=_.onCaughtError),_.onRecoverableError!==void 0&&(he=_.onRecoverableError),_.formState!==void 0&&(Pe=_.formState)),m=kF(h,1,!0,m,_??null,M,j,Pe,O,te,he,BF),m.context=jF(null),_=m.current,M=ws(),M=nr(M),j=vu(M),j.callback=null,_u(_,j,M),_=M,m.current.lanes=_,Xt(m,_),cl(m),h[gt]=m.current,IN(h),new Lv(m)},jx.version="19.2.0",jx}var ZF;function $ie(){if(ZF)return aA.exports;ZF=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(),aA.exports=Bie(),aA.exports}var Hie=$ie();const Zt=t=>typeof t=="string",Px=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},JF=t=>t==null?"":""+t,Vie=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Gie=/###/g,eU=t=>t&&t.indexOf("###")>-1?t.replace(Gie,"."):t,tU=t=>!t||Zt(t),yb=(t,e,n)=>{const r=Zt(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(tU(t))return{};const a=eU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return tU(t)?{}:{obj:t,k:eU(r[i])}},nU=(t,e,n)=>{const{obj:r,k:i}=yb(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],o=e.slice(0,e.length-1),l=yb(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=yb(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},Wie=(t,e,n,r)=>{const{obj:i,k:a}=yb(t,e,Object);i[a]=i[a]||[],i[a].push(n)},Y1=(t,e)=>{const{obj:n,k:r}=yb(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},qie=(t,e,n)=>{const r=Y1(t,n);return r!==void 0?r:Y1(e,n)},vG=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?Zt(t[r])||t[r]instanceof String||Zt(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):vG(t[r],e[r],n):t[r]=e[r]);return t},_m=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Kie={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Xie=t=>Zt(t)?t.replace(/[&<>"'\/]/g,e=>Kie[e]):t;class Yie{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 r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const Qie=[" ",",","?","!",";"],Zie=new Yie(20),Jie=(t,e,n)=>{e=e||"",n=n||"";const r=Qie.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Zie.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let a=!i.test(t);if(!a){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(a=!0)}return a},oj=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=o}return i},Hb=t=>t?.replace("_","-"),eae={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 Q1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||eae,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,r,i){return i&&!this.debug?null:(Zt(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Q1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Q1(this.logger,e)}}var _l=new Q1;let h2=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+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(([i,a])=>{for(let o=0;o<a;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i.apply(i,[e,...n])})}};class rU extends h2{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,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,o=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.indexOf(".")>-1?l=e.split("."):(l=[e,n],r&&(Array.isArray(r)?l.push(...r):Zt(r)&&a?l.push(...r.split(a)):l.push(r)));const c=Y1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!Zt(r)?c:oj(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=[e,n];r&&(l=l.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(l=e.split("."),i=n,n=l[1]),this.addNamespaces(n),nU(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(Zt(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,o={silent:!1,skipCopy:!1}){let l=[e,n];e.indexOf(".")>-1&&(l=e.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=Y1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?vG(c,r,a):c={...c,...r},nU(this.data,l,c),o.silent||this.emit("added",e,n,r)}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(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var _G={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const wG=Symbol("i18next/PATH_KEY");function tae(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===wG?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function lj(t,e){const{[wG]:n}=t(tae());return n.join(e?.keySeparator??".")}const iU={},cA=t=>!Zt(t)&&typeof t!="boolean"&&typeof t!="number";class Z1 extends h2{constructor(e,n={}){super(),Vie(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=_l.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=cA(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Jie(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:Zt(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:Zt(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=lj(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return p?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const g=this.resolve(e,i);let b=g?.res;const v=g?.usedKey||l,x=g?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],E=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,A=i.count!==void 0&&!Zt(i.count),N=Z1.hasDefaultValue(i),C=A?this.pluralResolver.getSuffix(f,i.count,i):"",T=i.ordinal&&A?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",D=A&&!i.ordinal&&i.count===0,k=D&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${T}`]||i.defaultValue;let P=b;w&&!b&&N&&(P=k);const z=cA(P),L=Object.prototype.toString.apply(P);if(w&&P&&z&&y.indexOf(L)<0&&!(Zt(E)&&Array.isArray(P))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const X=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,P,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(g.res=X,g.usedParams=this.getUsedParamsDetails(i),g):X}if(o){const X=Array.isArray(P),R=X?[]:{},Y=X?x:v;for(const J in P)if(Object.prototype.hasOwnProperty.call(P,J)){const G=`${Y}${o}${J}`;N&&!b?R[J]=this.translate(G,{...i,defaultValue:cA(k)?k[J]:void 0,joinArrays:!1,ns:c}):R[J]=this.translate(G,{...i,joinArrays:!1,ns:c}),R[J]===G&&(R[J]=P[J])}b=R}}else if(w&&Zt(E)&&Array.isArray(b))b=b.join(E),b&&(b=this.extendTranslation(b,e,i,r));else{let X=!1,R=!1;!this.isValidLookup(b)&&N&&(X=!0,b=k),this.isValidLookup(b)||(R=!0,b=l);const J=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:b,G=N&&k!==b&&this.options.updateMissing;if(R||X||G){if(this.logger.log(G?"updateKey":"missingKey",f,u,l,G?k:b),o){const F=this.resolve(l,{...i,keySeparator:!1});F&&F.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 W=[];const ee=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ee&&ee[0])for(let F=0;F<ee.length;F++)W.push(ee[F]);else this.options.saveMissingTo==="all"?W=this.languageUtils.toResolveHierarchy(i.lng||this.language):W.push(i.lng||this.language);const K=(F,q,ne)=>{const re=N&&ne!==b?ne:J;this.options.missingKeyHandler?this.options.missingKeyHandler(F,u,q,re,G,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(F,u,q,re,G,i),this.emit("missingKey",F,u,q,b)};this.options.saveMissing&&(this.options.saveMissingPlurals&&A?W.forEach(F=>{const q=this.pluralResolver.getSuffixes(F,i);D&&i[`defaultValue${this.options.pluralSeparator}zero`]&&q.indexOf(`${this.options.pluralSeparator}zero`)<0&&q.push(`${this.options.pluralSeparator}zero`),q.forEach(ne=>{K([F],l+ne,i[`defaultValue${ne}`]||k)})}):K(W,l,k))}b=this.extendTranslation(b,e,i,g,r),R&&b===l&&this.options.appendNamespaceToMissingKey&&(b=`${u}${d}${l}`),(R||X)&&this.options.parseMissingKeyHandler&&(b=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,X?b:void 0,i))}return a?(g.res=b,g.usedParams=this.getUsedParamsDetails(i),g):b}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=Zt(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!Zt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(d={...this.options.interpolation.defaultVariables,...d}),e=this.interpolator.interpolate(e,d,r.lng||this.language||i.usedLng,r),c){const f=e.match(this.interpolator.nestingRegexp),p=f&&f.length;u<p&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=Zt(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=_G.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,o,l;return Zt(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!Zt(n.count),g=p&&!n.ordinal&&n.count===0,b=n.context!==void 0&&(Zt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(x=>{this.isValidLookup(r)||(l=x,!iU[`${v[0]}-${x}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(iU[`${v[0]}-${x}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" 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!!!")),v.forEach(y=>{if(this.isValidLookup(r))return;o=y;const E=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(E,d,y,x,n);else{let A;p&&(A=this.pluralResolver.getSuffix(y,n.count,n));const N=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&A.indexOf(C)===0&&E.push(d+A.replace(C,this.options.pluralSeparator)),E.push(d+A),g&&E.push(d+N)),b){const T=`${d}${this.options.contextSeparator||"_"}${n.context}`;E.push(T),p&&(n.ordinal&&A.indexOf(C)===0&&E.push(T+A.replace(C,this.options.pluralSeparator)),E.push(T+A),g&&E.push(T+N))}}let w;for(;w=E.pop();)this.isValidLookup(r)||(a=w,r=this.getResource(y,x,w,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,usedLng:o,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}getUsedParamsDetails(e={}){const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=e.replace&&!Zt(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class aU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=_l.create("languageUtils")}getScriptPartFromCode(e){if(e=Hb(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=Hb(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(Zt(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(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getScriptPartFromCode(r);if(this.isSupportedCode(i))return n=i;const a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(o=>{if(o===a)return o;if(!(o.indexOf("-")<0&&a.indexOf("-")<0)&&(o.indexOf("-")>0&&a.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===a||o.indexOf(a)===0&&a.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),Zt(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes((n===!1?[]:n)||this.options.fallbackLng||[],e),i=[],a=o=>{o&&(this.isSupportedCode(o)?i.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return Zt(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))):Zt(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const sU={zero:0,one:1,two:2,few:3,many:4,other:5},oU={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class nae{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=_l.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=Hb(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),oU;if(!e.match(/-|_/))return oU;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[a]=o,o}needsPlural(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,r={}){return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e,n={}){let r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,a)=>sU[i]-sU[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const lU=(t,e,n,r=".",i=!0)=>{let a=qie(t,e,n);return!a&&i&&Zt(n)&&(a=oj(t,n,r),a===void 0&&(a=oj(e,n,r))),a},uA=t=>t.replace(/\$/g,"$$$$");class rae{constructor(e={}){this.logger=_l.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:r,useRawValueToEscape:i,prefix:a,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:g,nestingSuffix:b,nestingSuffixEscaped:v,nestingOptionsSeparator:x,maxReplaces:y,alwaysFormat:E}=e.interpolation;this.escape=n!==void 0?n:Xie,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?_m(a):o||"{{",this.suffix=l?_m(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?_m(p):g||_m("$t("),this.nestingSuffix=b?_m(b):v||_m(")"),this.nestingOptionsSeparator=x||",",this.maxReplaces=y||1e3,this.alwaysFormat=E!==void 0?E:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>n?.source===r?(n.lastIndex=0,n):new RegExp(r,"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,r,i){let a,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=g=>{if(g.indexOf(this.formatSeparator)<0){const y=lU(n,c,g,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...i,...n,interpolationkey:g}):y}const b=g.split(this.formatSeparator),v=b.shift().trim(),x=b.join(this.formatSeparator).trim();return this.format(lU(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),x,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:g=>uA(g)},{regex:this.regexp,safeValue:g=>this.escapeValue?uA(this.escape(g)):uA(g)}].forEach(g=>{for(l=0;a=g.regex.exec(e);){const b=a[1].trim();if(o=u(b),o===void 0)if(typeof d=="function"){const x=d(e,a,i);o=Zt(x)?x:""}else if(i&&Object.prototype.hasOwnProperty.call(i,b))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),o="";else!Zt(o)&&!this.useRawValueToEscape&&(o=JF(o));const v=g.safeValue(o);if(e=e.replace(a[0],v),f?(g.regex.lastIndex+=o.length,g.regex.lastIndex-=a[0].length):g.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,o);const g=p.match(/'/g),b=p.match(/"/g);((g?.length??0)%2===0&&!b||b.length%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),u&&(o={...u,...o})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${p}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,c};for(;i=this.nestingRegexp.exec(e);){let c=[];o={...r},o=o.replace&&!Zt(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const u=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(u!==-1&&(c=i[1].slice(u).split(this.formatSeparator).map(d=>d.trim()).filter(Boolean),i[1]=i[1].slice(0,u)),a=n(l.call(this,i[1].trim(),o),o),a&&i[0]===e&&!Zt(a))return a;Zt(a)||(a=JF(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const iae=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(o=>{if(o){const[l,...c]=o.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),d=l.trim();n[d]||(n[d]=u),u==="false"&&(n[d]=!1),u==="true"&&(n[d]=!0),isNaN(u)||(n[d]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},cU=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const o=r+JSON.stringify(a);let l=e[o];return l||(l=t(Hb(r),i),e[o]=l),l(n)}},aae=t=>(e,n,r)=>t(Hb(n),r)(e);class sae{constructor(e={}){this.logger=_l.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?cU:aae;this.formats={number:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a});return l=>o.format(l)}),currency:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>o.format(l)}),datetime:r((i,a)=>{const o=new Intl.DateTimeFormat(i,{...a});return l=>o.format(l)}),relativetime:r((i,a)=>{const o=new Intl.RelativeTimeFormat(i,{...a});return l=>o.format(l,a.range||"day")}),list:r((i,a)=>{const o=new Intl.ListFormat(i,{...a});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=cU(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=iae(c);if(this.formats[u]){let f=l;try{const p=i?.formatParams?.[i.interpolationkey]||{},g=p.locale||p.lng||i.locale||i.lng||r;f=this.formats[u](l,g,{...d,...i,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const oae=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class lae extends h2{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=_l.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,d=!1,o[p]===void 0&&(o[p]=!0),a[p]===void 0&&(a[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Wie(c.loaded,[a],o),oae(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:o});return}this.readingCalls++;const l=(u,d)=>{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(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,o)},a);return}o(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(e,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(e,n,l)}prepareLoading(e,n,r={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();Zt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Zt(n)&&(n=[n]);const a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e,n=""){const r=e.split("|"),i=r[0],a=r[1];this.read(i,a,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,o={},l=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" 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(!(r==null||r==="")){if(this.backend?.create){const c={...o,isUpdate:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const uU=()=>({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]),Zt(t[1])&&(e.defaultValue=t[1]),Zt(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),dU=t=>(Zt(t.ns)&&(t.ns=[t.ns]),Zt(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),Zt(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),Uv=()=>{},cae=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class vb extends h2{constructor(e={},n){if(super(),this.options=dU(e),this.services={},this.logger=_l,this.modules={external:[]},cae(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&&(Zt(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=uU();this.options={...r,...this.options,...dU(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const i=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?_l.init(i(this.modules.logger),this.options):_l.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=sae;const d=new aU(this.options);this.store=new rU(this.options.resources,this.options);const f=this.services;f.logger=_l,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new nae(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.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"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new rae(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new lae(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(g,...b)=>{this.emit(g,...b)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Z1(this.services,this.options),this.translator.on("*",(g,...b)=>{this.emit(g,...b)}),this.modules.external.forEach(g=>{g.init&&g.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Uv),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...d)=>this.store[u](...d)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...d)=>(this.store[u](...d),this)});const l=Px(),c=()=>{const u=(d,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),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=Uv){let r=n;const i=Zt(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const a=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.push(u)})};i?o(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>o(c)),this.options.preload?.forEach?.(l=>o(l)),this.services.backendConnector.load(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=Px();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=Uv),this.services.backendConnector.reload(e,n,a=>{i.resolve(),r(a)}),i}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"&&_G.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 r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;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 r=Px();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},o=l=>{!e&&!l&&this.services.languageDetector&&(l=[]);const c=Zt(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(Zt(l)?[l]:l);u&&(this.language||i(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector?.cacheUserLanguage?.(u)),this.loadResources(u,d=>{a(d,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,n,r){const i=(a,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([a,o].concat(l)):c={...o},c.lng=c.lng||i.lng,c.lngs=c.lngs||i.lngs,c.ns=c.ns||i.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||i.keyPrefix);const u=this.options.keySeparator||".";let d;return c.keyPrefix&&Array.isArray(a)?d=a.map(f=>(typeof f=="function"&&(f=lj(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=lj(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),this.t(d,c)};return Zt(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=r,i}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 r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,a=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!i||o(a,e)))}loadNamespaces(e,n){const r=Px();return this.options.ns?(Zt(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Px();Zt(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),this.loadResources(o=>{r.resolve(),n&&n(o)}),r):(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 i=new Intl.Locale(e);if(i&&i.getTextInfo){const a=i.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"],r=this.services?.languageUtils||new aU(uU());return e.toLowerCase().indexOf("-latn")>1?"ltr":n.indexOf(r.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){const r=new vb(e,n);return r.createInstance=vb.createInstance,r}cloneInstance(e={},n=Uv){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new vb(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new rU(l,i),a.services.resourceStore=a.store}return a.translator=new Z1(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,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 Ka=vb.createInstance();Ka.createInstance;Ka.dir;Ka.init;Ka.loadResources;Ka.reloadResources;Ka.use;Ka.changeLanguage;Ka.getFixedT;Ka.t;Ka.exists;Ka.setDefaultNamespace;Ka.hasLoadedNamespace;Ka.loadNamespaces;Ka.loadLanguages;const uae=(t,e,n,r)=>{const i=[n,{code:e,...r||{}}];if(t?.services?.logger?.forward)return t.services.logger.forward(i,"warn","react-i18next::",!0);uf(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},hU={},SG=(t,e,n,r)=>{uf(n)&&hU[n]||(uf(n)&&(hU[n]=new Date),uae(t,e,n,r))},MG=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},cj=(t,e,n)=>{t.loadNamespaces(e,MG(t,n))},fU=(t,e,n,r)=>{if(uf(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return cj(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,MG(t,r))},dae=(t,e,n={})=>!e.languages||!e.languages.length?(SG(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:n.lng,precheck:(r,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!i(r.isLanguageChangingTo,t))return!1}}),uf=t=>typeof t=="string",hae=t=>typeof t=="object"&&t!==null,fae=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,mae={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},pae=t=>mae[t],gae=t=>t.replace(fae,pae);let uj={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:gae};const xae=(t={})=>{uj={...uj,...t}},bae=()=>uj;let EG;const yae=t=>{EG=t},vae=()=>EG,_ae={type:"3rdParty",init(t){xae(t.options.react),yae(t)}},wae=S.createContext();class Sae{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var dA={exports:{}},hA={};var mU;function Mae(){if(mU)return hA;mU=1;var t=gg();function e(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,p){var g=p(),b=r({inst:{value:g,getSnapshot:p}}),v=b[0].inst,x=b[1];return a(function(){v.value=g,v.getSnapshot=p,c(v)&&x({inst:v})},[f,g,p]),i(function(){return c(v)&&x({inst:v}),f(function(){c(v)&&x({inst:v})})},[f]),o(g),g}function c(f){var p=f.getSnapshot;f=f.value;try{var g=p();return!n(f,g)}catch{return!0}}function u(f,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return hA.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,hA}var pU;function NG(){return pU||(pU=1,dA.exports=Mae()),dA.exports}var yR=NG();const Eae=(t,e)=>uf(e)?e:hae(e)&&uf(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Nae={t:Eae,ready:!1},Aae=()=>()=>{},xg=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=S.useContext(wae)||{},a=n||r||vae();a&&!a.reportNamespaces&&(a.reportNamespaces=new Sae),a||SG(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=S.useMemo(()=>({...bae(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=uf(u)?[u]:u||["translation"],f=S.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const p=S.useRef(0),g=S.useCallback(k=>{if(!a)return Aae;const{bindI18n:P,bindI18nStore:z}=o,L=()=>{p.current+=1,k()};return P&&a.on(P,L),z&&a.store.on(z,L),()=>{P&&P.split(" ").forEach(X=>a.off(X,L)),z&&z.split(" ").forEach(X=>a.store.off(X,L))}},[a,o]),b=S.useRef(),v=S.useCallback(()=>{if(!a)return Nae;const k=!!(a.isInitialized||a.initializedStoreOnce)&&f.every(Y=>dae(Y,a,o)),P=e.lng||a.language,z=p.current,L=b.current;if(L&&L.ready===k&&L.lng===P&&L.keyPrefix===c&&L.revision===z)return L;const R={t:a.getFixedT(P,o.nsMode==="fallback"?f:f[0],c),ready:k,lng:P,keyPrefix:c,revision:z};return b.current=R,R},[a,f,c,o,e.lng]),[x,y]=S.useState(0),{t:E,ready:w}=yR.useSyncExternalStore(g,v,v);S.useEffect(()=>{if(a&&!w&&!l){const k=()=>y(P=>P+1);e.lng?fU(a,e.lng,f,k):cj(a,f,k)}},[a,e.lng,f,w,l,x]);const A=a||{},N=S.useRef(null),C=S.useRef(),T=k=>{const P=Object.getOwnPropertyDescriptors(k);P.__original&&delete P.__original;const z=Object.create(Object.getPrototypeOf(k),P);if(!Object.prototype.hasOwnProperty.call(z,"__original"))try{Object.defineProperty(z,"__original",{value:k,writable:!1,enumerable:!1,configurable:!1})}catch{}return z},D=S.useMemo(()=>{const k=A,P=k?.language;let z=k;k&&(N.current&&N.current.__original===k?C.current!==P?(z=T(k),N.current=z,C.current=P):z=N.current:(z=T(k),N.current=z,C.current=P));const L=[E,z,w];return L.t=E,L.i18n=z,L.ready=w,L},[E,A,w,A.resolvedLanguage,A.language,A.languages]);if(a&&l&&!w)throw new Promise(k=>{const P=()=>k();e.lng?fU(a,e.lng,f,P):cj(a,f,P)});return D},{slice:Tae,forEach:Cae}=[];function kae(t){return Cae.call(Tae.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function jae(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 gU=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Pae=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!gU.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!gU.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.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 r.partitioned&&(a+="; Partitioned"),a},xU={create(t,e,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=Pae(t,e,i)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let r=0;r<n.length;r++){let i=n[r];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var Rae={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return xU.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&xU.create(n,t,r,i,a)}},Dae={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(n=a[o].substring(l+1))}}return n}},Oae={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const o=a.split("&");for(let l=0;l<o.length;l++){const c=o[l].indexOf("=");c>0&&o[l].substring(0,c)===e&&(r=o[l].substring(c+1))}}if(r)return r;if(!r&&n>-1){const o=i.match(/\/([a-zA-Z-]*)/g);return Array.isArray(o)?o[typeof n=="number"?n:0]?.replace("/",""):void 0}}}return r}};let wm=null;const bU=()=>{if(wm!==null)return wm;try{if(wm=typeof window<"u"&&window.localStorage!==null,!wm)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{wm=!1}return wm};var Lae={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&bU())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&bU()&&window.localStorage.setItem(n,t)}};let Sm=null;const yU=()=>{if(Sm!==null)return Sm;try{if(Sm=typeof window<"u"&&window.sessionStorage!==null,!Sm)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Sm=!1}return Sm};var Iae={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&yU())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&yU()&&window.sessionStorage.setItem(n,t)}},Fae={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Uae={name:"htmlTag",lookup(t){let{htmlTag:e}=t,n;const r=e||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(n=r.getAttribute("lang")),n}},zae={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}},Bae={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,r=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}};let AG=!1;try{document.cookie,AG=!0}catch{}const TG=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];AG||TG.splice(1,1);const $ae=()=>({order:TG,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class CG{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]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=kae(n,this.options||{},$ae()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=i=>i.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(Rae),this.addDetector(Dae),this.addDetector(Lae),this.addDetector(Iae),this.addDetector(Fae),this.addDetector(Uae),this.addDetector(zae),this.addDetector(Bae),this.addDetector(Oae)}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(r=>{if(this.detectors[r]){let i=this.detectors[r].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(n=n.concat(i))}}),n=n.filter(r=>r!=null&&!jae(r)).map(r=>this.options.convertDetectedLanguage(r)),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(r=>{this.detectors[r]&&this.detectors[r].cacheUserLanguage(e,this.options)}))}}CG.type="languageDetector";const Hae={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",files:"File Manager",settings:"Settings",system:"System",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",telemetry:"Anonymous telemetry",telemetryDescription:"Help improve BamBuddy by sending anonymous usage data",telemetryLearnMore:"Learn more",telemetryInfoTitle:"What data is collected?",telemetryInfoIntro:"BamBuddy collects minimal anonymous data to help understand how many people use the app, which versions and printer models are in use. This helps prioritize bug fixes and new features.",telemetryInfoCollected:"What we collect:",telemetryInfoItem1:"A random installation ID (not linked to you or your hardware)",telemetryInfoItem2:"The app version you're running",telemetryInfoItem3:"Printer model types (e.g., X1C, P1S) - not names or serial numbers",telemetryInfoItem4:"A timestamp (to count daily/weekly active users)",telemetryInfoNotCollected:"What we do NOT collect:",telemetryInfoNotItem1:"Your IP address is hashed and cannot be reversed",telemetryInfoNotItem2:"Printer names, serial numbers, or access codes",telemetryInfoNotItem3:"Print history, filenames, or any personal content",telemetryInfoNotItem4:"Any information that could identify you",telemetryInfoFooter:"You can disable telemetry at any time. The installation ID is randomly generated and cannot be traced back to you.",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?"}},Vae={nav:{printers:"Drucker",archives:"Archiv",queue:"Warteschlange",stats:"Statistiken",profiles:"Profile",maintenance:"Wartung",projects:"Projekte",files:"Dateimanager",settings:"Einstellungen",system:"System",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",telemetry:"Anonyme Telemetrie",telemetryDescription:"Helfen Sie BamBuddy zu verbessern, indem Sie anonyme Nutzungsdaten senden",telemetryLearnMore:"Mehr erfahren",telemetryInfoTitle:"Welche Daten werden gesammelt?",telemetryInfoIntro:"BamBuddy sammelt minimale anonyme Daten, um zu verstehen, wie viele Personen die App nutzen und welche Versionen verwendet werden. Dies hilft bei der Priorisierung von Fehlerbehebungen und neuen Funktionen.",telemetryInfoCollected:"Was wir sammeln:",telemetryInfoItem1:"Eine zufällige Installations-ID (nicht mit Ihnen oder Ihrer Hardware verknüpft)",telemetryInfoItem2:"Die App-Version, die Sie verwenden",telemetryInfoItem3:"Ein Zeitstempel (um tägliche/wöchentliche aktive Nutzer zu zählen)",telemetryInfoNotCollected:"Was wir NICHT sammeln:",telemetryInfoNotItem1:"IP-Adressen oder Standortdaten",telemetryInfoNotItem2:"Druckernamen, Seriennummern oder Druckerdaten",telemetryInfoNotItem3:"Druckverlauf, Dateinamen oder persönliche Inhalte",telemetryInfoNotItem4:"Informationen, die Sie identifizieren könnten",telemetryInfoFooter:"Sie können die Telemetrie jederzeit deaktivieren. Die Installations-ID wird zufällig generiert und kann nicht zu Ihnen zurückverfolgt werden.",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?"}},Gae={en:{translation:Hae},de:{translation:Vae}};Ka.use(CG).use(_ae).init({resources:Gae,fallbackLng:"en",supportedLngs:["en","de"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const vU=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"}];var _U="popstate";function Wae(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return dj("",{pathname:a,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:Vb(i)}return Kae(e,n,null,t)}function Dr(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Mo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function qae(){return Math.random().toString(36).substring(2,10)}function wU(t,e){return{usr:t.state,key:t.key,idx:e}}function dj(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?bg(e):e,state:n,key:e&&e.key||r||qae()}}function Vb({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 bg(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substring(n),t=t.substring(0,n));let r=t.indexOf("?");r>=0&&(e.search=t.substring(r),t=t.substring(0,r)),t&&(e.pathname=t)}return e}function Kae(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let x=d(),y=x==null?null:x-u;u=x,c&&c({action:l,location:v.location,delta:y})}function p(x,y){l="PUSH";let E=dj(v.location,x,y);u=d()+1;let w=wU(E,u),A=v.createHref(E);try{o.pushState(w,"",A)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;i.location.assign(A)}a&&c&&c({action:l,location:v.location,delta:1})}function g(x,y){l="REPLACE";let E=dj(v.location,x,y);u=d();let w=wU(E,u),A=v.createHref(E);o.replaceState(w,"",A),a&&c&&c({action:l,location:v.location,delta:0})}function b(x){return Xae(x)}let v={get action(){return l},get location(){return t(i,o)},listen(x){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(_U,f),c=x,()=>{i.removeEventListener(_U,f),c=null}},createHref(x){return e(i,x)},createURL:b,encodeLocation(x){let y=b(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:g,go(x){return o.go(x)}};return v}function Xae(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Dr(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:Vb(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function kG(t,e,n="/"){return Yae(t,e,n,!1)}function Yae(t,e,n,r){let i=typeof e=="string"?bg(e):e,a=Kc(i.pathname||"/",n);if(a==null)return null;let o=jG(t);Qae(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=lse(a);l=sse(o[c],u,r)}return l}function jG(t,e=[],n=[],r="",i=!1){let a=(o,l,c=i,u)=>{let d={relativePath:u===void 0?o.path||"":u,caseSensitive:o.caseSensitive===!0,childrenIndex:l,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(r)&&c)return;Dr(d.relativePath.startsWith(r),`Absolute route path "${d.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(r.length)}let f=Uc([r,d.relativePath]),p=n.concat(d);o.children&&o.children.length>0&&(Dr(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),jG(o.children,e,p,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:ise(f,o.index),routesMeta:p})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of PG(o.path))a(o,l,!0,c)}),e}function PG(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=PG(r.join("/")),l=[];return l.push(...o.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Qae(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:ase(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Zae=/^:[\w-]+$/,Jae=3,ese=2,tse=1,nse=10,rse=-2,SU=t=>t==="*";function ise(t,e){let n=t.split("/"),r=n.length;return n.some(SU)&&(r+=rse),e&&(r+=ese),n.filter(i=>!SU(i)).reduce((i,a)=>i+(Zae.test(a)?Jae:a===""?tse:nse),r)}function ase(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function sse(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=J1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=J1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Uc([a,f.pathname]),pathnameBase:fse(Uc([a,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(a=Uc([a,f.pathnameBase]))}return o}function J1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=ose(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},p)=>{if(d==="*"){let b=l[p]||"";o=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const g=l[p];return f&&!g?u[d]=void 0:u[d]=(g||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function ose(t,e=!1,n=!0){Mo(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 r=[],i="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(r.push({paramName:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function lse(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Mo(!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 Kc(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,r=t.charAt(n);return r&&r!=="/"?null:t.slice(n)||"/"}var cse=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,use=t=>cse.test(t);function dse(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?bg(t):t,a;if(n)if(use(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Mo(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=MU(n.substring(1),"/"):a=MU(n,e)}else a=e;return{pathname:a,search:mse(r),hash:pse(i)}}function MU(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function fA(t,e,n,r){return`Cannot include a '${t}' character in a manually specified \`to.${e}\` field [${JSON.stringify(r)}]. 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 hse(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function RG(t){let e=hse(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function DG(t,e,n,r=!1){let i;typeof t=="string"?i=bg(t):(i={...t},Dr(!i.pathname||!i.pathname.includes("?"),fA("?","pathname","search",i)),Dr(!i.pathname||!i.pathname.includes("#"),fA("#","pathname","hash",i)),Dr(!i.search||!i.search.includes("#"),fA("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),f-=1;i.pathname=p.join("/")}l=f>=0?e[f]:"/"}let c=dse(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Uc=t=>t.join("/").replace(/\/\/+/g,"/"),fse=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),mse=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,pse=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function gse(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 OG=["POST","PUT","PATCH","DELETE"];new Set(OG);var xse=["GET",...OG];new Set(xse);var yg=S.createContext(null);yg.displayName="DataRouter";var f2=S.createContext(null);f2.displayName="DataRouterState";S.createContext(!1);var LG=S.createContext({isTransitioning:!1});LG.displayName="ViewTransition";var bse=S.createContext(new Map);bse.displayName="Fetchers";var yse=S.createContext(null);yse.displayName="Await";var Ul=S.createContext(null);Ul.displayName="Navigation";var I0=S.createContext(null);I0.displayName="Location";var nl=S.createContext({outlet:null,matches:[],isDataRoute:!1});nl.displayName="Route";var vR=S.createContext(null);vR.displayName="RouteError";function vse(t,{relative:e}={}){Dr(F0(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=S.useContext(Ul),{hash:i,pathname:a,search:o}=U0(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Uc([n,a])),r.createHref({pathname:l,search:o,hash:i})}function F0(){return S.useContext(I0)!=null}function lu(){return Dr(F0(),"useLocation() may be used only in the context of a <Router> component."),S.useContext(I0).location}var IG="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function FG(t){S.useContext(Ul).static||S.useLayoutEffect(t)}function vg(){let{isDataRoute:t}=S.useContext(nl);return t?Ose():_se()}function _se(){Dr(F0(),"useNavigate() may be used only in the context of a <Router> component.");let t=S.useContext(yg),{basename:e,navigator:n}=S.useContext(Ul),{matches:r}=S.useContext(nl),{pathname:i}=lu(),a=JSON.stringify(RG(r)),o=S.useRef(!1);return FG(()=>{o.current=!0}),S.useCallback((c,u={})=>{if(Mo(o.current,IG),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=DG(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Uc([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var wse=S.createContext(null);function Sse(t){let e=S.useContext(nl).outlet;return S.useMemo(()=>e&&S.createElement(wse.Provider,{value:t},e),[e,t])}function _R(){let{matches:t}=S.useContext(nl),e=t[t.length-1];return e?e.params:{}}function U0(t,{relative:e}={}){let{matches:n}=S.useContext(nl),{pathname:r}=lu(),i=JSON.stringify(RG(n));return S.useMemo(()=>DG(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Mse(t,e){return UG(t,e)}function UG(t,e,n,r,i){Dr(F0(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=S.useContext(Ul),{matches:o}=S.useContext(nl),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let E=f&&f.path||"";zG(u,!f||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${E}">) 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="${E}"> to <Route path="${E==="/"?"*":`${E}/*`}">.`)}let p=lu(),g;if(e){let E=typeof e=="string"?bg(e):e;Dr(d==="/"||E.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${E.pathname}" was given in the \`location\` prop.`),g=E}else g=p;let b=g.pathname||"/",v=b;if(d!=="/"){let E=d.replace(/^\//,"").split("/");v="/"+b.replace(/^\//,"").split("/").slice(E.length).join("/")}let x=kG(t,{pathname:v});Mo(f||x!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),Mo(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.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 y=Cse(x&&x.map(E=>Object.assign({},E,{params:Object.assign({},c,E.params),pathname:Uc([d,a.encodeLocation?a.encodeLocation(E.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?d:Uc([d,a.encodeLocation?a.encodeLocation(E.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),o,n,r,i);return e&&y?S.createElement(I0.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},y):y}function Ese(){let t=Dse(),e=gse(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",t),o=S.createElement(S.Fragment,null,S.createElement("p",null,"💿 Hey developer 👋"),S.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",S.createElement("code",{style:a},"ErrorBoundary")," or"," ",S.createElement("code",{style:a},"errorElement")," prop on your route.")),S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},e),n?S.createElement("pre",{style:i},n):null,o)}var Nse=S.createElement(Ese,null),Ase=class extends S.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?S.createElement(nl.Provider,{value:this.props.routeContext},S.createElement(vR.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Tse({routeContext:t,match:e,children:n}){let r=S.useContext(yg);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),S.createElement(nl.Provider,{value:t},n)}function Cse(t,e=[],n=null,r=null,i=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,o=n?.errors;if(o!=null){let d=a.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);Dr(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:p,errors:g}=n,b=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!g||g[f.route.id]===void 0);if(f.route.lazy||b){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},errorInfo:f})}:void 0;return a.reduceRight((d,f,p)=>{let g,b=!1,v=null,x=null;n&&(g=o&&f.route.id?o[f.route.id]:void 0,v=f.route.errorElement||Nse,l&&(c<0&&p===0?(zG("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,x=null):c===p&&(b=!0,x=f.route.hydrateFallbackElement||null)));let y=e.concat(a.slice(0,p+1)),E=()=>{let w;return g?w=v:b?w=x:f.route.Component?w=S.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,S.createElement(Tse,{match:f,routeContext:{outlet:d,matches:y,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?S.createElement(Ase,{location:n.location,revalidation:n.revalidation,component:v,error:g,children:E(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):E()},null)}function wR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kse(t){let e=S.useContext(yg);return Dr(e,wR(t)),e}function jse(t){let e=S.useContext(f2);return Dr(e,wR(t)),e}function Pse(t){let e=S.useContext(nl);return Dr(e,wR(t)),e}function SR(t){let e=Pse(t),n=e.matches[e.matches.length-1];return Dr(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Rse(){return SR("useRouteId")}function Dse(){let t=S.useContext(vR),e=jse("useRouteError"),n=SR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Ose(){let{router:t}=kse("useNavigate"),e=SR("useNavigate"),n=S.useRef(!1);return FG(()=>{n.current=!0}),S.useCallback(async(i,a={})=>{Mo(n.current,IG),n.current&&(typeof i=="number"?t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var EU={};function zG(t,e,n){!e&&!EU[t]&&(EU[t]=!0,Mo(!1,n))}S.memo(Lse);function Lse({routes:t,future:e,state:n,unstable_onError:r}){return UG(t,void 0,n,r,e)}function Ise(t){return Sse(t.context)}function Da(t){Dr(!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 Fse({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1}){Dr(!F0(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let o=t.replace(/^\/*/,"/"),l=S.useMemo(()=>({basename:o,navigator:i,static:a,future:{}}),[o,i,a]);typeof n=="string"&&(n=bg(n));let{pathname:c="/",search:u="",hash:d="",state:f=null,key:p="default"}=n,g=S.useMemo(()=>{let b=Kc(c,o);return b==null?null:{location:{pathname:b,search:u,hash:d,state:f,key:p},navigationType:r}},[o,c,u,d,f,p,r]);return Mo(g!=null,`<Router basename="${o}"> is not able to match the URL "${c}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),g==null?null:S.createElement(Ul.Provider,{value:l},S.createElement(I0.Provider,{children:e,value:g}))}function Use({children:t,location:e}){return Mse(hj(t),e)}function hj(t,e=[]){let n=[];return S.Children.forEach(t,(r,i)=>{if(!S.isValidElement(r))return;let a=[...e,i];if(r.type===S.Fragment){n.push.apply(n,hj(r.props.children,a));return}Dr(r.type===Da,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Dr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let o={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=hj(r.props.children,a)),n.push(o)}),n}var S1="get",M1="application/x-www-form-urlencoded";function m2(t){return t!=null&&typeof t.tagName=="string"}function zse(t){return m2(t)&&t.tagName.toLowerCase()==="button"}function Bse(t){return m2(t)&&t.tagName.toLowerCase()==="form"}function $se(t){return m2(t)&&t.tagName.toLowerCase()==="input"}function Hse(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Vse(t,e){return t.button===0&&(!e||e==="_self")&&!Hse(t)}function fj(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let r=t[n];return e.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function Gse(t,e){let n=fj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var zv=null;function Wse(){if(zv===null)try{new FormData(document.createElement("form"),0),zv=!1}catch{zv=!0}return zv}var qse=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function mA(t){return t!=null&&!qse.has(t)?(Mo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${M1}"`),null):t}function Kse(t,e){let n,r,i,a,o;if(Bse(t)){let l=t.getAttribute("action");r=l?Kc(l,e):null,n=t.getAttribute("method")||S1,i=mA(t.getAttribute("enctype"))||M1,a=new FormData(t)}else if(zse(t)||$se(t)&&(t.type==="submit"||t.type==="image")){let l=t.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=t.getAttribute("formaction")||l.getAttribute("action");if(r=c?Kc(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||S1,i=mA(t.getAttribute("formenctype"))||mA(l.getAttribute("enctype"))||M1,a=new FormData(l,t),!Wse()){let{name:u,type:d,value:f}=t;if(d==="image"){let p=u?`${u}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else u&&a.append(u,f)}}else{if(m2(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=S1,r=null,i=M1,o=t}return a&&i==="text/plain"&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function MR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Xse(t,e,n){let r=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r.pathname==="/"?r.pathname=`_root.${n}`:e&&Kc(r.pathname,e)==="/"?r.pathname=`${e.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function Yse(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 Qse(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 Zse(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await Yse(a,n);return o.links?o.links():[]}return[]}));return noe(r.flat(1).filter(Qse).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function NU(t,e,n,r,i,a){let o=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>n[u].pathname!==c.pathname||n[u].route.path?.endsWith("*")&&n[u].params["*"]!==c.params["*"];return a==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Jse(t,e,{includeHydrateFallback:n}={}){return eoe(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function eoe(t){return[...new Set(t)]}function toe(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function noe(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(toe(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function BG(){let t=S.useContext(yg);return MR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function roe(){let t=S.useContext(f2);return MR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var ER=S.createContext(void 0);ER.displayName="FrameworkContext";function $G(){let t=S.useContext(ER);return MR(t,"You must render this element inside a <HydratedRouter> element"),t}function ioe(t,e){let n=S.useContext(ER),[r,i]=S.useState(!1),[a,o]=S.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,p=S.useRef(null);S.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let v=y=>{y.forEach(E=>{o(E.isIntersecting)})},x=new IntersectionObserver(v,{threshold:.5});return p.current&&x.observe(p.current),()=>{x.disconnect()}}},[t]),S.useEffect(()=>{if(r){let v=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(v)}}},[r]);let g=()=>{i(!0)},b=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,p,{}]:[a,p,{onFocus:Rx(l,g),onBlur:Rx(c,b),onMouseEnter:Rx(u,g),onMouseLeave:Rx(d,b),onTouchStart:Rx(f,g)}]:[!1,p,{}]}function Rx(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function aoe({page:t,...e}){let{router:n}=BG(),r=S.useMemo(()=>kG(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?S.createElement(ooe,{page:t,matches:r,...e}):null}function soe(t){let{manifest:e,routeModules:n}=$G(),[r,i]=S.useState([]);return S.useEffect(()=>{let a=!1;return Zse(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function ooe({page:t,matches:e,...n}){let r=lu(),{manifest:i,routeModules:a}=$G(),{basename:o}=BG(),{loaderData:l,matches:c}=roe(),u=S.useMemo(()=>NU(t,e,c,i,r,"data"),[t,e,c,i,r]),d=S.useMemo(()=>NU(t,e,c,i,r,"assets"),[t,e,c,i,r]),f=S.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,v=!1;if(e.forEach(y=>{let E=i.routes[y.route.id];!E||!E.hasLoader||(!u.some(w=>w.route.id===y.route.id)&&y.route.id in l&&a[y.route.id]?.shouldRevalidate||E.hasClientLoader?v=!0:b.add(y.route.id))}),b.size===0)return[];let x=Xse(t,o,"data");return v&&b.size>0&&x.searchParams.set("_routes",e.filter(y=>b.has(y.route.id)).map(y=>y.route.id).join(",")),[x.pathname+x.search]},[o,l,r,i,u,e,t,a]),p=S.useMemo(()=>Jse(d,i),[d,i]),g=soe(d);return S.createElement(S.Fragment,null,f.map(b=>S.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),p.map(b=>S.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),g.map(({key:b,link:v})=>S.createElement("link",{key:b,nonce:n.nonce,...v})))}function loe(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var HG=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{HG&&(window.__reactRouterVersion="7.9.6")}catch{}function coe({basename:t,children:e,window:n}){let r=S.useRef();r.current==null&&(r.current=Wae({window:n,v5Compat:!0}));let i=r.current,[a,o]=S.useState({action:i.action,location:i.location}),l=S.useCallback(c=>{S.startTransition(()=>o(c))},[o]);return S.useLayoutEffect(()=>i.listen(l),[i,l]),S.createElement(Fse,{basename:t,children:e,location:a.location,navigationType:a.action,navigator:i})}var VG=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ts=S.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,...p},g){let{basename:b}=S.useContext(Ul),v=typeof u=="string"&&VG.test(u),x,y=!1;if(typeof u=="string"&&v&&(x=u,HG))try{let k=new URL(window.location.href),P=u.startsWith("//")?new URL(k.protocol+u):new URL(u),z=Kc(P.pathname,b);P.origin===k.origin&&z!=null?u=z+P.search+P.hash:y=!0}catch{Mo(!1,`<Link to="${u}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let E=vse(u,{relative:i}),[w,A,N]=ioe(r,p),C=hoe(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f});function T(k){e&&e(k),k.defaultPrevented||C(k)}let D=S.createElement("a",{...p,...N,href:x||E,onClick:y||a?e:T,ref:loe(g,A),target:c,"data-discover":!v&&n==="render"?"true":void 0});return w&&!v?S.createElement(S.Fragment,null,D,S.createElement(aoe,{page:E})):D});Ts.displayName="Link";var ab=S.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=U0(o,{relative:u.relative}),p=lu(),g=S.useContext(f2),{navigator:b,basename:v}=S.useContext(Ul),x=g!=null&&boe(f)&&l===!0,y=b.encodeLocation?b.encodeLocation(f).pathname:f.pathname,E=p.pathname,w=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(E=E.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&v&&(w=Kc(w,v)||w);const A=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let N=E===y||!i&&E.startsWith(y)&&E.charAt(A)==="/",C=w!=null&&(w===y||!i&&w.startsWith(y)&&w.charAt(y.length)==="/"),T={isActive:N,isPending:C,isTransitioning:x},D=N?e:void 0,k;typeof r=="function"?k=r(T):k=[r,N?"active":null,C?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let P=typeof a=="function"?a(T):a;return S.createElement(Ts,{...u,"aria-current":D,className:k,ref:d,style:P,to:o,viewTransition:l},typeof c=="function"?c(T):c)});ab.displayName="NavLink";var uoe=S.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=S1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,...p},g)=>{let b=goe(),v=xoe(l,{relative:u}),x=o.toLowerCase()==="get"?"get":"post",y=typeof l=="string"&&VG.test(l),E=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let A=w.nativeEvent.submitter,N=A?.getAttribute("formmethod")||o;b(A||w.currentTarget,{fetcherKey:e,method:N,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f})};return S.createElement("form",{ref:g,method:x,action:v,onSubmit:r?c:E,...p,"data-discover":!y&&t==="render"?"true":void 0})});uoe.displayName="Form";function doe(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function GG(t){let e=S.useContext(yg);return Dr(e,doe(t)),e}function hoe(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o}={}){let l=vg(),c=lu(),u=U0(t,{relative:a});return S.useCallback(d=>{if(Vse(d,e)){d.preventDefault();let f=n!==void 0?n:Vb(c)===Vb(u);l(t,{replace:f,state:r,preventScrollReset:i,relative:a,viewTransition:o})}},[c,l,u,n,r,e,t,i,a,o])}function foe(t){Mo(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=S.useRef(fj(t)),n=S.useRef(!1),r=lu(),i=S.useMemo(()=>Gse(r.search,n.current?null:e.current),[r.search]),a=vg(),o=S.useCallback((l,c)=>{const u=fj(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var moe=0,poe=()=>`__${String(++moe)}__`;function goe(){let{router:t}=GG("useSubmit"),{basename:e}=S.useContext(Ul),n=Rse();return S.useCallback(async(r,i={})=>{let{action:a,method:o,encType:l,formData:c,body:u}=Kse(r,e);if(i.navigate===!1){let d=i.fetcherKey||poe();await t.fetch(d,n,i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,flushSync:i.flushSync})}else await t.navigate(i.action||a,{preventScrollReset:i.preventScrollReset,formData:c,body:u,formMethod:i.method||o,formEncType:i.encType||l,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[t,e,n])}function xoe(t,{relative:e}={}){let{basename:n}=S.useContext(Ul),r=S.useContext(nl);Dr(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...U0(t||".",{relative:e})},o=lu();if(t==null){a.search=o.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Uc([n,a.pathname])),Vb(a)}function boe(t,{relative:e}={}){let n=S.useContext(LG);Dr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=GG("useViewTransitionState"),i=U0(t,{relative:e});if(!n.isTransitioning)return!1;let a=Kc(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Kc(n.nextLocation.pathname,r)||n.nextLocation.pathname;return J1(i.pathname,o)!=null||J1(i.pathname,a)!=null}var Pc=yG();const yoe=Co(Pc);var _g=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(){}},voe={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},_oe=class{#e=voe;#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)}},Fh=new _oe;function woe(t){setTimeout(t,0)}var df=typeof window>"u"||"Deno"in globalThis;function Ia(){}function Soe(t,e){return typeof t=="function"?t(e):t}function mj(t){return typeof t=="number"&&t>=0&&t!==1/0}function WG(t,e){return Math.max(t+(e||0)-Date.now(),0)}function yd(t,e){return typeof t=="function"?t(e):t}function lo(t,e){return typeof t=="function"?t(e):t}function AU(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==NR(o,e.options))return!1}else if(!Gb(e.queryKey,o))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||i&&i!==e.state.fetchStatus||a&&!a(e))}function TU(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(hf(e.options.mutationKey)!==hf(a))return!1}else if(!Gb(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function NR(t,e){return(e?.queryKeyHashFn||hf)(t)}function hf(t){return JSON.stringify(t,(e,n)=>pj(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Gb(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Gb(t[n],e[n])):!1}var Moe=Object.prototype.hasOwnProperty;function qG(t,e){if(t===e)return t;const n=CU(t)&&CU(e);if(!n&&!(pj(t)&&pj(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:a[u],f=t[d],p=e[d];if(f===p){l[d]=f,(n?u<i:Moe.call(t,d))&&c++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){l[d]=p;continue}const g=qG(f,p);l[d]=g,g===f&&c++}return i===o&&c===i?t:l}function ew(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 CU(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function pj(t){if(!kU(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!kU(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function kU(t){return Object.prototype.toString.call(t)==="[object Object]"}function Eoe(t){return new Promise(e=>{Fh.setTimeout(e,t)})}function gj(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?qG(t,e):e}function Noe(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Aoe(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var AR=Symbol();function KG(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===AR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function XG(t,e){return typeof t=="function"?t(...e):!!t}var Toe=class extends _g{#e;#t;#n;constructor(){super(),this.#n=t=>{if(!df&&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"}},TR=new Toe;function xj(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var Coe=woe;function koe(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Coe;const a=l=>{e?t.push(l):i(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var Ni=koe(),joe=class extends _g{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(!df&&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}},tw=new joe;function Poe(t){return Math.min(1e3*2**t,3e4)}function YG(t){return(t??"online")==="online"?tw.isOnline():!0}var bj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function QG(t){let e=!1,n=0,r;const i=xj(),a=()=>i.status!=="pending",o=v=>{if(!a()){const x=new bj(v);p(x),t.onCancel?.(x)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>TR.isFocused()&&(t.networkMode==="always"||tw.isOnline())&&t.canRun(),d=()=>YG(t.networkMode)&&t.canRun(),f=v=>{a()||(r?.(),i.resolve(v))},p=v=>{a()||(r?.(),i.reject(v))},g=()=>new Promise(v=>{r=x=>{(a()||u())&&v(x)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),b=()=>{if(a())return;let v;const x=n===0?t.initialPromise:void 0;try{v=x??t.fn()}catch(y){v=Promise.reject(y)}Promise.resolve(v).then(f).catch(y=>{if(a())return;const E=t.retry??(df?0:3),w=t.retryDelay??Poe,A=typeof w=="function"?w(n,y):w,N=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,y);if(e||!N){p(y);return}n++,t.onFail?.(n,y),Eoe(A).then(()=>u()?void 0:g()).then(()=>{e?p(y):b()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?b():g().then(b),i)}}var ZG=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),mj(this.gcTime)&&(this.#e=Fh.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(df?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Fh.clearTimeout(this.#e),this.#e=void 0)}},Roe=class extends ZG{#e;#t;#n;#i;#r;#s;#o;constructor(t){super(),this.#o=!1,this.#s=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#n=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=PU(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#s,...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=PU(this.options);e.data!==void 0&&(this.setState(jU(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=gj(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.#r?.promise;return this.#r?.cancel(t),e?e.then(Ia).catch(Ia):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(t=>lo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===AR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>yd(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:!WG(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.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.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.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.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const n=new AbortController,r=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const l=KG(this.options,e),u=(()=>{const d={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(d),d})();return this.#o=!1,this.options.persister?this.options.persister(l,u,this):l(u)},o=(()=>{const l={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(l),l})();this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#a({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=QG({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof bj&&l.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(l,c)=>{this.#a({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const l=await this.#r.start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#n.config.onSuccess?.(l,this),this.#n.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof bj){if(l.silent)return this.#r.promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#a({type:"error",error:l}),this.#n.config.onError?.(l,this),this.#n.config.onSettled?.(this.state.data,l,this),l}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,...JG(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...jU(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=t.manual?r:void 0,r;case"error":const i=t.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),Ni.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function JG(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:YG(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function jU(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function PU(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,r=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Doe=class extends _g{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=xj(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#s;#o;#a;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),RU(this.#t,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return yj(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return yj(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),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 lo(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),e._defaulted&&!ew(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&DU(this.#t,n,this.options,e)&&this.#d(),this.updateResult(),r&&(this.#t!==n||lo(this.options.enabled,this.#t)!==lo(e.enabled,this.#t)||yd(this.options.staleTime,this.#t)!==yd(e.staleTime,this.#t))&&this.#g();const i=this.#x();r&&(this.#t!==n||lo(this.options.enabled,this.#t)!==lo(e.enabled,this.#t)||i!==this.#l)&&this.#b(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return Loe(this,n)&&(this.#i=n,this.#s=this.options,this.#r=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,r)=>(this.trackProp(r),e?.(r),r==="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,r))})}trackProp(t){this.#m.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.#i))}#d(t){this.#w();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Ia)),e}#g(){this.#v();const t=yd(this.options.staleTime,this.#t);if(df||this.#i.isStale||!mj(t))return;const n=WG(this.#i.dataUpdatedAt,t)+1;this.#c=Fh.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#b(t){this.#_(),this.#l=t,!(df||lo(this.options.enabled,this.#t)===!1||!mj(this.#l)||this.#l===0)&&(this.#u=Fh.setInterval(()=>{(this.options.refetchIntervalInBackground||TR.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Fh.clearTimeout(this.#c),this.#c=void 0)}#_(){this.#u&&(Fh.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#t,r=this.options,i=this.#i,a=this.#r,o=this.#s,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,p;if(e._optimisticResults){const D=this.hasListeners(),k=!D&&RU(t,e),P=D&&DU(t,n,e,r);(k||P)&&(d={...d,...JG(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:v}=d;p=d.data;let x=!1;if(e.placeholderData!==void 0&&p===void 0&&v==="pending"){let D;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(D=i.data,x=!0):D=typeof e.placeholderData=="function"?e.placeholderData(this.#f?.state.data,this.#f):e.placeholderData,D!==void 0&&(v="success",p=gj(i?.data,D,e),f=!0)}if(e.select&&p!==void 0&&!x)if(i&&p===a?.data&&e.select===this.#p)p=this.#h;else try{this.#p=e.select,p=e.select(p),p=gj(i?.data,p,e),this.#h=p,this.#a=null}catch(D){this.#a=D}this.#a&&(g=this.#a,p=this.#h,b=Date.now(),v="error");const y=d.fetchStatus==="fetching",E=v==="pending",w=v==="error",A=E&&y,N=p!==void 0,T={status:v,fetchStatus:d.fetchStatus,isPending:E,isSuccess:v==="success",isError:w,isInitialLoading:A,isLoading:A,data:p,dataUpdatedAt:d.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!E,isLoadingError:w&&!N,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&N,isStale:CR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:lo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const D=z=>{T.status==="error"?z.reject(T.error):T.data!==void 0&&z.resolve(T.data)},k=()=>{const z=this.#o=T.promise=xj();D(z)},P=this.#o;switch(P.status){case"pending":t.queryHash===n.queryHash&&D(P);break;case"fulfilled":(T.status==="error"||T.data!==P.value)&&k();break;case"rejected":(T.status!=="error"||T.error!==P.reason)&&k();break}}return T}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#s=this.options,this.#r.data!==void 0&&(this.#f=this.#t),ew(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;const a=new Set(i??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&a.has(l)})};this.#S({listeners:n()})}#w(){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()}#S(t){Ni.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Ooe(t,e){return lo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function RU(t,e){return Ooe(t,e)||t.state.data!==void 0&&yj(t,e,e.refetchOnMount)}function yj(t,e,n){if(lo(e.enabled,t)!==!1&&yd(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&CR(t,e)}return!1}function DU(t,e,n,r){return(t!==e||lo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&CR(t,n)}function CR(t,e){return lo(e.enabled,t)!==!1&&t.isStaleByTime(yd(e.staleTime,t))}function Loe(t,e){return!ew(t.getCurrentResult(),e)}function OU(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},p=KG(e.options,e.fetchOptions),g=async(b,v,x)=>{if(d)return Promise.reject();if(v==null&&b.pages.length)return Promise.resolve(b);const E=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:v,direction:x?"backward":"forward",meta:e.options.meta};return f(C),C})(),w=await p(E),{maxPages:A}=e.options,N=x?Aoe:Noe;return{pages:N(b.pages,w,A),pageParams:N(b.pageParams,v,A)}};if(i&&a.length){const b=i==="backward",v=b?Ioe:LU,x={pages:a,pageParams:o},y=v(r,x);l=await g(x,y,b)}else{const b=t??a.length;do{const v=c===0?o[0]??r.initialPageParam:LU(r,l);if(c>0&&v==null)break;l=await g(l,v),c++}while(c<b)}return l};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=u}}}function LU(t,{pages:e,pageParams:n}){const r=e.length-1;return e.length>0?t.getNextPageParam(e[r],e,n[r],n):void 0}function Ioe(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Foe=class extends ZG{#e;#t;#n;#i;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||eW(),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.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#r({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=QG({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)e();else{this.#r({type:"pending",variables:t,isPaused:i}),await this.#n.config.onMutate?.(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#r({type:"pending",context:o,variables:t,isPaused:i})}const a=await this.#i.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.#r({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.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(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),Ni.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function eW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Uoe=class extends _g{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 r=new Foe({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(r),r}add(t){this.#e.add(t);const e=Bv(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=Bv(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const r=n.indexOf(t);r!==-1&&n.splice(r,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=Bv(t);if(typeof e=="string"){const r=this.#t.get(e)?.find(i=>i.state.status==="pending");return!r||r===t}else return!0}runNext(t){const e=Bv(t);return typeof e=="string"?this.#t.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ni.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=>TU(e,n))}findAll(t={}){return this.getAll().filter(e=>TU(t,e))}notify(t){Ni.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Ni.batch(()=>Promise.all(t.map(e=>e.continue().catch(Ia))))}};function Bv(t){return t.options.scope?.id}var zoe=class extends _g{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#r()}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),ew(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&hf(n.mutationKey)!==hf(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.#r(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#s()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#r(){const e=this.#n?.state??eW();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){Ni.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,r=this.#t.context,i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,n,r,i),this.#i.onSettled?.(e.data,null,n,r,i)):e?.type==="error"&&(this.#i.onError?.(e.error,n,r,i),this.#i.onSettled?.(void 0,e.error,n,r,i))}this.listeners.forEach(n=>{n(this.#t)})})}},Boe=class extends _g{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const r=e.queryKey,i=e.queryHash??NR(r,e);let a=this.get(i);return a||(a=new Roe({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),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(){Ni.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=>AU(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>AU(t,n)):e}notify(t){Ni.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Ni.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ni.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},$oe=class{#e;#t;#n;#i;#r;#s;#o;#a;constructor(t={}){this.#e=t.queryCache||new Boe,this.#t=t.mutationCache||new Uoe,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#o=TR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=tw.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),r=n.state.data;return r===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(yd(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(r))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const r=n.data;return[e,r]})}setQueryData(t,e,n){const r=this.defaultQueryOptions({queryKey:t}),a=this.#e.get(r.queryHash)?.state.data,o=Soe(e,a);if(o!==void 0)return this.#e.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Ni.batch(()=>this.#e.findAll(t).map(({queryKey:r})=>[r,this.setQueryData(r,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;Ni.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return Ni.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=Ni.batch(()=>this.#e.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Ia).catch(Ia)}invalidateQueries(t,e={}){return Ni.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},r=Ni.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ia)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ia)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(yd(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ia).catch(Ia)}fetchInfiniteQuery(t){return t.behavior=OU(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ia).catch(Ia)}ensureInfiniteQueryData(t){return t.behavior=OU(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return tw.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.#i.set(hf(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{Gb(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(hf(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{Gb(t,r.mutationKey)&&Object.assign(n,r.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=NR(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===AR&&(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()}},tW=S.createContext(void 0),an=t=>{const e=S.useContext(tW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Hoe=({client:t,children:e})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(tW.Provider,{value:t,children:e})),nW=S.createContext(!1),Voe=()=>S.useContext(nW);nW.Provider;function Goe(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Woe=S.createContext(Goe()),qoe=()=>S.useContext(Woe),Koe=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},Xoe=t=>{S.useEffect(()=>{t.clearReset()},[t])},Yoe=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||XG(n,[t.error,r])),Qoe=t=>{if(t.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Zoe=(t,e)=>t.isLoading&&t.isFetching&&!e,Joe=(t,e)=>t?.suspense&&e.isPending,IU=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function ele(t,e,n){const r=Voe(),i=qoe(),a=an(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",Qoe(o),Koe(o,i),Xoe(i);const l=!a.getQueryCache().get(o.queryHash),[c]=S.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(f=>{const p=d?c.subscribe(Ni.batchCalls(f)):Ia;return c.updateResult(),p},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),S.useEffect(()=>{c.setOptions(o)},[o,c]),Joe(o,u))throw IU(o,c,i);if(Yoe({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!df&&Zoe(u,r)&&(l?IU(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ia).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function lt(t,e){return ele(t,Doe)}function ht(t,e){const n=an(),[r]=S.useState(()=>new zoe(n,t));S.useEffect(()=>{r.setOptions(t)},[r,t]);const i=S.useSyncExternalStore(S.useCallback(o=>r.subscribe(Ni.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=S.useCallback((o,l)=>{r.mutate(o,l).catch(Ia)},[r]);if(i.error&&XG(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const tle=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nle=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),FU=t=>{const e=nle(t);return e.charAt(0).toUpperCase()+e.slice(1)},rW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),rle=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var ile={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 ale=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>S.createElement("svg",{ref:c,...ile,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:rW("lucide",i),...!a&&!rle(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>S.createElement(u,d)),...Array.isArray(a)?a:[a]]));const We=(t,e)=>{const n=S.forwardRef(({className:r,...i},a)=>S.createElement(ale,{ref:a,iconNode:e,className:rW(`lucide-${tle(FU(t))}`,`lucide-${t}`,r),...i}));return n.displayName=FU(t),n};const sle=[["path",{d:"M18 17.5a2.5 2.5 0 1 1-4 2.03V12",key:"yd12zl"}],["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M6.6 15.572A2 2 0 1 0 10 17v-5",key:"1x1kqn"}]],ole=We("air-vent",sle);const lle=[["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"}]],Os=We("archive",lle);const cle=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],ule=We("arrow-down-wide-narrow",cle);const dle=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Wb=We("arrow-down",dle);const hle=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],fle=We("arrow-left",hle);const mle=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],vj=We("arrow-right",mle);const ple=[["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"}]],gle=We("arrow-up-down",ple);const xle=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]],ble=We("arrow-up-narrow-wide",xle);const yle=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Up=We("arrow-up",yle);const vle=[["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"}]],Kh=We("bell",vle);const _le=[["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"}]],wle=We("bold",_le);const Sle=[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]],Mle=We("book",Sle);const Ele=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Nle=We("bookmark",Ele);const Ale=[["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"}]],ks=We("box",Ale);const Tle=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],iW=We("briefcase",Tle);const Cle=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],aW=We("bug",Cle);const kle=[["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"}]],jle=We("cable",kle);const Ple=[["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"}]],Rle=We("calendar-days",Ple);const Dle=[["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"}]],qr=We("calendar",Dle);const Ole=[["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"}]],zp=We("camera",Ole);const Lle=[["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"}]],Ile=We("chart-column",Lle);const Fle=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Aa=We("check",Fle);const Ule=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qi=We("chevron-down",Ule);const zle=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Bs=We("chevron-right",zle);const Ble=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ff=We("chevron-left",Ble);const $le=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Xc=We("chevron-up",$le);const Hle=[["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"}]],pa=We("circle-alert",Hle);const Vle=[["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"}]],pA=We("circle-arrow-up",Vle);const Gle=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],pr=We("circle-check-big",Gle);const Wle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],p2=We("circle-check",Wle);const qle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Kle=We("circle-dot",qle);const Xle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Yle=We("circle-stop",Xle);const Qle=[["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"}]],Wi=We("circle-x",Qle);const Zle=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],qb=We("circle",Zle);const Jle=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],tr=We("clock",Jle);const ece=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],g2=We("cloud",ece);const tce=[["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"}]],nce=We("code-xml",tce);const rce=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],sW=We("code",rce);const ice=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],ace=We("coffee",ice);const sce=[["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}]],oce=We("cog",sce);const lce=[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cce=We("compass",lce);const uce=[["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"}]],$s=We("copy",uce);const dce=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],$v=We("cpu",dce);const hce=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],fce=We("cylinder",hce);const mce=[["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"}]],Bp=We("database",mce);const pce=[["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"}]],_j=We("dollar-sign",pce);const gce=[["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"}]],Yr=We("download",gce);const xce=[["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"}]],kR=We("droplet",xce);const bce=[["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"}]],jR=We("droplets",bce);const yce=[["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"}]],vd=We("ellipsis-vertical",yce);const vce=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],gA=We("equal",vce);const _ce=[["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"}]],Kr=We("external-link",_ce);const wce=[["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"}]],x2=We("eye-off",wce);const Sce=[["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"}]],mf=We("eye",Sce);const Mce=[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]],oW=We("fan",Mce);const Ece=[["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"}]],Xh=We("file-box",Ece);const Nce=[["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"}]],nw=We("file-code",Nce);const Ace=[["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"}]],Tce=We("file-exclamation-point",Ace);const Cce=[["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:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],rw=We("file-spreadsheet",Cce);const kce=[["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"}]],Ua=We("file-text",kce);const jce=[["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"}]],b2=We("file",jce);const Pce=[["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"}]],_d=We("film",Pce);const Rce=[["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"}]],Dce=We("flame",Rce);const Oce=[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]],ma=We("folder-kanban",Oce);const Lce=[["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"}]],Zo=We("folder-open",Lce);const Ice=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],Fce=We("folder-plus",Ice);const Uce=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],zce=We("folder-tree",Uce);const Bce=[["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"}]],lW=We("folder",Bce);const $ce=[["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"}]],y2=We("funnel",$ce);const Hce=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],v2=We("gauge",Hce);const Vce=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],Gce=We("gift",Vce);const Wce=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],Ep=We("git-compare",Wce);const qce=[["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"}]],UU=We("github",qce);const Kce=[["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"}]],pf=We("globe",Kce);const Xce=[["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"}]],Kb=We("grip-vertical",Xce);const Yce=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],PR=We("hand",Yce);const Qce=[["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"}]],_2=We("hard-drive",Qce);const Zce=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Jce=We("hash",Zce);const eue=[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]],tue=We("headphones",eue);const nue=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],rue=We("heart",nue);const iue=[["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"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],iw=We("history",iue);const aue=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],w2=We("house",aue);const sue=[["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"}]],z0=We("image",sue);const oue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],jd=We("info",oue);const lue=[["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"}]],cue=We("italic",lue);const uue=[["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"}]],Uh=We("key",uue);const due=[["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"}]],wj=We("keyboard",due);const hue=[["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"}]],Hs=We("layers",hue);const fue=[["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"}]],S2=We("layout-grid",fue);const mue=[["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"}]],pue=We("link-2-off",mue);const gue=[["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"}]],El=We("link-2",gue);const xue=[["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"}]],B0=We("link",xue);const bue=[["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"}]],cW=We("list-ordered",bue);const yue=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Sj=We("list-todo",yue);const vue=[["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"}]],M2=We("list",vue);const _ue=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ft=We("loader-circle",_ue);const wue=[["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"}]],zU=We("log-in",wue);const Sue=[["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"}]],Mue=We("log-out",Sue);const Eue=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Nue=We("mail",Eue);const Aue=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],Tue=We("map",Aue);const Cue=[["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"}]],kue=We("maximize-2",Cue);const jue=[["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"}]],Pue=We("maximize",jue);const Rue=[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]],Due=We("memory-stick",Rue);const Oue=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Lue=We("menu",Oue);const Iue=[["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"}]],Fue=We("minimize-2",Iue);const Uue=[["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"}]],zue=We("minimize",Uue);const Bue=[["path",{d:"M5 12h14",key:"1ays0h"}]],Mj=We("minus",Bue);const $ue=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Hue=We("monitor",$ue);const Vue=[["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"}]],aw=We("moon",Vue);const Gue=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Wue=We("move-right",Gue);const que=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ej=We("music",que);const Kue=[["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"}]],Cl=We("package",Kue);const Xue=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],RR=We("palette",Xue);const Yue=[["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"}]],DR=We("pause",Yue);const Que=[["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"}]],gf=We("pen-line",Que);const Zue=[["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"}]],OR=We("pen",Zue);const Jue=[["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"}]],Jo=We("pencil",Jue);const ede=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],tde=We("phone",ede);const nde=[["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"}]],Yc=We("play",nde);const rde=[["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"}]],Ls=We("plug",rde);const ide=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],dr=We("plus",ide);const ade=[["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"}]],E2=We("power-off",ade);const sde=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],zl=We("power",sde);const ode=[["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"}]],Qr=We("printer",ode);const lde=[["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"}]],uW=We("qr-code",lde);const cde=[["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"}]],Rr=We("refresh-cw",cde);const ude=[["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"}]],If=We("rotate-ccw",ude);const dde=[["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"}]],hde=We("ruler",dde);const fde=[["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"}]],Rs=We("save",fde);const mde=[["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"}]],dW=We("scan-search",mde);const pde=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],gde=We("scissors",pde);const xde=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Eo=We("search",xde);const bde=[["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"}]],LR=We("send",bde);const yde=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Nh=We("server",yde);const vde=[["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"}]],Pd=We("settings-2",vde);const _de=[["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"}]],$0=We("settings",_de);const wde=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Sde=We("shield",wde);const Mde=[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]],hW=We("shopping-cart",Mde);const Ede=[["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"}]],Nde=We("signal",Ede);const Ade=[["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"}]],Tde=We("skip-back",Ade);const Cde=[["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"}]],sw=We("skip-forward",Cde);const kde=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],BU=We("sliders-vertical",kde);const jde=[["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"}]],Xb=We("sparkles",jde);const Pde=[["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"}]],Qc=We("square-check-big",Pde);const Rde=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Zc=We("square",Rde);const Dde=[["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"}]],xf=We("star",Dde);const Ode=[["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"}]],fW=We("sticky-note",Ode);const Lde=[["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"}]],$U=We("sun",Lde);const Ide=[["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"}]],$p=We("tag",Ide);const Fde=[["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"}]],mW=We("target",Fde);const Ude=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],pW=We("terminal",Ude);const zde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Bde=We("text-align-center",zde);const $de=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Hde=We("text-align-end",$de);const Vde=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Gde=We("text-align-start",Vde);const Wde=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],N2=We("thermometer",Wde);const qde=[["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"}]],hd=We("timer",qde);const Kde=[["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"}]],ln=We("trash-2",Kde);const Xde=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],gW=We("trending-down",Xde);const Yde=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],xW=We("trending-up",Yde);const Qde=[["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"}]],yn=We("triangle-alert",Qde);const Zde=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Jde=We("underline",Zde);const ehe=[["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"}]],IR=We("unlink",ehe);const the=[["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"}]],xi=We("upload",the);const nhe=[["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"}]],Nj=We("user",nhe);const rhe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],ihe=We("users",rhe);const ahe=[["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"}]],bW=We("video",ahe);const she=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],ohe=We("volume-2",she);const lhe=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],che=We("volume-x",lhe);const uhe=[["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"}]],H0=We("wifi-off",uhe);const dhe=[["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"}]],Np=We("wifi",dhe);const hhe=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],yW=We("wind",hhe);const fhe=[["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"}]],Rd=We("wrench",fhe);const mhe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zt=We("x",mhe);const phe=[["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"}]],ghe=We("zoom-in",phe);const xhe=[["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"}]],bf=We("zap",xhe);const bhe=[["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"}]],yhe=We("zoom-out",bhe),mn="/api/v1";async function De(t,e={}){const n=await fetch(`${mn}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!n.ok){const i=(await n.json().catch(()=>({}))).detail,a=typeof i=="string"?i:i?JSON.stringify(i):`HTTP ${n.status}`;throw new Error(a)}return await n.json()}const be={getPrinters:()=>De("/printers/"),getPrinter:t=>De(`/printers/${t}`),createPrinter:t=>De("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>De(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>De(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>De(`/printers/${t}/status`),refreshPrinterStatus:t=>De(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>De(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>De(`/printers/${t}/disconnect`,{method:"POST"}),stopPrint:t=>De(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>De(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>De(`/printers/${t}/print/resume`,{method:"POST"}),setChamberLight:(t,e)=>De(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>De(`/printers/${t}/print/objects`),skipObjects:(t,e)=>De(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>De(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>De(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>De(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>De(`/printers/${t}/logging`),clearMQTTLogs:t=>De(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>De(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${mn}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,deletePrinterFile:(t,e)=>De(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>De(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),De(`/archives/?${i}`)},getArchive:t=>De(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),De(`/archives/search?${n}`)},rebuildSearchIndex:()=>De("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>De(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>De(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>De(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>De("/archives/stats"),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),De(`/archives/analysis/failures?${e}`)},compareArchives:t=>De(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>De(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n=await fetch(`${mn}/archives/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},exportStats:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId));const n=await fetch(`${mn}/archives/stats/export?${e}`);if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${n.status}`)}const r=n.headers.get("Content-Disposition");let i=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(r){const o=r.match(/filename="?([^"]+)"?/);o&&(i=o[1])}return{blob:await n.blob(),filename:i}},getArchiveDuplicates:t=>De(`/archives/${t}/duplicates`),backfillContentHashes:()=>De("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${mn}/archives/${t}/thumbnail?v=${Date.now()}`,getArchiveDownload:t=>`${mn}/archives/${t}/download`,getArchiveGcode:t=>`${mn}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${mn}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${mn}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>De(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>De(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${mn}/archives/${t}/timelapse/upload`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getTimelapseInfo:t=>De(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>De(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i=await fetch(`${mn}/archives/${t}/timelapse/process`,{method:"POST",body:r});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getArchivePhotoUrl:(t,e)=>`${mn}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${mn}/archives/${t}/photos`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteArchivePhoto:(t,e)=>De(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${mn}/archives/${t}/source`,getSource3mfForSlicer:(t,e)=>`${mn}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${mn}/archives/${t}/source`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteSource3mf:t=>De(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${mn}/archives/${t}/f3d`,uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${mn}/archives/${t}/f3d`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteF3d:t=>De(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${mn}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>De(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>De(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>De(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${mn}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${mn}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>De(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>De(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>De(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${mn}/archives/upload?printer_id=${e}`:`${mn}/archives/upload`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(a=>n.append("files",a));const r=e?`${mn}/archives/upload-bulk?printer_id=${e}`:`${mn}/archives/upload-bulk`,i=await fetch(r,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getSettings:()=>De("/settings/"),updateSettings:t=>De("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>De("/settings/mqtt/status"),resetSettings:()=>De("/settings/reset",{method:"POST"}),exportBackup:async t=>{const e=new URLSearchParams;t&&(t.settings!==void 0&&e.set("include_settings",String(t.settings)),t.notifications!==void 0&&e.set("include_notifications",String(t.notifications)),t.templates!==void 0&&e.set("include_templates",String(t.templates)),t.smart_plugs!==void 0&&e.set("include_smart_plugs",String(t.smart_plugs)),t.external_links!==void 0&&e.set("include_external_links",String(t.external_links)),t.printers!==void 0&&e.set("include_printers",String(t.printers)),t.filaments!==void 0&&e.set("include_filaments",String(t.filaments)),t.maintenance!==void 0&&e.set("include_maintenance",String(t.maintenance)),t.archives!==void 0&&e.set("include_archives",String(t.archives)),t.projects!==void 0&&e.set("include_projects",String(t.projects)),t.pending_uploads!==void 0&&e.set("include_pending_uploads",String(t.pending_uploads)),t.access_codes!==void 0&&e.set("include_access_codes",String(t.access_codes)),t.api_keys!==void 0&&e.set("include_api_keys",String(t.api_keys)));const n=`${mn}/settings/backup${e.toString()?"?"+e.toString():""}`,r=await fetch(n);if(!r.ok){const l=await r.text();throw new Error(l||`Backup failed with status ${r.status}`)}const i=r.headers.get("Content-Disposition");let a="bambuddy-backup.json";if(i){const l=i.match(/filename=([^;]+)/);l&&(a=l[1].trim())}return{blob:await r.blob(),filename:a}},importBackup:async(t,e=!1)=>{const n=new FormData;n.append("file",t);const r=`${mn}/settings/restore${e?"?overwrite=true":""}`;return(await fetch(r,{method:"POST",body:n})).json()},checkFfmpeg:()=>De("/settings/check-ffmpeg"),getCloudStatus:()=>De("/cloud/status"),cloudLogin:(t,e,n="global")=>De("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e)=>De("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e})}),cloudSetToken:t=>De("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>De("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>De(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>De(`/cloud/settings/${t}`),createCloudSetting:t=>De("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>De(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>De(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>De("/cloud/devices"),getCloudFields:t=>De(`/cloud/fields/${t}`),getAllCloudFields:()=>De("/cloud/fields"),getFilamentInfo:t=>De("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>De("/smart-plugs/"),getSmartPlug:t=>De(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>De(`/smart-plugs/by-printer/${t}`),createSmartPlug:t=>De("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>De(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>De(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>De(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>De(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>De("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${mn}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>De("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${mn}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>De("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>De("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:()=>De("/smart-plugs/ha/entities"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),De(`/queue/?${n}`)},getQueueItem:t=>De(`/queue/${t}`),addToQueue:t=>De("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>De(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>De(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>De("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>De(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>De(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>De(`/queue/${t}/start`,{method:"POST"}),getKProfiles:(t,e="0.4")=>De(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>De(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>De(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>De(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>De(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>De(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>De(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>De(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>De(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>De(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>De(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),De(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>De(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>De("/filaments/"),getFilament:t=>De(`/filaments/${t}`),getFilamentsByType:t=>De(`/filaments/by-type/${t}`),getNotificationProviders:()=>De("/notifications/"),getNotificationProvider:t=>De(`/notifications/${t}`),createNotificationProvider:t=>De("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>De(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>De(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>De(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>De("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>De("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>De("/notification-templates"),getNotificationTemplate:t=>De(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>De(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>De(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>De("/notification-templates/variables"),previewTemplate:t=>De("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),De(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>De(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>De(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>De("/spoolman/status"),connectSpoolman:()=>De("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>De("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>De(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>De("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>De("/spoolman/spools"),getSpoolmanFilaments:()=>De("/spoolman/filaments"),getUnlinkedSpools:()=>De("/spoolman/spools/unlinked"),linkSpool:(t,e)=>De(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getVersion:()=>De("/updates/version"),checkForUpdates:()=>De("/updates/check"),applyUpdate:()=>De("/updates/apply",{method:"POST"}),getUpdateStatus:()=>De("/updates/status"),getMaintenanceTypes:()=>De("/maintenance/types"),createMaintenanceType:t=>De("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>De(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>De(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>De("/maintenance/overview"),getPrinterMaintenance:t=>De(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>De(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>De(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>De(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>De("/maintenance/summary"),setPrinterHours:(t,e)=>De(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>De(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>De(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${mn}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${mn}/printers/${t}/camera/snapshot`,testCameraConnection:t=>De(`/printers/${t}/camera/test`),getExternalLinks:()=>De("/external-links/"),getExternalLink:t=>De(`/external-links/${t}`),createExternalLink:t=>De("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>De(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>De(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>De("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${mn}/external-links/${t}/icon`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},deleteExternalLinkIcon:t=>De(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${mn}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),De(`/projects/?${e}`)},getProject:t=>De(`/projects/${t}`),createProject:t=>De("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>De(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>De(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>De(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>De(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>De(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>De(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r=await fetch(`${mn}/projects/${t}/attachments`,{method:"POST",body:n});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},getProjectAttachmentUrl:(t,e)=>`${mn}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>De(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>De(`/projects/${t}/bom`),createBOMItem:(t,e)=>De(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>De(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>De(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>De("/projects/templates/"),createTemplateFromProject:t=>De(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>De(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>De(`/projects/${t}/timeline?limit=${e}`),getAPIKeys:()=>De("/api-keys/"),createAPIKey:t=>De("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>De(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>De(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>De(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>De("/system/info"),getLibraryFolders:()=>De("/library/folders"),createLibraryFolder:t=>De("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>De(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>De(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>De(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>De(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),De(`/library/files?${n}`)},getLibraryFile:t=>De(`/library/files/${t}`),uploadLibraryFile:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`?folder_id=${e}`:"",i=await fetch(`${mn}/library/files${r}`,{method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},updateLibraryFile:(t,e)=>De(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>De(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${mn}/library/files/${t}/download`,getLibraryFileThumbnailUrl:t=>`${mn}/library/files/${t}/thumbnail`,getLibraryFileGcodeUrl:t=>`${mn}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>De("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>De("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>De("/library/stats"),addLibraryFilesToQueue:t=>De("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})})},ul={getInfo:()=>De("/discovery/info"),getStatus:()=>De("/discovery/status"),startDiscovery:(t=10)=>De(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>De("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>De("/discovery/printers"),startSubnetScan:(t,e=1)=>De("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>De("/discovery/scan/status"),stopSubnetScan:()=>De("/discovery/scan/stop",{method:"POST"})},E1={getSettings:()=>De("/settings/virtual-printer"),getModels:()=>De("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),De(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},dp={list:()=>De("/pending-uploads/"),getCount:()=>De("/pending-uploads/count"),get:t=>De(`/pending-uploads/${t}`),archive:(t,e)=>De(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>De(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>De("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>De("/pending-uploads/discard-all",{method:"DELETE"})},N1={checkUpdates:()=>De("/firmware/updates"),checkPrinterUpdate:t=>De(`/firmware/updates/${t}`),prepareUpload:t=>De(`/firmware/updates/${t}/prepare`),startUpload:t=>De(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>De(`/firmware/updates/${t}/upload/status`)},A1={getDebugLoggingState:()=>De("/support/debug-logging"),setDebugLogging:t=>De("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t=await fetch(`${mn}/support/bundle`);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${t.status}`)}const n=t.headers.get("Content-Disposition")?.match(/filename=(.+)/),r=n?n[1]:"bambuddy-support.zip",i=await t.blob(),a=window.URL.createObjectURL(i),o=document.createElement("a");o.href=a,o.download=r,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(a)}},vW=S.createContext(void 0);function vhe({children:t}){const[e,n]=S.useState(()=>{const T=localStorage.getItem("theme-mode"),D=localStorage.getItem("theme");return T||D||"dark"}),[r,i]=S.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=S.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=S.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=S.useState(()=>localStorage.getItem("light-style")||"classic"),[f,p]=S.useState(()=>localStorage.getItem("light-background")||"neutral"),[g,b]=S.useState(()=>localStorage.getItem("light-accent")||"green");S.useEffect(()=>{be.getSettings().then(T=>{T.dark_style&&(i(T.dark_style),localStorage.setItem("dark-style",T.dark_style)),T.dark_background&&(o(T.dark_background),localStorage.setItem("dark-background",T.dark_background)),T.dark_accent&&(c(T.dark_accent),localStorage.setItem("dark-accent",T.dark_accent)),T.light_style&&(d(T.light_style),localStorage.setItem("light-style",T.light_style)),T.light_background&&(p(T.light_background),localStorage.setItem("light-background",T.light_background)),T.light_accent&&(b(T.light_accent),localStorage.setItem("light-accent",T.light_accent))}).catch(()=>{})},[]),S.useEffect(()=>{const T=document.documentElement;T.classList.remove("dark","style-classic","style-glow","style-vibrant","bg-neutral","bg-warm","bg-cool","bg-oled","bg-slate","bg-forest","accent-green","accent-teal","accent-blue","accent-orange","accent-purple","accent-red"),e==="dark"?(T.classList.add("dark"),T.classList.add(`style-${r}`),T.classList.add(`bg-${a}`),T.classList.add(`accent-${l}`)):(T.classList.add(`style-${u}`),T.classList.add(`bg-${f}`),T.classList.add(`accent-${g}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,g]);const v=()=>n(T=>T==="dark"?"light":"dark"),x=T=>n(T),y=T=>{i(T),localStorage.setItem("dark-style",T),be.updateSettings({dark_style:T}).catch(()=>{})},E=T=>{o(T),localStorage.setItem("dark-background",T),be.updateSettings({dark_background:T}).catch(()=>{})},w=T=>{c(T),localStorage.setItem("dark-accent",T),be.updateSettings({dark_accent:T}).catch(()=>{})},A=T=>{d(T),localStorage.setItem("light-style",T),be.updateSettings({light_style:T}).catch(()=>{})},N=T=>{p(T),localStorage.setItem("light-background",T),be.updateSettings({light_background:T}).catch(()=>{})},C=T=>{b(T),localStorage.setItem("light-accent",T),be.updateSettings({light_accent:T}).catch(()=>{})};return s.jsx(vW.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:g,toggleMode:v,setMode:x,setDarkStyle:y,setDarkBackground:E,setDarkAccent:w,setLightStyle:A,setLightBackground:N,setLightAccent:C},children:t})}function wg(){const t=S.useContext(vW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function _t({children:t,className:e="",onClick:n,onContextMenu:r,...i}){return s.jsx("div",{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary card-shadow ${e}`,onClick:n,onContextMenu:r,...i,children:t})}function Vr({children:t,className:e=""}){return s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Mt({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function _he(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function HU({children:t}){return s.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 whe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=xg(),i=_he(n,e,r);return S.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:s.jsx(_t,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wj,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(Kr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(HU,{children:l},l))})]},o.description))})]},a.category))}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",s.jsx(HU,{children:"Esc"})," or click outside to close"]})})]})})})}function Ee({variant:t="primary",size:e="md",className:n="",children:r,...i}){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",o={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"},l={sm:"px-3 py-1.5 text-sm gap-1.5 min-h-[44px] md:min-h-0",md:"px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0",lg:"px-6 py-3 text-base gap-2 min-h-[48px] md:min-h-0"};return s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Un({title:t,message:e,confirmText:n="Confirm",cancelText:r="Cancel",variant:i="default",onConfirm:a,onCancel:o}){S.useEffect(()=>{const u=d=>{d.key==="Escape"&&o()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[o]);const c={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"}}[i];return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:o,children:s.jsx(_t,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${c.icon}`,children:s.jsx(yn,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Ee,{variant:"secondary",onClick:o,className:"flex-1",children:r}),s.jsx(Ee,{onClick:a,className:`flex-1 ${c.button}`,children:n})]})]})})})}function She({plug:t}){const e=an(),[n,r]=S.useState(null),{data:i,isLoading:a}=lt({queryKey:["smart-plug-status",t.id],queryFn:()=>be.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=ht({mutationFn:f=>be.controlSmartPlug(t.id,f),onSuccess:()=>{e.invalidateQueries({queryKey:["smart-plug-status",t.id]})}}),l=i?.state==="ON",c=i?.reachable??!1,u=o.isPending,d=()=>{n&&(o.mutate(n),r(null))};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`p-1.5 rounded ${c?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:s.jsx(Ls,{className:`w-4 h-4 ${c?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),s.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?s.jsx(ft,{className:"w-3 h-3 text-bambu-gray animate-spin"}):c?s.jsxs(s.Fragment,{children:[s.jsx(Np,{className:"w-3 h-3 text-bambu-green"}),s.jsx("span",{className:l?"text-bambu-green":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(bf,{className:"w-3 h-3 text-yellow-400"}),s.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(H0,{className:"w-3 h-3 text-red-400"}),s.jsx("span",{className:"text-red-400",children:"Offline"})]})})]})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>r("on"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${l?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn On",children:u?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(zl,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("off"),disabled:!c||u,className:`p-1.5 rounded transition-colors ${!l&&c?"bg-bambu-dark-tertiary text-white":"bg-bambu-dark text-bambu-gray hover:text-white"} disabled:opacity-50 disabled:cursor-not-allowed`,title:"Turn Off",children:u?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(E2,{className:"w-4 h-4"})})]})]}),n&&s.jsx(Un,{title:`Turn ${n==="on"?"On":"Off"} Smart Plug`,message:`Are you sure you want to turn ${n==="on"?"on":"off"} "${t.name}"?`,confirmText:n==="on"?"Turn On":"Turn Off",variant:n==="off"?"warning":"default",onConfirm:d,onCancel:()=>r(null)})]})}function VU({onClose:t}){const{data:e,isLoading:n}=lt({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return s.jsxs("div",{className:"absolute bottom-full left-0 mb-2 w-72 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-xl z-50",onMouseLeave:t,children:[s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:s.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),s.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?s.jsxs("div",{className:"text-center py-6 px-4",children:[s.jsx(Ls,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):s.jsx("div",{className:"space-y-1",children:r.map(i=>s.jsx(She,{plug:i},i.id))})})]})}const _W=[{name:"globe",icon:pf},{name:"link",icon:B0},{name:"external-link",icon:Kr},{name:"book",icon:Mle},{name:"file-text",icon:Ua},{name:"home",icon:w2},{name:"star",icon:xf},{name:"heart",icon:rue},{name:"bookmark",icon:Nle},{name:"shopping-cart",icon:hW},{name:"music",icon:Ej},{name:"video",icon:bW},{name:"image",icon:z0},{name:"camera",icon:zp},{name:"map",icon:Tue},{name:"compass",icon:cce},{name:"coffee",icon:ace},{name:"gift",icon:Gce},{name:"wrench",icon:Rd},{name:"zap",icon:bf},{name:"cloud",icon:g2},{name:"database",icon:Bp},{name:"folder",icon:lW},{name:"mail",icon:Nue},{name:"phone",icon:tde},{name:"user",icon:Nj},{name:"users",icon:ihe},{name:"server",icon:Nh},{name:"terminal",icon:pW},{name:"code",icon:sW}];function A2(t){return _W.find(n=>n.name===t)?.icon||B0}function Mhe({value:t,onChange:e}){const[n,r]=S.useState(!1),i=A2(t);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{type:"button",onClick:()=>r(!n),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white hover:border-bambu-gray focus:border-bambu-green focus:outline-none w-full",children:[s.jsx(i,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),s.jsx("div",{className:"absolute z-50 mt-1 w-full max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg",children:s.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:_W.map(({name:a,icon:o})=>s.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const GU=768;function wW(){const[t,e]=S.useState(()=>typeof window<"u"?window.innerWidth<GU:!1);return S.useEffect(()=>{const n=window.matchMedia(`(max-width: ${GU-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const Yb=[{id:"printers",to:"/",icon:Qr,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:Os,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:qr,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Ile,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:g2,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:Rd,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:ma,labelKey:"nav.projects"},{id:"files",to:"/files",icon:Zo,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:$0,labelKey:"nav.settings"}];function Ehe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return Yb.map(e=>e.id)}return Yb.map(e=>e.id)}function Nhe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function xA(t){return t.startsWith("ext-")}function SW(){return localStorage.getItem("defaultView")||"/"}function Ahe(t){localStorage.setItem("defaultView",t)}function The(){const t=vg(),e=lu(),{mode:n,toggleMode:r}=wg(),{t:i}=xg(),a=wW(),[o,l]=S.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[c,u]=S.useState(!1),[d,f]=S.useState(!1),[p,g]=S.useState(!1),[b,v]=S.useState(Ehe),[x,y]=S.useState(null),[E,w]=S.useState(null),A=S.useRef(!1),[N,C]=S.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),{data:T}=lt({queryKey:["version"],queryFn:be.getVersion,staleTime:1/0}),{data:D}=lt({queryKey:["settings"],queryFn:be.getSettings,staleTime:300*1e3}),{data:k}=lt({queryKey:["updateCheck"],queryFn:be.checkForUpdates,enabled:D?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:P}=lt({queryKey:["external-links"],queryFn:be.getExternalLinks}),{data:z}=lt({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs,staleTime:30*1e3}),L=z?.some(ge=>ge.show_in_switchbar)??!1,{data:X}=lt({queryKey:["debugLogging"],queryFn:A1.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:R}=lt({queryKey:["queue","pending"],queryFn:()=>be.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Y=R?.length??0,{data:J}=lt({queryKey:["pending-uploads","count"],queryFn:dp.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),G=J?.count??0,[W,ee]=S.useState(null);S.useEffect(()=>{if(!X?.enabled||!X.enabled_at){ee(null);return}const ge=new Date(X.enabled_at).getTime(),ue=()=>{ee(Math.floor((Date.now()-ge)/1e3))};ue();const Le=setInterval(ue,1e3);return()=>clearInterval(Le)},[X?.enabled,X?.enabled_at]);const K=S.useMemo(()=>new Map(Yb.map(ge=>[ge.id,ge])),[]),F=S.useMemo(()=>new Map((P||[]).map(ge=>[`ext-${ge.id}`,ge])),[P]),q=(()=>{const ge=[],ue=new Set;for(const Le of b)(K.has(Le)||F.has(Le))&&(ge.push(Le),ue.add(Le));for(const Le of Yb)ue.has(Le.id)||(ge.push(Le.id),ue.add(Le.id));for(const Le of P||[]){const V=`ext-${Le.id}`;ue.has(V)||(ge.push(V),ue.add(V))}return ge})(),ne=(ge,ue)=>{y(ue),ge.dataTransfer.effectAllowed="move",ge.dataTransfer.setData("text/plain",ue)},re=(ge,ue)=>{ge.preventDefault(),ge.dataTransfer.dropEffect="move",w(ue)},se=()=>{w(null)},de=(ge,ue)=>{if(ge.preventDefault(),x===null||x===ue){y(null),w(null);return}const Le=[...q],V=Le.indexOf(x),$=Le.indexOf(ue);if(V===-1||$===-1){y(null),w(null);return}Le.splice(V,1),Le.splice($,0,x),v(Le),Nhe(Le),y(null),w(null)},pe=()=>{y(null),w(null)},Ce=k?.update_available&&k.latest_version&&k.latest_version!==N,oe=()=>{k?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",k.latest_version),C(k.latest_version))};S.useEffect(()=>{if(!A.current&&e.pathname==="/"){const ge=SW();ge!=="/"&&(A.current=!0,t(ge,{replace:!0}))}},[e.pathname,t]),S.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(o))},[o]),S.useEffect(()=>{a&&u(!1)},[e.pathname,a]);const ae=S.useCallback(ge=>{const ue=ge.target;if(!(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.isContentEditable)&&!ge.metaKey&&!ge.ctrlKey&&!ge.altKey){const Le=parseInt(ge.key);if(Le>=1&&Le<=q.length&&Le<=9){const V=q[Le-1];if(ge.preventDefault(),xA(V)){const $=V.replace("ext-","");t(`/external/${$}`)}else{const $=K.get(V);$&&t($.to)}return}switch(ge.key){case"?":ge.preventDefault(),f(!0);break;case"Escape":f(!1);break}}},[t,q,K]);return S.useEffect(()=>(document.addEventListener("keydown",ae),()=>document.removeEventListener("keydown",ae)),[ae]),s.jsxs("div",{className:"flex min-h-screen",children:[a&&s.jsxs("header",{className:"fixed top-0 left-0 right-0 z-40 h-14 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-4",children:[s.jsx("button",{onClick:()=>u(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(Lue,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&c&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>u(!1)}),s.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${c?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${o?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||o?"p-4":"p-2"}`,children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||o?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),s.jsx("nav",{className:"flex-1 p-2",children:s.jsx("ul",{className:"space-y-2",children:q.map(ge=>{if(xA(ge)){const Le=F.get(ge);if(!Le)return null;const V=Le.custom_icon?null:A2(Le.icon);return s.jsx("li",{draggable:!0,onDragStart:$=>ne($,ge),onDragOver:$=>re($,ge),onDragLeave:se,onDrop:$=>de($,ge),onDragEnd:pe,className:`relative ${x===ge?"opacity-50":""} ${E===ge&&x!==ge?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(ab,{to:`/external/${Le.id}`,className:({isActive:$})=>`flex items-center ${a||o?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${$?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!o?Le.name:void 0,children:[o&&!a&&s.jsx(Kb,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),Le.custom_icon?s.jsx("img",{src:`/api/v1/external-links/${Le.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):V&&s.jsx(V,{className:"w-5 h-5 flex-shrink-0"}),(a||o)&&s.jsx("span",{children:Le.name})]})},ge)}else{const Le=K.get(ge);if(!Le)return null;const{to:V,icon:$,labelKey:Z}=Le,B=ge==="queue"&&Y>0,U=ge==="archives"&&G>0,Q=B?Y:U?G:0,Me=B||U;return s.jsx("li",{draggable:!0,onDragStart:Te=>ne(Te,ge),onDragOver:Te=>re(Te,ge),onDragLeave:se,onDrop:Te=>de(Te,ge),onDragEnd:pe,className:`relative ${x===ge?"opacity-50":""} ${E===ge&&x!==ge?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(ab,{to:V,className:({isActive:Te})=>`flex items-center ${a||o?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${Te?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!o?i(Z):void 0,children:[o&&!a&&s.jsx(Kb,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsxs("div",{className:"relative",children:[s.jsx($,{className:"w-5 h-5 flex-shrink-0"}),Me&&s.jsx("span",{className:`absolute -top-1.5 -right-1.5 min-w-[18px] h-[18px] px-1 flex items-center justify-center text-[10px] font-bold rounded-full ${U?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Q>99?"99+":Q})]}),(a||o)&&s.jsx("span",{children:i(Z)})]})},ge)}})})}),!a&&s.jsx("button",{onClick:()=>l(!o),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:i(o?"nav.collapseSidebar":"nav.expandSidebar"),children:o?s.jsx(ff,{className:"w-5 h-5"}):s.jsx(Bs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||o?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[L&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>g(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${p?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ls,{className:"w-5 h-5"})}),p&&s.jsx(VU,{onClose:()=>g(!1)})]}),s.jsx(ab,{to:"/system",className:({isActive:ge})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ge?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(jd,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",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:i("nav.viewOnGithub"),children:s.jsx(UU,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(wj,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx($U,{className:"w-5 h-5"}):s.jsx(aw,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",T?.version||"..."]}),k?.update_available&&s.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:k.latest_version}),children:[s.jsx(pA,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[k?.update_available&&s.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:i("nav.updateAvailable",{version:k.latest_version}),children:s.jsx(pA,{className:"w-5 h-5"})}),L&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>g(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${p?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:s.jsx(Ls,{className:"w-5 h-5"})}),p&&s.jsx(VU,{onClose:()=>g(!1)})]}),s.jsx(ab,{to:"/system",className:({isActive:ge})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${ge?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:s.jsx(jd,{className:"w-5 h-5"})}),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",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:i("nav.viewOnGithub"),children:s.jsx(UU,{className:"w-5 h-5"})}),s.jsx("button",{onClick:()=>f(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("nav.keyboardShortcuts"),children:s.jsx(wj,{className:"w-5 h-5"})}),s.jsx("button",{onClick:r,className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i(n==="dark"?"nav.switchToLight":"nav.switchToDark"),children:n==="dark"?s.jsx($U,{className:"w-5 h-5"}):s.jsx(aw,{className:"w-5 h-5"})})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":o?"ml-64":"ml-16"}`,children:[X?.enabled&&s.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(aW,{className:"w-4 h-4 text-amber-500 animate-pulse"}),s.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),W!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(W/60),"m ",W%60,"s)"]})]}),s.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),Ce&&s.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(pA,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:k?.latest_version,defaultValue:`Version ${k?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:oe,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(zt,{className:"w-4 h-4"})})]}),s.jsx(Ise,{})]}),d&&s.jsx(whe,{onClose:()=>f(!1),sidebarItems:q.map(ge=>{if(xA(ge)){const ue=F.get(ge);return ue?{type:"external",label:ue.name}:null}else{const ue=K.get(ge);return ue?{type:"nav",label:ue.labelKey,labelKey:ue.labelKey}:null}}).filter(Boolean)})]})}function _b(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function fi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Hp(t,e){const n=fi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Vp(t,e="system",n){const r=fi(t);if(!r)return"";const a=_b(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Che(t,e="system",n){const i=_b({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const MW=S.createContext(void 0);function Wn(){const t=S.useContext(MW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const khe={success:s.jsx(pr,{className:"w-5 h-5 text-green-400"}),error:s.jsx(Wi,{className:"w-5 h-5 text-red-400"}),warning:s.jsx(pa,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(jd,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(ft,{className:"w-5 h-5 text-bambu-green animate-spin"})},jhe={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",loading:"bg-bambu-green/10 border-bambu-green/30"};function Phe({children:t}){const[e,n]=S.useState([]),r=S.useCallback((o,l="success")=>{const c=Math.random().toString(36).substr(2,9);n(u=>[...u,{id:c,message:o,type:l}]),setTimeout(()=>{n(u=>u.filter(d=>d.id!==c))},3e3)},[]),i=S.useCallback((o,l,c="info")=>{n(u=>u.find(f=>f.id===o)?u.map(f=>f.id===o?{...f,message:l,type:c,persistent:!0}:f):[...u,{id:o,message:l,type:c,persistent:!0}])},[]),a=S.useCallback(o=>{n(l=>l.filter(c=>c.id!==o))},[]);return s.jsxs(MW.Provider,{value:{showToast:r,showPersistentToast:i,dismissToast:a},children:[t,s.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(o=>s.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${jhe[o.type]}`,children:[khe[o.type],s.jsx("span",{className:"text-white text-sm",children:o.message}),s.jsx("button",{onClick:()=>a(o.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-4 h-4"})})]},o.id))})]})}function Rhe(t){if(t===0)return"0 B";const e=1024,n=["B","KB","MB","GB"],r=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/Math.pow(e,r)).toFixed(1))} ${n[r]}`}function WU(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 Dhe(t,e){if(e)return lW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Xh;case"gcode":return Ua;case"mp4":case"avi":return _d;case"png":case"jpg":case"jpeg":return z0;default:return b2}}function Ohe({printerId:t,printerName:e,onClose:n}){const{showToast:r}=Wn(),i=an(),[a,o]=S.useState("/"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,p]=S.useState(null);S.useEffect(()=>{const T=D=>{D.key==="Escape"&&n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);const{data:g,isLoading:b,refetch:v}=lt({queryKey:["printerFiles",t,a],queryFn:()=>be.getPrinterFiles(t,a)}),{data:x}=lt({queryKey:["printerStorage",t],queryFn:()=>be.getPrinterStorage(t),staleTime:3e4}),y=ht({mutationFn:T=>be.deletePrinterFile(t,T),onSuccess:(T,D)=>{r(`Deleted: ${D.split("/").pop()}`),i.invalidateQueries({queryKey:["printerFiles",t]}),c(null)},onError:T=>{r(`Delete failed: ${T.message}`,"error")}}),E=T=>{o(T),c(null)},w=()=>{if(a==="/")return;const T=a.split("/").filter(Boolean);T.pop(),o(T.length?"/"+T.join("/"):"/"),c(null)},A=T=>{window.open(be.getPrinterFileDownloadUrl(t,T),"_blank")},N=T=>{p(T)},C=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.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:T=>T.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(_2,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"File Manager"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[x&&(x.used_bytes!=null||x.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[x.used_bytes!=null&&s.jsxs("span",{children:["Used: ",WU(x.used_bytes)]}),x.used_bytes!=null&&x.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),x.free_bytes!=null&&s.jsxs("span",{children:["Free: ",WU(x.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[C.map(T=>s.jsx("button",{onClick:()=>{E(T.path),d("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${a===T.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:T.label},T.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(Eo,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Filter files...",value:u,onChange:T=>d(T.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"})]}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>v(),disabled:b,children:s.jsx(Rr,{className:`w-4 h-4 ${b?"animate-spin":""}`})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[s.jsx("button",{onClick:w,disabled:a==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(ff,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:a})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:b?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):g?.files?.length?s.jsx("div",{className:"space-y-1",children:[...g.files].filter(T=>!u||T.name.toLowerCase().includes(u.toLowerCase())).sort((T,D)=>T.is_directory&&!D.is_directory?-1:!T.is_directory&&D.is_directory?1:T.name.localeCompare(D.name)).map(T=>{const D=Dhe(T.name,T.is_directory),k=l===T.path;return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${k?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{T.is_directory?E(T.path):c(k?null:T.path)},children:[s.jsx(D,{className:`w-5 h-5 flex-shrink-0 ${T.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:T.name}),!T.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:Rhe(T.size)}),T.is_directory&&s.jsx(ff,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},T.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:u?`${g?.files?.filter(T=>T.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${g?.files?.length||0} items`:`${g?.files?.length||0} items`}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ee,{variant:"secondary",disabled:!l,onClick:()=>l&&A(l),children:[s.jsx(Yr,{className:"w-4 h-4"}),"Download"]}),s.jsxs(Ee,{variant:"secondary",disabled:!l||y.isPending,onClick:()=>l&&N(l),className:"text-red-400 hover:text-red-300",children:[y.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]})]})]}),f&&s.jsx(Un,{title:"Delete File",message:`Delete "${f.split("/").pop()}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{y.mutate(f),p(null)},onCancel:()=>p(null)})]})}function Lhe({printerId:t,printerName:e,onClose:n}){const r=an(),[i,a]=S.useState(!0),[o,l]=S.useState(new Set),[c,u]=S.useState(""),[d,f]=S.useState("all"),p=S.useRef(null),{data:g,isLoading:b,refetch:v}=lt({queryKey:["mqtt-logs",t],queryFn:()=>be.getMQTTLogs(t),refetchInterval:1e3}),x=ht({mutationFn:()=>be.enableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),y=ht({mutationFn:()=>be.disableMQTTLogging(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}}),E=ht({mutationFn:()=>be.clearMQTTLogs(t),onSuccess:()=>{r.invalidateQueries({queryKey:["mqtt-logs",t]})}});S.useEffect(()=>{const k=P=>{P.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[n]),S.useEffect(()=>{i&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[g?.logs,i]);const w=k=>{l(P=>{const z=new Set(P);return z.has(k)?z.delete(k):z.add(k),z})},A=k=>new Date(k).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),N=(k,P)=>{if(k==null)return"<empty>";const z=typeof k=="string"?JSON.parse(k):k,L=JSON.stringify(z,null,P?2:0);return!P&&L.length>100?L.substring(0,100)+"...":L},C=g?.logging_enabled??!1,T=S.useMemo(()=>g?.logs??[],[g?.logs]),D=S.useMemo(()=>T.filter(k=>{if(d!=="all"&&k.direction!==d)return!1;if(c.trim()){const P=c.toLowerCase(),z=k.topic.toLowerCase().includes(P),X=JSON.stringify(k.payload).toLowerCase().includes(P);return z||X}return!0}),[T,c,d]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"MQTT Debug Log"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[C?s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>y.mutate(),disabled:y.isPending,children:[s.jsx(Zc,{className:"w-4 h-4"}),"Stop"]}):s.jsxs(Ee,{size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[s.jsx(Yc,{className:"w-4 h-4"}),"Start Logging"]}),s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>E.mutate(),disabled:E.isPending||T.length===0,children:[s.jsx(ln,{className:"w-4 h-4"}),"Clear"]}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:b,children:s.jsx(Rr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:i,onChange:k=>a(k.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[D.length,"/",T.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Eo,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search topic or payload...",value:c,onChange:k=>u(k.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"}),c&&s.jsx("button",{onClick:()=>u(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>f("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),s.jsxs("button",{onClick:()=>f("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(Wb,{className:"w-3 h-3"}),"In"]}),s.jsxs("button",{onClick:()=>f("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(Up,{className:"w-3 h-3"}),"Out"]})]})]})]}),s.jsx("div",{ref:p,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages logged yet"}),!C&&s.jsx("p",{className:"text-sm",children:'Click "Start Logging" to begin capturing MQTT messages'})]}):D.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No messages match your filter"}),s.jsx("p",{className:"text-sm",children:"Try adjusting your search or filter criteria"})]}):s.jsx("div",{className:"space-y-1",children:D.map((k,P)=>{const z=o.has(P),L=k.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${z?"bg-bambu-dark-secondary":""}`,onClick:()=>w(P),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:A(k.timestamp)}),s.jsx("span",{className:`shrink-0 ${L?"text-blue-400":"text-green-400"}`,title:L?"Incoming":"Outgoing",children:L?s.jsx(Wb,{className:"w-3 h-3"}):s.jsx(Up,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:k.topic})]}),z?s.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:N(k.payload,!0)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:N(k.payload,!1)})]},P)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:C?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Logging active - messages will auto-refresh"]}):s.jsx("span",{children:"Logging stopped"})}),s.jsx(Ee,{variant:"secondary",onClick:n,children:"Close"})]})]})})}const Aj={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function Ihe(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:yn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:yn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:pa};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:jd}}}function Tj(t,e){const n=t>>16&65535||(t>>8&255)<<8|t&255,r=e&65535;return`${n.toString(16).padStart(4,"0").toUpperCase()}_${r.toString(16).padStart(4,"0").toUpperCase()}`}function Fhe(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=Tj(e.attr,n);return Aj[r]!==void 0})}function Uhe(){return"https://wiki.bambulab.com/en/hms/home"}function zhe({printerName:t,errors:e,onClose:n}){console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const r=e.filter(i=>{const a=parseInt(i.code.replace("0x",""),16)||0,o=Tj(i.attr,a);return Aj[o]!==void 0});return S.useEffect(()=>{const i=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yn,{className:"w-5 h-5 text-orange-400"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Errors - ",t]})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(pa,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:"No errors"})]}):s.jsx("div",{className:"space-y-3",children:r.map((i,a)=>{const{label:o,color:l,bgColor:c,Icon:u}=Ihe(i.severity),d=parseInt(i.code.replace("0x",""),16)||0,f=Tj(i.attr,d),p=Aj[f],g=Uhe(),b=f.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${c} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(u,{className:`w-5 h-5 ${l} flex-shrink-0 mt-0.5`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsxs("span",{className:`font-mono text-sm ${l}`,children:["[",b,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${c} ${l}`,children:o})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:p}),s.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-3 h-3"}),"View on Bambu Lab Wiki"]})]})]})},`${i.code}-${a}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:"Clear errors on the printer to dismiss them here."})})]})})}function Bhe(t){if(!t)return"ASAP";const e=fi(t);if(!e)return"ASAP";const n=new Date,r=e.getTime()-n.getTime();return r<0?"Now":r<6e4?"In <1 min":r<36e5?`In ${Math.round(r/6e4)} min`:r<864e5?`In ${Math.round(r/36e5)}h`:e.toLocaleDateString()}function $he({printerId:t}){const{data:e}=lt({queryKey:["queue",t,"pending"],queryFn:()=>be.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(Ts,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(qr,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),s.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),Bhe(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(Bs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function EW(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=EW(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function On(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=EW(t))&&(r&&(r+=" "),r+=e);return r}var Hhe=["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 FR(t){if(typeof t!="string")return!1;var e=Hhe;return e.includes(t)}var Vhe=["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"],Ghe=new Set(Vhe);function NW(t){return typeof t!="string"?!1:Ghe.has(t)}function AW(t){return typeof t=="string"&&t.startsWith("data-")}function Ha(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(NW(n)||AW(n))&&(e[n]=t[n]);return e}function yf(t){if(t==null)return null;if(S.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return Ha(e)}return typeof t=="object"&&!Array.isArray(t)?Ha(t):null}function ga(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(NW(n)||AW(n)||FR(n))&&(e[n]=t[n]);return e}function Whe(t){return t==null?null:S.isValidElement(t)?ga(t.props):typeof t=="object"&&!Array.isArray(t)?ga(t):null}var qhe=["children","width","height","viewBox","className","style","title","desc"];function Cj(){return Cj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cj.apply(null,arguments)}function Khe(t,e){if(t==null)return{};var n,r,i=Xhe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Xhe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var UR=S.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=Khe(t,qhe),f=a||{width:r,height:i,x:0,y:0},p=On("recharts-surface",o);return S.createElement("svg",Cj({},ga(d),{className:p,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),S.createElement("title",null,c),S.createElement("desc",null,u),n)}),Yhe=["children","className"];function kj(){return kj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},kj.apply(null,arguments)}function Qhe(t,e){if(t==null)return{};var n,r,i=Zhe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Zhe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Or=S.forwardRef((t,e)=>{var{children:n,className:r}=t,i=Qhe(t,Yhe),a=On("recharts-layer",r);return S.createElement("g",kj({className:a},ga(i),{ref:e}),n)}),TW=S.createContext(null),Jhe=()=>S.useContext(TW);function yr(t){return function(){return t}}const CW=Math.cos,ow=Math.sin,rl=Math.sqrt,lw=Math.PI,T2=2*lw,jj=Math.PI,Pj=2*jj,Ah=1e-6,efe=Pj-Ah;function kW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function tfe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return kW;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class nfe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?kW:tfe(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,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,p=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>Ah)if(!(Math.abs(f*c-u*d)>Ah)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let g=r-o,b=i-l,v=c*c+u*u,x=g*g+b*b,y=Math.sqrt(v),E=Math.sqrt(p),w=a*Math.tan((jj-Math.acos((v+p-x)/(2*y*E)))/2),A=w/E,N=w/y;Math.abs(A-1)>Ah&&this._append`L${e+A*d},${n+A*f}`,this._append`A${a},${a},0,0,${+(f*g>d*b)},${this._x1=e+N*c},${this._y1=n+N*u}`}}arc(e,n,r,i,a,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,p=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Ah||Math.abs(this._y1-d)>Ah)&&this._append`L${u},${d}`,r&&(p<0&&(p=p%Pj+Pj),p>efe?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:p>Ah&&this._append`A${r},${r},0,${+(p>=jj)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function zR(t){let e=3;return t.digits=function(n){if(!arguments.length)return e;if(n==null)e=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);e=r}return t},()=>new nfe(e)}function BR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function jW(t){this._context=t}jW.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 C2(t){return new jW(t)}function PW(t){return t[0]}function RW(t){return t[1]}function DW(t,e){var n=yr(!0),r=null,i=C2,a=null,o=zR(l);t=typeof t=="function"?t:t===void 0?PW:yr(t),e=typeof e=="function"?e:e===void 0?RW:yr(e);function l(c){var u,d=(c=BR(c)).length,f,p=!1,g;for(r==null&&(a=i(g=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===p&&((p=!p)?a.lineStart():a.lineEnd()),p&&a.point(+t(f,u,c),+e(f,u,c));if(g)return a=null,g+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:yr(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:yr(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:yr(!!c),l):n},l.curve=function(c){return arguments.length?(i=c,r!=null&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function Hv(t,e,n){var r=null,i=yr(!0),a=null,o=C2,l=null,c=zR(u);t=typeof t=="function"?t:t===void 0?PW:yr(+t),e=typeof e=="function"?e:yr(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?RW:yr(+n);function u(f){var p,g,b,v=(f=BR(f)).length,x,y=!1,E,w=new Array(v),A=new Array(v);for(a==null&&(l=o(E=c())),p=0;p<=v;++p){if(!(p<v&&i(x=f[p],p,f))===y)if(y=!y)g=p,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),b=p-1;b>=g;--b)l.point(w[b],A[b]);l.lineEnd(),l.areaEnd()}y&&(w[p]=+t(x,p,f),A[p]=+e(x,p,f),l.point(r?+r(x,p,f):w[p],n?+n(x,p,f):A[p]))}if(E)return l=null,E+""||null}function d(){return DW().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:yr(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:yr(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:yr(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:yr(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:yr(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:yr(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:yr(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),u):o},u.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),u):a},u}class OW{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 rfe(t){return new OW(t,!0)}function ife(t){return new OW(t,!1)}const $R={draw(t,e){const n=rl(e/lw);t.moveTo(n,0),t.arc(0,0,n,0,T2)}},afe={draw(t,e){const n=rl(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()}},LW=rl(1/3),sfe=LW*2,ofe={draw(t,e){const n=rl(e/sfe),r=n*LW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},lfe={draw(t,e){const n=rl(e),r=-n/2;t.rect(r,r,n,n)}},cfe=.8908130915292852,IW=ow(lw/10)/ow(7*lw/10),ufe=ow(T2/10)*IW,dfe=-CW(T2/10)*IW,hfe={draw(t,e){const n=rl(e*cfe),r=ufe*n,i=dfe*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=T2*a/5,l=CW(o),c=ow(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},bA=rl(3),ffe={draw(t,e){const n=-rl(e/(bA*3));t.moveTo(0,n*2),t.lineTo(-bA*n,-n),t.lineTo(bA*n,-n),t.closePath()}},eo=-.5,to=rl(3)/2,Rj=1/rl(12),mfe=(Rj/2+1)*3,pfe={draw(t,e){const n=rl(e/mfe),r=n/2,i=n*Rj,a=r,o=n*Rj+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(eo*r-to*i,to*r+eo*i),t.lineTo(eo*a-to*o,to*a+eo*o),t.lineTo(eo*l-to*c,to*l+eo*c),t.lineTo(eo*r+to*i,eo*i-to*r),t.lineTo(eo*a+to*o,eo*o-to*a),t.lineTo(eo*l+to*c,eo*c-to*l),t.closePath()}};function gfe(t,e){let n=null,r=zR(i);t=typeof t=="function"?t:yr(t||$R),e=typeof e=="function"?e:yr(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:yr(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:yr(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function cw(){}function uw(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 FW(t){this._context=t}FW.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:uw(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:uw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function xfe(t){return new FW(t)}function UW(t){this._context=t}UW.prototype={areaStart:cw,areaEnd:cw,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:uw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function bfe(t){return new UW(t)}function zW(t){this._context=t}zW.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,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:uw(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function yfe(t){return new zW(t)}function BW(t){this._context=t}BW.prototype={areaStart:cw,areaEnd:cw,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 vfe(t){return new BW(t)}function qU(t){return t<0?-1:1}function KU(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(qU(a)+qU(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function XU(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function yA(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,o-l*n,a,o)}function dw(t){this._context=t}dw.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:yA(this,this._t0,XU(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,yA(this,XU(this,n=KU(this,t,e)),n);break;default:yA(this,this._t0,n=KU(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function $W(t){this._context=new HW(t)}($W.prototype=Object.create(dw.prototype)).point=function(t,e){dw.prototype.point.call(this,e,t)};function HW(t){this._context=t}HW.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,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function _fe(t){return new dw(t)}function wfe(t){return new $W(t)}function VW(t){this._context=t}VW.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 r=YU(t),i=YU(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],t[o],e[o]);(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 YU(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function Sfe(t){return new VW(t)}function k2(t,e){this._context=t,this._t=e}k2.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 Mfe(t){return new k2(t,.5)}function Efe(t){return new k2(t,0)}function Nfe(t){return new k2(t,1)}function Gp(t,e){if((o=t.length)>1)for(var n=1,r,i,a=t[e[0]],o,l=a.length;n<o;++n)for(i=a,a=t[e[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Dj(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function Afe(t,e){return t[e]}function Tfe(t){const e=[];return e.key=t,e}function Cfe(){var t=yr([]),e=Dj,n=Gp,r=Afe;function i(a){var o=Array.from(t.apply(this,arguments),Tfe),l,c=o.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,a)]).data=f;for(l=0,d=BR(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:yr(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:yr(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?Dj:typeof a=="function"?a:yr(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??Gp,i):n},i}function kfe(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=t[n][i][1]||0;if(o)for(n=0;n<r;++n)t[n][i][1]/=o}Gp(t,e)}}function jfe(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}Gp(t,e)}}function Pfe(t,e){if(!(!((o=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,p=d[r-1][1]||0,g=(f-p)/2,b=0;b<l;++b){var v=t[e[b]],x=v[r][1]||0,y=v[r-1][1]||0;g+=x-y}c+=f,u+=g*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,Gp(t,e)}}var vA={},_A={},QU;function Rfe(){return QU||(QU=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(_A)),_A}var wA={},ZU;function GW(){return ZU||(ZU=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})(wA)),wA}var SA={},JU;function HR(){return JU||(JU=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})(SA)),SA}var MA={},EA={},ez;function Dfe(){return ez||(ez=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 r=String(n);return r==="0"&&Object.is(Number(n),-0)?"-0":r}t.toString=e})(EA)),EA}var tz;function VR(){return tz||(tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Dfe(),n=HR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(MA)),MA}var nz;function GR(){return nz||(nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rfe(),n=GW(),r=HR(),i=VR();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(vA)),vA}var NA,rz;function Ofe(){return rz||(rz=1,NA=GR().get),NA}var Lfe=Ofe();const vf=Co(Lfe);var Ki=t=>t===0?0:t>0?1:-1,hs=t=>typeof t=="number"&&t!=+t,Jc=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Ot=t=>(typeof t=="number"||t instanceof Number)&&!hs(t),No=t=>Ot(t)||typeof t=="string",Ife=0,Qb=t=>{var e=++Ife;return"".concat(t||"").concat(e)},Ta=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Ot(e)&&typeof e!="string")return r;var a;if(Jc(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return hs(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},WW=t=>{if(!Array.isArray(t))return!1;for(var e=t.length,n={},r=0;r<e;r++)if(!n[t[r]])n[t[r]]=!0;else return!0;return!1};function Gn(t,e,n){return Ot(t)&&Ot(e)?t+n*(e-t):e}function qW(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):vf(r,e))===n)}var Nr=t=>t===null||typeof t>"u",V0=t=>Nr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function Ffe(t){return t!=null}function G0(){}var Ufe=["type","size","sizeType"];function Oj(){return Oj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Oj.apply(null,arguments)}function iz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function az(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?iz(Object(n),!0).forEach(function(r){zfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):iz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zfe(t,e,n){return(e=Bfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bfe(t){var e=$fe(t,"string");return typeof e=="symbol"?e:e+""}function $fe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Hfe(t,e){if(t==null)return{};var n,r,i=Vfe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Vfe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var KW={symbolCircle:$R,symbolCross:afe,symbolDiamond:ofe,symbolSquare:lfe,symbolStar:hfe,symbolTriangle:ffe,symbolWye:pfe},Gfe=Math.PI/180,Wfe=t=>{var e="symbol".concat(V0(t));return KW[e]||$R},qfe=(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 r=18*Gfe;return 1.25*t*t*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**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}},Kfe=(t,e)=>{KW["symbol".concat(V0(t))]=e},WR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=Hfe(t,Ufe),a=az(az({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var p=Wfe(o),g=gfe().type(p).size(qfe(n,r,o)),b=g();if(b!==null)return b},{className:c,cx:u,cy:d}=a,f=ga(a);return Ot(u)&&Ot(d)&&Ot(n)?S.createElement("path",Oj({},f,{className:On("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};WR.registerSymbol=Kfe;var XW=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,qR=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(S.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{FR(i)&&(r[i]=(a=>n[i](n,a)))}),r},Xfe=(t,e,n)=>r=>(t(e,n,r),null),W0=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];FR(i)&&typeof a=="function"&&(r||(r={}),r[i]=Xfe(a,e,n))}),r};function sz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Yfe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sz(Object(n),!0).forEach(function(r){Qfe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Qfe(t,e,n){return(e=Zfe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Zfe(t){var e=Jfe(t,"string");return typeof e=="symbol"?e:e+""}function Jfe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Lr(t,e){var n=Yfe({},t),r=e,i=Object.keys(e),a=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return a}function hw(){return hw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},hw.apply(null,arguments)}function oz(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eme(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oz(Object(n),!0).forEach(function(r){tme(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oz(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tme(t,e,n){return(e=nme(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nme(t){var e=rme(t,"string");return typeof e=="symbol"?e:e+""}function rme(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var so=32,ime={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function ame(t){var{data:e,iconType:n,inactiveColor:r}=t,i=so/2,a=so/6,o=so/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return S.createElement("line",{strokeWidth:4,fill:"none",stroke:l,strokeDasharray:(u=e.payload)===null||u===void 0?void 0:u.strokeDasharray,x1:0,y1:i,x2:so,y2:i,className:"recharts-legend-icon"})}if(c==="line")return S.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(so,"M").concat(2*o,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return S.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(so/8,"h").concat(so,"v").concat(so*3/4,"h").concat(-so,"z"),className:"recharts-legend-icon"});if(S.isValidElement(e.legendIcon)){var d=eme({},e);return delete d.legendIcon,S.cloneElement(e.legendIcon,d)}return S.createElement(WR,{fill:l,cx:i,cy:i,size:so,sizeType:"diameter",type:c})}function sme(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:so,height:so},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var p=d.formatter||i,g=On({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var b=d.inactive?a:d.color,v=p?p(d.value,d,f):d.value;return S.createElement("li",hw({className:g,style:c,key:"legend-item-".concat(f)},W0(t,d,f)),S.createElement(UR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(v," legend icon")},S.createElement(ame,{data:d,iconType:o,inactiveColor:a})),S.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},v))})}var ome=t=>{var e=Lr(t,ime),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return S.createElement("ul",{className:"recharts-default-legend",style:a},S.createElement(sme,hw({},e,{payload:n})))},AA={},TA={},lz;function lme(){return lz||(lz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(TA)),TA}var CA={},cz;function YW(){return cz||(cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(CA)),CA}var kA={},jA={},PA={},uz;function cme(){return uz||(uz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(PA)),PA}var dz;function KR(){return dz||(dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cme();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(jA)),jA}var RA={},hz;function ume(){return hz||(hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(RA)),RA}var fz;function dme(){return fz||(fz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=KR(),n=ume();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(kA)),kA}var DA={},OA={},mz;function hme(){return mz||(mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(OA)),OA}var LA={},IA={},FA={},UA={},pz;function QW(){return pz||(pz=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})(UA)),UA}var zA={},gz;function ZW(){return gz||(gz=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})(zA)),zA}var BA={},xz;function JW(){return xz||(xz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){return n===r||Number.isNaN(n)&&Number.isNaN(r)}t.eq=e})(BA)),BA}var bz;function fme(){return bz||(bz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QW(),n=ZW(),r=JW();function i(d,f,p){return typeof p!="function"?i(d,f,()=>{}):a(d,f,function g(b,v,x,y,E,w){const A=p(b,v,x,y,E,w);return A!==void 0?!!A:a(b,v,g,w)},new Map)}function a(d,f,p,g){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,p,g);case"function":return Object.keys(f).length>0?a(d,{...f},p,g):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,p,g){if(f==null)return!0;if(Array.isArray(f))return c(d,f,p,g);if(f instanceof Map)return l(d,f,p,g);if(f instanceof Set)return u(d,f,p,g);const b=Object.keys(f);if(d==null)return b.length===0;if(b.length===0)return!0;if(g?.has(f))return g.get(f)===d;g?.set(f,d);try{for(let v=0;v<b.length;v++){const x=b[v];if(!n.isPrimitive(d)&&!(x in d)||f[x]===void 0&&d[x]!==void 0||f[x]===null&&d[x]!==null||!p(d[x],f[x],x,d,f,g))return!1}return!0}finally{g?.delete(f)}}function l(d,f,p,g){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[b,v]of f.entries()){const x=d.get(b);if(p(x,v,b,d,f,g)===!1)return!1}return!0}function c(d,f,p,g){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const b=new Set;for(let v=0;v<f.length;v++){const x=f[v];let y=!1;for(let E=0;E<d.length;E++){if(b.has(E))continue;const w=d[E];let A=!1;if(p(w,x,v,d,f,g)&&(A=!0),A){b.add(E),y=!0;break}}if(!y)return!1}return!0}function u(d,f,p,g){return f.size===0?!0:d instanceof Set?c([...d],[...f],p,g):!1}t.isMatchWith=i,t.isSetMatch=u})(FA)),FA}var yz;function eq(){return yz||(yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=fme();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(IA)),IA}var $A={},HA={},VA={},vz;function mme(){return vz||(vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Object.getOwnPropertySymbols(n).filter(r=>Object.prototype.propertyIsEnumerable.call(n,r))}t.getSymbols=e})(VA)),VA}var GA={},_z;function tq(){return _z||(_z=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})(GA)),GA}var WA={},wz;function nq(){return wz||(wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",p="[object ArrayBuffer]",g="[object Object]",b="[object Error]",v="[object DataView]",x="[object Uint8Array]",y="[object Uint8ClampedArray]",E="[object Uint16Array]",w="[object Uint32Array]",A="[object BigUint64Array]",N="[object Int8Array]",C="[object Int16Array]",T="[object Int32Array]",D="[object BigInt64Array]",k="[object Float32Array]",P="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=D,t.bigUint64ArrayTag=A,t.booleanTag=i,t.dataViewTag=v,t.dateTag=l,t.errorTag=b,t.float32ArrayTag=k,t.float64ArrayTag=P,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=T,t.int8ArrayTag=N,t.mapTag=c,t.numberTag=r,t.objectTag=g,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=E,t.uint32ArrayTag=w,t.uint8ArrayTag=x,t.uint8ClampedArrayTag=y})(WA)),WA}var qA={},Sz;function pme(){return Sz||(Sz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(qA)),qA}var Mz;function rq(){return Mz||(Mz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=mme(),n=tq(),r=nq(),i=ZW(),a=pme();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,p,g=new Map,b=void 0){const v=b?.(d,f,p,g);if(v!==void 0)return v;if(i.isPrimitive(d))return d;if(g.has(d))return g.get(d);if(Array.isArray(d)){const x=new Array(d.length);g.set(d,x);for(let y=0;y<d.length;y++)x[y]=l(d[y],y,p,g,b);return Object.hasOwn(d,"index")&&(x.index=d.index),Object.hasOwn(d,"input")&&(x.input=d.input),x}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const x=new RegExp(d.source,d.flags);return x.lastIndex=d.lastIndex,x}if(d instanceof Map){const x=new Map;g.set(d,x);for(const[y,E]of d)x.set(y,l(E,y,p,g,b));return x}if(d instanceof Set){const x=new Set;g.set(d,x);for(const y of d)x.add(l(y,void 0,p,g,b));return x}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const x=new(Object.getPrototypeOf(d)).constructor(d.length);g.set(d,x);for(let y=0;y<d.length;y++)x[y]=l(d[y],y,p,g,b);return x}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const x=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return g.set(d,x),c(x,d,p,g,b),x}if(typeof File<"u"&&d instanceof File){const x=new File([d],d.name,{type:d.type});return g.set(d,x),c(x,d,p,g,b),x}if(typeof Blob<"u"&&d instanceof Blob){const x=new Blob([d],{type:d.type});return g.set(d,x),c(x,d,p,g,b),x}if(d instanceof Error){const x=new d.constructor;return g.set(d,x),x.message=d.message,x.name=d.name,x.stack=d.stack,x.cause=d.cause,c(x,d,p,g,b),x}if(d instanceof Boolean){const x=new Boolean(d.valueOf());return g.set(d,x),c(x,d,p,g,b),x}if(d instanceof Number){const x=new Number(d.valueOf());return g.set(d,x),c(x,d,p,g,b),x}if(d instanceof String){const x=new String(d.valueOf());return g.set(d,x),c(x,d,p,g,b),x}if(typeof d=="object"&&u(d)){const x=Object.create(Object.getPrototypeOf(d));return g.set(d,x),c(x,d,p,g,b),x}return d}function c(d,f,p=d,g,b){const v=[...Object.keys(f),...e.getSymbols(f)];for(let x=0;x<v.length;x++){const y=v[x],E=Object.getOwnPropertyDescriptor(d,y);(E==null||E.writable)&&(d[y]=l(f[y],y,p,g,b))}}function u(d){switch(n.getTag(d)){case r.argumentsTag:case r.arrayTag:case r.arrayBufferTag:case r.dataViewTag:case r.booleanTag:case r.dateTag:case r.float32ArrayTag:case r.float64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.mapTag:case r.numberTag:case r.objectTag:case r.regexpTag:case r.setTag:case r.stringTag:case r.symbolTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:return!0;default:return!1}}t.cloneDeepWith=o,t.cloneDeepWithImpl=l,t.copyProperties=c})(HA)),HA}var Ez;function gme(){return Ez||(Ez=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rq();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})($A)),$A}var Nz;function xme(){return Nz||(Nz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eq(),n=gme();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(LA)),LA}var KA={},XA={},YA={},Az;function bme(){return Az||(Az=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=rq(),n=nq();function r(i,a){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=a?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(YA)),YA}var Tz;function yme(){return Tz||(Tz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bme();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(XA)),XA}var QA={},ZA={},Cz;function iq(){return Cz||(Cz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return e.test(r)}}t.isIndex=n})(ZA)),ZA}var JA={},kz;function vme(){return kz||(kz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=tq();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(JA)),JA}var jz;function _me(){return jz||(jz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GW(),n=iq(),r=vme(),i=VR();function a(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(QA)),QA}var Pz;function wme(){return Pz||(Pz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=eq(),n=HR(),r=yme(),i=GR(),a=_me();function o(l,c){switch(typeof l){case"object":{Object.is(l?.valueOf(),-0)&&(l="-0");break}case"number":{l=n.toKey(l);break}}return c=r.cloneDeep(c),function(u){const d=i.get(u,l);return d===void 0?a.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(KA)),KA}var Rz;function Sme(){return Rz||(Rz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=YW(),n=hme(),r=xme(),i=wme();function a(o){if(o==null)return e.identity;switch(typeof o){case"function":return o;case"object":return Array.isArray(o)&&o.length===2?i.matchesProperty(o[0],o[1]):r.matches(o);case"string":case"symbol":case"number":return n.property(o)}}t.iteratee=a})(DA)),DA}var Dz;function Mme(){return Dz||(Dz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lme(),n=YW(),r=dme(),i=Sme();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})(AA)),AA}var eT,Oz;function Eme(){return Oz||(Oz=1,eT=Mme().uniqBy),eT}var Nme=Eme();const Lz=Co(Nme);function aq(t,e,n){return e===!0?Lz(t,n):typeof e=="function"?Lz(t,e):t}var tT={exports:{}},nT={};var Iz;function Ame(){if(Iz)return nT;Iz=1;var t=gg(),e=NG();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return nT.useSyncExternalStoreWithSelector=function(u,d,f,p,g){var b=a(null);if(b.current===null){var v={hasValue:!1,value:null};b.current=v}else v=b.current;b=l(function(){function y(C){if(!E){if(E=!0,w=C,C=p(C),g!==void 0&&v.hasValue){var T=v.value;if(g(T,C))return A=T}return A=C}if(T=A,r(w,C))return T;var D=p(C);return g!==void 0&&g(T,D)?(w=C,T):(w=C,A=D)}var E=!1,w,A,N=f===void 0?null:f;return[function(){return y(d())},N===null?void 0:function(){return y(N())}]},[d,f,p,g]);var x=i(u,b[0],b[1]);return o(function(){v.hasValue=!0,v.value=x},[x]),c(x),x},nT}var Fz;function Tme(){return Fz||(Fz=1,tT.exports=Ame()),tT.exports}var sq=Tme(),XR=S.createContext(null),Cme=t=>t,br=()=>{var t=S.useContext(XR);return t?t.store.dispatch:Cme},T1=()=>{},kme=()=>T1,jme=(t,e)=>t===e;function Pt(t){var e=S.useContext(XR);return sq.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:kme,e?e.store.getState:T1,e?e.store.getState:T1,e?t:T1,jme)}function Pme(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Rme(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function Dme(t,e="expected all items to be functions, instead received the following types: "){if(!t.every(n=>typeof n=="function")){const n=t.map(r=>typeof r=="function"?`function ${r.name||"unnamed"}()`:typeof r).join(", ");throw new TypeError(`${e}[${n}]`)}}var Uz=t=>Array.isArray(t)?t:[t];function Ome(t){const e=Array.isArray(t[0])?t[0]:t;return Dme(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function Lme(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Ime=class{constructor(t){this.value=t}deref(){return this.value}},Fme=typeof WeakRef<"u"?WeakRef:Ime,Ume=0,zz=1;function Vv(){return{s:Ume,v:void 0,o:null,p:null}}function oq(t,e={}){let n=Vv();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,p=c;f<p;f++){const g=arguments[f];if(typeof g=="function"||typeof g=="object"&&g!==null){let b=l.o;b===null&&(l.o=b=new WeakMap);const v=b.get(g);v===void 0?(l=Vv(),b.set(g,l)):l=v}else{let b=l.p;b===null&&(l.p=b=new Map);const v=b.get(g);v===void 0?(l=Vv(),b.set(g,l)):l=v}}const u=l;let d;if(l.s===zz)d=l.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new Fme(d):d}return u.s=zz,u.v=d,d}return o.clearCache=()=>{n=Vv(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function zme(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Pme(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:p=[],argsMemoize:g=oq,argsMemoizeOptions:b=[]}=d,v=Uz(p),x=Uz(b),y=Ome(i),E=f(function(){return a++,u.apply(null,arguments)},...v),w=g(function(){o++;const N=Lme(y,arguments);return l=E.apply(null,N),l},...x);return Object.assign(w,{resultFunc:u,memoizedResultFunc:E,dependencies:y,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:g})};return Object.assign(r,{withTypes:()=>r}),r}var Ze=zme(oq),Bme=Object.assign((t,e=Ze)=>{Rme(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),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>Bme}),rT={},iT={},aT={},Bz;function $me(){return Bz||(Bz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-o:o-l}return 0};t.compareValues=n})(aT)),aT}var sT={},oT={},$z;function lq(){return $z||($z=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(oT)),oT}var Hz;function Hme(){return Hz||(Hz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lq(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}t.isKey=i})(sT)),sT}var Vz;function Vme(){return Vz||(Vz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$me(),n=Hme(),r=VR();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),Array.isArray(o)||(o=o==null?[null]:[o]),o.length===0&&(o=[null]),Array.isArray(l)||(l=l==null?[]:[l]),l=l.map(g=>String(g));const u=(g,b)=>{let v=g;for(let x=0;x<b.length&&v!=null;++x)v=v[b[x]];return v},d=(g,b)=>b==null||g==null?b:typeof g=="object"&&"key"in g?Object.hasOwn(b,g.key)?b[g.key]:u(b,g.path):typeof g=="function"?g(b):Array.isArray(g)?u(b,g):typeof b=="object"?b[g]:b,f=o.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:r.toPath(g)}));return a.map(g=>({original:g,criteria:f.map(b=>d(b,g))})).slice().sort((g,b)=>{for(let v=0;v<f.length;v++){const x=e.compareValues(g.criteria[v],b.criteria[v],l[v]);if(x!==0)return x}return 0}).map(g=>g.original)}t.orderBy=i})(iT)),iT}var lT={},Gz;function Gme(){return Gz||(Gz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(lT)),lT}var cT={},Wz;function cq(){return Wz||(Wz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=iq(),n=KR(),r=QW(),i=JW();function a(o,l,c){return r.isObject(c)&&(typeof l=="number"&&n.isArrayLike(c)&&e.isIndex(l)&&l<c.length||typeof l=="string"&&l in c)?i.eq(c[l],o):!1}t.isIterateeCall=a})(cT)),cT}var qz;function Wme(){return qz||(qz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Vme(),n=Gme(),r=cq();function i(a,...o){const l=o.length;return l>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(a,n.flatten(o),["asc"])}t.sortBy=i})(rT)),rT}var uT,Kz;function qme(){return Kz||(Kz=1,uT=Wme().sortBy),uT}var Kme=qme();const j2=Co(Kme);var uq=t=>t.legend.settings,Xme=t=>t.legend.size,Yme=t=>t.legend.payload,Qme=Ze([Yme,uq],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?j2(r,n):r});function Zme(){return Pt(Qme)}var Gv=1;function dq(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=S.useState({height:0,left:0,top:0,width:0}),r=S.useCallback(i=>{if(i!=null){var a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>Gv||Math.abs(o.left-e.left)>Gv||Math.abs(o.top-e.top)>Gv||Math.abs(o.width-e.width)>Gv)&&n({height:o.height,left:o.left,top:o.top,width:o.width})}},[e.width,e.height,e.top,e.left,...t]);return[e,r]}function oa(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 Jme=typeof Symbol=="function"&&Symbol.observable||"@@observable",Xz=Jme,dT=()=>Math.random().toString(36).substring(7).split("").join("."),epe={INIT:`@@redux/INIT${dT()}`,REPLACE:`@@redux/REPLACE${dT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${dT()}`},fw=epe;function YR(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 hq(t,e,n){if(typeof t!="function")throw new Error(oa(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(oa(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(oa(1));return n(hq)(t,e)}let r=t,i=e,a=new Map,o=a,l=0,c=!1;function u(){o===a&&(o=new Map,a.forEach((x,y)=>{o.set(y,x)}))}function d(){if(c)throw new Error(oa(3));return i}function f(x){if(typeof x!="function")throw new Error(oa(4));if(c)throw new Error(oa(5));let y=!0;u();const E=l++;return o.set(E,x),function(){if(y){if(c)throw new Error(oa(6));y=!1,u(),o.delete(E),a=null}}}function p(x){if(!YR(x))throw new Error(oa(7));if(typeof x.type>"u")throw new Error(oa(8));if(typeof x.type!="string")throw new Error(oa(17));if(c)throw new Error(oa(9));try{c=!0,i=r(i,x)}finally{c=!1}return(a=o).forEach(E=>{E()}),x}function g(x){if(typeof x!="function")throw new Error(oa(10));r=x,p({type:fw.REPLACE})}function b(){const x=f;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(oa(11));function E(){const A=y;A.next&&A.next(d())}return E(),{unsubscribe:x(E)}},[Xz](){return this}}}return p({type:fw.INIT}),{dispatch:p,subscribe:f,getState:d,replaceReducer:g,[Xz]:b}}function tpe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:fw.INIT})>"u")throw new Error(oa(12));if(typeof n(void 0,{type:fw.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(oa(13))})}function fq(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const o=e[a];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{tpe(n)}catch(a){i=a}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],p=n[f],g=o[f],b=p(g,l);if(typeof b>"u")throw l&&l.type,new Error(oa(14));u[f]=b,c=c||b!==g}return c=c||r.length!==Object.keys(o).length,c?u:o}}function mw(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function npe(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(oa(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=mw(...l)(i.dispatch),{...i,dispatch:a}}}function mq(t){return YR(t)&&"type"in t&&typeof t.type=="string"}var pq=Symbol.for("immer-nothing"),Yz=Symbol.for("immer-draftable"),Va=Symbol.for("immer-state");function $o(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Ds=Object,Wp=Ds.getPrototypeOf,pw="constructor",P2="prototype",Lj="configurable",gw="enumerable",C1="writable",Zb="value",eu=t=>!!t&&!!t[Va];function el(t){return t?gq(t)||R2(t)||!!t[Yz]||!!t[pw]?.[Yz]||D2(t)||O2(t):!1}var rpe=Ds[P2][pw].toString(),Qz=new WeakMap;function gq(t){if(!t||!QR(t))return!1;const e=Wp(t);if(e===null||e===Ds[P2])return!0;const n=Ds.hasOwnProperty.call(e,pw)&&e[pw];if(n===Object)return!0;if(!hp(n))return!1;let r=Qz.get(n);return r===void 0&&(r=Function.toString.call(n),Qz.set(n,r)),r===rpe}function q0(t,e,n=!0){K0(t)===0?(n?Reflect.ownKeys(t):Ds.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function K0(t){const e=t[Va];return e?e.type_:R2(t)?1:D2(t)?2:O2(t)?3:0}var Zz=(t,e,n=K0(t))=>n===2?t.has(e):Ds[P2].hasOwnProperty.call(t,e),Ij=(t,e,n=K0(t))=>n===2?t.get(e):t[e],xw=(t,e,n,r=K0(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function ipe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var R2=Array.isArray,D2=t=>t instanceof Map,O2=t=>t instanceof Set,QR=t=>typeof t=="object",hp=t=>typeof t=="function",hT=t=>typeof t=="boolean",Ac=t=>t.copy_||t.base_,ZR=t=>t.modified_?t.copy_:t.base_;function Fj(t,e){if(D2(t))return new Map(t);if(O2(t))return new Set(t);if(R2(t))return Array[P2].slice.call(t);const n=gq(t);if(e===!0||e==="class_only"&&!n){const r=Ds.getOwnPropertyDescriptors(t);delete r[Va];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[C1]===!1&&(l[C1]=!0,l[Lj]=!0),(l.get||l.set)&&(r[o]={[Lj]:!0,[C1]:!0,[gw]:l[gw],[Zb]:t[o]})}return Ds.create(Wp(t),r)}else{const r=Wp(t);if(r!==null&&n)return{...t};const i=Ds.create(r);return Ds.assign(i,t)}}function JR(t,e=!1){return L2(t)||eu(t)||!el(t)||(K0(t)>1&&Ds.defineProperties(t,{set:Wv,add:Wv,clear:Wv,delete:Wv}),Ds.freeze(t),e&&q0(t,(n,r)=>{JR(r,!0)},!1)),t}function ape(){$o(2)}var Wv={[Zb]:ape};function L2(t){return t===null||!QR(t)?!0:Ds.isFrozen(t)}var bw="MapSet",Uj="Patches",xq={};function qp(t){const e=xq[t];return e||$o(0,t),e}var spe=t=>!!xq[t],Jb,bq=()=>Jb,ope=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:spe(bw)?qp(bw):void 0});function Jz(t,e){e&&(t.patchPlugin_=qp(Uj),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function zj(t){Bj(t),t.drafts_.forEach(lpe),t.drafts_=null}function Bj(t){t===Jb&&(Jb=t.parent_)}var eB=t=>Jb=ope(Jb,t);function lpe(t){const e=t[Va];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function tB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[Va].modified_&&(zj(e),$o(4)),el(t)&&(t=nB(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[Va].base_,t,e)}else t=nB(e,n);return cpe(e,t,!0),zj(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==pq?t:void 0}function nB(t,e){if(L2(e))return e;const n=e[Va];if(!n)return eD(e,t.handledSet_,t);if(!I2(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);_q(n,t)}return n.copy_}function cpe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&JR(e,n)}function yq(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var I2=(t,e)=>t.scope_===e,upe=[];function vq(t,e,n,r){const i=Ac(t),a=t.type_;if(r!==void 0&&Ij(i,r,a)===e){xw(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;q0(i,(c,u)=>{if(eu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??upe;for(const l of o)xw(i,l,n,a)}function dpe(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!I2(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=ZR(a);vq(t,a.draft_??a,o,n),_q(a,i)})}function _q(t,e){if(t.modified_&&!t.finalized_&&(t.type_===3||(t.assigned_?.size??0)>0)){const{patchPlugin_:r}=e;if(r){const i=r.getPath(t);i&&r.generatePatches_(t,i,e)}yq(t)}}function hpe(t,e,n){const{scope_:r}=t;if(eu(n)){const i=n[Va];I2(i,r)&&i.callbacks_.push(function(){k1(t);const o=ZR(i);vq(t,n,o,e)})}else el(n)&&t.callbacks_.push(function(){const a=Ac(t);Ij(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&eD(Ij(t.copy_,e,t.type_),r.handledSet_,r)})}function eD(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||eu(t)||e.has(t)||!el(t)||L2(t)||(e.add(t),q0(t,(r,i)=>{if(eu(i)){const a=i[Va];if(I2(a,n)){const o=ZR(a);xw(t,r,o,t.type_),yq(a)}}else el(i)&&eD(i,e,n)})),t}function fpe(t,e){const n=R2(t),r={type_:n?1:0,scope_:e?e.scope_:bq(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=tD;n&&(i=[r],a=e0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var tD={get(t,e){if(e===Va)return t;const n=Ac(t);if(!Zz(n,e,t.type_))return mpe(t,n,e);const r=n[e];if(t.finalized_||!el(r))return r;if(r===fT(t.base_,e)){k1(t);const i=t.type_===1?+e:e,a=Hj(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in Ac(t)},ownKeys(t){return Reflect.ownKeys(Ac(t))},set(t,e,n){const r=wq(Ac(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=fT(Ac(t),e),a=i?.[Va];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(ipe(n,i)&&(n!==void 0||Zz(t.base_,e,t.type_)))return!0;k1(t),$j(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),hpe(t,e,n)),!0},deleteProperty(t,e){return k1(t),fT(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),$j(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ac(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[C1]:!0,[Lj]:t.type_!==1||e!=="length",[gw]:r[gw],[Zb]:n[e]}},defineProperty(){$o(11)},getPrototypeOf(t){return Wp(t.base_)},setPrototypeOf(){$o(12)}},e0={};q0(tD,(t,e)=>{e0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});e0.deleteProperty=function(t,e){return e0.set.call(this,t,e,void 0)};e0.set=function(t,e,n){return tD.set.call(this,t[0],e,n,t[0])};function fT(t,e){const n=t[Va];return(n?Ac(n):t)[e]}function mpe(t,e,n){const r=wq(e,n);return r?Zb in r?r[Zb]:r.get?.call(t.draft_):void 0}function wq(t,e){if(!(e in t))return;let n=Wp(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Wp(n)}}function $j(t){t.modified_||(t.modified_=!0,t.parent_&&$j(t.parent_))}function k1(t){t.copy_||(t.assigned_=new Map,t.copy_=Fj(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var ppe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(hp(n)&&!hp(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}hp(r)||$o(6),i!==void 0&&!hp(i)&&$o(7);let a;if(el(n)){const o=eB(this),l=Hj(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?zj(o):Bj(o)}return Jz(o,i),tB(a,o)}else if(!n||!QR(n)){if(a=r(n),a===void 0&&(a=n),a===pq&&(a=void 0),this.autoFreeze_&&JR(a,!0),i){const o=[],l=[];qp(Uj).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else $o(1,n)},this.produceWithPatches=(n,r)=>{if(hp(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},hT(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),hT(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),hT(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){el(e)||$o(8),eu(e)&&(e=Yo(e));const n=eB(this),r=Hj(n,e,void 0);return r[Va].isManual_=!0,Bj(n),r}finishDraft(e,n){const r=e&&e[Va];(!r||!r.isManual_)&&$o(9);const{scope_:i}=r;return Jz(i,n),tB(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=qp(Uj).applyPatches_;return eu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function Hj(t,e,n,r){const[i,a]=D2(e)?qp(bw).proxyMap_(e,n):O2(e)?qp(bw).proxySet_(e,n):fpe(e,n);return(n?.scope_??bq()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?dpe(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Yo(t){return eu(t)||$o(10,t),Sq(t)}function Sq(t){if(!el(t)||L2(t))return t;const e=t[Va];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Fj(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=Fj(t,!0);return q0(n,(i,a)=>{xw(n,i,Sq(a))},r),e&&(e.finalized_=!1),n}var gpe=new ppe,Mq=gpe.produce;function Eq(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var xpe=Eq(),bpe=Eq,ype=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?mw:mw.apply(null,arguments)};function Ao(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(Is(0));return{type:t,payload:i.payload,..."meta"in i&&{meta:i.meta},..."error"in i&&{error:i.error}}}return{type:t,payload:r[0]}}return n.toString=()=>`${t}`,n.type=t,n.match=r=>mq(r)&&r.type===t,n}var Nq=class sb extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,sb.prototype)}static get[Symbol.species](){return sb}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new sb(...e[0].concat(this)):new sb(...e.concat(this))}};function rB(t){return el(t)?Mq(t,()=>{}):t}function qv(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function vpe(t){return typeof t=="boolean"}var _pe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new Nq;return n&&(vpe(n)?o.push(xpe):o.push(bpe(n.extraArgument))),o},Aq="RTK_autoBatch",Tr=()=>t=>({payload:t,meta:{[Aq]:!0}}),iB=t=>e=>{setTimeout(e,t)},Tq=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:iB(10):t.type==="callback"?t.queueNotification:iB(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),p=r.subscribe(f);return l.add(d),()=>{p(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[Aq],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},wpe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new Nq(t);return r&&i.push(Tq(typeof r=="object"?r:void 0)),i};function Spe(t){const e=_pe(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(YR(n))l=fq(n);else throw new Error(Is(1));let c;typeof r=="function"?c=r(e):c=e();let u=mw;i&&(u=ype({trace:!1,...typeof i=="object"&&i}));const d=npe(...c),f=wpe(d);let p=typeof o=="function"?o(f):f();const g=u(...p);return hq(l,a,g)}function Cq(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(Is(28));if(l in e)throw new Error(Is(29));return e[l]=o,i},addAsyncThunk(a,o){return o.pending&&(e[a.pending.type]=o.pending),o.rejected&&(e[a.rejected.type]=o.rejected),o.fulfilled&&(e[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function Mpe(t){return typeof t=="function"}function Epe(t,e){let[n,r,i]=Cq(e),a;if(Mpe(t))a=()=>rB(t());else{const l=rB(t);a=()=>l}function o(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(eu(d)){const g=f(d,c);return g===void 0?d:g}else{if(el(d))return Mq(d,p=>f(p,c));{const p=f(d,c);if(p===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return d},l)}return o.getInitialState=a,o}var Npe="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Ape=(t=21)=>{let e="",n=t;for(;n--;)e+=Npe[Math.random()*64|0];return e},Tpe=Symbol.for("rtk-slice-createasyncthunk");function Cpe(t,e){return`${t}/${e}`}function kpe({creators:t}={}){const e=t?.asyncThunk?.[Tpe];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(Is(11));const o=(typeof r.reducers=="function"?r.reducers(Ppe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(w,A){const N=typeof w=="string"?w:w.type;if(!N)throw new Error(Is(12));if(N in c.sliceCaseReducersByType)throw new Error(Is(13));return c.sliceCaseReducersByType[N]=A,u},addMatcher(w,A){return c.sliceMatchers.push({matcher:w,reducer:A}),u},exposeAction(w,A){return c.actionCreators[w]=A,u},exposeCaseReducer(w,A){return c.sliceCaseReducersByName[w]=A,u}};l.forEach(w=>{const A=o[w],N={reducerName:w,type:Cpe(i,w),createNotation:typeof r.reducers=="function"};Dpe(A)?Lpe(N,A,u,e):Rpe(N,A,u)});function d(){const[w={},A=[],N=void 0]=typeof r.extraReducers=="function"?Cq(r.extraReducers):[r.extraReducers],C={...w,...c.sliceCaseReducersByType};return Epe(r.initialState,T=>{for(let D in C)T.addCase(D,C[D]);for(let D of c.sliceMatchers)T.addMatcher(D.matcher,D.reducer);for(let D of A)T.addMatcher(D.matcher,D.reducer);N&&T.addDefaultCase(N)})}const f=w=>w,p=new Map,g=new WeakMap;let b;function v(w,A){return b||(b=d()),b(w,A)}function x(){return b||(b=d()),b.getInitialState()}function y(w,A=!1){function N(T){let D=T[w];return typeof D>"u"&&A&&(D=qv(g,N,x)),D}function C(T=f){const D=qv(p,A,()=>new WeakMap);return qv(D,T,()=>{const k={};for(const[P,z]of Object.entries(r.selectors??{}))k[P]=jpe(z,T,()=>qv(g,T,x),A);return k})}return{reducerPath:w,getSelectors:C,get selectors(){return C(N)},selectSlice:N}}const E={name:i,reducer:v,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:x,...y(a),injectInto(w,{reducerPath:A,...N}={}){const C=A??a;return w.inject({reducerPath:C,reducer:v},N),{...E,...y(C,!0)}}};return E}}function jpe(t,e,n,r){function i(a,...o){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var fs=kpe();function Ppe(){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 Rpe({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!Ope(r))throw new Error(Is(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?Ao(t,o):Ao(t))}function Dpe(t){return t._reducerDefinitionType==="asyncThunk"}function Ope(t){return t._reducerDefinitionType==="reducerWithPrepare"}function Lpe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(Is(18));const{payloadCreator:a,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||Kv,pending:l||Kv,rejected:c||Kv,settled:u||Kv})}function Kv(){}var Ipe="task",kq="listener",jq="completed",nD="cancelled",Fpe=`task-${nD}`,Upe=`task-${jq}`,Vj=`${kq}-${nD}`,zpe=`${kq}-${jq}`,F2=class{constructor(t){this.code=t,this.message=`${Ipe} ${nD} (reason: ${t})`}name="TaskAbortError";message},rD=(t,e)=>{if(typeof t!="function")throw new TypeError(Is(32))},yw=()=>{},Pq=(t,e=yw)=>(t.catch(e),t),Rq=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Yh=(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))},Qh=t=>{if(t.aborted){const{reason:e}=t;throw new F2(e)}};function Dq(t,e){let n=yw;return new Promise((r,i)=>{const a=()=>i(new F2(t.reason));if(t.aborted){a();return}n=Rq(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=yw})}var Bpe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof F2?"cancelled":"rejected",error:n}}finally{e?.()}},vw=t=>e=>Pq(Dq(t,e).then(n=>(Qh(t),n))),Oq=t=>{const e=vw(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Ap}=Object,aB={},U2="listenerMiddleware",$pe=(t,e)=>{const n=r=>Rq(t,()=>Yh(r,t.reason));return(r,i)=>{rD(r);const a=new AbortController;n(a);const o=Bpe(async()=>{Qh(t),Qh(a.signal);const l=await r({pause:vw(a.signal),delay:Oq(a.signal),signal:a.signal});return Qh(a.signal),l},()=>Yh(a,Upe));return i?.autoJoin&&e.push(o.catch(yw)),{result:vw(t)(o),cancel(){Yh(a,Fpe)}}}},Hpe=(t,e)=>{const n=async(r,i)=>{Qh(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,p)=>{p.unsubscribe(),c([f,p.getState(),p.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await Dq(e,Promise.race(l));return Qh(e),c}finally{a()}};return(r,i)=>Pq(n(r,i))},Lq=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=Ao(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(Is(21));return rD(a),{predicate:i,type:e,effect:a}},Iq=Ap(t=>{const{type:e,predicate:n,effect:r}=Lq(t);return{id:Ape(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(Is(22))}}},{withTypes:()=>Iq}),sB=(t,e)=>{const{type:n,effect:r,predicate:i}=Lq(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},Gj=t=>{t.pending.forEach(e=>{Yh(e,Vj)})},Vpe=(t,e)=>()=>{for(const n of e.keys())Gj(n);t.clear()},oB=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},Fq=Ap(Ao(`${U2}/add`),{withTypes:()=>Fq}),Gpe=Ao(`${U2}/removeAll`),Uq=Ap(Ao(`${U2}/remove`),{withTypes:()=>Uq}),Wpe=(...t)=>{console.error(`${U2}/error`,...t)},X0=(t={})=>{const e=new Map,n=new Map,r=g=>{const b=n.get(g)??0;n.set(g,b+1)},i=g=>{const b=n.get(g)??1;b===1?n.delete(g):n.set(g,b-1)},{extra:a,onError:o=Wpe}=t;rD(o);const l=g=>(g.unsubscribe=()=>e.delete(g.id),e.set(g.id,g),b=>{g.unsubscribe(),b?.cancelActive&&Gj(g)}),c=g=>{const b=sB(e,g)??Iq(g);return l(b)};Ap(c,{withTypes:()=>c});const u=g=>{const b=sB(e,g);return b&&(b.unsubscribe(),g.cancelActive&&Gj(b)),!!b};Ap(u,{withTypes:()=>u});const d=async(g,b,v,x)=>{const y=new AbortController,E=Hpe(c,y.signal),w=[];try{g.pending.add(y),r(g),await Promise.resolve(g.effect(b,Ap({},v,{getOriginalState:x,condition:(A,N)=>E(A,N).then(Boolean),take:E,delay:Oq(y.signal),pause:vw(y.signal),extra:a,signal:y.signal,fork:$pe(y.signal,w),unsubscribe:g.unsubscribe,subscribe:()=>{e.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((A,N,C)=>{A!==y&&(Yh(A,Vj),C.delete(A))})},cancel:()=>{Yh(y,Vj),g.pending.delete(y)},throwIfCancelled:()=>{Qh(y.signal)}})))}catch(A){A instanceof F2||oB(o,A,{raisedBy:"effect"})}finally{await Promise.all(w),Yh(y,zpe),i(g),g.pending.delete(y)}},f=Vpe(e,n);return{middleware:g=>b=>v=>{if(!mq(v))return b(v);if(Fq.match(v))return c(v.payload);if(Gpe.match(v)){f();return}if(Uq.match(v))return u(v.payload);let x=g.getState();const y=()=>{if(x===aB)throw new Error(Is(23));return x};let E;try{if(E=b(v),e.size>0){const w=g.getState(),A=Array.from(e.values());for(const N of A){let C=!1;try{C=N.predicate(v,w,x)}catch(T){C=!1,oB(o,T,{raisedBy:"predicate"})}C&&d(N,v,g,y)}}}finally{x=aB}return E},startListening:c,stopListening:u,clearListeners:f}};function Is(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 qpe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},zq=fs({name:"chartLayout",initialState:qpe,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,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:Kpe,setLayout:Xpe,setChartSize:Ype,setScale:Qpe}=zq.actions,Zpe=zq.reducer;function Bq(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function lB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lB(Object(n),!0).forEach(function(r){Jpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Jpe(t,e,n){return(e=ege(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ege(t){var e=tge(t,"string");return typeof e=="symbol"?e:e+""}function tge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Jn(t,e,n){return Nr(t)||Nr(e)?n:No(e)?vf(t,e,n):typeof e=="function"?e(t):n}var nge=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&a!=="center"&&Ot(t[a]))return yp(yp({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&Ot(t[o]))return yp(yp({},t),{},{[o]:t[o]+(i||0)})}return t},Bl=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",$q=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||o.push(e),a||o.push(n),o},Hq=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:p,axisType:g}=t;if(!o)return null;var b=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,v=i==="category"&&o.bandwidth?o.bandwidth()/b:0;if(v=g==="angleAxis"&&a&&a.length>=2?Ki(a[0]-a[1])*2*v:v,f||p){var x=(f||p||[]).map((y,E)=>{var w=r?r.indexOf(y):y;return{coordinate:o(w)+v,value:y,offset:v,index:E}});return x.filter(y=>!hs(y.coordinate))}return c&&u?u.map((y,E)=>({coordinate:o(y)+v,value:y,index:E,offset:v})):o.ticks&&d!=null?o.ticks(d).map((y,E)=>({coordinate:o(y)+v,value:y,offset:v,index:E})):o.domain().map((y,E)=>({coordinate:o(y)+v,value:r?r[y]:y,index:E,offset:v}))},cB=1e-4,rge=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-cB,a=Math.max(r[0],r[1])+cB,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},ige=(t,e)=>{if(!e||e.length!==2||!Ot(e[0])||!Ot(e[1]))return t;var n=Math.min(e[0],e[1]),r=Math.max(e[0],e[1]),i=[t[0],t[1]];return(!Ot(t[0])||t[0]<n)&&(i[0]=n),(!Ot(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},age=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,o=0;o<e;++o){var l=hs(t[o][n][1])?t[o][n][0]:t[o][n][1];l>=0?(t[o][n][0]=i,t[o][n][1]=i+l,i=t[o][n][1]):(t[o][n][0]=a,t[o][n][1]=a+l,a=t[o][n][1])}},sge=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var o=hs(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},oge={sign:age,expand:kfe,none:Gp,silhouette:jfe,wiggle:Pfe,positive:sge},lge=(t,e,n)=>{var r=oge[n],i=Cfe().keys(e).value((a,o)=>Number(Jn(a,o,0))).order(Dj).offset(r);return i(t)};function Vq(t){return t==null?void 0:String(t)}function _w(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Nr(i[e.dataKey])){var l=qW(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=Jn(i,Nr(o)?e.dataKey:o);return Nr(c)?null:e.scale(c)}var uB=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=Jn(a,e.dataKey,e.scale.domain()[o]);return Nr(l)?null:e.scale(l)-i/2+r},cge=t=>{var{numericAxis:e}=t,n=e.scale.domain();if(e.type==="number"){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},uge=t=>{var e=t.flat(2).filter(Ot);return[Math.min(...e),Math.max(...e)]},dge=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],hge=(t,e,n)=>{if(t!=null)return dge(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=Bq(u,e,n),f=uge(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},dB=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,hB=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Dd=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=j2(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function fB(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return yp(yp({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Gd(t,e){if(t)return String(t);if(typeof e=="string")return e}var fge=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},mge=(t,e)=>e==="centric"?t.angle:t.radius,cu=t=>t.layout.width,uu=t=>t.layout.height,pge=t=>t.layout.scale,Gq=t=>t.layout.margin,z2=Ze(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),B2=Ze(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),Wq="data-recharts-item-index",qq="data-recharts-item-data-key",Y0=60;function mB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?mB(Object(n),!0).forEach(function(r){gge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gge(t,e,n){return(e=xge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xge(t){var e=bge(t,"string");return typeof e=="symbol"?e:e+""}function bge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var yge=t=>t.brush.height;function vge(t){var e=B2(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Y0;return n+i}return n},0)}function _ge(t){var e=B2(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Y0;return n+i}return n},0)}function wge(t){var e=z2(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Sge(t){var e=z2(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ji=Ze([cu,uu,Gq,yge,vge,_ge,wge,Sge,uq,Xme],(t,e,n,r,i,a,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},p=Xv(Xv({},f),d),g=p.bottom;p.bottom+=r,p=nge(p,c,u);var b=t-p.left-p.right,v=e-p.top-p.bottom;return Xv(Xv({brushBottom:g},p),{},{width:Math.max(b,0),height:Math.max(v,0)})}),Mge=Ze(ji,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),iD=Ze(cu,uu,(t,e)=>({x:0,y:0,width:t,height:e})),Ege=S.createContext(null),Pi=()=>S.useContext(Ege)!=null,$2=t=>t.brush,H2=Ze([$2,ji,Gq],(t,e,n)=>({height:t.height,x:Ot(t.x)?t.x:e.left,y:Ot(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Ot(t.width)?t.width:e.width})),mT={},pT={},gT={},pB;function Nge(){return pB||(pB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),v()};let p=null;const g=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,f()},r)},b=()=>{p!==null&&(clearTimeout(p),p=null)},v=()=>{b(),o=void 0,l=null},x=()=>{d()},y=function(...E){if(i?.aborted)return;o=this,l=E;const w=p==null;g(),c&&w&&d()};return y.schedule=g,y.cancel=v,y.flush=x,i?.addEventListener("abort",v,{once:!0}),y}t.debounce=e})(gT)),gT}var gB;function Age(){return gB||(gB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Nge();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const p=e.debounce(function(...v){d=r.apply(this,v),f=null},i,{edges:u}),g=function(...v){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,v),f=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,v),d)},b=()=>(p.flush(),d);return g.cancel=p.cancel,g.flush=b,g}t.debounce=n})(pT)),pT}var xB;function Tge(){return xB||(xB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Age();function n(r,i=0,a={}){const{leading:o=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(mT)),mT}var xT,bB;function Cge(){return bB||(bB=1,xT=Tge().throttle),xT}var kge=Cge();const jge=Co(kge);var ww=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[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 o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},Kq=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=Jc(r)?t:Number(r),c=Jc(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},Pge={width:0,height:0,overflow:"visible"},Rge={width:0,overflowX:"visible"},Dge={height:0,overflowY:"visible"},Oge={},Lge=t=>{var{width:e,height:n}=t,r=Jc(e),i=Jc(n);return r&&i?Pge:r?Rge:i?Dge:Oge};function Ige(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function er(t){return Number.isFinite(t)}function kl(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function Wj(){return Wj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Wj.apply(null,arguments)}function yB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?yB(Object(n),!0).forEach(function(r){Fge(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):yB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Fge(t,e,n){return(e=Uge(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Uge(t){var e=zge(t,"string");return typeof e=="symbol"?e:e+""}function zge(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Xq=S.createContext({width:-1,height:-1});function Bge(t){return kl(t.width)&&kl(t.height)}function Yq(t){var{children:e,width:n,height:r}=t,i=S.useMemo(()=>({width:n,height:r}),[n,r]);return Bge(i)?S.createElement(Xq.Provider,{value:i},e):null}var aD=()=>S.useContext(Xq),$ge=S.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:p,onResize:g,style:b={}}=t,v=S.useRef(null),x=S.useRef();x.current=g,S.useImperativeHandle(e,()=>v.current);var[y,E]=S.useState({containerWidth:r.width,containerHeight:r.height}),w=S.useCallback((D,k)=>{E(P=>{var z=Math.round(D),L=Math.round(k);return P.containerWidth===z&&P.containerHeight===L?P:{containerWidth:z,containerHeight:L}})},[]);S.useEffect(()=>{if(v.current==null||typeof ResizeObserver>"u")return G0;var D=L=>{var X,{width:R,height:Y}=L[0].contentRect;w(R,Y),(X=x.current)===null||X===void 0||X.call(x,R,Y)};d>0&&(D=jge(D,d,{trailing:!0,leading:!1}));var k=new ResizeObserver(D),{width:P,height:z}=v.current.getBoundingClientRect();return w(P,z),k.observe(v.current),()=>{k.disconnect()}},[w,d]);var{containerWidth:A,containerHeight:N}=y;ww(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:T}=Kq(A,N,{width:i,height:a,aspect:n,maxHeight:c});return ww(C!=null&&C>0||T!=null&&T>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.`,C,T,i,a,o,l,n),S.createElement("div",{id:f?"".concat(f):void 0,className:On("recharts-responsive-container",p),style:vB(vB({},b),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:v},S.createElement("div",{style:Lge({width:i,height:a})},S.createElement(Yq,{width:C,height:T},u)))}),j1=S.forwardRef((t,e)=>{var n=aD();if(kl(n.width)&&kl(n.height))return t.children;var{width:r,height:i}=Ige({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=Kq(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Ot(a)&&Ot(o)?S.createElement(Yq,{width:a,height:o},t.children):S.createElement($ge,Wj({},t,{width:r,height:i,ref:e}))});function Qq(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 Q0=()=>{var t,e=Pi(),n=Pt(Mge),r=Pt(H2),i=(t=Pt($2))===null||t===void 0?void 0:t.padding;return!e||!r||!i?n:{width:r.width-i.left-i.right,height:r.height-i.top-i.bottom,x:i.left,y:i.top}},Hge={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},Zq=()=>{var t;return(t=Pt(ji))!==null&&t!==void 0?t:Hge},sD=()=>Pt(cu),oD=()=>Pt(uu),Vge=()=>Pt(t=>t.layout.margin),Tn=t=>t.layout.layoutType,Ff=()=>Pt(Tn),Gge=()=>{var t=Ff();if(t==="horizontal"||t==="vertical")return t},Wge=()=>{var t=Ff();return t!==void 0},V2=t=>{var e=br(),n=Pi(),{width:r,height:i}=t,a=aD(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),S.useEffect(()=>{!n&&kl(o)&&kl(l)&&e(Ype({width:o,height:l}))},[e,n,o,l]),null},Jq=Symbol.for("immer-nothing"),_B=Symbol.for("immer-draftable"),Vs=Symbol.for("immer-state");function Ho(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var t0=Object.getPrototypeOf;function Kp(t){return!!t&&!!t[Vs]}function _f(t){return t?eK(t)||Array.isArray(t)||!!t[_B]||!!t.constructor?.[_B]||Z0(t)||W2(t):!1}var qge=Object.prototype.constructor.toString(),wB=new WeakMap;function eK(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 r=wB.get(n);return r===void 0&&(r=Function.toString.call(n),wB.set(n,r)),r===qge}function Sw(t,e,n=!0){G2(t)===0?(n?Reflect.ownKeys(t):Object.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function G2(t){const e=t[Vs];return e?e.type_:Array.isArray(t)?1:Z0(t)?2:W2(t)?3:0}function qj(t,e){return G2(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function tK(t,e,n){const r=G2(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function Kge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Z0(t){return t instanceof Map}function W2(t){return t instanceof Set}function Th(t){return t.copy_||t.base_}function Kj(t,e){if(Z0(t))return new Map(t);if(W2(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=eK(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Vs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(r[o]={configurable:!0,writable:!0,enumerable:l.enumerable,value:t[o]})}return Object.create(t0(t),r)}else{const r=t0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function lD(t,e=!1){return q2(t)||Kp(t)||!_f(t)||(G2(t)>1&&Object.defineProperties(t,{set:Yv,add:Yv,clear:Yv,delete:Yv}),Object.freeze(t),e&&Object.values(t).forEach(n=>lD(n,!0))),t}function Xge(){Ho(2)}var Yv={value:Xge};function q2(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var Yge={};function wf(t){const e=Yge[t];return e||Ho(0,t),e}var n0;function nK(){return n0}function Qge(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function SB(t,e){e&&(wf("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Xj(t){Yj(t),t.drafts_.forEach(Zge),t.drafts_=null}function Yj(t){t===n0&&(n0=t.parent_)}function MB(t){return n0=Qge(n0,t)}function Zge(t){const e=t[Vs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function EB(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Vs].modified_&&(Xj(e),Ho(4)),_f(t)&&(t=Mw(e,t),e.parent_||Ew(e,t)),e.patches_&&wf("Patches").generateReplacementPatches_(n[Vs].base_,t,e.patches_,e.inversePatches_)):t=Mw(e,n,[]),Xj(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Jq?t:void 0}function Mw(t,e,n){if(q2(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Vs];if(!i)return Sw(e,(a,o)=>NB(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return Ew(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,l=!1;i.type_===3&&(o=new Set(a),a.clear(),l=!0),Sw(o,(c,u)=>NB(t,i,a,c,u,n,l),r),Ew(t,a,!1),n&&t.patches_&&wf("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function NB(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=q2(i);if(!(l&&!o)){if(Kp(i)){const c=a&&e&&e.type_!==3&&!qj(e.assigned_,r)?a.concat(r):void 0,u=Mw(t,i,c);if(tK(n,r,u),Kp(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(_f(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;Mw(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Z0(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Ew(t,i)}}}function Ew(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&lD(e,n)}function Jge(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:nK(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=cD;n&&(i=[r],a=r0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var cD={get(t,e){if(e===Vs)return t;const n=Th(t);if(!qj(n,e))return exe(t,n,e);const r=n[e];return t.finalized_||!_f(r)?r:r===bT(t.base_,e)?(yT(t),t.copy_[e]=Zj(r,t)):r},has(t,e){return e in Th(t)},ownKeys(t){return Reflect.ownKeys(Th(t))},set(t,e,n){const r=rK(Th(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=bT(Th(t),e),a=i?.[Vs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Kge(n,i)&&(n!==void 0||qj(t.base_,e)))return!0;yT(t),Qj(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 bT(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,yT(t),Qj(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Th(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Ho(11)},getPrototypeOf(t){return t0(t.base_)},setPrototypeOf(){Ho(12)}},r0={};Sw(cD,(t,e)=>{r0[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});r0.deleteProperty=function(t,e){return r0.set.call(this,t,e,void 0)};r0.set=function(t,e,n){return cD.set.call(this,t[0],e,n,t[0])};function bT(t,e){const n=t[Vs];return(n?Th(n):t)[e]}function exe(t,e,n){const r=rK(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function rK(t,e){if(!(e in t))return;let n=t0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=t0(n)}}function Qj(t){t.modified_||(t.modified_=!0,t.parent_&&Qj(t.parent_))}function yT(t){t.copy_||(t.copy_=Kj(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var txe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const o=this;return function(c=a,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Ho(6),r!==void 0&&typeof r!="function"&&Ho(7);let i;if(_f(e)){const a=MB(this),o=Zj(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?Xj(a):Yj(a)}return SB(a,r),EB(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===Jq&&(i=void 0),this.autoFreeze_&&lD(i,!0),r){const a=[],o=[];wf("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Ho(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(o,...l)=>this.produceWithPatches(o,c=>e(c,...l));let r,i;return[this.produce(e,n,(o,l)=>{r=o,i=l}),r,i]},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){_f(t)||Ho(8),Kp(t)&&(t=nxe(t));const e=MB(this),n=Zj(t,void 0);return n[Vs].isManual_=!0,Yj(e),n}finishDraft(t,e){const n=t&&t[Vs];(!n||!n.isManual_)&&Ho(9);const{scope_:r}=n;return SB(r,e),EB(void 0,r)}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 i=e[n];if(i.path.length===0&&i.op==="replace"){t=i.value;break}}n>-1&&(e=e.slice(n+1));const r=wf("Patches").applyPatches_;return Kp(t)?r(t,e):this.produce(t,i=>r(i,e))}};function Zj(t,e){const n=Z0(t)?wf("MapSet").proxyMap_(t,e):W2(t)?wf("MapSet").proxySet_(t,e):Jge(t,e);return(e?e.scope_:nK()).drafts_.push(n),n}function nxe(t){return Kp(t)||Ho(10,t),iK(t)}function iK(t){if(!_f(t)||q2(t))return t;const e=t[Vs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Kj(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=Kj(t,!0);return Sw(n,(i,a)=>{tK(n,i,iK(a))},r),e&&(e.finalized_=!1),n}var rxe=new txe;rxe.produce;var ixe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},aK=fs({name:"legend",initialState:ixe,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:Tr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Yo(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Tr()},removeLegendPayload:{reducer(t,e){var n=Yo(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Tr()}}}),{setLegendSize:AB,setLegendSettings:axe,addLegendPayload:sK,replaceLegendPayload:oK,removeLegendPayload:lK}=aK.actions,sxe=aK.reducer,oxe=["contextPayload"];function Jj(){return Jj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Jj.apply(null,arguments)}function TB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TB(Object(n),!0).forEach(function(r){lxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lxe(t,e,n){return(e=cxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cxe(t){var e=uxe(t,"string");return typeof e=="symbol"?e:e+""}function uxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dxe(t,e){if(t==null)return{};var n,r,i=hxe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function hxe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function fxe(t){return t.value}function mxe(t){var{contextPayload:e}=t,n=dxe(t,oxe),r=aq(e,t.payloadUniqBy,fxe),i=Xp(Xp({},n),{},{payload:r});return S.isValidElement(t.content)?S.cloneElement(t.content,i):typeof t.content=="function"?S.createElement(t.content,i):S.createElement(ome,i)}function pxe(t,e,n,r,i,a){var{layout:o,align:l,verticalAlign:c}=e,u,d;return(!t||(t.left===void 0||t.left===null)&&(t.right===void 0||t.right===null))&&(l==="center"&&o==="vertical"?u={left:((r||0)-a.width)/2}:u=l==="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))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Xp(Xp({},u),d)}function gxe(t){var e=br();return S.useEffect(()=>{e(axe(t))},[e,t]),null}function xxe(t){var e=br();return S.useEffect(()=>(e(AB(t)),()=>{e(AB({width:0,height:0}))}),[e,t]),null}function bxe(t,e,n,r){return t==="vertical"&&Ot(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var yxe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function uD(t){var e=Lr(t,yxe),n=Zme(),r=Jhe(),i=Vge(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=dq([n]),f=sD(),p=oD();if(f==null||p==null)return null;var g=f-(i?.left||0)-(i?.right||0),b=bxe(e.layout,o,a,g),v=c?l:Xp(Xp({position:"absolute",width:b?.width||a||"auto",height:b?.height||o||"auto"},pxe(l,e,i,f,p,u)),l),x=c??r;if(x==null||n==null)return null;var y=S.createElement("div",{className:"recharts-legend-wrapper",style:v,ref:d},S.createElement(gxe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&S.createElement(xxe,{width:u.width,height:u.height}),S.createElement(mxe,Jj({},e,b,{margin:i,chartWidth:f,chartHeight:p,contextPayload:n})));return Pc.createPortal(y,x)}uD.displayName="Legend";function e3(){return e3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e3.apply(null,arguments)}function CB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function vT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?CB(Object(n),!0).forEach(function(r){vxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):CB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vxe(t,e,n){return(e=_xe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function _xe(t){var e=wxe(t,"string");return typeof e=="symbol"?e:e+""}function wxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Sxe(t){return Array.isArray(t)&&No(t[0])&&No(t[1])?t.join(" ~ "):t}var Mxe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:p=!1}=t,g=()=>{if(a&&a.length){var N={padding:0,margin:0},C=(l?j2(a,l):a).map((T,D)=>{if(T.type==="none")return null;var k=T.formatter||o||Sxe,{value:P,name:z}=T,L=P,X=z;if(k){var R=k(P,z,T,D,a);if(Array.isArray(R))[L,X]=R;else if(R!=null)L=R;else return null}var Y=vT({display:"block",paddingTop:4,paddingBottom:4,color:T.color||"#000"},r);return S.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:Y},No(X)?S.createElement("span",{className:"recharts-tooltip-item-name"},X):null,No(X)?S.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,S.createElement("span",{className:"recharts-tooltip-item-value"},L),S.createElement("span",{className:"recharts-tooltip-item-unit"},T.unit||""))});return S.createElement("ul",{className:"recharts-tooltip-item-list",style:N},C)}return null},b=vT({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),v=vT({margin:0},i),x=!Nr(d),y=x?d:"",E=On("recharts-default-tooltip",c),w=On("recharts-tooltip-label",u);x&&f&&a!==void 0&&a!==null&&(y=f(d,a));var A=p?{role:"status","aria-live":"assertive"}:{};return S.createElement("div",e3({className:E,style:b},A),S.createElement("p",{className:w,style:v},S.isValidElement(y)?y:"".concat(y)),g())},Dx="recharts-tooltip-wrapper",Exe={visibility:"hidden"};function Nxe(t){var{coordinate:e,translateX:n,translateY:r}=t;return On(Dx,{["".concat(Dx,"-right")]:Ot(n)&&e&&Ot(e.x)&&n>=e.x,["".concat(Dx,"-left")]:Ot(n)&&e&&Ot(e.x)&&n<e.x,["".concat(Dx,"-bottom")]:Ot(r)&&e&&Ot(e.y)&&r>=e.y,["".concat(Dx,"-top")]:Ot(r)&&e&&Ot(e.y)&&r<e.y})}function kB(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&Ot(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var p=c[r];if(p==null)return 0;if(o[r]){var g=d,b=p;return g<b?Math.max(f,p):Math.max(d,p)}if(u==null)return 0;var v=f+l,x=p+u;return v>x?Math.max(d,p):Math.max(f,p)}function Axe(t){var{translateX:e,translateY:n,useTranslate3d:r}=t;return{transform:r?"translate3d(".concat(e,"px, ").concat(n,"px, 0)"):"translate(".concat(e,"px, ").concat(n,"px)")}}function Txe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=kB({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=kB({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=Axe({translateX:d,translateY:f,useTranslate3d:l})):u=Exe,{cssProperties:u,cssClasses:Nxe({translateX:d,translateY:f,coordinate:n})}}function jB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Qv(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?jB(Object(n),!0).forEach(function(r){t3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):jB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t3(t,e,n){return(e=Cxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Cxe(t){var e=kxe(t,"string");return typeof e=="symbol"?e:e+""}function kxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class jxe extends S.PureComponent{constructor(){super(...arguments),t3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),t3(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i: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:r,animationEasing:i,children:a,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:p,viewBox:g,wrapperStyle:b,lastBoundingBox:v,innerRef:x,hasPortalFromProps:y}=this.props,{cssClasses:E,cssProperties:w}=Txe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:v.height,width:v.width},useTranslate3d:p,viewBox:g}),A=y?{}:Qv(Qv({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),N=Qv(Qv({},A),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},b);return S.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:E,style:N,ref:x},a)}}var cK=()=>{var t;return(t=Pt(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function n3(){return n3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},n3.apply(null,arguments)}function PB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PB(Object(n),!0).forEach(function(r){Pxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pxe(t,e,n){return(e=Rxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Rxe(t){var e=Dxe(t,"string");return typeof e=="symbol"?e:e+""}function Dxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var DB={curveBasisClosed:bfe,curveBasisOpen:yfe,curveBasis:xfe,curveBumpX:rfe,curveBumpY:ife,curveLinearClosed:vfe,curveLinear:C2,curveMonotoneX:_fe,curveMonotoneY:wfe,curveNatural:Sfe,curveStep:Mfe,curveStepAfter:Nfe,curveStepBefore:Efe},Nw=t=>er(t.x)&&er(t.y),OB=t=>t.base!=null&&Nw(t.base)&&Nw(t),Ox=t=>t.x,Lx=t=>t.y,Oxe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(V0(t));return(n==="curveMonotone"||n==="curveBump")&&e?DB["".concat(n).concat(e==="vertical"?"Y":"X")]:DB[n]||C2},Lxe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=Oxe(e,i),l=a?n.filter(Nw):n,c;if(Array.isArray(r)){var u=n.map((g,b)=>RB(RB({},g),{},{base:r[b]}));i==="vertical"?c=Hv().y(Lx).x1(Ox).x0(g=>g.base.x):c=Hv().x(Ox).y1(Lx).y0(g=>g.base.y);var d=c.defined(OB).curve(o),f=a?u.filter(OB):u;return d(f)}i==="vertical"&&Ot(r)?c=Hv().y(Lx).x1(Ox).x0(r):Ot(r)?c=Hv().x(Ox).y1(Lx).y0(r):c=DW().x(Ox).y(Lx);var p=c.defined(Nw).curve(o);return p(l)},Tp=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?Lxe(t):r;return S.createElement("path",n3({},Ha(t),qR(t),{className:On("recharts-curve",e),d:a===null?void 0:a,ref:i}))},Ixe=["x","y","top","left","width","height","className"];function r3(){return r3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},r3.apply(null,arguments)}function LB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Fxe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LB(Object(n),!0).forEach(function(r){Uxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Uxe(t,e,n){return(e=zxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zxe(t){var e=Bxe(t,"string");return typeof e=="symbol"?e:e+""}function Bxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $xe(t,e){if(t==null)return{};var n,r,i=Hxe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Hxe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Vxe=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),Gxe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=$xe(t,Ixe),u=Fxe({x:e,y:n,top:r,left:i,width:a,height:o},c);return!Ot(e)||!Ot(n)||!Ot(a)||!Ot(o)||!Ot(r)||!Ot(i)?null:S.createElement("path",r3({},ga(u),{className:On("recharts-cross",l),d:Vxe(e,n,a,o,r,i)}))};function Wxe(t,e,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-i:n.left+.5,y:t==="horizontal"?n.top+.5:e.y-i,width:t==="horizontal"?r:n.width-1,height:t==="horizontal"?n.height-1:r}}function IB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function FB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IB(Object(n),!0).forEach(function(r){qxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qxe(t,e,n){return(e=Kxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kxe(t){var e=Xxe(t,"string");return typeof e=="symbol"?e:e+""}function Xxe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Yxe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),uK=(t,e,n)=>t.map(r=>"".concat(Yxe(r)," ").concat(e,"ms ").concat(n)).join(","),Qxe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),i0=(t,e)=>Object.keys(e).reduce((n,r)=>FB(FB({},n),{},{[r]:t(r,e[r])}),{});function UB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Mi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UB(Object(n),!0).forEach(function(r){Zxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Zxe(t,e,n){return(e=Jxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Jxe(t){var e=ebe(t,"string");return typeof e=="symbol"?e:e+""}function ebe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Aw=(t,e,n)=>t+(e-t)*n,i3=t=>{var{from:e,to:n}=t;return e!==n},dK=(t,e,n)=>{var r=i0((i,a)=>{if(i3(a)){var[o,l]=t(a.from,a.to,a.velocity);return Mi(Mi({},a),{},{from:o,velocity:l})}return a},e);return n<1?i0((i,a)=>i3(a)?Mi(Mi({},a),{},{velocity:Aw(a.velocity,r[i].velocity,n),from:Aw(a.from,r[i].from,n)}):a,e):dK(t,r,n-1)};function tbe(t,e,n,r,i,a){var o,l=r.reduce((p,g)=>Mi(Mi({},p),{},{[g]:{from:t[g],velocity:0,to:e[g]}}),{}),c=()=>i0((p,g)=>g.from,l),u=()=>!Object.values(l).filter(i3).length,d=null,f=p=>{o||(o=p);var g=p-o,b=g/n.dt;l=dK(n,l,b),i(Mi(Mi(Mi({},t),e),c())),o=p,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var p;(p=d)===null||p===void 0||p()})}function nbe(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,p)=>Mi(Mi({},f),{},{[p]:[t[p],e[p]]}),{}),u,d=f=>{u||(u=f);var p=(f-u)/r,g=i0((v,x)=>Aw(...x,n(p)),c);if(a(Mi(Mi(Mi({},t),e),g)),p<1)l=o.setTimeout(d);else{var b=i0((v,x)=>Aw(...x,n(1)),c);a(Mi(Mi(Mi({},t),e),b))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const rbe=(t,e,n,r,i,a)=>{var o=Qxe(t,e);return n==null?()=>(i(Mi(Mi({},t),e)),()=>{}):n.isStepper===!0?tbe(t,e,n,o,i,a):nbe(t,e,n,r,o,i,a)};var Tw=1e-4,hK=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],fK=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),zB=(t,e)=>n=>{var r=hK(t,e);return fK(r,n)},ibe=(t,e)=>n=>{var r=hK(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return fK(i,n)},abe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];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 i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=a[1].split(")")[0].split(",").map(l=>parseFloat(l));return[o[0],o[1],o[2],o[3]]}}}return n.length===4?n:[0,0,1,1]},sbe=(t,e,n,r)=>{var i=zB(t,n),a=zB(e,r),o=ibe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,p=0;p<8;++p){var g=i(f)-d,b=o(f);if(Math.abs(g-d)<Tw||b<Tw)return a(f);f=l(f-g/b)}return a(f)};return c.isStepper=!1,c},BB=function(){return sbe(...abe(...arguments))},obe=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l)<Tw&&Math.abs(f)<Tw?[l,0]:[p,f]};return a.isStepper=!0,a.dt=i,a},lbe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return BB(t);case"spring":return obe();default:if(t.split("(")[0]==="cubic-bezier")return BB(t)}return typeof t=="function"?t:null};function cbe(t){var e,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof o=="string"&&(e=o,n(e)),typeof o=="object"&&(e=o,n(e)),typeof o=="function"&&o()}};return{stop:()=>{r=!0},start:o=>{r=!1,i&&(i(),i=null),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class ube{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function dbe(){return cbe(new ube)}var hbe=S.createContext(dbe);function fbe(t,e){var n=S.useContext(hbe);return S.useMemo(()=>e??n(t),[t,e,n])}var mbe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),Sg={devToolsEnabled:!1,isSsr:mbe()},pbe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},$B={t:0},_T={t:1};function Mg(t){var e=Lr(t,pbe),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!Sg.isSsr:n,f=fbe(e.animationId,e.animationManager),[p,g]=S.useState(d?$B:_T),b=S.useRef(null);return S.useEffect(()=>{d||g(_T)},[d]),S.useEffect(()=>{if(!d||!r)return G0;var v=rbe($B,_T,lbe(a),i,g,f.getTimeoutController()),x=()=>{b.current=v()};return f.start([c,o,x,i,l]),()=>{f.stop(),b.current&&b.current(),l()}},[d,r,i,a,o,c,l,f]),u(p.t)}function Eg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=S.useRef(Qb(e)),r=S.useRef(t);return r.current!==t&&(n.current=Qb(e),r.current=t),n.current}var gbe=["radius"],xbe=["radius"];function HB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function VB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HB(Object(n),!0).forEach(function(r){bbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bbe(t,e,n){return(e=ybe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ybe(t){var e=vbe(t,"string");return typeof e=="symbol"?e:e+""}function vbe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Cw(){return Cw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cw.apply(null,arguments)}function GB(t,e){if(t==null)return{};var n,r,i=_be(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function _be(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var WB=(t,e,n,r,i)=>{var a=Math.min(Math.abs(n)/2,Math.abs(r)/2),o=r>=0?1:-1,l=n>=0?1:-1,c=r>=0&&n>=0||r<0&&n<0?1:0,u;if(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,p=4;f<p;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var g=Math.min(a,i);u="M ".concat(t,",").concat(e+o*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+l*g,",").concat(e,`
- L `).concat(t+n-l*g,",").concat(e,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*g,`
- L `).concat(t+n,",").concat(e+r-o*g,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t+n-l*g,",").concat(e+r,`
- L `).concat(t+l*g,",").concat(e+r,`
- A `).concat(g,",").concat(g,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*g," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},qB={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},mK=t=>{var e=Lr(t,qB),n=S.useRef(null),[r,i]=S.useState(-1);S.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var G=n.current.getTotalLength();G&&i(G)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:p,animationBegin:g,isAnimationActive:b,isUpdateAnimationActive:v}=e,x=S.useRef(l),y=S.useRef(c),E=S.useRef(a),w=S.useRef(o),A=S.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),N=Eg(A,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=On("recharts-rectangle",d);if(!v){var T=ga(e),{radius:D}=T,k=GB(T,gbe);return S.createElement("path",Cw({},k,{radius:typeof u=="number"?u:void 0,className:C,d:WB(a,o,l,c,u)}))}var P=x.current,z=y.current,L=E.current,X=w.current,R="0px ".concat(r===-1?1:r,"px"),Y="".concat(r,"px 0px"),J=uK(["strokeDasharray"],p,typeof f=="string"?f:qB.animationEasing);return S.createElement(Mg,{animationId:N,key:N,canBegin:r>0,duration:p,easing:f,isActive:v,begin:g},G=>{var W=Gn(P,l,G),ee=Gn(z,c,G),K=Gn(L,a,G),F=Gn(X,o,G);n.current&&(x.current=W,y.current=ee,E.current=K,w.current=F);var q;b?G>0?q={transition:J,strokeDasharray:Y}:q={strokeDasharray:R}:q={strokeDasharray:Y};var ne=ga(e),{radius:re}=ne,se=GB(ne,xbe);return S.createElement("path",Cw({},se,{radius:typeof u=="number"?u:void 0,className:C,d:WB(K,F,W,ee,u),ref:n,style:VB(VB({},q),e.style)}))})};function KB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function XB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KB(Object(n),!0).forEach(function(r){wbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function wbe(t,e,n){return(e=Sbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sbe(t){var e=Mbe(t,"string");return typeof e=="symbol"?e:e+""}function Mbe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var kw=Math.PI/180,Ebe=t=>t*180/Math.PI,pi=(t,e,n,r)=>({x:t+Math.cos(-kw*r)*n,y:e+Math.sin(-kw*r)*n}),pK=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(e-(r.left||0)-(r.right||0)),Math.abs(n-(r.top||0)-(r.bottom||0)))/2},Nbe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},Abe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=Nbe({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:o,angle:Ebe(c),angleInRadian:c}},Tbe=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},Cbe=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return t+o*360},kbe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=Abe({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=Tbe(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?XB(XB({},e),{},{radius:i,angle:Cbe(d,e)}):null};function gK(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=pi(e,n,r,i),l=pi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function a3(){return a3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},a3.apply(null,arguments)}var jbe=(t,e)=>{var n=Ki(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Zv=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/kw,f=c?i:i+a*d,p=pi(e,n,u,f),g=pi(e,n,r,f),b=c?i-a*d:i,v=pi(e,n,u*Math.cos(d*kw),b);return{center:p,circleTangency:g,lineTangency:v,theta:d}},xK=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=jbe(a,o),c=a+l,u=pi(e,n,i,a),d=pi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var p=pi(e,n,r,a),g=pi(e,n,r,c);f+="L ".concat(g.x,",").concat(g.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
- `).concat(p.x,",").concat(p.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},Pbe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=Ki(u-c),{circleTangency:f,lineTangency:p,theta:g}=Zv({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:b,lineTangency:v,theta:x}=Zv({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),y=l?Math.abs(c-u):Math.abs(c-u)-g-x;if(y<0)return o?"M ".concat(p.x,",").concat(p.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):xK({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var E="M ".concat(p.x,",").concat(p.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(y>180),",").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(v.x,",").concat(v.y,`
- `);if(r>0){var{circleTangency:w,lineTangency:A,theta:N}=Zv({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:T,theta:D}=Zv({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),k=l?Math.abs(c-u):Math.abs(c-u)-N-D;if(k<0&&a===0)return"".concat(E,"L").concat(e,",").concat(n,"Z");E+="L".concat(T.x,",").concat(T.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(k>180),",").concat(+(d>0),",").concat(w.x,",").concat(w.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(A.x,",").concat(A.y,"Z")}else E+="L".concat(e,",").concat(n,"Z");return E},Rbe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},bK=t=>{var e=Lr(t,Rbe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var p=On("recharts-sector",f),g=a-i,b=Ta(o,g,0,!0),v;return b>0&&Math.abs(u-d)<360?v=Pbe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(b,g/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):v=xK({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),S.createElement("path",a3({},ga(e),{className:p,d:v}))};function Dbe(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(XW(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=pi(r,i,a,l),u=pi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return gK(e)}}var wT={},ST={},MT={},YB;function Obe(){return YB||(YB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=lq();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(MT)),MT}var QB;function Lbe(){return QB||(QB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Obe();function n(r){return r?(r=e.toNumber(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}t.toFinite=n})(ST)),ST}var ZB;function Ibe(){return ZB||(ZB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=cq(),n=Lbe();function r(i,a,o){o&&typeof o!="number"&&e.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?i<a?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((a-i)/(o||1)),0),c=new Array(l);for(let u=0;u<l;u++)c[u]=i,i+=o;return c}t.range=r})(wT)),wT}var ET,JB;function Fbe(){return JB||(JB=1,ET=Ibe().range),ET}var Ube=Fbe();const yK=Co(Ube);function wd(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function zbe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function dD(t){let e,n,r;t.length!==2?(e=wd,n=(l,c)=>wd(t(l),c),r=(l,c)=>t(l)-c):(e=t===wd||t===zbe?t:Bbe,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function o(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:o,right:a}}function Bbe(){return 0}function vK(t){return t===null?NaN:+t}function*$be(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const Hbe=dD(wd),J0=Hbe.right;dD(vK).center;class e8 extends Map{constructor(e,n=Wbe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),e!=null)for(const[r,i]of e)this.set(r,i)}get(e){return super.get(t8(this,e))}has(e){return super.has(t8(this,e))}set(e,n){return super.set(Vbe(this,e),n)}delete(e){return super.delete(Gbe(this,e))}}function t8({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function Vbe({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function Gbe({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function Wbe(t){return t!==null&&typeof t=="object"?t.valueOf():t}function qbe(t=wd){if(t===wd)return _K;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,n)=>{const r=t(e,n);return r||r===0?r:(t(n,n)===0)-(t(e,e)===0)}}function _K(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const Kbe=Math.sqrt(50),Xbe=Math.sqrt(10),Ybe=Math.sqrt(2);function jw(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=Kbe?10:a>=Xbe?5:a>=Ybe?2:1;let l,c,u;return i<0?(u=Math.pow(10,-i)/o,l=Math.round(t*u),c=Math.round(e*u),l/u<t&&++l,c/u>e&&--c,u=-u):(u=Math.pow(10,i)*o,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=n&&n<2?jw(t,e,n*2):[l,c,u]}function s3(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,o]=r?jw(e,t,n):jw(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(a-u)/-o;else for(let u=0;u<l;++u)c[u]=(a-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(i+u)/-o;else for(let u=0;u<l;++u)c[u]=(i+u)*o;return c}function o3(t,e,n){return e=+e,t=+t,n=+n,jw(t,e,n)[2]}function l3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?o3(e,t,n):o3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function n8(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function r8(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function wK(t,e,n=0,r=1/0,i){if(e=Math.floor(e),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(t.length-1,r)),!(n<=e&&e<=r))return t;for(i=i===void 0?_K:qbe(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),g=Math.max(n,Math.floor(e-u*f/c+p)),b=Math.min(r,Math.floor(e+(c-u)*f/c+p));wK(t,e,g,b,i)}const a=t[e];let o=n,l=r;for(Ix(t,n,e),i(t[r],a)>0&&Ix(t,n,r);o<l;){for(Ix(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?Ix(t,n,l):(++l,Ix(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Ix(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function Qbe(t,e,n){if(t=Float64Array.from($be(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return r8(t);if(e>=1)return n8(t);var r,i=(r-1)*e,a=Math.floor(i),o=n8(wK(t,a).subarray(0,a+1)),l=r8(t.subarray(a+1));return o+(l-o)*(i-a)}}function Zbe(t,e,n=vK){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),o=+n(t[a],a,t),l=+n(t[a+1],a+1,t);return o+(l-o)*(i-a)}}function Jbe(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function ko(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function du(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 c3=Symbol("implicit");function hD(){var t=new e8,e=[],n=[],r=c3;function i(a){let o=t.get(a);if(o===void 0){if(r!==c3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new e8;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return hD(e,n).unknown(r)},ko.apply(i,arguments),i}function fD(){var t=hD().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var p=e().length,g=i<r,b=g?i:r,v=g?r:i;a=(v-b)/Math.max(1,p-c+u*2),l&&(a=Math.floor(a)),b+=(v-b-a*(p-c))*d,o=a*(1-c),l&&(b=Math.round(b),o=Math.round(o));var x=Jbe(p).map(function(y){return b+a*y});return n(g?x.reverse():x)}return t.domain=function(p){return arguments.length?(e(p),f()):e()},t.range=function(p){return arguments.length?([r,i]=p,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(p){return[r,i]=p,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(p){return arguments.length?(l=!!p,f()):l},t.padding=function(p){return arguments.length?(c=Math.min(1,u=+p),f()):c},t.paddingInner=function(p){return arguments.length?(c=Math.min(1,p),f()):c},t.paddingOuter=function(p){return arguments.length?(u=+p,f()):u},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),f()):d},t.copy=function(){return fD(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},ko.apply(f(),arguments)}function SK(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return SK(e())},t}function e0e(){return SK(fD.apply(null,arguments).paddingInner(1))}function mD(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function MK(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function ey(){}var a0=.7,Pw=1/a0,Cp="\\s*([+-]?\\d+)\\s*",s0="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Nl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",t0e=/^#([0-9a-f]{3,8})$/,n0e=new RegExp(`^rgb\\(${Cp},${Cp},${Cp}\\)$`),r0e=new RegExp(`^rgb\\(${Nl},${Nl},${Nl}\\)$`),i0e=new RegExp(`^rgba\\(${Cp},${Cp},${Cp},${s0}\\)$`),a0e=new RegExp(`^rgba\\(${Nl},${Nl},${Nl},${s0}\\)$`),s0e=new RegExp(`^hsl\\(${s0},${Nl},${Nl}\\)$`),o0e=new RegExp(`^hsla\\(${s0},${Nl},${Nl},${s0}\\)$`),i8={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};mD(ey,o0,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:a8,formatHex:a8,formatHex8:l0e,formatHsl:c0e,formatRgb:s8,toString:s8});function a8(){return this.rgb().formatHex()}function l0e(){return this.rgb().formatHex8()}function c0e(){return EK(this).formatHsl()}function s8(){return this.rgb().formatRgb()}function o0(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=t0e.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?o8(e):n===3?new ss(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Jv(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Jv(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=n0e.exec(t))?new ss(e[1],e[2],e[3],1):(e=r0e.exec(t))?new ss(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=i0e.exec(t))?Jv(e[1],e[2],e[3],e[4]):(e=a0e.exec(t))?Jv(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=s0e.exec(t))?u8(e[1],e[2]/100,e[3]/100,1):(e=o0e.exec(t))?u8(e[1],e[2]/100,e[3]/100,e[4]):i8.hasOwnProperty(t)?o8(i8[t]):t==="transparent"?new ss(NaN,NaN,NaN,0):null}function o8(t){return new ss(t>>16&255,t>>8&255,t&255,1)}function Jv(t,e,n,r){return r<=0&&(t=e=n=NaN),new ss(t,e,n,r)}function u0e(t){return t instanceof ey||(t=o0(t)),t?(t=t.rgb(),new ss(t.r,t.g,t.b,t.opacity)):new ss}function u3(t,e,n,r){return arguments.length===1?u0e(t):new ss(t,e,n,r??1)}function ss(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}mD(ss,u3,MK(ey,{brighter(t){return t=t==null?Pw:Math.pow(Pw,t),new ss(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?a0:Math.pow(a0,t),new ss(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ss(Zh(this.r),Zh(this.g),Zh(this.b),Rw(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:l8,formatHex:l8,formatHex8:d0e,formatRgb:c8,toString:c8}));function l8(){return`#${zh(this.r)}${zh(this.g)}${zh(this.b)}`}function d0e(){return`#${zh(this.r)}${zh(this.g)}${zh(this.b)}${zh((isNaN(this.opacity)?1:this.opacity)*255)}`}function c8(){const t=Rw(this.opacity);return`${t===1?"rgb(":"rgba("}${Zh(this.r)}, ${Zh(this.g)}, ${Zh(this.b)}${t===1?")":`, ${t})`}`}function Rw(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Zh(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function zh(t){return t=Zh(t),(t<16?"0":"")+t.toString(16)}function u8(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Vo(t,e,n,r)}function EK(t){if(t instanceof Vo)return new Vo(t.h,t.s,t.l,t.opacity);if(t instanceof ey||(t=o0(t)),!t)return new Vo;if(t instanceof Vo)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,l=a-i,c=(a+i)/2;return l?(e===a?o=(n-r)/l+(n<r)*6:n===a?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?a+i:2-a-i,o*=60):l=c>0&&c<1?0:o,new Vo(o,l,c,t.opacity)}function h0e(t,e,n,r){return arguments.length===1?EK(t):new Vo(t,e,n,r??1)}function Vo(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}mD(Vo,h0e,MK(ey,{brighter(t){return t=t==null?Pw:Math.pow(Pw,t),new Vo(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?a0:Math.pow(a0,t),new Vo(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,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new ss(NT(t>=240?t-240:t+120,i,r),NT(t,i,r),NT(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Vo(d8(this.h),e_(this.s),e_(this.l),Rw(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=Rw(this.opacity);return`${t===1?"hsl(":"hsla("}${d8(this.h)}, ${e_(this.s)*100}%, ${e_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function d8(t){return t=(t||0)%360,t<0?t+360:t}function e_(t){return Math.max(0,Math.min(1,t||0))}function NT(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 pD=t=>()=>t;function f0e(t,e){return function(n){return t+n*e}}function m0e(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function p0e(t){return(t=+t)==1?NK:function(e,n){return n-e?m0e(e,n,t):pD(isNaN(e)?n:e)}}function NK(t,e){var n=e-t;return n?f0e(t,n):pD(isNaN(t)?e:t)}const h8=(function t(e){var n=p0e(e);function r(i,a){var o=n((i=u3(i)).r,(a=u3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=NK(i.opacity,a.opacity);return function(d){return i.r=o(d),i.g=l(d),i.b=c(d),i.opacity=u(d),i+""}}return r.gamma=t,r})(1);function g0e(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function x0e(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function b0e(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),o;for(o=0;o<r;++o)i[o]=Ng(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(l){for(o=0;o<r;++o)a[o]=i[o](l);return a}}function y0e(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function Dw(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function v0e(t,e){var n={},r={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?n[i]=Ng(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var d3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,AT=new RegExp(d3.source,"g");function _0e(t){return function(){return t}}function w0e(t){return function(e){return t(e)+""}}function S0e(t,e){var n=d3.lastIndex=AT.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=d3.exec(t))&&(i=AT.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:Dw(r,i)})),n=AT.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?w0e(c[0].x):_0e(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function Ng(t,e){var n=typeof e,r;return e==null||n==="boolean"?pD(e):(n==="number"?Dw:n==="string"?(r=o0(e))?(e=r,h8):S0e:e instanceof o0?h8:e instanceof Date?y0e:x0e(e)?g0e:Array.isArray(e)?b0e:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?v0e:Dw)(t,e)}function gD(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function M0e(t,e){e===void 0&&(e=t,t=Ng);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[l](o-l)}}function E0e(t){return function(){return t}}function Ow(t){return+t}var f8=[0,1];function za(t){return t}function h3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:E0e(isNaN(e)?NaN:.5)}function N0e(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function A0e(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=h3(i,r),a=n(o,a)):(r=h3(r,i),a=n(a,o)),function(l){return a(r(l))}}function T0e(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=h3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=J0(t,l,1,r)-1;return a[c](i[c](l))}}function ty(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function K2(){var t=f8,e=f8,n=Ng,r,i,a,o=za,l,c,u;function d(){var p=Math.min(t.length,e.length);return o!==za&&(o=N0e(t[0],t[p-1])),l=p>2?T0e:A0e,c=u=null,f}function f(p){return p==null||isNaN(p=+p)?a:(c||(c=l(t.map(r),e,n)))(r(o(p)))}return f.invert=function(p){return o(i((u||(u=l(e,t.map(r),Dw)))(p)))},f.domain=function(p){return arguments.length?(t=Array.from(p,Ow),d()):t.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),n=gD,d()},f.clamp=function(p){return arguments.length?(o=p?!0:za,d()):o!==za},f.interpolate=function(p){return arguments.length?(n=p,d()):n},f.unknown=function(p){return arguments.length?(a=p,f):a},function(p,g){return r=p,i=g,d()}}function xD(){return K2()(za,za)}function C0e(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Lw(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Yp(t){return t=Lw(Math.abs(t)),t?t[1]:NaN}function k0e(t,e){return function(n,r){for(var i=n.length,a=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),a.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return a.reverse().join(e)}}function j0e(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var P0e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function l0(t){if(!(e=P0e.exec(t)))throw new Error("invalid format: "+t);var e;return new bD({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]})}l0.prototype=bD.prototype;function bD(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+""}bD.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 R0e(t){e:for(var e=t.length,n=1,r=-1,i;n<e;++n)switch(t[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+t[n])break e;r>0&&(r=0);break}return r>0?t.slice(0,r)+t.slice(i+1):t}var AK;function D0e(t,e){var n=Lw(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(AK=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+Lw(t,Math.max(0,e+a-1))[0]}function m8(t,e){var n=Lw(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const p8={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:C0e,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)=>m8(t*100,e),r:m8,s:D0e,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function g8(t){return t}var x8=Array.prototype.map,b8=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function O0e(t){var e=t.grouping===void 0||t.thousands===void 0?g8:k0e(x8.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?g8:j0e(x8.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=l0(f);var p=f.fill,g=f.align,b=f.sign,v=f.symbol,x=f.zero,y=f.width,E=f.comma,w=f.precision,A=f.trim,N=f.type;N==="n"?(E=!0,N="g"):p8[N]||(w===void 0&&(w=12),A=!0,N="g"),(x||p==="0"&&g==="=")&&(x=!0,p="0",g="=");var C=v==="$"?n:v==="#"&&/[boxX]/.test(N)?"0"+N.toLowerCase():"",T=v==="$"?r:/[%p]/.test(N)?o:"",D=p8[N],k=/[defgprs%]/.test(N);w=w===void 0?6:/[gprs]/.test(N)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function P(z){var L=C,X=T,R,Y,J;if(N==="c")X=D(z)+X,z="";else{z=+z;var G=z<0||1/z<0;if(z=isNaN(z)?c:D(Math.abs(z),w),A&&(z=R0e(z)),G&&+z==0&&b!=="+"&&(G=!1),L=(G?b==="("?b:l:b==="-"||b==="("?"":b)+L,X=(N==="s"?b8[8+AK/3]:"")+X+(G&&b==="("?")":""),k){for(R=-1,Y=z.length;++R<Y;)if(J=z.charCodeAt(R),48>J||J>57){X=(J===46?i+z.slice(R+1):z.slice(R))+X,z=z.slice(0,R);break}}}E&&!x&&(z=e(z,1/0));var W=L.length+z.length+X.length,ee=W<y?new Array(y-W+1).join(p):"";switch(E&&x&&(z=e(ee+z,ee.length?y-X.length:1/0),ee=""),g){case"<":z=L+z+X+ee;break;case"=":z=L+ee+z+X;break;case"^":z=ee.slice(0,W=ee.length>>1)+L+z+X+ee.slice(W);break;default:z=ee+L+z+X;break}return a(z)}return P.toString=function(){return f+""},P}function d(f,p){var g=u((f=l0(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor(Yp(p)/3)))*3,v=Math.pow(10,-b),x=b8[8+b/3];return function(y){return g(v*y)+x}}return{format:u,formatPrefix:d}}var t_,yD,TK;L0e({thousands:",",grouping:[3],currency:["$",""]});function L0e(t){return t_=O0e(t),yD=t_.format,TK=t_.formatPrefix,t_}function I0e(t){return Math.max(0,-Yp(Math.abs(t)))}function F0e(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Yp(e)/3)))*3-Yp(Math.abs(t)))}function U0e(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Yp(e)-Yp(t))+1}function CK(t,e,n,r){var i=l3(t,e,n),a;switch(r=l0(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=F0e(i,o))&&(r.precision=a),TK(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=U0e(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=I0e(i))&&(r.precision=a-(r.type==="%")*2);break}}return yD(r)}function Wd(t){var e=t.domain;return t.ticks=function(n){var r=e();return s3(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return CK(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,o=r[i],l=r[a],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=o3(o,l,n),u===c)return r[i]=o,r[a]=l,e(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function kK(){var t=xD();return t.copy=function(){return ty(t,kK())},ko.apply(t,arguments),Wd(t)}function jK(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,Ow),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return jK(t).unknown(e)},t=arguments.length?Array.from(t,Ow):[0,1],Wd(n)}function PK(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function y8(t){return Math.log(t)}function v8(t){return Math.exp(t)}function z0e(t){return-Math.log(-t)}function B0e(t){return-Math.exp(-t)}function $0e(t){return isFinite(t)?+("1e"+t):t<0?0:t}function H0e(t){return t===10?$0e:t===Math.E?Math.exp:e=>Math.pow(t,e)}function V0e(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 _8(t){return(e,n)=>-t(-e,n)}function vD(t){const e=t(y8,v8),n=e.domain;let r=10,i,a;function o(){return i=V0e(r),a=H0e(r),n()[0]<0?(i=_8(i),a=_8(a),t(z0e,B0e)):t(y8,v8),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let p=i(u),g=i(d),b,v;const x=l==null?10:+l;let y=[];if(!(r%1)&&g-p<x){if(p=Math.floor(p),g=Math.ceil(g),u>0){for(;p<=g;++p)for(b=1;b<r;++b)if(v=p<0?b/a(-p):b*a(p),!(v<u)){if(v>d)break;y.push(v)}}else for(;p<=g;++p)for(b=r-1;b>=1;--b)if(v=p>0?b/a(-p):b*a(p),!(v<u)){if(v>d)break;y.push(v)}y.length*2<x&&(y=s3(u,d,x))}else y=s3(p,g,Math.min(g-p,x)).map(a);return f?y.reverse():y},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=l0(c)).precision==null&&(c.trim=!0),c=yD(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(PK(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function RK(){const t=vD(K2()).domain([1,10]);return t.copy=()=>ty(t,RK()).base(t.base()),ko.apply(t,arguments),t}function w8(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function S8(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function _D(t){var e=1,n=t(w8(e),S8(e));return n.constant=function(r){return arguments.length?t(w8(e=+r),S8(e)):e},Wd(n)}function DK(){var t=_D(K2());return t.copy=function(){return ty(t,DK()).constant(t.constant())},ko.apply(t,arguments)}function M8(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function G0e(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function W0e(t){return t<0?-t*t:t*t}function wD(t){var e=t(za,za),n=1;function r(){return n===1?t(za,za):n===.5?t(G0e,W0e):t(M8(n),M8(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Wd(e)}function SD(){var t=wD(K2());return t.copy=function(){return ty(t,SD()).exponent(t.exponent())},ko.apply(t,arguments),t}function q0e(){return SD.apply(null,arguments).exponent(.5)}function E8(t){return Math.sign(t)*t*t}function K0e(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function OK(){var t=xD(),e=[0,1],n=!1,r;function i(a){var o=K0e(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(E8(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,Ow)).map(E8)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return OK(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},ko.apply(i,arguments),Wd(i)}function LK(){var t=[],e=[],n=[],r;function i(){var o=0,l=Math.max(1,e.length);for(n=new Array(l-1);++o<l;)n[o-1]=Zbe(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[J0(n,o)]}return a.invertExtent=function(o){var l=e.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:t[0],l<n.length?n[l]:t[t.length-1]]},a.domain=function(o){if(!arguments.length)return t.slice();t=[];for(let l of o)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(wd),i()},a.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},a.unknown=function(o){return arguments.length?(r=o,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return LK().domain(t).range(e).unknown(r)},ko.apply(a,arguments)}function IK(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[J0(r,c,0,n)]:a}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return o}return o.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,l()):[t,e]},o.range=function(c){return arguments.length?(n=(i=Array.from(c)).length-1,l()):i.slice()},o.invertExtent=function(c){var u=i.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,r[0]]:u>=n?[r[n-1],e]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(a=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return IK().domain([t,e]).range(i).unknown(a)},ko.apply(Wd(o),arguments)}function FK(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[J0(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var o=e.indexOf(a);return[t[o-1],t[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return FK().domain(t).range(e).unknown(n)},ko.apply(i,arguments)}const TT=new Date,CT=new Date;function Ri(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const o=i(a),l=i.ceil(a);return a-o<l-a?o:l},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<o)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<o);return c},i.filter=a=>Ri(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(TT.setTime(+a),CT.setTime(+o),t(TT),t(CT),Math.floor(n(TT,CT))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const Iw=Ri(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);Iw.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Ri(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):Iw);Iw.range;const Rc=1e3,bo=Rc*60,Dc=bo*60,tu=Dc*24,MD=tu*7,N8=tu*30,kT=tu*365,Bh=Ri(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Rc)},(t,e)=>(e-t)/Rc,t=>t.getUTCSeconds());Bh.range;const ED=Ri(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Rc)},(t,e)=>{t.setTime(+t+e*bo)},(t,e)=>(e-t)/bo,t=>t.getMinutes());ED.range;const ND=Ri(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*bo)},(t,e)=>(e-t)/bo,t=>t.getUTCMinutes());ND.range;const AD=Ri(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Rc-t.getMinutes()*bo)},(t,e)=>{t.setTime(+t+e*Dc)},(t,e)=>(e-t)/Dc,t=>t.getHours());AD.range;const TD=Ri(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Dc)},(t,e)=>(e-t)/Dc,t=>t.getUTCHours());TD.range;const ny=Ri(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*bo)/tu,t=>t.getDate()-1);ny.range;const X2=Ri(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/tu,t=>t.getUTCDate()-1);X2.range;const UK=Ri(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/tu,t=>Math.floor(t/tu));UK.range;function Uf(t){return Ri(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())*bo)/MD)}const Y2=Uf(0),Fw=Uf(1),X0e=Uf(2),Y0e=Uf(3),Qp=Uf(4),Q0e=Uf(5),Z0e=Uf(6);Y2.range;Fw.range;X0e.range;Y0e.range;Qp.range;Q0e.range;Z0e.range;function zf(t){return Ri(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)/MD)}const Q2=zf(0),Uw=zf(1),J0e=zf(2),eye=zf(3),Zp=zf(4),tye=zf(5),nye=zf(6);Q2.range;Uw.range;J0e.range;eye.range;Zp.range;tye.range;nye.range;const CD=Ri(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());CD.range;const kD=Ri(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());kD.range;const nu=Ri(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());nu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ri(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)});nu.range;const ru=Ri(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());ru.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Ri(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)});ru.range;function zK(t,e,n,r,i,a){const o=[[Bh,1,Rc],[Bh,5,5*Rc],[Bh,15,15*Rc],[Bh,30,30*Rc],[a,1,bo],[a,5,5*bo],[a,15,15*bo],[a,30,30*bo],[i,1,Dc],[i,3,3*Dc],[i,6,6*Dc],[i,12,12*Dc],[r,1,tu],[r,2,2*tu],[n,1,MD],[e,1,N8],[e,3,3*N8],[t,1,kT]];function l(u,d,f){const p=d<u;p&&([u,d]=[d,u]);const g=f&&typeof f.range=="function"?f:c(u,d,f),b=g?g.range(u,+d+1):[];return p?b.reverse():b}function c(u,d,f){const p=Math.abs(d-u)/f,g=dD(([,,x])=>x).right(o,p);if(g===o.length)return t.every(l3(u/kT,d/kT,f));if(g===0)return Iw.every(Math.max(l3(u,d,f),1));const[b,v]=o[p/o[g-1][2]<o[g][2]/p?g-1:g];return b.every(v)}return[l,c]}const[rye,iye]=zK(ru,kD,Q2,UK,TD,ND),[aye,sye]=zK(nu,CD,Y2,ny,AD,ED);function jT(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 PT(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 Fx(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function oye(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Ux(i),d=zx(i),f=Ux(a),p=zx(a),g=Ux(o),b=zx(o),v=Ux(l),x=zx(l),y=Ux(c),E=zx(c),w={a:G,A:W,b:ee,B:K,c:null,d:P8,e:P8,f:kye,g:zye,G:$ye,H:Aye,I:Tye,j:Cye,L:BK,m:jye,M:Pye,p:F,q,Q:O8,s:L8,S:Rye,u:Dye,U:Oye,V:Lye,w:Iye,W:Fye,x:null,X:null,y:Uye,Y:Bye,Z:Hye,"%":D8},A={a:ne,A:re,b:se,B:de,c:null,d:R8,e:R8,f:qye,g:rve,G:ave,H:Vye,I:Gye,j:Wye,L:HK,m:Kye,M:Xye,p:pe,q:Ce,Q:O8,s:L8,S:Yye,u:Qye,U:Zye,V:Jye,w:eve,W:tve,x:null,X:null,y:nve,Y:ive,Z:sve,"%":D8},N={a:P,A:z,b:L,B:X,c:R,d:k8,e:k8,f:Sye,g:C8,G:T8,H:j8,I:j8,j:yye,L:wye,m:bye,M:vye,p:k,q:xye,Q:Eye,s:Nye,S:_ye,u:hye,U:fye,V:mye,w:dye,W:pye,x:Y,X:J,y:C8,Y:T8,Z:gye,"%":Mye};w.x=C(n,w),w.X=C(r,w),w.c=C(e,w),A.x=C(n,A),A.X=C(r,A),A.c=C(e,A);function C(oe,ae){return function(ge){var ue=[],Le=-1,V=0,$=oe.length,Z,B,U;for(ge instanceof Date||(ge=new Date(+ge));++Le<$;)oe.charCodeAt(Le)===37&&(ue.push(oe.slice(V,Le)),(B=A8[Z=oe.charAt(++Le)])!=null?Z=oe.charAt(++Le):B=Z==="e"?" ":"0",(U=ae[Z])&&(Z=U(ge,B)),ue.push(Z),V=Le+1);return ue.push(oe.slice(V,Le)),ue.join("")}}function T(oe,ae){return function(ge){var ue=Fx(1900,void 0,1),Le=D(ue,oe,ge+="",0),V,$;if(Le!=ge.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(ae&&!("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?(V=PT(Fx(ue.y,0,1)),$=V.getUTCDay(),V=$>4||$===0?Uw.ceil(V):Uw(V),V=X2.offset(V,(ue.V-1)*7),ue.y=V.getUTCFullYear(),ue.m=V.getUTCMonth(),ue.d=V.getUTCDate()+(ue.w+6)%7):(V=jT(Fx(ue.y,0,1)),$=V.getDay(),V=$>4||$===0?Fw.ceil(V):Fw(V),V=ny.offset(V,(ue.V-1)*7),ue.y=V.getFullYear(),ue.m=V.getMonth(),ue.d=V.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),$="Z"in ue?PT(Fx(ue.y,0,1)).getUTCDay():jT(Fx(ue.y,0,1)).getDay(),ue.m=0,ue.d="W"in ue?(ue.w+6)%7+ue.W*7-($+5)%7:ue.w+ue.U*7-($+6)%7);return"Z"in ue?(ue.H+=ue.Z/100|0,ue.M+=ue.Z%100,PT(ue)):jT(ue)}}function D(oe,ae,ge,ue){for(var Le=0,V=ae.length,$=ge.length,Z,B;Le<V;){if(ue>=$)return-1;if(Z=ae.charCodeAt(Le++),Z===37){if(Z=ae.charAt(Le++),B=N[Z in A8?ae.charAt(Le++):Z],!B||(ue=B(oe,ge,ue))<0)return-1}else if(Z!=ge.charCodeAt(ue++))return-1}return ue}function k(oe,ae,ge){var ue=u.exec(ae.slice(ge));return ue?(oe.p=d.get(ue[0].toLowerCase()),ge+ue[0].length):-1}function P(oe,ae,ge){var ue=g.exec(ae.slice(ge));return ue?(oe.w=b.get(ue[0].toLowerCase()),ge+ue[0].length):-1}function z(oe,ae,ge){var ue=f.exec(ae.slice(ge));return ue?(oe.w=p.get(ue[0].toLowerCase()),ge+ue[0].length):-1}function L(oe,ae,ge){var ue=y.exec(ae.slice(ge));return ue?(oe.m=E.get(ue[0].toLowerCase()),ge+ue[0].length):-1}function X(oe,ae,ge){var ue=v.exec(ae.slice(ge));return ue?(oe.m=x.get(ue[0].toLowerCase()),ge+ue[0].length):-1}function R(oe,ae,ge){return D(oe,e,ae,ge)}function Y(oe,ae,ge){return D(oe,n,ae,ge)}function J(oe,ae,ge){return D(oe,r,ae,ge)}function G(oe){return o[oe.getDay()]}function W(oe){return a[oe.getDay()]}function ee(oe){return c[oe.getMonth()]}function K(oe){return l[oe.getMonth()]}function F(oe){return i[+(oe.getHours()>=12)]}function q(oe){return 1+~~(oe.getMonth()/3)}function ne(oe){return o[oe.getUTCDay()]}function re(oe){return a[oe.getUTCDay()]}function se(oe){return c[oe.getUTCMonth()]}function de(oe){return l[oe.getUTCMonth()]}function pe(oe){return i[+(oe.getUTCHours()>=12)]}function Ce(oe){return 1+~~(oe.getUTCMonth()/3)}return{format:function(oe){var ae=C(oe+="",w);return ae.toString=function(){return oe},ae},parse:function(oe){var ae=T(oe+="",!1);return ae.toString=function(){return oe},ae},utcFormat:function(oe){var ae=C(oe+="",A);return ae.toString=function(){return oe},ae},utcParse:function(oe){var ae=T(oe+="",!0);return ae.toString=function(){return oe},ae}}}var A8={"-":"",_:" ",0:"0"},Zi=/^\s*\d+/,lye=/^%/,cye=/[\\^$*+?|[\]().{}]/g;function zn(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function uye(t){return t.replace(cye,"\\$&")}function Ux(t){return new RegExp("^(?:"+t.map(uye).join("|")+")","i")}function zx(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function dye(t,e,n){var r=Zi.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function hye(t,e,n){var r=Zi.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function fye(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function mye(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function pye(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function T8(t,e,n){var r=Zi.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function C8(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function gye(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1}function xye(t,e,n){var r=Zi.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function bye(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function k8(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function yye(t,e,n){var r=Zi.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function j8(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function vye(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function _ye(t,e,n){var r=Zi.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function wye(t,e,n){var r=Zi.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Sye(t,e,n){var r=Zi.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Mye(t,e,n){var r=lye.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Eye(t,e,n){var r=Zi.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Nye(t,e,n){var r=Zi.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function P8(t,e){return zn(t.getDate(),e,2)}function Aye(t,e){return zn(t.getHours(),e,2)}function Tye(t,e){return zn(t.getHours()%12||12,e,2)}function Cye(t,e){return zn(1+ny.count(nu(t),t),e,3)}function BK(t,e){return zn(t.getMilliseconds(),e,3)}function kye(t,e){return BK(t,e)+"000"}function jye(t,e){return zn(t.getMonth()+1,e,2)}function Pye(t,e){return zn(t.getMinutes(),e,2)}function Rye(t,e){return zn(t.getSeconds(),e,2)}function Dye(t){var e=t.getDay();return e===0?7:e}function Oye(t,e){return zn(Y2.count(nu(t)-1,t),e,2)}function $K(t){var e=t.getDay();return e>=4||e===0?Qp(t):Qp.ceil(t)}function Lye(t,e){return t=$K(t),zn(Qp.count(nu(t),t)+(nu(t).getDay()===4),e,2)}function Iye(t){return t.getDay()}function Fye(t,e){return zn(Fw.count(nu(t)-1,t),e,2)}function Uye(t,e){return zn(t.getFullYear()%100,e,2)}function zye(t,e){return t=$K(t),zn(t.getFullYear()%100,e,2)}function Bye(t,e){return zn(t.getFullYear()%1e4,e,4)}function $ye(t,e){var n=t.getDay();return t=n>=4||n===0?Qp(t):Qp.ceil(t),zn(t.getFullYear()%1e4,e,4)}function Hye(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+zn(e/60|0,"0",2)+zn(e%60,"0",2)}function R8(t,e){return zn(t.getUTCDate(),e,2)}function Vye(t,e){return zn(t.getUTCHours(),e,2)}function Gye(t,e){return zn(t.getUTCHours()%12||12,e,2)}function Wye(t,e){return zn(1+X2.count(ru(t),t),e,3)}function HK(t,e){return zn(t.getUTCMilliseconds(),e,3)}function qye(t,e){return HK(t,e)+"000"}function Kye(t,e){return zn(t.getUTCMonth()+1,e,2)}function Xye(t,e){return zn(t.getUTCMinutes(),e,2)}function Yye(t,e){return zn(t.getUTCSeconds(),e,2)}function Qye(t){var e=t.getUTCDay();return e===0?7:e}function Zye(t,e){return zn(Q2.count(ru(t)-1,t),e,2)}function VK(t){var e=t.getUTCDay();return e>=4||e===0?Zp(t):Zp.ceil(t)}function Jye(t,e){return t=VK(t),zn(Zp.count(ru(t),t)+(ru(t).getUTCDay()===4),e,2)}function eve(t){return t.getUTCDay()}function tve(t,e){return zn(Uw.count(ru(t)-1,t),e,2)}function nve(t,e){return zn(t.getUTCFullYear()%100,e,2)}function rve(t,e){return t=VK(t),zn(t.getUTCFullYear()%100,e,2)}function ive(t,e){return zn(t.getUTCFullYear()%1e4,e,4)}function ave(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Zp(t):Zp.ceil(t),zn(t.getUTCFullYear()%1e4,e,4)}function sve(){return"+0000"}function D8(){return"%"}function O8(t){return+t}function L8(t){return Math.floor(+t/1e3)}var Mm,GK,WK;ove({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 ove(t){return Mm=oye(t),GK=Mm.format,Mm.parse,WK=Mm.utcFormat,Mm.utcParse,Mm}function lve(t){return new Date(t)}function cve(t){return t instanceof Date?+t:+new Date(+t)}function jD(t,e,n,r,i,a,o,l,c,u){var d=xD(),f=d.invert,p=d.domain,g=u(".%L"),b=u(":%S"),v=u("%I:%M"),x=u("%I %p"),y=u("%a %d"),E=u("%b %d"),w=u("%B"),A=u("%Y");function N(C){return(c(C)<C?g:l(C)<C?b:o(C)<C?v:a(C)<C?x:r(C)<C?i(C)<C?y:E:n(C)<C?w:A)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?p(Array.from(C,cve)):p().map(lve)},d.ticks=function(C){var T=p();return t(T[0],T[T.length-1],C??10)},d.tickFormat=function(C,T){return T==null?N:u(T)},d.nice=function(C){var T=p();return(!C||typeof C.range!="function")&&(C=e(T[0],T[T.length-1],C??10)),C?p(PK(T,C)):d},d.copy=function(){return ty(d,jD(t,e,n,r,i,a,o,l,c,u))},d}function uve(){return ko.apply(jD(aye,sye,nu,CD,Y2,ny,AD,ED,Bh,GK).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function dve(){return ko.apply(jD(rye,iye,ru,kD,Q2,X2,TD,ND,Bh,WK).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Z2(){var t=0,e=1,n,r,i,a,o=za,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(p){var g,b;return arguments.length?([g,b]=p,o=f(g,b),u):[o(0),o(1)]}}return u.range=d(Ng),u.rangeRound=d(gD),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function qd(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function qK(){var t=Wd(Z2()(za));return t.copy=function(){return qd(t,qK())},du.apply(t,arguments)}function KK(){var t=vD(Z2()).domain([1,10]);return t.copy=function(){return qd(t,KK()).base(t.base())},du.apply(t,arguments)}function XK(){var t=_D(Z2());return t.copy=function(){return qd(t,XK()).constant(t.constant())},du.apply(t,arguments)}function PD(){var t=wD(Z2());return t.copy=function(){return qd(t,PD()).exponent(t.exponent())},du.apply(t,arguments)}function hve(){return PD.apply(null,arguments).exponent(.5)}function YK(){var t=[],e=za;function n(r){if(r!=null&&!isNaN(r=+r))return e((J0(t,r,1)-1)/(t.length-1))}return n.domain=function(r){if(!arguments.length)return t.slice();t=[];for(let i of r)i!=null&&!isNaN(i=+i)&&t.push(i);return t.sort(wd),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>Qbe(t,a/r))},n.copy=function(){return YK(e).domain(t)},du.apply(n,arguments)}function J2(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=za,d,f=!1,p;function g(v){return isNaN(v=+v)?p:(v=.5+((v=+d(v))-a)*(r*v<r*a?l:c),u(f?Math.max(0,Math.min(1,v)):v))}g.domain=function(v){return arguments.length?([t,e,n]=v,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,g):[t,e,n]},g.clamp=function(v){return arguments.length?(f=!!v,g):f},g.interpolator=function(v){return arguments.length?(u=v,g):u};function b(v){return function(x){var y,E,w;return arguments.length?([y,E,w]=x,u=M0e(v,[y,E,w]),g):[u(0),u(.5),u(1)]}}return g.range=b(Ng),g.rangeRound=b(gD),g.unknown=function(v){return arguments.length?(p=v,g):p},function(v){return d=v,i=v(t),a=v(e),o=v(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,g}}function QK(){var t=Wd(J2()(za));return t.copy=function(){return qd(t,QK())},du.apply(t,arguments)}function ZK(){var t=vD(J2()).domain([.1,1,10]);return t.copy=function(){return qd(t,ZK()).base(t.base())},du.apply(t,arguments)}function JK(){var t=_D(J2());return t.copy=function(){return qd(t,JK()).constant(t.constant())},du.apply(t,arguments)}function RD(){var t=wD(J2());return t.copy=function(){return qd(t,RD()).exponent(t.exponent())},du.apply(t,arguments)}function fve(){return RD.apply(null,arguments).exponent(.5)}const ob=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:fD,scaleDiverging:QK,scaleDivergingLog:ZK,scaleDivergingPow:RD,scaleDivergingSqrt:fve,scaleDivergingSymlog:JK,scaleIdentity:jK,scaleImplicit:c3,scaleLinear:kK,scaleLog:RK,scaleOrdinal:hD,scalePoint:e0e,scalePow:SD,scaleQuantile:LK,scaleQuantize:IK,scaleRadial:OK,scaleSequential:qK,scaleSequentialLog:KK,scaleSequentialPow:PD,scaleSequentialQuantile:YK,scaleSequentialSqrt:hve,scaleSequentialSymlog:XK,scaleSqrt:q0e,scaleSymlog:DK,scaleThreshold:FK,scaleTime:uve,scaleUtc:dve,tickFormat:CK},Symbol.toStringTag,{value:"Module"}));var Kd=t=>t.chartData,DD=Ze([Kd],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),ry=(t,e,n,r)=>r?DD(t):Kd(t);function Od(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(er(e)&&er(n))return!0}return!1}function I8(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function eX(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(er(n))i=n;else if(typeof n=="function")return;if(er(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(Od(o))return o}}function mve(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Od(r))return I8(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(Ot(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&dB.test(i)){var c=dB.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(Ot(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&hB.test(a)){var d=hB.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var p=[o,l];if(Od(p))return e==null?p:I8(p,e,n)}}}var Ag=1e9,pve={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},LD,kr=!0,To="[DecimalError] ",Jh=To+"Invalid argument: ",OD=To+"Exponent out of range: ",Tg=Math.floor,Ch=Math.pow,gve=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,js,Vi=1e7,Er=7,tX=9007199254740991,zw=Tg(tX/Er),It={};It.absoluteValue=It.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};It.comparedTo=It.cmp=function(t){var e,n,r,i,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(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};It.decimalPlaces=It.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Er;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};It.dividedBy=It.div=function(t){return zc(this,new this.constructor(t))};It.dividedToIntegerBy=It.idiv=function(t){var e=this,n=e.constructor;return xr(zc(e,new n(t),0,1),n.precision)};It.equals=It.eq=function(t){return!this.cmp(t)};It.exponent=function(){return bi(this)};It.greaterThan=It.gt=function(t){return this.cmp(t)>0};It.greaterThanOrEqualTo=It.gte=function(t){return this.cmp(t)>=0};It.isInteger=It.isint=function(){return this.e>this.d.length-2};It.isNegative=It.isneg=function(){return this.s<0};It.isPositive=It.ispos=function(){return this.s>0};It.isZero=function(){return this.s===0};It.lessThan=It.lt=function(t){return this.cmp(t)<0};It.lessThanOrEqualTo=It.lte=function(t){return this.cmp(t)<1};It.logarithm=It.log=function(t){var e,n=this,r=n.constructor,i=r.precision,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(js))throw Error(To+"NaN");if(n.s<1)throw Error(To+(n.s?"NaN":"-Infinity"));return n.eq(js)?new r(0):(kr=!1,e=zc(c0(n,a),c0(t,a),a),kr=!0,xr(e,i))};It.minus=It.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?iX(e,t):nX(e,(t.s=-t.s,t))};It.modulo=It.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(To+"NaN");return n.s?(kr=!1,e=zc(n,t,0,1).times(t),kr=!0,n.minus(e)):xr(new r(n),i)};It.naturalExponential=It.exp=function(){return rX(this)};It.naturalLogarithm=It.ln=function(){return c0(this)};It.negated=It.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};It.plus=It.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?nX(e,t):iX(e,(t.s=-t.s,t))};It.precision=It.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Jh+t);if(e=bi(i)+1,r=i.d.length-1,n=r*Er+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return t&&e>n?e:n};It.squareRoot=It.sqrt=function(){var t,e,n,r,i,a,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(To+"NaN")}for(t=bi(l),kr=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=wl(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Tg((t+1)/2)-(t<0||t%2),i==1/0?e="5e"+t:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),r=new c(e)):r=new c(i.toString()),n=c.precision,i=o=n+3;;)if(a=r,r=a.plus(zc(l,a,o+2)).times(.5),wl(a.d).slice(0,o)===(e=wl(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(xr(a,n+1,0),a.times(a).eq(l)){r=a;break}}else if(e!="9999")break;o+=4}return kr=!0,xr(r,n)};It.times=It.mul=function(t){var e,n,r,i,a,o,l,c,u,d=this,f=d.constructor,p=d.d,g=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=p.length,u=g.length,c<u&&(a=p,p=g,g=a,o=c,c=u,u=o),a=[],o=c+u,r=o;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=a[i]+g[r]*p[i-r-1]+e,a[i--]=l%Vi|0,e=l/Vi|0;a[i]=(a[i]+e)%Vi|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,kr?xr(t,f.precision):t};It.toDecimalPlaces=It.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(jl(t,0,Ag),e===void 0?e=r.rounding:jl(e,0,8),xr(n,t+bi(n)+1,e))};It.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=Sf(r,!0):(jl(t,0,Ag),e===void 0?e=i.rounding:jl(e,0,8),r=xr(new i(r),t+1,e),n=Sf(r,!0,t+1)),n};It.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?Sf(i):(jl(t,0,Ag),e===void 0?e=a.rounding:jl(e,0,8),r=xr(new a(i),t+bi(i)+1,e),n=Sf(r.abs(),!1,t+bi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};It.toInteger=It.toint=function(){var t=this,e=t.constructor;return xr(new e(t),bi(t)+1,e.rounding)};It.toNumber=function(){return+this};It.toPower=It.pow=function(t){var e,n,r,i,a,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(js);if(l=new c(l),!l.s){if(t.s<1)throw Error(To+"Infinity");return l}if(l.eq(js))return l;if(r=c.precision,t.eq(js))return xr(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=tX){for(i=new c(js),e=Math.ceil(r/Er+4),kr=!1;n%2&&(i=i.times(l),U8(i.d,e)),n=Tg(n/2),n!==0;)l=l.times(l),U8(l.d,e);return kr=!0,t.s<0?new c(js).div(i):xr(i,r)}}else if(a<0)throw Error(To+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,kr=!1,i=t.times(c0(l,r+u)),kr=!0,i=rX(i),i.s=a,i};It.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=bi(i),r=Sf(i,n<=a.toExpNeg||n>=a.toExpPos)):(jl(t,1,Ag),e===void 0?e=a.rounding:jl(e,0,8),i=xr(new a(i),t,e),n=bi(i),r=Sf(i,t<=n||n<=a.toExpNeg,t)),r};It.toSignificantDigits=It.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(jl(t,1,Ag),e===void 0?e=r.rounding:jl(e,0,8)),xr(new r(n),t,e)};It.toString=It.valueOf=It.val=It.toJSON=It[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=bi(t),n=t.constructor;return Sf(t,e<=n.toExpNeg||e>=n.toExpPos)};function nX(t,e){var n,r,i,a,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),kr?xr(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Er),l=o>l?o+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/Vi|0,c[a]%=Vi;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,kr?xr(e,f):e}function jl(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Jh+t)}function wl(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Er-r.length,n&&(a+=ed(n)),a+=r;o=t[e],r=o+"",n=Er-r.length,n&&(a+=ed(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var zc=(function(){function t(r,i){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+o,r[l]=a%Vi|0,o=a/Vi|0;return o&&r.unshift(o),r}function e(r,i,a,o){var l,c;if(a!=o)c=a>o?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]<i[a]?1:0,r[a]=o*Vi+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,p,g,b,v,x,y,E,w,A,N,C,T,D,k=r.constructor,P=r.s==i.s?1:-1,z=r.d,L=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(To+"Division by zero");for(c=r.e-i.e,T=L.length,N=z.length,g=new k(P),b=g.d=[],u=0;L[u]==(z[u]||0);)++u;if(L[u]>(z[u]||0)&&--c,a==null?E=a=k.precision:o?E=a+(bi(r)-bi(i))+1:E=a,E<0)return new k(0);if(E=E/Er+2|0,u=0,T==1)for(d=0,L=L[0],E++;(u<N||d)&&E--;u++)w=d*Vi+(z[u]||0),b[u]=w/L|0,d=w%L|0;else{for(d=Vi/(L[0]+1)|0,d>1&&(L=t(L,d),z=t(z,d),T=L.length,N=z.length),A=T,v=z.slice(0,T),x=v.length;x<T;)v[x++]=0;D=L.slice(),D.unshift(0),C=L[0],L[1]>=Vi/2&&++C;do d=0,l=e(L,v,T,x),l<0?(y=v[0],T!=x&&(y=y*Vi+(v[1]||0)),d=y/C|0,d>1?(d>=Vi&&(d=Vi-1),f=t(L,d),p=f.length,x=v.length,l=e(f,v,p,x),l==1&&(d--,n(f,T<p?D:L,p))):(d==0&&(l=d=1),f=L.slice()),p=f.length,p<x&&f.unshift(0),n(v,f,x),l==-1&&(x=v.length,l=e(L,v,T,x),l<1&&(d++,n(v,T<x?D:L,x))),x=v.length):l===0&&(d++,v=[0]),b[u++]=d,l&&v[0]?v[x++]=z[A]||0:(v=[z[A]],x=1);while((A++<N||v[0]!==void 0)&&E--)}return b[0]||b.shift(),g.e=c,xr(g,o?a+bi(g)+1:a)}})();function rX(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(bi(t)>16)throw Error(OD+bi(t));if(!t.s)return new d(js);for(kr=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Ch(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(js),d.precision=l;;){if(i=xr(i.times(t),l),n=n.times(++c),o=a.plus(zc(i,n,l)),wl(o.d).slice(0,l)===wl(a.d).slice(0,l)){for(;u--;)a=xr(a.times(a),l);return d.precision=f,e==null?(kr=!0,xr(a,f)):a}a=o}}function bi(t){for(var e=t.e*Er,n=t.d[0];n>=10;n/=10)e++;return e}function RT(t,e,n){if(e>t.LN10.sd())throw kr=!0,n&&(t.precision=n),Error(To+"LN10 precision limit exceeded");return xr(new t(t.LN10),e)}function ed(t){for(var e="";t--;)e+="0";return e}function c0(t,e){var n,r,i,a,o,l,c,u,d,f=1,p=10,g=t,b=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(To+(g.s?"NaN":"-Infinity"));if(g.eq(js))return new v(0);if(e==null?(kr=!1,u=x):u=e,g.eq(10))return e==null&&(kr=!0),RT(v,u);if(u+=p,v.precision=u,n=wl(b),r=n.charAt(0),a=bi(g),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(t),n=wl(g.d),r=n.charAt(0),f++;a=bi(g),r>1?(g=new v("0."+n),a++):g=new v(r+"."+n.slice(1))}else return c=RT(v,u+2,x).times(a+""),g=c0(new v(r+"."+n.slice(1)),u-p).plus(c),v.precision=x,e==null?(kr=!0,xr(g,x)):g;for(l=o=g=zc(g.minus(js),g.plus(js),u),d=xr(g.times(g),u),i=3;;){if(o=xr(o.times(d),u),c=l.plus(zc(o,new v(i),u)),wl(c.d).slice(0,u)===wl(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(RT(v,u+2,x).times(a+""))),l=zc(l,new v(f),u),v.precision=x,e==null?(kr=!0,xr(l,x)):l;l=c,i+=2}}function F8(t,e){var n,r,i;for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(n<0&&(n=r),n+=+e.slice(r+1),e=e.substring(0,r)):n<0&&(n=e.length),r=0;e.charCodeAt(r)===48;)++r;for(i=e.length;e.charCodeAt(i-1)===48;)--i;if(e=e.slice(r,i),e){if(i-=r,n=n-r-1,t.e=Tg(n/Er),t.d=[],r=(n+1)%Er,n<0&&(r+=Er),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Er;r<i;)t.d.push(+e.slice(r,r+=Er));e=e.slice(r),r=Er-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),kr&&(t.e>zw||t.e<-zw))throw Error(OD+n)}else t.s=0,t.e=0,t.d=[0];return t}function xr(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=Er,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Er),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Er,i=r-Er+o}if(n!==void 0&&(a=Ch(10,o-i-1),l=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/Ch(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=bi(t),f.length=1,e=e-a-1,f[0]=Ch(10,(Er-e%Er)%Er),t.e=Tg(-e/Er)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=Ch(10,Er-r),f[d]=i>0?(u/Ch(10,o-i)%Ch(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==Vi&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=Vi)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(kr&&(t.e>zw||t.e<-zw))throw Error(OD+bi(t));return t}function iX(t,e){var n,r,i,a,o,l,c,u,d,f,p=t.constructor,g=p.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new p(t),kr?xr(e,g):e;if(c=t.d,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(g/Er),l)+2,o>i&&(o=i,n.length=1),n.reverse(),i=o;i--;)n.push(0);n.reverse()}else{for(i=c.length,l=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}o=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=Vi-1;--c[a],c[i]+=Vi}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,kr?xr(e,g):e):new p(0)}function Sf(t,e,n){var r,i=bi(t),a=wl(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+ed(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+ed(-i-1)+a,n&&(r=n-o)>0&&(a+=ed(r))):i>=o?(a+=ed(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+ed(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=ed(r))),t.s<0?"-"+a:a}function U8(t,e){if(t.length>e)return t.length=e,!0}function aX(t){var e,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Jh+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return F8(o,a.toString())}else if(typeof a!="string")throw Error(Jh+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,gve.test(a))F8(o,a);else throw Error(Jh+a)}if(i.prototype=It,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=aX,i.config=i.set=xve,t===void 0&&(t={}),t)for(r=["precision","rounding","toExpNeg","toExpPos","LN10"],e=0;e<r.length;)t.hasOwnProperty(n=r[e++])||(t[n]=this[n]);return i.config(t),i}function xve(t){if(!t||typeof t!="object")throw Error(To+"Object expected");var e,n,r,i=["precision",1,Ag,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<i.length;e+=3)if((r=t[n=i[e]])!==void 0)if(Tg(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Jh+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Jh+n+": "+r);return this}var LD=aX(pve);js=new LD(1);const Zn=LD;var bve=t=>t,sX={},oX=t=>t===sX,z8=t=>function e(){return arguments.length===0||arguments.length===1&&oX(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},lX=(t,e)=>t===1?e:z8(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(o=>o!==sX).length;return a>=t?e(...r):lX(t-a,z8(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>oX(d)?l.shift():d);return e(...u,...l)}))}),yve=t=>lX(t.length,t),f3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},vve=yve((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),_ve=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return bve;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},m3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function cX(t){var e;return t===0?e=1:e=Math.floor(new Zn(t).abs().log(10).toNumber())+1,e}function uX(t,e,n){for(var r=new Zn(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var dX=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},hX=(t,e,n)=>{if(t.lte(0))return new Zn(0);var r=cX(t.toNumber()),i=new Zn(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new Zn(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new Zn(c.toNumber()):new Zn(Math.ceil(c.toNumber()))},wve=(t,e,n)=>{var r=new Zn(1),i=new Zn(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new Zn(10).pow(cX(t)-1),i=new Zn(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new Zn(Math.floor(t)))}else t===0?i=new Zn(Math.floor((e-1)/2)):n||(i=new Zn(Math.floor(t)));var o=Math.floor((e-1)/2),l=_ve(vve(c=>i.add(new Zn(c-o).mul(r)).toNumber()),f3);return l(0,e)},fX=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new Zn(0),tickMin:new Zn(0),tickMax:new Zn(0)};var o=hX(new Zn(n).sub(e).div(r-1),i,a),l;e<=0&&n>=0?l=new Zn(0):(l=new Zn(e).add(n).div(2),l=l.sub(new Zn(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new Zn(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?fX(e,n,r,i,a+1):(d<r&&(u=n>0?u+(r-d):u,c=n>0?c:c+(r-d)),{step:o,tickMin:l.sub(new Zn(c).mul(o)),tickMax:l.add(new Zn(u).mul(o))})},Sve=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=dX([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...f3(0,i-1).map(()=>1/0)]:[...f3(0,i-1).map(()=>-1/0),c];return n>r?m3(u):u}if(l===c)return wve(l,i,a);var{step:d,tickMin:f,tickMax:p}=fX(l,c,o,a,0),g=uX(f,p.add(new Zn(.1).mul(d)),d);return n>r?m3(g):g},Mve=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=dX([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=hX(new Zn(l).sub(o).div(c-1),a,0),d=[...uX(new Zn(o),new Zn(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?m3(d):d},mX=t=>t.rootProps.maxBarSize,Eve=t=>t.rootProps.barGap,pX=t=>t.rootProps.barCategoryGap,Nve=t=>t.rootProps.barSize,iy=t=>t.rootProps.stackOffset,gX=t=>t.rootProps.reverseStackOrder,ID=t=>t.options.chartName,FD=t=>t.rootProps.syncId,xX=t=>t.rootProps.syncMethod,UD=t=>t.options.eventEmitter,Ave=t=>t.rootProps.baseValue,Xr={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},Tc={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},As={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},eM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Tve={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:Tc.angleAxisId,includeHidden:!1,name:void 0,reversed:Tc.reversed,scale:Tc.scale,tick:Tc.tick,tickCount:void 0,ticks:void 0,type:Tc.type,unit:void 0},Cve={allowDataOverflow:As.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:As.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:As.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:As.scale,tick:As.tick,tickCount:As.tickCount,ticks:void 0,type:As.type,unit:void 0},kve={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:Tc.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:Tc.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:Tc.scale,tick:Tc.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},jve={allowDataOverflow:As.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:As.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:As.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:As.scale,tick:As.tick,tickCount:As.tickCount,ticks:void 0,type:"category",unit:void 0},zD=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?kve:Tve,BD=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?jve:Cve,tM=t=>t.polarOptions,$D=Ze([cu,uu,ji],pK),bX=Ze([tM,$D],(t,e)=>{if(t!=null)return Ta(t.innerRadius,e,0)}),yX=Ze([tM,$D],(t,e)=>{if(t!=null)return Ta(t.outerRadius,e,e*.8)}),Pve=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},vX=Ze([tM],Pve);Ze([zD,vX],eM);var _X=Ze([$D,bX,yX],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});Ze([BD,_X],eM);var wX=Ze([Tn,tM,bX,yX,cu,uu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:Ta(o,i,i/2),cy:Ta(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),jr=(t,e)=>e,ay=(t,e,n)=>n;function nM(t){return t?.id}function SX(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return t.forEach(l=>{var c,u=(c=l.data)!==null&&c!==void 0?c:r;if(!(u==null||u.length===0)){var d=nM(l);u.forEach((f,p)=>{var g=a==null||i?p:String(Jn(f,a,null)),b=Jn(f,l.dataKey,0),v;o.has(g)?v=o.get(g):v={},Object.assign(v,{[d]:b}),o.set(g,v)})}}),Array.from(o.values())}function rM(t){return t.stackId!=null&&t.dataKey!=null}var iM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function aM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Rve(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 Di=t=>{var e=Tn(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Cg=t=>t.tooltip.settings.axisId;function B8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Bw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B8(Object(n),!0).forEach(function(r){Dve(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Dve(t,e,n){return(e=Ove(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ove(t){var e=Lve(t,"string");return typeof e=="symbol"?e:e+""}function Lve(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var p3=[0,"auto"],$i={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},MX=(t,e)=>t.cartesianAxis.xAxis[e],$l=(t,e)=>{var n=MX(t,e);return n??$i},Hi={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:p3,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:Y0},EX=(t,e)=>t.cartesianAxis.yAxis[e],Hl=(t,e)=>{var n=EX(t,e);return n??Hi},Ive={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:""},HD=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Ive},Ir=(t,e,n)=>{switch(e){case"xAxis":return $l(t,n);case"yAxis":return Hl(t,n);case"zAxis":return HD(t,n);case"angleAxis":return zD(t,n);case"radiusAxis":return BD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},Fve=(t,e,n)=>{switch(e){case"xAxis":return $l(t,n);case"yAxis":return Hl(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},sy=(t,e,n)=>{switch(e){case"xAxis":return $l(t,n);case"yAxis":return Hl(t,n);case"angleAxis":return zD(t,n);case"radiusAxis":return BD(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},NX=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function VD(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 oy=t=>t.graphicalItems.cartesianItems,Uve=Ze([jr,ay],VD),GD=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),ly=Ze([oy,Ir,Uve],GD,{memoizeOptions:{resultEqualityCheck:aM}}),AX=Ze([ly],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(rM)),TX=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),zve=Ze([ly],TX),WD=t=>t.map(e=>e.data).filter(Boolean).flat(1),Bve=Ze([ly],WD,{memoizeOptions:{resultEqualityCheck:aM}}),qD=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},KD=Ze([Bve,ry],qD),XD=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:Jn(i,r)}))):t.map(r=>({value:r})),sM=Ze([KD,Ir,ly],XD);function CX(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function P1(t){if(No(t)||t instanceof Date){var e=Number(t);if(er(e))return e}}function $8(t){if(Array.isArray(t)){var e=[P1(t[0]),P1(t[1])];return Od(e)?e:void 0}var n=P1(t);if(n!=null)return[n,n]}function iu(t){return t.map(P1).filter(Ffe)}function $ve(t,e,n){return!n||typeof e!="number"||hs(e)?[]:n.length?iu(n.flatMap(r=>{var i=Jn(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!er(a)||!er(o)))return[e-a,e+o]})):[]}var Oi=t=>{var e=Di(t),n=Cg(t);return sy(t,e,n)},cy=Ze([Oi],t=>t?.dataKey),Hve=Ze([AX,ry,Oi],SX),kX=(t,e,n,r)=>{var i={},a=e.reduce((o,l)=>(l.stackId==null||(o[l.stackId]==null&&(o[l.stackId]=[]),o[l.stackId].push(l)),o),i);return Object.fromEntries(Object.entries(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(nM);return[l,{stackedData:lge(t,d,n),graphicalItems:u}]}))},u0=Ze([Hve,AX,iy,gX],kX),jX=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=hge(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Vve=Ze([Ir],t=>t.allowDataOverflow),YD=t=>{var e;if(t==null||!("domain"in t))return p3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=iu(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:p3},QD=Ze([Ir],YD),ZD=Ze([QD,Vve],eX),Gve=Ze([u0,Kd,jr,ZD],jX,{memoizeOptions:{resultEqualityCheck:iM}}),oM=t=>t.errorBars,Wve=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>CX(n,r)),$w=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),o=Math.min(...a),l=Math.max(...a);return[o,l]}},JD=(t,e,n,r,i)=>{var a,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(y=>CX(i,y)),p=Jn(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),g=$ve(l,p,f);if(g.length>=2){var b=Math.min(...g),v=Math.max(...g);(a==null||b<a)&&(a=b),(o==null||v>o)&&(o=v)}var x=$8(p);x!=null&&(a=a==null?x[0]:Math.min(a,x[0]),o=o==null?x[1]:Math.max(o,x[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=$8(Jn(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),er(a)&&er(o))return[a,o]},qve=Ze([KD,Ir,zve,oM,jr],JD,{memoizeOptions:{resultEqualityCheck:iM}});function Kve(t){var{value:e}=t;if(No(e)||e instanceof Date)return e}var Xve=(t,e,n)=>{var r=t.map(Kve).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&WW(r))?yK(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},PX=t=>t.referenceElements.dots,kg=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),Yve=Ze([PX,jr,ay],kg),RX=t=>t.referenceElements.areas,Qve=Ze([RX,jr,ay],kg),DX=t=>t.referenceElements.lines,Zve=Ze([DX,jr,ay],kg),OX=(t,e)=>{var n=iu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},Jve=Ze(Yve,jr,OX),LX=(t,e)=>{var n=iu(t.flatMap(r=>[e==="xAxis"?r.x1:r.y1,e==="xAxis"?r.x2:r.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},e_e=Ze([Qve,jr],LX);function t_e(t){var e;if(t.x!=null)return iu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:iu(n)}function n_e(t){var e;if(t.y!=null)return iu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:iu(n)}var IX=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?t_e(r):n_e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},r_e=Ze([Zve,jr],IX),i_e=Ze(Jve,r_e,e_e,(t,e,n)=>$w(t,n,e)),e4=(t,e,n,r,i,a,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?$w(r,a,i):$w(a,i);return mve(e,u,t.allowDataOverflow)},a_e=Ze([Ir,QD,ZD,Gve,qve,i_e,Tn,jr],e4,{memoizeOptions:{resultEqualityCheck:iM}}),s_e=[0,1],t4=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Bl(e,a);if(u&&l==null){var d;return yK(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?Xve(r,t,u):i==="expand"?s_e:o}},n4=Ze([Ir,Tn,KD,sM,iy,jr,a_e],t4),FX=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:o}=t;if(a==="auto")return e==="radial"&&i==="radiusAxis"?"band":e==="radial"&&i==="angleAxis"?"linear":o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?"point":o==="category"?"band":"linear";if(typeof a=="string"){var l="scale".concat(V0(a));return l in ob?l:"point"}}},jg=Ze([Ir,Tn,NX,ID,jr],FX);function o_e(t){if(t!=null){if(t in ob)return ob[t]();var e="scale".concat(V0(t));if(e in ob)return ob[e]()}}function r4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=o_e(e);if(i!=null){var a=i.domain(n).range(r);return rge(a),a}}}var i4=(t,e,n)=>{var r=YD(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Od(t))return Sve(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Od(t))return Mve(t,e.tickCount,e.allowDecimals)}},a4=Ze([n4,sy,jg],i4),s4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Od(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(o,l)]}return e},l_e=Ze([Ir,n4,a4,jr],s4),c_e=Ze(sM,Ir,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(iu(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var o=r[a+1]-r[a];n=Math.min(n,o)}return n/i}}),UX=Ze(c_e,Tn,pX,ji,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!er(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=Ta(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),u_e=(t,e)=>{var n=$l(t,e);return n==null||typeof n.padding!="string"?0:UX(t,"xAxis",e,n.padding)},d_e=(t,e)=>{var n=Hl(t,e);return n==null||typeof n.padding!="string"?0:UX(t,"yAxis",e,n.padding)},h_e=Ze($l,u_e,(t,e)=>{var n,r;if(t==null)return{left:0,right:0};var{padding:i}=t;return typeof i=="string"?{left:e,right:e}:{left:((n=i.left)!==null&&n!==void 0?n:0)+e,right:((r=i.right)!==null&&r!==void 0?r:0)+e}}),f_e=Ze(Hl,d_e,(t,e)=>{var n,r;if(t==null)return{top:0,bottom:0};var{padding:i}=t;return typeof i=="string"?{top:e,bottom:e}:{top:((n=i.top)!==null&&n!==void 0?n:0)+e,bottom:((r=i.bottom)!==null&&r!==void 0?r:0)+e}}),m_e=Ze([ji,h_e,H2,$2,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),p_e=Ze([ji,Tn,f_e,H2,$2,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:e==="horizontal"?[t.top+t.height-n.bottom,t.top+n.top]:[t.top+n.top,t.top+t.height-n.bottom]}),uy=(t,e,n,r)=>{var i;switch(e){case"xAxis":return m_e(t,n,r);case"yAxis":return p_e(t,n,r);case"zAxis":return(i=HD(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return vX(t);case"radiusAxis":return _X(t,n);default:return}},zX=Ze([Ir,uy],eM),Ld=Ze([Ir,jg,l_e,zX],r4);Ze([ly,oM,jr],Wve);function BX(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var lM=(t,e)=>e,cM=(t,e,n)=>n,g_e=Ze(z2,lM,cM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BX)),x_e=Ze(B2,lM,cM,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(BX)),$X=(t,e)=>({width:t.width,height:e.height}),b_e=(t,e)=>{var n=typeof e.width=="number"?e.width:Y0;return{width:n,height:t.height}},HX=Ze(ji,$l,$X),y_e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},v_e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},__e=Ze(uu,ji,g_e,lM,cM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=$X(e,l);o==null&&(o=y_e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),a}),w_e=Ze(cu,ji,x_e,lM,cM,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=b_e(e,l);o==null&&(o=v_e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),a}),S_e=(t,e)=>{var n=$l(t,e);if(n!=null)return __e(t,n.orientation,n.mirror)},M_e=Ze([ji,$l,S_e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:t.left,y:0}:{x:t.left,y:i}}}),E_e=(t,e)=>{var n=Hl(t,e);if(n!=null)return w_e(t,n.orientation,n.mirror)},N_e=Ze([ji,Hl,E_e,(t,e)=>e],(t,e,n,r)=>{if(e!=null){var i=n?.[r];return i==null?{x:0,y:t.top}:{x:i,y:t.top}}}),VX=Ze(ji,Hl,(t,e)=>{var n=typeof e.width=="number"?e.width:Y0;return{width:n,height:t.height}}),H8=(t,e,n)=>{switch(e){case"xAxis":return HX(t,n).width;case"yAxis":return VX(t,n).height;default:return}},GX=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Bl(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&WW(c))return c}},o4=Ze([Tn,sM,Ir,jr],GX),WX=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Bl(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},l4=Ze([Tn,sM,sy,jr],WX),V8=Ze([Tn,Fve,jg,Ld,o4,l4,uy,a4,jr],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=Bl(t,c);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:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),A_e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Bl(t,c),{type:d,ticks:f,tickCount:p}=e,g=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,b=d==="category"&&r.bandwidth?r.bandwidth()/g:0;b=c==="angleAxis"&&a!=null&&a.length>=2?Ki(a[0]-a[1])*2*b:b;var v=f||i;if(v){var x=v.map((y,E)=>{var w=o?o.indexOf(y):y;return{index:E,coordinate:r(w)+b,value:y,offset:b}});return x.filter(y=>er(y.coordinate))}return u&&l?l.map((y,E)=>({coordinate:r(y)+b,value:y,index:E,offset:b})).filter(y=>er(y.coordinate)):r.ticks?r.ticks(p).map(y=>({coordinate:r(y)+b,value:y,offset:b})):r.domain().map((y,E)=>({coordinate:r(y)+b,value:o?o[y]:y,index:E,offset:b}))}},qX=Ze([Tn,sy,jg,Ld,a4,uy,o4,l4,jr],A_e),T_e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Bl(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?Ki(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},Pl=Ze([Tn,sy,Ld,uy,o4,l4,jr],T_e),Rl=Ze(Ir,Ld,(t,e)=>{if(!(t==null||e==null))return Bw(Bw({},t),{},{scale:e})}),C_e=Ze([Ir,jg,n4,zX],r4);Ze((t,e,n)=>HD(t,n),C_e,(t,e)=>{if(!(t==null||e==null))return Bw(Bw({},t),{},{scale:e})});var k_e=Ze([Tn,z2,B2],(t,e,n)=>{switch(t){case"horizontal":return e.some(r=>r.reversed)?"right-to-left":"left-to-right";case"vertical":return n.some(r=>r.reversed)?"bottom-to-top":"top-to-bottom";case"centric":case"radial":return"left-to-right";default:return}}),KX=t=>t.options.defaultTooltipEventType,XX=t=>t.options.validateTooltipEventTypes;function YX(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function c4(t,e){var n=KX(t),r=XX(t);return YX(e,n,r)}function j_e(t){return Pt(e=>c4(e,t))}var QX=(t,e)=>{var n,r=Number(e);if(!(hs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},P_e=t=>t.tooltip.settings,ld={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},R_e={itemInteraction:{click:ld,hover:ld},axisInteraction:{click:ld,hover:ld},keyboardInteraction:ld,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}},ZX=fs({name:"tooltip",initialState:R_e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Tr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Yo(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Tr()},removeTooltipEntrySettings:{reducer(t,e){var n=Yo(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Tr()},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:D_e,replaceTooltipEntrySettings:O_e,removeTooltipEntrySettings:L_e,setTooltipSettingsState:I_e,setActiveMouseOverItemIndex:JX,mouseLeaveItem:F_e,mouseLeaveChart:eY,setActiveClickItemIndex:U_e,setMouseOverAxisIndex:tY,setMouseClickAxisIndex:z_e,setSyncInteraction:g3,setKeyboardInteraction:x3}=ZX.actions,B_e=ZX.reducer;function G8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function n_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G8(Object(n),!0).forEach(function(r){$_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $_e(t,e,n){return(e=H_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function H_e(t){var e=V_e(t,"string");return typeof e=="symbol"?e:e+""}function V_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function G_e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function W_e(t){return t.index!=null}var nY=(t,e,n,r)=>{if(e==null)return ld;var i=G_e(t,e,n);if(i==null)return ld;if(i.active)return i;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(W_e(i)){if(a)return n_(n_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return n_(n_({},ld),{},{coordinate:i.coordinate})};function q_e(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 K_e(t,e){var n=q_e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function X_e(t,e,n){if(n==null||e==null)return!0;var r=Jn(t,e);return r==null||!Od(n)?!0:K_e(r,n)}var u4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!er(a))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(a,l)),u=e[c];return u==null||X_e(u,n,r)?String(c):null},rY=(t,e,n,r,i,a,o,l)=>{if(!(a==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},iY=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var o;return((o=a.settings)===null||o===void 0?void 0:o.dataKey)===i})},dy=t=>t.options.tooltipPayloadSearcher,Pg=t=>t.tooltip;function W8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function q8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W8(Object(n),!0).forEach(function(r){Y_e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Y_e(t,e,n){return(e=Q_e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Q_e(t){var e=Z_e(t,"string");return typeof e=="symbol"?e:e+""}function Z_e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function J_e(t,e){return t??e}var aY=(t,e,n,r,i,a,o)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((p,g)=>{var b,{dataDefinedOnItem:v,settings:x}=g,y=J_e(v,l),E=Array.isArray(y)?Bq(y,u,d):y,w=(b=x?.dataKey)!==null&&b!==void 0?b:r,A=x?.nameKey,N;if(r&&Array.isArray(E)&&!Array.isArray(E[0])&&o==="axis"?N=qW(E,r,i):N=a(E,e,c,A),Array.isArray(N))N.forEach(T=>{var D=q8(q8({},x),{},{name:T.name,unit:T.unit,color:void 0,fill:void 0});p.push(fB({tooltipEntrySettings:D,dataKey:T.dataKey,payload:T.payload,value:Jn(T.payload,T.dataKey),name:T.name}))});else{var C;p.push(fB({tooltipEntrySettings:x,dataKey:w,payload:N,value:Jn(N,w),name:(C=Jn(N,A))!==null&&C!==void 0?C:x?.name}))}return p},f)}},d4=Ze([Oi,Tn,NX,ID,Di],FX),e1e=Ze([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),t1e=Ze([Di,Cg],VD),hy=Ze([e1e,Oi,t1e],GD,{memoizeOptions:{resultEqualityCheck:aM}}),n1e=Ze([hy],t=>t.filter(rM)),r1e=Ze([hy],WD,{memoizeOptions:{resultEqualityCheck:aM}}),Rg=Ze([r1e,Kd],qD),i1e=Ze([n1e,Kd,Oi],SX),h4=Ze([Rg,Oi,hy],XD),sY=Ze([Oi],YD),a1e=Ze([Oi],t=>t.allowDataOverflow),oY=Ze([sY,a1e],eX),s1e=Ze([hy],t=>t.filter(rM)),o1e=Ze([i1e,s1e,iy,gX],kX),l1e=Ze([o1e,Kd,Di,oY],jX),c1e=Ze([hy],TX),u1e=Ze([Rg,Oi,c1e,oM,Di],JD,{memoizeOptions:{resultEqualityCheck:iM}}),d1e=Ze([PX,Di,Cg],kg),h1e=Ze([d1e,Di],OX),f1e=Ze([RX,Di,Cg],kg),m1e=Ze([f1e,Di],LX),p1e=Ze([DX,Di,Cg],kg),g1e=Ze([p1e,Di],IX),x1e=Ze([h1e,g1e,m1e],$w),b1e=Ze([Oi,sY,oY,l1e,u1e,x1e,Tn,Di],e4),fy=Ze([Oi,Tn,Rg,h4,iy,Di,b1e],t4),y1e=Ze([fy,Oi,d4],i4),v1e=Ze([Oi,fy,y1e,Di],s4),lY=t=>{var e=Di(t),n=Cg(t),r=!1;return uy(t,e,n,r)},cY=Ze([Oi,lY],eM),uY=Ze([Oi,d4,v1e,cY],r4),_1e=Ze([Tn,h4,Oi,Di],GX),w1e=Ze([Tn,h4,Oi,Di],WX),S1e=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=Bl(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?Ki(i[0]-i[1])*2*f:f,u&&o?o.map((p,g)=>({coordinate:r(p)+f,value:p,index:g,offset:f})):r.domain().map((p,g)=>({coordinate:r(p)+f,value:a?a[p]:p,index:g,offset:f}))}}},hu=Ze([Tn,Oi,d4,uY,lY,_1e,w1e,Di],S1e),f4=Ze([KX,XX,P_e],(t,e,n)=>YX(n.shared,t,e)),dY=t=>t.tooltip.settings.trigger,m4=t=>t.tooltip.settings.defaultIndex,my=Ze([Pg,f4,dY,m4],nY),Id=Ze([my,Rg,cy,fy],u4),hY=Ze([hu,Id],QX),p4=Ze([my],t=>{if(t)return t.dataKey}),M1e=Ze([my],t=>{if(t)return t.graphicalItemId}),fY=Ze([Pg,f4,dY,m4],iY),E1e=Ze([cu,uu,Tn,ji,hu,m4,fY,dy],rY),N1e=Ze([my,E1e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),A1e=Ze([my],t=>t.active),T1e=Ze([fY,Id,Kd,cy,hY,dy,f4],aY),C1e=Ze([T1e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function K8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function X8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K8(Object(n),!0).forEach(function(r){k1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function k1e(t,e,n){return(e=j1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function j1e(t){var e=P1e(t,"string");return typeof e=="symbol"?e:e+""}function P1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var R1e=()=>Pt(Oi),D1e=()=>{var t=R1e(),e=Pt(hu),n=Pt(uY);return Dd(!t||!n?void 0:X8(X8({},t),{},{scale:n}),e)};function Y8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Em(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y8(Object(n),!0).forEach(function(r){O1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function O1e(t,e,n){return(e=L1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function L1e(t){var e=I1e(t,"string");return typeof e=="symbol"?e:e+""}function I1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var F1e=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},U1e=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:o}=r;return Em(Em(Em({},r),pi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return Em(Em(Em({},r),pi(r.cx,r.cy,l,c)),{},{angle:c,radius:l})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function z1e(t,e){var{chartX:n,chartY:r}=t;return n>=e.left&&n<=e.left+e.width&&r>=e.top&&r<=e.top+e.height}var mY=(t,e,n,r,i)=>{var a,o=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,p=void 0;if(Ki(d-u)!==Ki(f-d)){var g=[];if(Ki(f-d)===Ki(i[1]-i[0])){p=f;var b=d+i[1]-i[0];g[0]=Math.min(b,(b+u)/2),g[1]=Math.max(b,(b+u)/2)}else{p=u;var v=f+i[1]-i[0];g[0]=Math.min(d,(v+d)/2),g[1]=Math.max(d,(v+d)/2)}var x=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>x[0]&&t<=x[1]||t>=g[0]&&t<=g[1]){({index:o}=n[c]);break}}else{var y=Math.min(u,f),E=Math.max(u,f);if(t>(y+d)/2&&t<=(E+d)/2){({index:o}=n[c]);break}}}else if(e){for(var w=0;w<l;w++)if(w===0&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w>0&&w<l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2&&t<=(e[w].coordinate+e[w+1].coordinate)/2||w===l-1&&t>(e[w].coordinate+e[w-1].coordinate)/2){({index:o}=e[w]);break}}return o},pY=()=>Pt(ID),g4=(t,e)=>e,gY=(t,e,n)=>n,x4=(t,e,n,r)=>r,B1e=Ze(hu,t=>j2(t,e=>e.coordinate)),b4=Ze([Pg,g4,gY,x4],nY),y4=Ze([b4,Rg,cy,fy],u4),$1e=(t,e,n)=>{if(e!=null){var r=Pg(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},xY=Ze([Pg,g4,gY,x4],iY),Hw=Ze([cu,uu,Tn,ji,hu,x4,xY,dy],rY),H1e=Ze([b4,Hw],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),bY=Ze([hu,y4],QX),V1e=Ze([xY,y4,Kd,cy,bY,dy,g4],aY),G1e=Ze([b4,y4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),W1e=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&z1e(t,o)){var l=fge(t,e),c=mY(l,a,i,n,r),u=F1e(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},q1e=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=kbe(t,n);if(l){var c=mge(l,e),u=mY(c,o,a,r,i),d=U1e(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},K1e=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?W1e(t,e,r,i,a,o,l):q1e(t,e,n,r,i,a,o)},X1e=Ze(t=>t.zIndex.zIndexMap,(t,e)=>e,(t,e,n)=>n,(t,e,n)=>{if(e!=null){var r=t[e];if(r!=null)return n?r.panoramaElementId:r.elementId}}),Y1e=Ze(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(Xr)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Rve}});function Q8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Z8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q8(Object(n),!0).forEach(function(r){Q1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q1e(t,e,n){return(e=Z1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z1e(t){var e=J1e(t,"string");return typeof e=="symbol"?e:e+""}function J1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var ewe={},twe={zIndexMap:Object.values(Xr).reduce((t,e)=>Z8(Z8({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),ewe)},nwe=new Set(Object.values(Xr));function rwe(t){return nwe.has(t)}var yY=fs({name:"zIndex",initialState:twe,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:Tr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!rwe(n)&&delete t.zIndexMap[n])},prepare:Tr()},registerZIndexPortalId:{reducer:(t,e)=>{var{zIndex:n,elementId:r,isPanorama:i}=e.payload;t.zIndexMap[n]?i?t.zIndexMap[n].panoramaElementId=r:t.zIndexMap[n].elementId=r:t.zIndexMap[n]={consumers:0,elementId:i?void 0:r,panoramaElementId:i?r:void 0}},prepare:Tr()},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:Tr()}}}),{registerZIndexPortal:iwe,unregisterZIndexPortal:awe,registerZIndexPortalId:swe,unregisterZIndexPortalId:owe}=yY.actions,lwe=yY.reducer;function Ca(t){var{zIndex:e,children:n}=t,r=Wge(),i=r&&e!==void 0&&e!==0,a=Pi(),o=br();S.useLayoutEffect(()=>i?(o(iwe({zIndex:e})),()=>{o(awe({zIndex:e}))}):G0,[o,e,i]);var l=Pt(u=>X1e(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?Pc.createPortal(n,c):null}function b3(){return b3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b3.apply(null,arguments)}function J8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function r_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?J8(Object(n),!0).forEach(function(r){cwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):J8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cwe(t,e,n){return(e=uwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uwe(t){var e=dwe(t,"string");return typeof e=="symbol"?e:e+""}function dwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function hwe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return S.isValidElement(e)?S.cloneElement(e,r):S.createElement(n,r)}function fwe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,p=r,g=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var b,v,x;if(d==="ScatterChart")b=f,v=Gxe,x=Xr.cursorLine;else if(d==="BarChart")b=Wxe(l,f,a,o),v=mK,x=Xr.cursorRectangle;else if(l==="radial"&&XW(f)){var{cx:y,cy:E,radius:w,startAngle:A,endAngle:N}=gK(f);b={cx:y,cy:E,startAngle:A,endAngle:N,innerRadius:w,outerRadius:w},v=bK,x=Xr.cursorLine}else b={points:Dbe(l,f,a)},v=Tp,x=Xr.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,T=r_(r_(r_(r_({stroke:"#ccc",pointerEvents:"none"},a),b),yf(c)),{},{payload:p,payloadIndex:g,className:On("recharts-tooltip-cursor",C)});return S.createElement(Ca,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:x},S.createElement(hwe,{cursor:c,cursorComp:v,cursorProps:T}))}function mwe(t){var e=D1e(),n=Zq(),r=Ff(),i=pY();return e==null||n==null||r==null||i==null?null:S.createElement(fwe,b3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var vY=S.createContext(null),pwe=()=>S.useContext(vY),DT={exports:{}},e6;function gwe(){return e6||(e6=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var g=new i(d,f||c,p),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],g]:c._events[b].push(g):(c._events[b]=g,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,g=f.length,b=new Array(g);p<g;p++)b[p]=f[p].fn;return b},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,p,g,b){var v=n?n+u:u;if(!this._events[v])return!1;var x=this._events[v],y=arguments.length,E,w;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),y){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,d),!0;case 3:return x.fn.call(x.context,d,f),!0;case 4:return x.fn.call(x.context,d,f,p),!0;case 5:return x.fn.call(x.context,d,f,p,g),!0;case 6:return x.fn.call(x.context,d,f,p,g,b),!0}for(w=1,E=new Array(y-1);w<y;w++)E[w-1]=arguments[w];x.fn.apply(x.context,E)}else{var A=x.length,N;for(w=0;w<A;w++)switch(x[w].once&&this.removeListener(u,x[w].fn,void 0,!0),y){case 1:x[w].fn.call(x[w].context);break;case 2:x[w].fn.call(x[w].context,d);break;case 3:x[w].fn.call(x[w].context,d,f);break;case 4:x[w].fn.call(x[w].context,d,f,p);break;default:if(!E)for(N=1,E=new Array(y-1);N<y;N++)E[N-1]=arguments[N];x[w].fn.apply(x[w].context,E)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,p){var g=n?n+u:u;if(!this._events[g])return this;if(!d)return o(this,g),this;var b=this._events[g];if(b.fn)b.fn===d&&(!p||b.once)&&(!f||b.context===f)&&o(this,g);else{for(var v=0,x=[],y=b.length;v<y;v++)(b[v].fn!==d||p&&!b[v].once||f&&b[v].context!==f)&&x.push(b[v]);x.length?this._events[g]=x.length===1?x[0]:x:o(this,g)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,t.exports=l})(DT)),DT.exports}var xwe=gwe();const bwe=Co(xwe);var d0=new bwe,y3="recharts.syncEvent.tooltip",t6="recharts.syncEvent.brush";function uM(t,e){if(e){var n=Number.parseInt(e,10);if(!hs(n))return t?.[n]}}var ywe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},_Y=fs({name:"options",initialState:ywe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),vwe=_Y.reducer,{createEventEmitter:_we}=_Y.actions;function wwe(t){return t.tooltip.syncInteraction}var Swe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},wY=fs({name:"chartData",initialState:Swe,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:r}=e.payload;n!=null&&(t.dataStartIndex=n),r!=null&&(t.dataEndIndex=r)}}}),{setChartData:n6,setDataStartEndIndexes:Mwe,setComputedData:Zqe}=wY.actions,Ewe=wY.reducer,Nwe=["x","y"];function r6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Nm(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r6(Object(n),!0).forEach(function(r){Awe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Awe(t,e,n){return(e=Twe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Twe(t){var e=Cwe(t,"string");return typeof e=="symbol"?e:e+""}function Cwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function kwe(t,e){if(t==null)return{};var n,r,i=jwe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jwe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Pwe(){var t=Pt(FD),e=Pt(UD),n=br(),r=Pt(xX),i=Pt(hu),a=Ff(),o=Q0(),l=Pt(c=>c.rootProps.className);S.useEffect(()=>{if(t==null)return G0;var c=(u,d,f)=>{if(e!==f&&t===u){if(r==="index"){var p;if(o&&d!==null&&d!==void 0&&(p=d.payload)!==null&&p!==void 0&&p.coordinate&&d.payload.sourceViewBox){var g=d.payload.coordinate,{x:b,y:v}=g,x=kwe(g,Nwe),{x:y,y:E,width:w,height:A}=d.payload.sourceViewBox,N=Nm(Nm({},x),{},{x:o.x+(w?(b-y)/w:0)*o.width,y:o.y+(A?(v-E)/A:0)*o.height});n(Nm(Nm({},d),{},{payload:Nm(Nm({},d.payload),{},{coordinate:N})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var T={activeTooltipIndex:d.payload.index==null?void 0:Number(d.payload.index),isTooltipActive:d.payload.active,activeIndex:d.payload.index==null?void 0:Number(d.payload.index),activeLabel:d.payload.label,activeDataKey:d.payload.dataKey,activeCoordinate:d.payload.coordinate},D=r(i,T);C=i[D]}else r==="value"&&(C=i.find(J=>String(J.value)===d.payload.label));var{coordinate:k}=d.payload;if(C==null||d.payload.active===!1||k==null||o==null){n(g3({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:P,y:z}=k,L=Math.min(P,o.x+o.width),X=Math.min(z,o.y+o.height),R={x:a==="horizontal"?C.coordinate:L,y:a==="horizontal"?X:C.coordinate},Y=g3({active:d.payload.active,coordinate:R,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(Y)}}};return d0.on(y3,c),()=>{d0.off(y3,c)}},[l,n,e,t,r,i,a,o])}function Rwe(){var t=Pt(FD),e=Pt(UD),n=br();S.useEffect(()=>{if(t==null)return G0;var r=(i,a,o)=>{e!==o&&t===i&&n(Mwe(a))};return d0.on(t6,r),()=>{d0.off(t6,r)}},[n,e,t])}function Dwe(){var t=br();S.useEffect(()=>{t(_we())},[t]),Pwe(),Rwe()}function Owe(t,e,n,r,i,a){var o=Pt(g=>$1e(g,t,e)),l=Pt(UD),c=Pt(FD),u=Pt(xX),d=Pt(wwe),f=d?.active,p=Q0();S.useEffect(()=>{if(!f&&c!=null&&l!=null){var g=g3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:p,graphicalItemId:void 0});d0.emit(y3,c,g,l)}},[f,n,o,i,r,l,c,u,a,p])}function i6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function a6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i6(Object(n),!0).forEach(function(r){Lwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lwe(t,e,n){return(e=Iwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Iwe(t){var e=Fwe(t,"string");return typeof e=="symbol"?e:e+""}function Fwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Uwe(t){return t.dataKey}function zwe(t,e){return S.isValidElement(t)?S.cloneElement(t,e):typeof t=="function"?S.createElement(t,e):S.createElement(Mxe,e)}var s6=[],Bwe={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 R1(t){var e,n,r=Lr(t,Bwe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:p,position:g,reverseDirection:b,useTranslate3d:v,wrapperStyle:x,cursor:y,shared:E,trigger:w,defaultIndex:A,portal:N,axisId:C}=r,T=br(),D=typeof A=="number"?String(A):A;S.useEffect(()=>{T(I_e({shared:E,trigger:w,axisId:C,active:i,defaultIndex:D}))},[T,E,w,C,i,D]);var k=Q0(),P=cK(),z=j_e(E),{activeIndex:L,isActive:X}=(e=Pt(pe=>G1e(pe,z,w,D)))!==null&&e!==void 0?e:{},R=Pt(pe=>V1e(pe,z,w,D)),Y=Pt(pe=>bY(pe,z,w,D)),J=Pt(pe=>H1e(pe,z,w,D)),G=R,W=pwe(),ee=(n=i??X)!==null&&n!==void 0?n:!1,[K,F]=dq([G,ee]),q=z==="axis"?Y:void 0;Owe(z,w,J,q,L,ee);var ne=N??W;if(ne==null||k==null||z==null)return null;var re=G??s6;ee||(re=s6),u&&re.length&&(re=aq(re.filter(pe=>pe.value!=null&&(pe.hide!==!0||r.includeHidden)),p,Uwe));var se=re.length>0,de=S.createElement(jxe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:ee,coordinate:J,hasPayload:se,offset:f,position:g,reverseDirection:b,useTranslate3d:v,viewBox:k,wrapperStyle:x,lastBoundingBox:K,innerRef:F,hasPortalFromProps:!!N},zwe(c,a6(a6({},r),{},{payload:re,label:q,active:ee,activeIndex:L,coordinate:J,accessibilityLayer:P})));return S.createElement(S.Fragment,null,Pc.createPortal(de,ne),ee&&S.createElement(mwe,{cursor:y,tooltipEventType:z,coordinate:J,payload:re,index:L}))}var py=t=>null;py.displayName="Cell";function $we(t,e,n){return(e=Hwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Hwe(t){var e=Vwe(t,"string");return typeof e=="symbol"?e:e+""}function Vwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class Gwe{constructor(e){$we(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 r=this.cache.keys().next().value;r!=null&&this.cache.delete(r)}this.cache.set(e,n)}clear(){this.cache.clear()}size(){return this.cache.size}}function o6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Wwe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o6(Object(n),!0).forEach(function(r){qwe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function qwe(t,e,n){return(e=Kwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Kwe(t){var e=Xwe(t,"string");return typeof e=="symbol"?e:e+""}function Xwe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ywe={cacheSize:2e3,enableCache:!0},SY=Wwe({},Ywe),l6=new Gwe(SY.cacheSize),Qwe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},c6="recharts_measurement_span";function Zwe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(o,"|").concat(l)}var u6=(t,e)=>{try{var n=document.getElementById(c6);n||(n=document.createElement("span"),n.setAttribute("id",c6),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,Qwe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},wb=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Sg.isSsr)return{width:0,height:0};if(!SY.enableCache)return u6(e,n);var r=Zwe(e,n),i=l6.get(r);if(i)return i;var a=u6(e,n);return l6.set(r,a),a},d6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,h6=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Jwe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,eSe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,MY={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},tSe=Object.keys(MY),vp="NaN";function nSe(t,e){return t*MY[e]}class rs{static parse(e){var n,[,r,i]=(n=eSe.exec(e))!==null&&n!==void 0?n:[];return new rs(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,hs(e)&&(this.unit=""),n!==""&&!Jwe.test(n)&&(this.num=NaN,this.unit=""),tSe.includes(n)&&(this.num=nSe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new rs(NaN,""):new rs(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new rs(NaN,""):new rs(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new rs(NaN,""):new rs(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new rs(NaN,""):new rs(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return hs(this.num)}}function EY(t){if(t.includes(vp))return vp;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=d6.exec(e))!==null&&n!==void 0?n:[],o=rs.parse(r??""),l=rs.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return vp;e=e.replace(d6,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,p]=(u=h6.exec(e))!==null&&u!==void 0?u:[],g=rs.parse(d??""),b=rs.parse(p??""),v=f==="+"?g.add(b):g.subtract(b);if(v.isNaN())return vp;e=e.replace(h6,v.toString())}return e}var f6=/\(([^()]*)\)/;function rSe(t){for(var e=t,n;(n=f6.exec(e))!=null;){var[,r]=n;e=e.replace(f6,EY(r))}return e}function iSe(t){var e=t.replace(/\s+/g,"");return e=rSe(e),e=EY(e),e}function aSe(t){try{return iSe(t)}catch{return vp}}function OT(t){var e=aSe(t.slice(5,-1));return e===vp?"":e}var sSe=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],oSe=["dx","dy","angle","className","breakAll"];function v3(){return v3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},v3.apply(null,arguments)}function m6(t,e){if(t==null)return{};var n,r,i=lSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function lSe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var NY=/[ \f\n\r\t\v\u2028\u2029]+/,AY=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Nr(e)||(n?i=e.toString().split(""):i=e.toString().split(NY));var a=i.map(l=>({word:l,width:wb(l,r).width})),o=n?0:wb(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function cSe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var TY=(t,e,n,r)=>t.reduce((i,a)=>{var{word:o,width:l}=a,c=i[i.length-1];if(c&&l!=null&&(e==null||r||c.width+l+n<Number(e)))c.words.push(o),c.width+=l+n;else{var u={words:[o],width:l};i.push(u)}return i},[]),CY=t=>t.reduce((e,n)=>e.width>n.width?e:n),uSe="…",p6=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=AY({breakAll:n,style:r,children:c+uSe});if(!u)return[!1,[]];var d=TY(u.wordsWithComputedWidth,a,o,l),f=d.length>i||CY(d).width>Number(a);return[f,d]},dSe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=Ot(a),d=String(o),f=TY(e,r,n,i);if(!u||i)return f;var p=f.length>a||CY(f).width>Number(r);if(!p)return f;for(var g=0,b=d.length-1,v=0,x;g<=b&&v<=d.length-1;){var y=Math.floor((g+b)/2),E=y-1,[w,A]=p6(d,E,c,l,a,r,n,i),[N]=p6(d,y,c,l,a,r,n,i);if(!w&&!N&&(g=y+1),w&&N&&(b=y-1),!w&&N){x=A;break}v++}return x||f},g6=t=>{var e=Nr(t)?[]:t.toString().split(NY);return[{words:e,width:void 0}]},hSe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!Sg.isSsr){var l,c,u=AY({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return g6(r);return dSe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return g6(r)},kY="#808080",fSe={angle:0,breakAll:!1,capHeight:"0.71em",fill:kY,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},dM=S.forwardRef((t,e)=>{var n=Lr(t,fSe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=m6(n,sSe),p=S.useMemo(()=>hSe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:g,dy:b,angle:v,className:x,breakAll:y}=f,E=m6(f,oSe);if(!No(r)||!No(i)||p.length===0)return null;var w=Number(r)+(Ot(g)?g:0),A=Number(i)+(Ot(b)?b:0);if(!er(w)||!er(A))return null;var N;switch(d){case"start":N=OT("calc(".concat(o,")"));break;case"middle":N=OT("calc(".concat((p.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:N=OT("calc(".concat(p.length-1," * -").concat(a,")"));break}var C=[];if(c){var T=p[0].width,{width:D}=f;C.push("scale(".concat(Ot(D)&&Ot(T)?D/T:1,")"))}return v&&C.push("rotate(".concat(v,", ").concat(w,", ").concat(A,")")),C.length&&(E.transform=C.join(" ")),S.createElement("text",v3({},ga(E),{ref:e,x:w,y:A,className:On("recharts-text",x),textAnchor:u,fill:l.includes("url")?kY:l}),p.map((k,P)=>{var z=k.words.join(y?"":" ");return S.createElement("tspan",{x:w,dy:P===0?N:a,key:"".concat(z,"-").concat(P)},z)}))});dM.displayName="Text";var mSe=["labelRef"];function pSe(t,e){if(t==null)return{};var n,r,i=gSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function gSe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function x6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ri(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?x6(Object(n),!0).forEach(function(r){xSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):x6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xSe(t,e,n){return(e=bSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bSe(t){var e=ySe(t,"string");return typeof e=="symbol"?e:e+""}function ySe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Cc(){return Cc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Cc.apply(null,arguments)}var jY=S.createContext(null),PY=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=S.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return S.createElement(jY.Provider,{value:c},l)},RY=()=>{var t=S.useContext(jY),e=Q0();return t||Qq(e)},vSe=S.createContext(null),_Se=()=>{var t=S.useContext(vSe),e=Pt(wX);return t||e},wSe=t=>{var{value:e,formatter:n}=t,r=Nr(t.children)?e:t.children;return typeof n=="function"?n(r):r},v4=t=>t!=null&&typeof t=="function",SSe=(t,e)=>{var n=Ki(e-t),r=Math.min(Math.abs(e-t),360);return n*r},MSe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:p,clockWise:g}=i,b=(u+d)/2,v=SSe(f,p),x=v>=0?1:-1,y,E;switch(e){case"insideStart":y=f+x*a,E=g;break;case"insideEnd":y=p-x*a,E=!g;break;case"end":y=p+x*a,E=g;break;default:throw new Error("Unsupported position ".concat(e))}E=v<=0?E:!E;var w=pi(l,c,b,y),A=pi(l,c,b,y+(E?1:-1)*359),N="M".concat(w.x,",").concat(w.y,`
- A`).concat(b,",").concat(b,",0,1,").concat(E?0:1,`,
- `).concat(A.x,",").concat(A.y),C=Nr(t.id)?Qb("recharts-radial-line-"):t.id;return S.createElement("text",Cc({},r,{dominantBaseline:"central",className:On("recharts-radial-bar-label",o)}),S.createElement("defs",null,S.createElement("path",{id:C,d:N})),S.createElement("textPath",{xlinkHref:"#".concat(C)},n))},ESe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=pi(r,i,o+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var p=(a+o)/2,{x:g,y:b}=pi(r,i,p,u);return{x:g,y:b,textAnchor:"middle",verticalAnchor:"middle"}},_3=t=>"cx"in t&&Ot(t.cx),NSe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!_3(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,p=o+(c-u)/2,g=(f+p)/2,b=(c+u)/2,v=f+c/2,x=d>=0?1:-1,y=x*r,E=x>0?"end":"start",w=x>0?"start":"end",A=c>=0?1:-1,N=A*r,C=A>0?"end":"start",T=A>0?"start":"end";if(i==="top"){var D={x:f+c/2,y:l-y,textAnchor:"middle",verticalAnchor:E};return ri(ri({},D),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var k={x:p+u/2,y:l+d+y,textAnchor:"middle",verticalAnchor:w};return ri(ri({},k),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var P={x:g-N,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return ri(ri({},P),a?{width:Math.max(P.x-a.x,0),height:d}:{})}if(i==="right"){var z={x:g+b+N,y:l+d/2,textAnchor:T,verticalAnchor:"middle"};return ri(ri({},z),a?{width:Math.max(a.x+a.width-z.x,0),height:d}:{})}var L=a?{width:b,height:d}:{};return i==="insideLeft"?ri({x:g+N,y:l+d/2,textAnchor:T,verticalAnchor:"middle"},L):i==="insideRight"?ri({x:g+b-N,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},L):i==="insideTop"?ri({x:f+c/2,y:l+y,textAnchor:"middle",verticalAnchor:w},L):i==="insideBottom"?ri({x:p+u/2,y:l+d-y,textAnchor:"middle",verticalAnchor:E},L):i==="insideTopLeft"?ri({x:f+N,y:l+y,textAnchor:T,verticalAnchor:w},L):i==="insideTopRight"?ri({x:f+c-N,y:l+y,textAnchor:C,verticalAnchor:w},L):i==="insideBottomLeft"?ri({x:p+N,y:l+d-y,textAnchor:T,verticalAnchor:E},L):i==="insideBottomRight"?ri({x:p+u-N,y:l+d-y,textAnchor:C,verticalAnchor:E},L):i&&typeof i=="object"&&(Ot(i.x)||Jc(i.x))&&(Ot(i.y)||Jc(i.y))?ri({x:o+Ta(i.x,b),y:l+Ta(i.y,d),textAnchor:"end",verticalAnchor:"end"},L):ri({x:v,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},L)},ASe={angle:0,offset:5,zIndex:Xr.label,position:"middle",textBreakAll:!1};function td(t){var e=Lr(t,ASe),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=_Se(),f=RY(),p=r==="center"?f:d??f,g,b,v;if(n==null?g=p:_3(n)?g=n:g=Qq(n),!g||Nr(i)&&Nr(a)&&!S.isValidElement(o)&&typeof o!="function")return null;var x=ri(ri({},e),{},{viewBox:g});if(S.isValidElement(o)){var{labelRef:y}=x,E=pSe(x,mSe);return S.cloneElement(o,E)}if(typeof o=="function"){if(b=S.createElement(o,x),S.isValidElement(b))return b}else b=wSe(e);var w=ga(e);if(_3(g)){if(r==="insideStart"||r==="insideEnd"||r==="end")return MSe(e,r,b,w,g);v=ESe(g,e.offset,e.position)}else v=NSe(e,g);return S.createElement(Ca,{zIndex:e.zIndex},S.createElement(dM,Cc({ref:u,className:On("recharts-label",l)},w,v,{textAnchor:cSe(w.textAnchor)?w.textAnchor:v.textAnchor,breakAll:c}),b))}td.displayName="Label";var TSe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?S.createElement(td,Cc({key:"label-implicit"},r)):No(t)?S.createElement(td,Cc({key:"label-implicit",value:t},r)):S.isValidElement(t)?t.type===td?S.cloneElement(t,ri({key:"label-implicit"},r)):S.createElement(td,Cc({key:"label-implicit",content:t},r)):v4(t)?S.createElement(td,Cc({key:"label-implicit",content:t},r)):t&&typeof t=="object"?S.createElement(td,Cc({},t,{key:"label-implicit"},r)):null};function DY(t){var{label:e,labelRef:n}=t,r=RY();return TSe(e,r,n)||null}var LT={},IT={},b6;function CSe(){return b6||(b6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(IT)),IT}var FT={},y6;function kSe(){return y6||(y6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(FT)),FT}var v6;function jSe(){return v6||(v6=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=CSe(),n=kSe(),r=KR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(LT)),LT}var UT,_6;function PSe(){return _6||(_6=1,UT=jSe().last),UT}var RSe=PSe();const DSe=Co(RSe);var OSe=["valueAccessor"],LSe=["dataKey","clockWise","id","textBreakAll","zIndex"];function Vw(){return Vw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Vw.apply(null,arguments)}function w6(t,e){if(t==null)return{};var n,r,i=ISe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ISe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var FSe=t=>Array.isArray(t.value)?DSe(t.value):t.value,OY=S.createContext(void 0),_4=OY.Provider,LY=S.createContext(void 0),USe=LY.Provider;function zSe(){return S.useContext(OY)}function BSe(){return S.useContext(LY)}function D1(t){var{valueAccessor:e=FSe}=t,n=w6(t,OSe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=w6(n,LSe),u=zSe(),d=BSe(),f=u||d;return!f||!f.length?null:S.createElement(Ca,{zIndex:l??Xr.label},S.createElement(Or,{className:"recharts-label-list"},f.map((p,g)=>{var b,v=Nr(r)?e(p,g):Jn(p&&p.payload,r),x=Nr(a)?{}:{id:"".concat(a,"-").concat(g)};return S.createElement(td,Vw({key:"label-".concat(g)},ga(p),c,x,{fill:(b=n.fill)!==null&&b!==void 0?b:p.fill,parentViewBox:p.parentViewBox,value:v,textBreakAll:o,viewBox:p.viewBox,index:g,zIndex:0}))})))}D1.displayName="LabelList";function hM(t){var{label:e}=t;return e?e===!0?S.createElement(D1,{key:"labelList-implicit"}):S.isValidElement(e)||v4(e)?S.createElement(D1,{key:"labelList-implicit",content:e}):typeof e=="object"?S.createElement(D1,Vw({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function w3(){return w3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},w3.apply(null,arguments)}var IY=t=>{var{cx:e,cy:n,r,className:i}=t,a=On("recharts-dot",i);return Ot(e)&&Ot(n)&&Ot(r)?S.createElement("circle",w3({},Ha(t),qR(t),{className:a,cx:e,cy:n,r})):null},FY=t=>t.graphicalItems.polarItems,$Se=Ze([jr,ay],VD),fM=Ze([FY,Ir,$Se],GD),HSe=Ze([fM],WD),mM=Ze([HSe,DD],qD),VSe=Ze([mM,Ir,fM],XD);Ze([mM,Ir,fM],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=Jn(r,(a=e.dataKey)!==null&&a!==void 0?a:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:Jn(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var S6=()=>{},GSe=Ze([mM,Ir,fM,oM,jr],JD),WSe=Ze([Ir,QD,ZD,S6,GSe,S6,Tn,jr],e4),UY=Ze([Ir,Tn,mM,VSe,iy,jr,WSe],t4),qSe=Ze([UY,Ir,jg],i4);Ze([Ir,UY,qSe,jr],s4);var KSe={radiusAxis:{},angleAxis:{}},zY=fs({name:"polarAxis",initialState:KSe,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:Jqe,removeRadiusAxis:eKe,addAngleAxis:tKe,removeAngleAxis:nKe}=zY.actions,XSe=zY.reducer;function M6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function E6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?M6(Object(n),!0).forEach(function(r){YSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):M6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function YSe(t,e,n){return(e=QSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function QSe(t){var e=ZSe(t,"string");return typeof e=="symbol"?e:e+""}function ZSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var JSe=(t,e)=>e,w4=Ze([FY,JSe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),e2e=[],S4=(t,e,n)=>n?.length===0?e2e:n,BY=Ze([DD,w4,S4],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>E6(E6({},e.presentationProps),a.props))),i!=null)return i}}),t2e=Ze([BY,w4,S4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=Jn(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Gd(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),n2e=Ze([BY,w4,S4,ji],(t,e,n,r)=>{if(!(e==null||t==null))return rMe({offset:r,pieSettings:e,displayedData:t,cells:n})}),zT={exports:{}},sr={};var N6;function r2e(){if(N6)return sr;N6=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),g=Symbol.for("react.client.reference");function b(v){if(typeof v=="object"&&v!==null){var x=v.$$typeof;switch(x){case t:switch(v=v.type,v){case n:case i:case r:case c:case u:case p:return v;default:switch(v=v&&v.$$typeof,v){case o:case l:case f:case d:return v;case a:return v;default:return x}}case e:return x}}}return sr.ContextConsumer=a,sr.ContextProvider=o,sr.Element=t,sr.ForwardRef=l,sr.Fragment=n,sr.Lazy=f,sr.Memo=d,sr.Portal=e,sr.Profiler=i,sr.StrictMode=r,sr.Suspense=c,sr.SuspenseList=u,sr.isContextConsumer=function(v){return b(v)===a},sr.isContextProvider=function(v){return b(v)===o},sr.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===t},sr.isForwardRef=function(v){return b(v)===l},sr.isFragment=function(v){return b(v)===n},sr.isLazy=function(v){return b(v)===f},sr.isMemo=function(v){return b(v)===d},sr.isPortal=function(v){return b(v)===e},sr.isProfiler=function(v){return b(v)===i},sr.isStrictMode=function(v){return b(v)===r},sr.isSuspense=function(v){return b(v)===c},sr.isSuspenseList=function(v){return b(v)===u},sr.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===n||v===i||v===r||v===c||v===u||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===d||v.$$typeof===o||v.$$typeof===a||v.$$typeof===l||v.$$typeof===g||v.getModuleId!==void 0)},sr.typeOf=b,sr}var A6;function i2e(){return A6||(A6=1,zT.exports=r2e()),zT.exports}var a2e=i2e(),T6=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",C6=null,BT=null,$Y=t=>{if(t===C6&&Array.isArray(BT))return BT;var e=[];return S.Children.forEach(t,n=>{Nr(n)||(a2e.isFragment(n)?e=e.concat($Y(n.props.children)):e.push(n))}),BT=e,C6=t,e};function M4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>T6(i)):r=[T6(e)],$Y(t).forEach(i=>{var a=vf(i,"type.displayName")||vf(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var E4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,$T={},k6;function s2e(){return k6||(k6=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 i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})($T)),$T}var HT,j6;function o2e(){return j6||(j6=1,HT=s2e().isPlainObject),HT}var l2e=o2e();const c2e=Co(l2e);function P6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function R6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P6(Object(n),!0).forEach(function(r){u2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u2e(t,e,n){return(e=d2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d2e(t){var e=h2e(t,"string");return typeof e=="symbol"?e:e+""}function h2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Gw(){return Gw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Gw.apply(null,arguments)}var D6=(t,e,n,r,i)=>{var a=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-a/2,",").concat(e+i),o+="L ".concat(t+n-a/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},f2e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},m2e=t=>{var e=Lr(t,f2e),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,p=S.useRef(null),[g,b]=S.useState(-1),v=S.useRef(i),x=S.useRef(a),y=S.useRef(o),E=S.useRef(n),w=S.useRef(r),A=Eg(t,"trapezoid-");if(S.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var R=p.current.getTotalLength();R&&b(R)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var N=On("recharts-trapezoid",l);if(!f)return S.createElement("g",null,S.createElement("path",Gw({},ga(e),{className:N,d:D6(n,r,i,a,o)})));var C=v.current,T=x.current,D=y.current,k=E.current,P=w.current,z="0px ".concat(g===-1?1:g,"px"),L="".concat(g,"px 0px"),X=uK(["strokeDasharray"],u,c);return S.createElement(Mg,{animationId:A,key:A,canBegin:g>0,duration:u,easing:c,isActive:f,begin:d},R=>{var Y=Gn(C,i,R),J=Gn(T,a,R),G=Gn(D,o,R),W=Gn(k,n,R),ee=Gn(P,r,R);p.current&&(v.current=Y,x.current=J,y.current=G,E.current=W,w.current=ee);var K=R>0?{transition:X,strokeDasharray:L}:{strokeDasharray:z};return S.createElement("path",Gw({},ga(e),{className:N,d:D6(W,ee,Y,J,G),ref:p,style:R6(R6({},K),e.style)}))})},p2e=["option","shapeType","propTransformer","activeClassName"];function g2e(t,e){if(t==null)return{};var n,r,i=x2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function x2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function O6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ww(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O6(Object(n),!0).forEach(function(r){b2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function b2e(t,e,n){return(e=y2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function y2e(t){var e=v2e(t,"string");return typeof e=="symbol"?e:e+""}function v2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function _2e(t,e){return Ww(Ww({},e),t)}function w2e(t,e){return t==="symbols"}function L6(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return S.createElement(mK,n);case"trapezoid":return S.createElement(m2e,n);case"sector":return S.createElement(bK,n);case"symbols":if(w2e(e))return S.createElement(WR,n);break;case"curve":return S.createElement(Tp,n);default:return null}}function S2e(t){return S.isValidElement(t)?t.props:t}function N4(t){var{option:e,shapeType:n,propTransformer:r=_2e,activeClassName:i="recharts-active-shape"}=t,a=g2e(t,p2e),o;if(S.isValidElement(e))o=S.cloneElement(e,Ww(Ww({},a),S2e(e)));else if(typeof e=="function")o=e(a,a.index);else if(c2e(e)&&typeof e!="boolean"){var l=r(e,a);o=S.createElement(L6,{shapeType:n,elementProps:l})}else{var c=a;o=S.createElement(L6,{shapeType:n,elementProps:c})}return a.isActive?S.createElement(Or,{className:i},o):o}var A4=(t,e,n)=>{var r=br();return(i,a)=>o=>{t?.(i,a,o),r(JX({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},T4=t=>{var e=br();return(n,r)=>i=>{t?.(n,r,i),e(F_e())}},C4=(t,e,n)=>{var r=br();return(i,a)=>o=>{t?.(i,a,o),r(U_e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function pM(t){var{tooltipEntrySettings:e}=t,n=br(),r=Pi(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(D_e(e)):i.current!==e&&n(O_e({prev:i.current,next:e})),i.current=e)},[e,n,r]),S.useLayoutEffect(()=>()=>{i.current&&(n(L_e(i.current)),i.current=null)},[n]),null}function k4(t){var{legendPayload:e}=t,n=br(),r=Pi(),i=S.useRef(null);return S.useLayoutEffect(()=>{r||(i.current===null?n(sK(e)):i.current!==e&&n(oK({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(lK(i.current)),i.current=null)},[n]),null}function M2e(t){var{legendPayload:e}=t,n=br(),r=Pt(Tn),i=S.useRef(null);return S.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(sK(e)):i.current!==e&&n(oK({prev:i.current,next:e})),i.current=e)},[n,r,e]),S.useLayoutEffect(()=>()=>{i.current&&(n(lK(i.current)),i.current=null)},[n]),null}var VT,E2e=()=>{var[t]=S.useState(()=>Qb("uid-"));return t},N2e=(VT=Iie.useId)!==null&&VT!==void 0?VT:E2e;function HY(t,e){var n=N2e();return e||(t?"".concat(t,"-").concat(n):n)}var A2e=S.createContext(void 0),gM=t=>{var{id:e,type:n,children:r}=t,i=HY("recharts-".concat(n),e);return S.createElement(A2e.Provider,{value:i},r(i))},T2e={cartesianItems:[],polarItems:[]},VY=fs({name:"graphicalItems",initialState:T2e,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Tr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Yo(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Tr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Yo(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Tr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Tr()},removePolarGraphicalItem:{reducer(t,e){var n=Yo(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Tr()}}}),{addCartesianGraphicalItem:C2e,replaceCartesianGraphicalItem:k2e,removeCartesianGraphicalItem:j2e,addPolarGraphicalItem:P2e,removePolarGraphicalItem:R2e}=VY.actions,D2e=VY.reducer,O2e=t=>{var e=br(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(C2e(t)):n.current!==t&&e(k2e({prev:n.current,next:t})),n.current=t},[e,t]),S.useLayoutEffect(()=>()=>{n.current&&(e(j2e(n.current)),n.current=null)},[e]),null},j4=S.memo(O2e);function L2e(t){var e=br();return S.useLayoutEffect(()=>(e(P2e(t)),()=>{e(R2e(t))}),[e,t]),null}var I2e=["key"],F2e=["onMouseEnter","onClick","onMouseLeave"],U2e=["id"],z2e=["id"];function I6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Gr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?I6(Object(n),!0).forEach(function(r){B2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function B2e(t,e,n){return(e=$2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $2e(t){var e=H2e(t,"string");return typeof e=="symbol"?e:e+""}function H2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Fd(){return Fd=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Fd.apply(null,arguments)}function xM(t,e){if(t==null)return{};var n,r,i=V2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function V2e(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function G2e(t){var e=S.useMemo(()=>M4(t.children,py),[t.children]),n=Pt(r=>t2e(r,t.id,e));return n==null?null:S.createElement(M2e,{legendPayload:n})}var W2e=S.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:o,dataKey:e,nameKey:n,name:Gd(l,e),hide:c,type:u,color:o,unit:""}};return S.createElement(pM,{tooltipEntrySettings:d})}),q2e=(t,e)=>t>e?"start":t<e?"end":"middle",K2e=(t,e,n)=>Ta(typeof e=="function"?e(t):e,n,n*.8),X2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=pK(a,o),c=i+Ta(t.cx,a,a/2),u=r+Ta(t.cy,o,o/2),d=Ta(t.innerRadius,l,0),f=K2e(n,t.outerRadius,l),p=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:p}},Y2e=(t,e)=>{var n=Ki(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function Q2e(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var Z2e=(t,e)=>{if(S.isValidElement(t))return S.cloneElement(t,e);if(typeof t=="function")return t(e);var n=On("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=xM(e,I2e);return S.createElement(Tp,Fd({},i,{type:"linear",className:n}))},J2e=(t,e,n)=>{if(S.isValidElement(t))return S.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),S.isValidElement(r)))return r;var i=On("recharts-pie-label-text",Q2e(t));return S.createElement(dM,Fd({},e,{alignmentBaseline:"middle",className:i}),r)};function eMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=Ha(n),c=yf(i),u=yf(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((p,g)=>{var b=(p.startAngle+p.endAngle)/2,v=pi(p.cx,p.cy,p.outerRadius+d,b),x=Gr(Gr(Gr(Gr({},l),p),{},{stroke:"none"},c),{},{index:g,textAnchor:q2e(v.x,p.cx)},v),y=Gr(Gr(Gr(Gr({},l),p),{},{fill:"none",stroke:p.fill},u),{},{index:g,points:[pi(p.cx,p.cy,p.outerRadius,b),v],key:"line"});return S.createElement(Ca,{zIndex:Xr.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(g)},S.createElement(Or,null,a&&Z2e(a,y),J2e(i,x,Jn(p,o))))});return S.createElement(Or,{className:"recharts-pie-labels"},f)}function tMe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?S.createElement(hM,{label:i}):S.createElement(eMe,{sectors:e,props:n,showLabels:r})}function nMe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=Pt(Id),c=Pt(p4),u=Pt(M1e),{onMouseEnter:d,onClick:f,onMouseLeave:p}=i,g=xM(i,F2e),b=A4(d,i.dataKey,o),v=T4(p),x=C4(f,i.dataKey,o);return e==null||e.length===0?null:S.createElement(S.Fragment,null,e.map((y,E)=>{if(y?.startAngle===0&&y?.endAngle===0&&e.length!==1)return null;var w=u==null||u===o,A=String(E)===l&&(c==null||i.dataKey===c)&&w,N=l?r:null,C=n&&A?n:N,T=Gr(Gr({},y),{},{stroke:y.stroke,tabIndex:-1,[Wq]:E,[qq]:i.dataKey});return S.createElement(Or,Fd({key:"sector-".concat(y?.startAngle,"-").concat(y?.endAngle,"-").concat(y.midAngle,"-").concat(E),tabIndex:-1,className:"recharts-pie-sector"},W0(g,y,E),{onMouseEnter:b(y,E),onMouseLeave:v(y,E),onClick:x(y,E)}),S.createElement(N4,Fd({option:a??C,index:E,shapeType:"sector",isActive:A},T)))}))}function rMe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,p=Math.abs(n.minAngle),g=Y2e(l,c),b=Math.abs(g),v=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,x=r.filter(C=>Jn(C,u,0)!==0).length,y=(b>=360?x:x-1)*v,E=b-x*p-y,w=r.reduce((C,T)=>{var D=Jn(T,u,0);return C+(Ot(D)?D:0)},0),A;if(w>0){var N;A=r.map((C,T)=>{var D=Jn(C,u,0),k=Jn(C,d,T),P=X2e(n,a,C),z=(Ot(D)?D:0)/w,L,X=Gr(Gr({},C),i&&i[T]&&i[T].props);T?L=N.endAngle+Ki(g)*v*(D!==0?1:0):L=l;var R=L+Ki(g)*((D!==0?p:0)+z*E),Y=(L+R)/2,J=(P.innerRadius+P.outerRadius)/2,G=[{name:k,value:D,payload:X,dataKey:u,type:f}],W=pi(P.cx,P.cy,J,Y);return N=Gr(Gr(Gr(Gr({},n.presentationProps),{},{percent:z,cornerRadius:typeof o=="string"?parseFloat(o):o,name:k,tooltipPayload:G,midAngle:Y,middleRadius:J,tooltipPosition:W},X),P),{},{value:D,dataKey:u,startAngle:L,endAngle:R,payload:X,paddingAngle:Ki(g)*v}),N})}return A}function iMe(t){var{showLabels:e,sectors:n,children:r}=t,i=S.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 S.createElement(USe,{value:e?i:void 0},r)}function aMe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:p}=e,g=Eg(e,"recharts-pie-"),b=n.current,[v,x]=S.useState(!1),y=S.useCallback(()=>{typeof p=="function"&&p(),x(!1)},[p]),E=S.useCallback(()=>{typeof f=="function"&&f(),x(!0)},[f]);return S.createElement(iMe,{showLabels:!v,sectors:i},S.createElement(Mg,{animationId:g,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:E,onAnimationEnd:y,key:g},w=>{var A=[],N=i&&i[0],C=N?.startAngle;return i?.forEach((T,D)=>{var k=b&&b[D],P=D>0?vf(T,"paddingAngle",0):0;if(k){var z=Gn(k.endAngle-k.startAngle,T.endAngle-T.startAngle,w),L=Gr(Gr({},T),{},{startAngle:C+P,endAngle:C+z+P});A.push(L),C=L.endAngle}else{var{endAngle:X,startAngle:R}=T,Y=Gn(0,X-R,w),J=Gr(Gr({},T),{},{startAngle:C+P,endAngle:C+Y+P});A.push(J),C=J.endAngle}}),n.current=A,S.createElement(Or,null,S.createElement(nMe,{sectors:A,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),S.createElement(tMe,{showLabels:!v,sectors:i,props:e}),e.children)}var sMe={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:Xr.area};function oMe(t){var{id:e}=t,n=xM(t,U2e),{hide:r,className:i,rootTabIndex:a}=t,o=S.useMemo(()=>M4(t.children,py),[t.children]),l=Pt(d=>n2e(d,e,o)),c=S.useRef(null),u=On("recharts-pie",i);return r||l==null?(c.current=null,S.createElement(Or,{tabIndex:a,className:u})):S.createElement(Ca,{zIndex:t.zIndex},S.createElement(W2e,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:l,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType}),S.createElement(Or,{tabIndex:a,className:u},S.createElement(aMe,{props:Gr(Gr({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function GY(t){var e=Lr(t,sMe),{id:n}=e,r=xM(e,z2e),i=Ha(r);return S.createElement(gM,{id:n,type:"pie"},a=>S.createElement(S.Fragment,null,S.createElement(L2e,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),S.createElement(G2e,Fd({},r,{id:a})),S.createElement(oMe,Fd({},r,{id:a}))))}GY.displayName="Pie";var lMe=["points"];function F6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function GT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?F6(Object(n),!0).forEach(function(r){cMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):F6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cMe(t,e,n){return(e=uMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uMe(t){var e=dMe(t,"string");return typeof e=="symbol"?e:e+""}function dMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qw(){return qw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},qw.apply(null,arguments)}function hMe(t,e){if(t==null)return{};var n,r,i=fMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function fMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function mMe(t){var{option:e,dotProps:n,className:r}=t;if(S.isValidElement(e))return S.cloneElement(e,n);if(typeof e=="function")return e(n);var i=On(r,typeof e!="boolean"?e.className:""),a=n??{},{points:o}=a,l=hMe(a,lMe);return S.createElement(IY,qw({},l,{className:i}))}function pMe(t,e){return t==null?!1:e?!0:t.length===1}function WY(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=Xr.scatter}=t;if(!pMe(e,n))return null;var d=E4(n),f=Whe(n),p=e.map((b,v)=>{var x,y,E=GT(GT(GT({r:3},o),f),{},{index:v,cx:(x=b.x)!==null&&x!==void 0?x:void 0,cy:(y=b.y)!==null&&y!==void 0?y:void 0,dataKey:a,value:b.value,payload:b.payload,points:e});return S.createElement(mMe,{key:"dot-".concat(v),option:n,dotProps:E,className:i})}),g={};return l&&c!=null&&(g.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),S.createElement(Ca,{zIndex:u},S.createElement(Or,qw({className:r},g),p))}function U6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function z6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U6(Object(n),!0).forEach(function(r){gMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gMe(t,e,n){return(e=xMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xMe(t){var e=bMe(t,"string");return typeof e=="symbol"?e:e+""}function bMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var yMe={xAxis:{},yAxis:{},zAxis:{}},qY=fs({name:"cartesianAxis",initialState:yMe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Tr()},replaceXAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.xAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.xAxis[n.id],t.xAxis[r.id]=r)},prepare:Tr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Tr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Tr()},replaceYAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.yAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.yAxis[n.id],t.yAxis[r.id]=r)},prepare:Tr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Tr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Tr()},replaceZAxis:{reducer(t,e){var{prev:n,next:r}=e.payload;t.zAxis[n.id]!==void 0&&(n.id!==r.id&&delete t.zAxis[n.id],t.zAxis[r.id]=r)},prepare:Tr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Tr()},updateYAxisWidth(t,e){var{id:n,width:r}=e.payload,i=t.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var o=[...a,r].slice(-3);t.yAxis[n]=z6(z6({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:vMe,replaceXAxis:_Me,removeXAxis:wMe,addYAxis:SMe,replaceYAxis:MMe,removeYAxis:EMe,addZAxis:rKe,replaceZAxis:iKe,removeZAxis:aKe,updateYAxisWidth:NMe}=qY.actions,AMe=qY.reducer,TMe=Ze([ji],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),CMe=Ze([TMe,cu,uu],(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)}}),bM=()=>Pt(CMe),kMe=()=>Pt(C1e);function B6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function WT(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?B6(Object(n),!0).forEach(function(r){jMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):B6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jMe(t,e,n){return(e=PMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PMe(t){var e=RMe(t,"string");return typeof e=="symbol"?e:e+""}function RMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var DMe=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=WT(WT(WT({},l),yf(i)),qR(i)),u;return S.isValidElement(i)?u=S.cloneElement(i,c):typeof i=="function"?u=i(c):u=S.createElement(IY,c),S.createElement(Or,{className:"recharts-active-dot",clipPath:o},u)};function S3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=Xr.activeDot}=t,l=Pt(Id),c=kMe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Nr(u)?null:S.createElement(Ca,{zIndex:o},S.createElement(DMe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var OMe="Invariant failed";function LMe(t,e){throw new Error(OMe)}var IMe=["x","y"];function M3(){return M3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},M3.apply(null,arguments)}function $6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Bx(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$6(Object(n),!0).forEach(function(r){FMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function FMe(t,e,n){return(e=UMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function UMe(t){var e=zMe(t,"string");return typeof e=="symbol"?e:e+""}function zMe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function BMe(t,e){if(t==null)return{};var n,r,i=$Me(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function $Me(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function HMe(t,e){var{x:n,y:r}=t,i=BMe(t,IMe),a="".concat(n),o=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),p=parseInt(f,10);return Bx(Bx(Bx(Bx(Bx({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function Kw(t){return S.createElement(N4,M3({shapeType:"rectangle",propTransformer:HMe,activeClassName:"recharts-active-bar"},t))}var VMe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Ot(e))return e;var a=Ot(r)||Nr(r);return a?e(r,i):(a||LMe(),n)}},GMe={},KY=fs({name:"errorBars",initialState:GMe,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:sKe,replaceErrorBar:oKe,removeErrorBar:lKe}=KY.actions,WMe=KY.reducer,qMe=["children"];function KMe(t,e){if(t==null)return{};var n,r,i=XMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function XMe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var YMe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},QMe=S.createContext(YMe);function XY(t){var{children:e}=t,n=KMe(t,qMe);return S.createElement(QMe.Provider,{value:n},e)}function yM(t,e){var n,r,i=Pt(u=>$l(u,t)),a=Pt(u=>Hl(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:$i.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Hi.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function P4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=bM(),{needClipX:a,needClipY:o,needClip:l}=yM(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return S.createElement("clipPath",{id:"clipPath-".concat(r)},S.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}function ZMe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&er(t.zIndex)?t.zIndex:e}var qT={exports:{}},KT={};var H6;function JMe(){if(H6)return KT;H6=1;var t=gg();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return KT.useSyncExternalStoreWithSelector=function(c,u,d,f,p){var g=i(null);if(g.current===null){var b={hasValue:!1,value:null};g.current=b}else b=g.current;g=o(function(){function x(N){if(!y){if(y=!0,E=N,N=f(N),p!==void 0&&b.hasValue){var C=b.value;if(p(C,N))return w=C}return w=N}if(C=w,n(E,N))return C;var T=f(N);return p!==void 0&&p(C,T)?(E=N,C):(E=N,w=T)}var y=!1,E,w,A=d===void 0?null:d;return[function(){return x(u())},A===null?void 0:function(){return x(A())}]},[u,d,f,p]);var v=r(c,g[0],g[1]);return a(function(){b.hasValue=!0,b.value=v},[v]),l(v),v},KT}var V6;function eEe(){return V6||(V6=1,qT.exports=JMe()),qT.exports}eEe();function tEe(t){t()}function nEe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){tEe(()=>{let n=t;for(;n;)n.callback(),n=n.next})},get(){const n=[];let r=t;for(;r;)n.push(r),r=r.next;return n},subscribe(n){let r=!0;const i=e={callback:n,next:null,prev:e};return i.prev?i.prev.next=i:t=i,function(){!r||t===null||(r=!1,i.next?i.next.prev=i.prev:e=i.prev,i.prev?i.prev.next=i.next:t=i.next)}}}}var G6={notify(){},get:()=>[]};function rEe(t,e){let n,r=G6,i=0,a=!1;function o(v){d();const x=r.subscribe(v);let y=!1;return()=>{y||(y=!0,x(),f())}}function l(){r.notify()}function c(){b.onStateChange&&b.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=nEe())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=G6)}function p(){a||(a=!0,d())}function g(){a&&(a=!1,f())}const b={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:p,tryUnsubscribe:g,getListeners:()=>r};return b}var iEe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",aEe=iEe(),sEe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",oEe=sEe(),lEe=()=>aEe||oEe?S.useLayoutEffect:S.useEffect,cEe=lEe();function W6(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function uEe(t,e){if(W6(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++)if(!Object.prototype.hasOwnProperty.call(e,n[i])||!W6(t[n[i]],e[n[i]]))return!1;return!0}var dEe=Symbol.for("react-redux-context"),hEe=typeof globalThis<"u"?globalThis:{};function fEe(){if(!S.createContext)return{};const t=hEe[dEe]??=new Map;let e=t.get(S.createContext);return e||(e=S.createContext(null),t.set(S.createContext,e)),e}var mEe=fEe();function pEe(t){const{children:e,context:n,serverState:r,store:i}=t,a=S.useMemo(()=>{const c=rEe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=S.useMemo(()=>i.getState(),[i]);cEe(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,o]);const l=n||mEe;return S.createElement(l.Provider,{value:a},e)}var gEe=pEe,xEe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function bEe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function gy(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(xEe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!uEe(t[r],e[r]))return!1}else if(!bEe(t[r],e[r]))return!1;return!0}var yEe=["onMouseEnter","onMouseLeave","onClick"],vEe=["value","background","tooltipPosition"],_Ee=["id"],wEe=["onMouseEnter","onClick","onMouseLeave"];function au(){return au=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},au.apply(null,arguments)}function q6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Fa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q6(Object(n),!0).forEach(function(r){SEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function SEe(t,e,n){return(e=MEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MEe(t){var e=EEe(t,"string");return typeof e=="symbol"?e:e+""}function EEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Xw(t,e){if(t==null)return{};var n,r,i=NEe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function NEe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var AEe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Gd(n,e),payload:t}]},TEe=S.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:l,tooltipType:c}=t,u={dataDefinedOnItem:void 0,positions:void 0,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:e,nameKey:void 0,name:Gd(a,e),hide:o,type:c,color:i,unit:l}};return S.createElement(pM,{tooltipEntrySettings:u})});function CEe(t){var e=Pt(Id),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=Xw(a,yEe),d=A4(o,r),f=T4(l),p=C4(c,r);if(!i||n==null)return null;var g=yf(i);return S.createElement(Ca,{zIndex:ZMe(i,Xr.barBackground)},n.map((b,v)=>{var{value:x,background:y,tooltipPosition:E}=b,w=Xw(b,vEe);if(!y)return null;var A=d(b,v),N=f(b,v),C=p(b,v),T=Fa(Fa(Fa(Fa(Fa({option:i,isActive:String(v)===e},w),{},{fill:"#eee"},y),g),W0(u,b,v)),{},{onMouseEnter:A,onMouseLeave:N,onClick:C,dataKey:r,index:v,className:"recharts-bar-background-rectangle"});return S.createElement(Kw,au({key:"background-bar-".concat(v)},T))}))}function kEe(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return Fa(Fa({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return S.createElement(_4,{value:e?i:void 0},n)}function jEe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=Pt(Id),c=Pt(p4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?S.createElement(Ca,{zIndex:Xr.activeBar},S.createElement(Kw,au({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):S.createElement(Kw,au({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function PEe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return S.createElement(Kw,au({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function REe(t){var e,{data:n,props:r}=t,i=(e=Ha(r))!==null&&e!==void 0?e:{},{id:a}=i,o=Xw(i,_Ee),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:p}=r,g=Xw(r,wEe),b=A4(d,c),v=T4(p),x=C4(f,c);return n?S.createElement(S.Fragment,null,n.map((y,E)=>S.createElement(Or,au({key:"rectangle-".concat(y?.x,"-").concat(y?.y,"-").concat(y?.value,"-").concat(E),className:"recharts-bar-rectangle"},W0(g,y,E),{onMouseEnter:b(y,E),onMouseLeave:v(y,E),onClick:x(y,E)}),u?S.createElement(jEe,{shape:l,activeBar:u,baseProps:o,entry:y,index:E,dataKey:c}):S.createElement(PEe,{shape:l,baseProps:o,entry:y,index:E,dataKey:c})))):null}function DEe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,p=Eg(e,"recharts-bar-"),[g,b]=S.useState(!1),v=!g,x=S.useCallback(()=>{typeof u=="function"&&u(),b(!1)},[u]),y=S.useCallback(()=>{typeof d=="function"&&d(),b(!0)},[d]);return S.createElement(kEe,{showLabels:v,rects:r},S.createElement(Mg,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:x,onAnimationStart:y,key:p},E=>{var w=E===1?r:r?.map((A,N)=>{var C=f&&f[N];if(C)return Fa(Fa({},A),{},{x:Gn(C.x,A.x,E),y:Gn(C.y,A.y,E),width:Gn(C.width,A.width,E),height:Gn(C.height,A.height,E)});if(i==="horizontal"){var T=Gn(0,A.height,E),D=Gn(A.stackedBarStart,A.y,E);return Fa(Fa({},A),{},{y:D,height:T})}var k=Gn(0,A.width,E),P=Gn(A.stackedBarStart,A.x,E);return Fa(Fa({},A),{},{width:k,x:P})});return E>0&&(n.current=w??null),w==null?null:S.createElement(Or,null,S.createElement(REe,{props:e,data:w}))}),S.createElement(hM,{label:e.label}),e.children)}function OEe(t){var e=S.useRef(null);return S.createElement(DEe,{previousRectanglesRef:e,props:t})}var YY=0,LEe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:Jn(t,e)}};class IEe extends S.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=On("recharts-bar",i),f=u;return S.createElement(Or,{className:d,id:u},l&&S.createElement("defs",null,S.createElement(P4,{clipPathId:f,xAxisId:a,yAxisId:o})),S.createElement(Or,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},S.createElement(CEe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),S.createElement(OEe,this.props)))}}var FEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:YY,xAxisId:0,yAxisId:0,zIndex:Xr.bar};function UEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=yM(e,n),p=Ff(),g=Pi(),b=M4(t.children,py),v=Pt(E=>fNe(E,e,n,g,t.id,b));if(p!=="vertical"&&p!=="horizontal")return null;var x,y=v?.[0];return y==null||y.height==null||y.width==null?x=0:x=p==="vertical"?y.height/2:y.width/2,S.createElement(XY,{xAxisId:e,yAxisId:n,data:v,dataPointFormatter:LEe,errorBarOffset:x},S.createElement(IEe,au({},t,{layout:p,needClip:f,data:v,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function zEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:p,cells:g,parentViewBox:b,dataStartIndex:v}=t,x=e==="horizontal"?l:o,y=d?x.scale.domain():null,E=cge({numericAxis:x}),w=x.scale(E);return f.map((A,N)=>{var C,T,D,k,P,z;d?C=ige(d[N+v],y):(C=Jn(A,n),Array.isArray(C)||(C=[E,C]));var L=VMe(r,YY)(C[1],N);if(e==="horizontal"){var X,[R,Y]=[l.scale(C[0]),l.scale(C[1])];T=uB({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:A,index:N}),D=(X=Y??R)!==null&&X!==void 0?X:void 0,k=i.size;var J=R-Y;if(P=hs(J)?0:J,z={x:T,y:p.top,width:k,height:p.height},Math.abs(L)>0&&Math.abs(P)<Math.abs(L)){var G=Ki(P||L)*(Math.abs(L)-Math.abs(P));D-=G,P+=G}}else{var[W,ee]=[o.scale(C[0]),o.scale(C[1])];if(T=W,D=uB({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:A,index:N}),k=ee-W,P=i.size,z={x:p.left,y:D,width:p.width,height:P},Math.abs(L)>0&&Math.abs(k)<Math.abs(L)){var K=Ki(k||L)*(Math.abs(L)-Math.abs(k));k+=K}}if(T==null||D==null||k==null||P==null)return null;var F=Fa(Fa({},A),{},{stackedBarStart:w,x:T,y:D,width:k,height:P,value:d?C:C[1],payload:A,background:z,tooltipPosition:{x:T+k/2,y:D+P/2},parentViewBox:b},g&&g[N]&&g[N].props);return F}).filter(Boolean)}function BEe(t){var e=Lr(t,FEe),n=Pi();return S.createElement(gM,{id:e.id,type:"bar"},r=>S.createElement(S.Fragment,null,S.createElement(k4,{legendPayload:AEe(e)}),S.createElement(TEe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),S.createElement(j4,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:Vq(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),S.createElement(Ca,{zIndex:e.zIndex},S.createElement(UEe,au({},e,{id:r})))))}var QY=S.memo(BEe,gy);QY.displayName="Bar";function K6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function i_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K6(Object(n),!0).forEach(function(r){$Ee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Ee(t,e,n){return(e=HEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function HEe(t){var e=VEe(t,"string");return typeof e=="symbol"?e:e+""}function VEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var GEe=(t,e)=>e,WEe=(t,e,n)=>n,qEe=(t,e,n,r)=>r,KEe=(t,e,n,r,i)=>i,xy=Ze([oy,KEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),XEe=Ze([xy],t=>t?.maxBarSize),YEe=(t,e,n,r,i,a)=>a,X6=(t,e,n)=>{var r=n??t;if(!Nr(r))return Ta(r,e,0)},QEe=Ze([Tn,oy,GEe,WEe,qEe],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),ZEe=(t,e,n,r)=>{var i=Tn(t);return i==="horizontal"?u0(t,"yAxis",n,r):u0(t,"xAxis",e,r)},JEe=(t,e,n)=>{var r=Tn(t);return r==="horizontal"?H8(t,"xAxis",e):H8(t,"yAxis",n)},eNe=(t,e,n)=>{var r={},i=t.filter(rM),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,p=f.map(b=>b.dataKey),g=X6(e,n,f[0].barSize);return{stackId:d,dataKeys:p,barSize:g}}),c=a.map(u=>{var d=[u.dataKey].filter(p=>p!=null),f=X6(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},tNe=Ze([QEe,Nve,JEe],eNe),nNe=(t,e,n,r,i)=>{var a,o,l=xy(t,e,n,r,i);if(l!=null){var c=Tn(t),u=mX(t),{maxBarSize:d}=l,f=Nr(d)?u:d,p,g;return c==="horizontal"?(p=Rl(t,"xAxis",e,r),g=Pl(t,"xAxis",e,r)):(p=Rl(t,"yAxis",n,r),g=Pl(t,"yAxis",n,r)),(a=(o=Dd(p,g,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},ZY=(t,e,n,r)=>{var i=Tn(t),a,o;return i==="horizontal"?(a=Rl(t,"xAxis",e,r),o=Pl(t,"xAxis",e,r)):(a=Rl(t,"yAxis",n,r),o=Pl(t,"yAxis",n,r)),Dd(a,o)};function rNe(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=Ta(t,n,0,!0),l,c=[];if(er(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((y,E)=>y+(E.barSize||0),0);f+=(a-1)*o,f>=n&&(f-=(a-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var p=(n-f)/2>>0,g={offset:p-o,size:0};l=r.reduce((y,E)=>{var w,A={stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:g.offset+g.size+o,size:u?d:(w=E.barSize)!==null&&w!==void 0?w:0}},N=[...y,A];return g=N[N.length-1].position,N},c)}else{var b=Ta(e,n,0,!0);n-2*b-(a-1)*o<=0&&(o=0);var v=(n-2*b-(a-1)*o)/a;v>1&&(v>>=0);var x=er(i)?Math.min(v,i):v;l=r.reduce((y,E,w)=>[...y,{stackId:E.stackId,dataKeys:E.dataKeys,position:{offset:b+(v+o)*w+(v-x)/2,size:x}}],c)}return l}}var iNe=(t,e,n,r,i,a,o)=>{var l=Nr(o)?e:o,c=rNe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>i_(i_({},u),{},{position:i_(i_({},u.position),{},{offset:u.position.offset-i/2})}))),c},aNe=Ze([tNe,mX,Eve,pX,nNe,ZY,XEe],iNe),sNe=(t,e,n,r)=>Rl(t,"xAxis",e,r),oNe=(t,e,n,r)=>Rl(t,"yAxis",n,r),lNe=(t,e,n,r)=>Pl(t,"xAxis",e,r),cNe=(t,e,n,r)=>Pl(t,"yAxis",n,r),uNe=Ze([aNe,xy],(t,e)=>{if(!(t==null||e==null)){var n=t.find(r=>r.stackId===e.stackId&&e.dataKey!=null&&r.dataKeys.includes(e.dataKey));if(n!=null)return n.position}}),dNe=(t,e)=>{var n=nM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},hNe=Ze([ZEe,xy],dNe),fNe=Ze([ji,iD,sNe,oNe,lNe,cNe,uNe,Tn,ry,ZY,hNe,xy,YEe],(t,e,n,r,i,a,o,l,c,u,d,f,p)=>{var{chartData:g,dataStartIndex:b,dataEndIndex:v}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:x}=f,y;if(x!=null&&x.length>0?y=x:y=g?.slice(b,v+1),y!=null)return zEe({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:y,offset:t,cells:p,dataStartIndex:b})}}),JY=t=>{var{chartData:e}=t,n=br(),r=Pi();return S.useEffect(()=>r?()=>{}:(n(n6(e)),()=>{n(n6(void 0))}),[e,n,r]),null},Y6={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},eQ=fs({name:"brush",initialState:Y6,reducers:{setBrushSettings(t,e){return e.payload==null?Y6:e.payload}}}),{setBrushSettings:cKe}=eQ.actions,mNe=eQ.reducer;function Q6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function a_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q6(Object(n),!0).forEach(function(r){tQ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Q6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tQ(t,e,n){return(e=pNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pNe(t){var e=gNe(t,"string");return typeof e=="symbol"?e:e+""}function gNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var xNe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},bNe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return xNe({x:e,y:n},{x:r,y:i})};class vM{static create(e){return new vM(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:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+o}return this.scale(e)}}isInRange(e){var n=this.range(),r=n[0],i=n[n.length-1];return r<=i?e>=r&&e<=i:e>=i&&e<=r}}tQ(vM,"EPS",1e-4);var yNe=t=>{var e=Object.keys(t).reduce((n,r)=>a_(a_({},n),{},{[r]:vM.create(t[r])}),{});return a_(a_({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[o,l]=a;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function vNe(t){return(t%180+180)%180}var _Ne=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=vNe(i),o=a*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},wNe={dots:[],areas:[],lines:[]},nQ=fs({name:"referenceElements",initialState:wNe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Yo(t).dots.findIndex(r=>r===e.payload);n!==-1&&t.dots.splice(n,1)},addArea:(t,e)=>{t.areas.push(e.payload)},removeArea:(t,e)=>{var n=Yo(t).areas.findIndex(r=>r===e.payload);n!==-1&&t.areas.splice(n,1)},addLine:(t,e)=>{t.lines.push(e.payload)},removeLine:(t,e)=>{var n=Yo(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:uKe,removeDot:dKe,addArea:hKe,removeArea:fKe,addLine:SNe,removeLine:MNe}=nQ.actions,ENe=nQ.reducer,rQ=S.createContext(void 0),NNe=t=>{var{children:e}=t,[n]=S.useState("".concat(Qb("recharts"),"-clip")),r=bM();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return S.createElement(rQ.Provider,{value:n},S.createElement("defs",null,S.createElement("clipPath",{id:n},S.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},ANe=()=>S.useContext(rQ);function Z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function J6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z6(Object(n),!0).forEach(function(r){TNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function TNe(t,e,n){return(e=CNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CNe(t){var e=kNe(t,"string");return typeof e=="symbol"?e:e+""}function kNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Yw(){return Yw=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Yw.apply(null,arguments)}var jNe=(t,e)=>{var n;if(S.isValidElement(t))n=S.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!er(e.x1)||!er(e.y1)||!er(e.x2)||!er(e.y2))return null;n=S.createElement("line",Yw({},e,{className:"recharts-reference-line-line"}))}return n},PNe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(hs(c)||e==="discard"&&!i.y.isInRange(c))return null;var u=[{x:o+l,y:c},{x:o,y:c}];return r==="left"?u.reverse():u},RNe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(hs(c)||e==="discard"&&!i.x.isInRange(c))return null;var u=[{x:c,y:o+l},{x:c,y:o}];return r==="top"?u.reverse():u},DNe=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},ONe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=No(o),f=No(l);return f?PNe(l,u,n,i,t,e):d?RNe(o,u,n,r,t,e):c!=null&&c.length===2?DNe(c,u,n,t):null};function LNe(t){var e=br();return S.useEffect(()=>(e(SNe(t)),()=>{e(MNe(t))})),null}function INe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=Pi(),l=ANe(),c=Pt(C=>$l(C,e)),u=Pt(C=>Hl(C,n)),d=Pt(C=>Ld(C,"xAxis",e,o)),f=Pt(C=>Ld(C,"yAxis",n,o)),p=Q0();if(!l||!p||c==null||u==null||d==null||f==null)return null;var g=yNe({x:d,y:f}),b=ONe(g,p,t.position,c.orientation,u.orientation,t);if(!b)return null;var[{x:v,y:x},{x:y,y:E}]=b,w=a==="hidden"?"url(#".concat(l,")"):void 0,A=J6(J6({clipPath:w},ga(t)),{},{x1:v,y1:x,x2:y,y2:E}),N=bNe({x1:v,y1:x,x2:y,y2:E});return S.createElement(Ca,{zIndex:t.zIndex},S.createElement(Or,{className:On("recharts-reference-line",i)},jNe(r,A),S.createElement(PY,Yw({},N,{lowerWidth:N.width,upperWidth:N.width}),S.createElement(DY,{label:t.label}),t.children)))}var FNe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:Xr.line};function lb(t){var e=Lr(t,FNe);return S.createElement(S.Fragment,null,S.createElement(LNe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),S.createElement(INe,e))}lb.displayName="ReferenceLine";function iQ(t,e){if(e<1)return[];if(e===1)return t;for(var n=[],r=0;r<t.length;r+=e)n.push(t[r]);return n}function UNe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return _Ne(r,n)}function zNe(t,e,n){var r=n==="width",{x:i,y:a,width:o,height:l}=t;return e===1?{start:r?i:a,end:r?i+o:a+l}:{start:r?i+o:a+l,end:r?i:a}}function Qw(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function BNe(t,e){return iQ(t,e+1)}function $Ne(t,e,n,r,i){for(var a=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var b=r?.[c];if(b===void 0)return{v:iQ(r,u)};var v=c,x,y=()=>(x===void 0&&(x=n(b,v)),x),E=b.coordinate,w=c===0||Qw(t,E,y,d,l);w||(c=0,d=o,u+=1),w&&(d=E+t*(y()/2+i),c+=u)},p;u<=a.length;)if(p=f(),p)return p.v;return[]}function e$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Sa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?e$(Object(n),!0).forEach(function(r){HNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function HNe(t,e,n){return(e=VNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VNe(t){var e=GNe(t,"string");return typeof e=="symbol"?e:e+""}function GNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function WNe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(p){var g=a[p],b,v=()=>(b===void 0&&(b=n(g,p)),b);if(p===o-1){var x=t*(g.coordinate+t*v()/2-c);a[p]=g=Sa(Sa({},g),{},{tickCoord:x>0?g.coordinate-x*t:g.coordinate})}else a[p]=g=Sa(Sa({},g),{},{tickCoord:g.coordinate});if(g.tickCoord!=null){var y=Qw(t,g.tickCoord,v,l,c);y&&(c=g.tickCoord-t*(v()/2+i),a[p]=Sa(Sa({},g),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function qNe(t,e,n,r,i,a){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),p=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=Sa(Sa({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var g=Qw(t,d.tickCoord,()=>f,c,u);g&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Sa(Sa({},d),{},{isShow:!0}))}}for(var b=a?l-1:l,v=function(E){var w=o[E],A,N=()=>(A===void 0&&(A=n(w,E)),A);if(E===0){var C=t*(w.coordinate-t*N()/2-c);o[E]=w=Sa(Sa({},w),{},{tickCoord:C<0?w.coordinate-C*t:w.coordinate})}else o[E]=w=Sa(Sa({},w),{},{tickCoord:w.coordinate});if(w.tickCoord!=null){var T=Qw(t,w.tickCoord,N,c,u);T&&(c=w.tickCoord+t*(N()/2+i),o[E]=Sa(Sa({},w),{},{isShow:!0}))}},x=0;x<b;x++)v(x);return o}function R4(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(Ot(c)||Sg.isSsr){var p;return(p=BNe(i,Ot(c)?c:0))!==null&&p!==void 0?p:[]}var g=[],b=l==="top"||l==="bottom"?"width":"height",v=d&&b==="width"?wb(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},x=(w,A)=>{var N=typeof u=="function"?u(w.value,A):w.value;return b==="width"?UNe(wb(N,{fontSize:e,letterSpacing:n}),v,f):wb(N,{fontSize:e,letterSpacing:n})[b]},y=i.length>=2?Ki(i[1].coordinate-i[0].coordinate):1,E=zNe(a,y,b);return c==="equidistantPreserveStart"?$Ne(y,E,x,i,o):(c==="preserveStart"||c==="preserveStartEnd"?g=qNe(y,E,x,i,o,c==="preserveStartEnd"):g=WNe(y,E,x,i,o),g.filter(w=>w.isShow))}var KNe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+a,u=o+c+l+(n?r:0);return Math.round(u)}return 0},XNe=["axisLine","width","height","className","hide","ticks","axisType"];function YNe(t,e){if(t==null)return{};var n,r,i=QNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function QNe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Mf(){return Mf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Mf.apply(null,arguments)}function t$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t$(Object(n),!0).forEach(function(r){ZNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZNe(t,e,n){return(e=JNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JNe(t){var e=eAe(t,"string");return typeof e=="symbol"?e:e+""}function eAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Bc={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:Xr.axis};function tAe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=hi(hi(hi({},c),Ha(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=hi(hi({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=hi(hi({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return S.createElement("line",Mf({},u,{className:On("recharts-cartesian-axis-line",vf(l,"className"))}))}function nAe(t,e,n,r,i,a,o,l,c){var u,d,f,p,g,b,v=l?-1:1,x=t.tickSize||o,y=Ot(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,p=n+ +!l*i,f=p-v*x,b=f-v*c,g=y;break;case"left":f=p=t.coordinate,d=e+ +!l*r,u=d-v*x,g=u-v*c,b=y;break;case"right":f=p=t.coordinate,d=e+ +l*r,u=d+v*x,g=u+v*c,b=y;break;default:u=d=t.coordinate,p=n+ +l*i,f=p+v*x,b=f+v*c,g=y;break}return{line:{x1:u,y1:f,x2:d,y2:p},tick:{x:g,y:b}}}function rAe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function iAe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function aAe(t){var{option:e,tickProps:n,value:r}=t,i,a=On(n.className,"recharts-cartesian-axis-tick-value");if(S.isValidElement(e))i=S.cloneElement(e,hi(hi({},n),{},{className:a}));else if(typeof e=="function")i=e(hi(hi({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=On(o,e?.className)),i=S.createElement(dM,Mf({},n,{className:o}),r)}return i}var sAe=S.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:p,y:g,width:b,height:v,tickSize:x,tickMargin:y,fontSize:E,letterSpacing:w,getTicksConfig:A,events:N,axisType:C}=t,T=R4(hi(hi({},A),{},{ticks:n}),E,w),D=rAe(d,f),k=iAe(d,f),P=Ha(A),z=yf(r),L={};typeof i=="object"&&(L=i);var X=hi(hi({},P),{},{fill:"none"},L),R=T.map(G=>hi({entry:G},nAe(G,p,g,b,v,d,x,f,y))),Y=R.map(G=>{var{entry:W,line:ee}=G;return S.createElement(Or,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(W.value,"-").concat(W.coordinate,"-").concat(W.tickCoord)},i&&S.createElement("line",Mf({},X,ee,{className:On("recharts-cartesian-axis-tick-line",vf(i,"className"))})))}),J=R.map((G,W)=>{var{entry:ee,tick:K}=G,F=hi(hi(hi(hi({textAnchor:D,verticalAnchor:k},P),{},{stroke:"none",fill:a},z),K),{},{index:W,payload:ee,visibleTicksCount:T.length,tickFormatter:o,padding:c},u);return S.createElement(Or,Mf({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(ee.value,"-").concat(ee.coordinate,"-").concat(ee.tickCoord)},W0(N,ee,W)),r&&S.createElement(aAe,{option:r,tickProps:F,value:"".concat(typeof o=="function"?o(ee.value,W):ee.value).concat(l||"")}))});return S.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},J.length>0&&S.createElement(Ca,{zIndex:Xr.label},S.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},J)),Y.length>0&&S.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},Y))}),oAe=S.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=YNe(t,XNe),[d,f]=S.useState(""),[p,g]=S.useState(""),b=S.useRef(null);S.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var x;return KNe({ticks:b.current,label:(x=t.labelRef)===null||x===void 0?void 0:x.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var v=S.useCallback(x=>{if(x){var y=x.getElementsByClassName("recharts-cartesian-axis-tick-value");b.current=y;var E=y[0];if(E){var w=window.getComputedStyle(E),A=w.fontSize,N=w.letterSpacing;(A!==d||N!==p)&&(f(A),g(N))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:S.createElement(Ca,{zIndex:t.zIndex},S.createElement(Or,{className:On("recharts-cartesian-axis",a)},S.createElement(tAe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:Ha(t)}),S.createElement(sAe,{ref:v,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:p,mirror:t.mirror,orientation:t.orientation,padding:t.padding,stroke:t.stroke,tick:t.tick,tickFormatter:t.tickFormatter,tickLine:t.tickLine,tickMargin:t.tickMargin,tickSize:t.tickSize,tickTextProps:t.tickTextProps,ticks:l,unit:t.unit,width:t.width,x:t.x,y:t.y}),S.createElement(PY,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},S.createElement(DY,{label:t.label,labelRef:t.labelRef}),t.children)))}),D4=S.forwardRef((t,e)=>{var n=Lr(t,Bc);return S.createElement(oAe,Mf({},n,{ref:e}))});D4.displayName="CartesianAxis";var lAe=["x1","y1","x2","y2","key"],cAe=["offset"],uAe=["xAxisId","yAxisId"],dAe=["xAxisId","yAxisId"];function n$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ea(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n$(Object(n),!0).forEach(function(r){hAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hAe(t,e,n){return(e=fAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fAe(t){var e=mAe(t,"string");return typeof e=="symbol"?e:e+""}function mAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $h(){return $h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$h.apply(null,arguments)}function Zw(t,e){if(t==null)return{};var n,r,i=pAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function pAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var gAe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:l}=t;return S.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function aQ(t){var{option:e,lineItemProps:n}=t,r;if(S.isValidElement(e))r=S.cloneElement(e,n);else if(typeof e=="function")r=e(n);else{var i,{x1:a,y1:o,x2:l,y2:c,key:u}=n,d=Zw(n,lAe),f=(i=Ha(d))!==null&&i!==void 0?i:{},{offset:p}=f,g=Zw(f,cAe);r=S.createElement("line",$h({},g,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function xAe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=Zw(t,uAe),c=i.map((u,d)=>{var f=Ea(Ea({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return S.createElement(aQ,{key:"line-".concat(d),option:r,lineItemProps:f})});return S.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function bAe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=Zw(t,dAe),c=i.map((u,d)=>{var f=Ea(Ea({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return S.createElement(aQ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return S.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function yAe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var g=!u[p+1],b=g?i+o-f:u[p+1]-f;if(b<=0)return null;var v=p%e.length;return S.createElement("rect",{key:"react-".concat(p),y:f,x:r,height:b,width:a,stroke:"none",fill:e[v],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function vAe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var g=!u[p+1],b=g?i+o-f:u[p+1]-f;if(b<=0)return null;var v=p%n.length;return S.createElement("rect",{key:"react-".concat(p),x:f,y:a,width:b,height:l,stroke:"none",fill:n[v],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return S.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var _Ae=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return $q(R4(Ea(Ea(Ea({},Bc),n),{},{ticks:Hq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},wAe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return $q(R4(Ea(Ea(Ea({},Bc),n),{},{ticks:Hq(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},SAe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Xr.grid};function Jw(t){var e=sD(),n=oD(),r=Zq(),i=Ea(Ea({},Lr(t,SAe)),{},{x:Ot(t.x)?t.x:r.left,y:Ot(t.y)?t.y:r.top,width:Ot(t.width)?t.width:r.width,height:Ot(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:p,verticalValues:g}=i,b=Pi(),v=Pt(k=>V8(k,"xAxis",a,b)),x=Pt(k=>V8(k,"yAxis",o,b));if(!kl(u)||!kl(d)||!Ot(l)||!Ot(c))return null;var y=i.verticalCoordinatesGenerator||_Ae,E=i.horizontalCoordinatesGenerator||wAe,{horizontalPoints:w,verticalPoints:A}=i;if((!w||!w.length)&&typeof E=="function"){var N=p&&p.length,C=E({yAxis:x?Ea(Ea({},x),{},{ticks:N?p:x.ticks}):void 0,width:e??u,height:n??d,offset:r},N?!0:f);ww(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(w=C)}if((!A||!A.length)&&typeof y=="function"){var T=g&&g.length,D=y({xAxis:v?Ea(Ea({},v),{},{ticks:T?g:v.ticks}):void 0,width:e??u,height:n??d,offset:r},T?!0:f);ww(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof D,"]")),Array.isArray(D)&&(A=D)}return S.createElement(Ca,{zIndex:i.zIndex},S.createElement("g",{className:"recharts-cartesian-grid"},S.createElement(gAe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(yAe,$h({},i,{horizontalPoints:w})),S.createElement(vAe,$h({},i,{verticalPoints:A})),S.createElement(xAe,$h({},i,{offset:r,horizontalPoints:w,xAxis:v,yAxis:x})),S.createElement(bAe,$h({},i,{offset:r,verticalPoints:A,xAxis:v,yAxis:x}))))}Jw.displayName="CartesianGrid";var sQ=(t,e,n,r)=>Rl(t,"xAxis",e,r),oQ=(t,e,n,r)=>Pl(t,"xAxis",e,r),lQ=(t,e,n,r)=>Rl(t,"yAxis",n,r),cQ=(t,e,n,r)=>Pl(t,"yAxis",n,r),MAe=Ze([Tn,sQ,lQ,oQ,cQ],(t,e,n,r,i)=>Bl(t,"xAxis")?Dd(e,r,!1):Dd(n,i,!1)),EAe=(t,e,n,r,i)=>i;function NAe(t){return t.type==="line"}var AAe=Ze([oy,EAe],(t,e)=>t.filter(NAe).find(n=>n.id===e)),TAe=Ze([Tn,sQ,lQ,oQ,cQ,AAe,MAe,ry],(t,e,n,r,i,a,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:p}=a,g;if(p!=null&&p.length>0?g=p:g=c?.slice(u,d+1),g!=null)return KAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:g})}});function uQ(t){var e=yf(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,o=Number(i),l=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:n,strokeWidth:r}}var CAe=["id"],kAe=["type","layout","connectNulls","needClip","shape"],jAe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function h0(){return h0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},h0.apply(null,arguments)}function r$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?r$(Object(n),!0).forEach(function(r){PAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function PAe(t,e,n){return(e=RAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RAe(t){var e=DAe(t,"string");return typeof e=="symbol"?e:e+""}function DAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function O4(t,e){if(t==null)return{};var n,r,i=OAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function OAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var LAe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Gd(n,e),payload:t}]},IAe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Gd(o,e),hide:l,type:u,color:r,unit:c}};return S.createElement(pM,{tooltipEntrySettings:d})}),dQ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function FAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var UAe=(t,e,n)=>{var r=n.reduce((f,p)=>f+p);if(!r)return dQ(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,o]:[o];return[...FAe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function zAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=O4(r,CAe),u=Ha(c);return S.createElement(WY,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function BAe(t){var{showLabels:e,children:n,points:r}=t,i=S.useMemo(()=>r?.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return xl(xl({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return S.createElement(_4,{value:e?i:void 0},n)}function i$(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=O4(a,kAe),p=xl(xl({},ga(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return S.createElement(S.Fragment,null,r?.length>1&&S.createElement(N4,h0({shapeType:"curve",option:d},p,{pathRef:n})),S.createElement(zAe,{points:r,clipPathId:e,props:a}))}function $Ae(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function HAe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:p,width:g,height:b,onAnimationEnd:v,onAnimationStart:x}=n,y=i.current,E=Eg(o,"recharts-line-"),w=S.useRef(E),[A,N]=S.useState(!1),C=!A,T=S.useCallback(()=>{typeof v=="function"&&v(),N(!1)},[v]),D=S.useCallback(()=>{typeof x=="function"&&x(),N(!0)},[x]),k=$Ae(r.current),P=S.useRef(0);w.current!==E&&(P.current=a.current,w.current=E);var z=P.current;return S.createElement(BAe,{points:o,showLabels:C},n.children,S.createElement(Mg,{animationId:E,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:D,key:E},L=>{var X=Gn(z,k+z,L),R=Math.min(X,k),Y;if(c)if(l){var J="".concat(l).split(/[,\s]+/gim).map(ee=>parseFloat(ee));Y=UAe(R,k,J)}else Y=dQ(k,R);else Y=l==null?void 0:String(l);if(L>0&&k>0&&(i.current=o,a.current=Math.max(a.current,R)),y){var G=y.length/o.length,W=L===1?o:o.map((ee,K)=>{var F=Math.floor(K*G);if(y[F]){var q=y[F];return xl(xl({},ee),{},{x:Gn(q.x,ee.x,L),y:Gn(q.y,ee.y,L)})}return p?xl(xl({},ee),{},{x:Gn(g*2,ee.x,L),y:Gn(b/2,ee.y,L)}):xl(xl({},ee),{},{x:ee.x,y:ee.y})});return i.current=W,S.createElement(i$,{props:n,points:W,clipPathId:e,pathRef:r,strokeDasharray:Y})}return S.createElement(i$,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:Y})}),S.createElement(hM,{label:n.label}))}function VAe(t){var{clipPathId:e,props:n}=t,r=S.useRef(null),i=S.useRef(0),a=S.useRef(null);return S.createElement(HAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var GAe=(t,e)=>{var n,r;return{x:(n=t.x)!==null&&n!==void 0?n:void 0,y:(r=t.y)!==null&&r!==void 0?r:void 0,value:t.value,errorVal:Jn(t.payload,e)}};class WAe extends S.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:p,zIndex:g}=this.props;if(e)return null;var b=On("recharts-line",i),v=f,{r:x,strokeWidth:y}=uQ(n),E=E4(n),w=x*2+y,A=p?"url(#clipPath-".concat(E?"":"dots-").concat(v,")"):void 0;return S.createElement(Ca,{zIndex:g},S.createElement(Or,{className:b},p&&S.createElement("defs",null,S.createElement(P4,{clipPathId:v,xAxisId:a,yAxisId:o}),!E&&S.createElement("clipPath",{id:"clipPath-dots-".concat(v)},S.createElement("rect",{x:c-w/2,y:l-w/2,width:u+w,height:d+w}))),S.createElement(XY,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:GAe,errorBarOffset:0},S.createElement(VAe,{props:this.props,clipPathId:v}))),S.createElement(S3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:A}))}}var hQ={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Xr.line,type:"linear"};function qAe(t){var e=Lr(t,hQ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:p,xAxisId:g,yAxisId:b,id:v}=e,x=O4(e,jAe),{needClip:y}=yM(g,b),E=bM(),w=Ff(),A=Pi(),N=Pt(P=>TAe(P,g,b,A,v));if(w!=="horizontal"&&w!=="vertical"||N==null||E==null)return null;var{height:C,width:T,x:D,y:k}=E;return S.createElement(WAe,h0({},x,{id:v,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:p,xAxisId:g,yAxisId:b,points:N,layout:w,height:C,width:T,left:D,top:k,needClip:y}))}function KAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=Jn(u,o);if(e==="horizontal"){var p=_w({axis:n,ticks:i,bandSize:l,entry:u,index:d}),g=Nr(f)?null:r.scale(f);return{x:p,y:g,value:f,payload:u}}var b=Nr(f)?null:n.scale(f),v=_w({axis:r,ticks:a,bandSize:l,entry:u,index:d});return b==null||v==null?null:{x:b,y:v,value:f,payload:u}}).filter(Boolean)}function XAe(t){var e=Lr(t,hQ),n=Pi();return S.createElement(gM,{id:e.id,type:"line"},r=>S.createElement(S.Fragment,null,S.createElement(k4,{legendPayload:LAe(e)}),S.createElement(IAe,{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}),S.createElement(j4,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),S.createElement(qAe,h0({},e,{id:r}))))}var fQ=S.memo(XAe,gy);fQ.displayName="Line";var mQ=(t,e,n,r)=>Rl(t,"xAxis",e,r),pQ=(t,e,n,r)=>Pl(t,"xAxis",e,r),gQ=(t,e,n,r)=>Rl(t,"yAxis",n,r),xQ=(t,e,n,r)=>Pl(t,"yAxis",n,r),YAe=Ze([Tn,mQ,gQ,pQ,xQ],(t,e,n,r,i)=>Bl(t,"xAxis")?Dd(e,r,!1):Dd(n,i,!1)),QAe=(t,e,n,r,i)=>i,bQ=Ze([oy,QAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),ZAe=(t,e,n,r,i)=>{var a,o=bQ(t,e,n,r,i);if(o!=null){var l=Tn(t),c=Bl(l,"xAxis"),u;if(c?u=u0(t,"yAxis",n,r):u=u0(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=nM(o);if(!(d==null||f==null)){var p=(a=u[d])===null||a===void 0?void 0:a.stackedData;return p?.find(g=>g.key===f)}}}},JAe=Ze([Tn,mQ,gQ,pQ,xQ,ZAe,ry,YAe,bQ,Ave],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,dataEndIndex:p}=o;if(!(c==null||t!=="horizontal"&&t!=="vertical"||e==null||n==null||r==null||i==null||r.length===0||i.length===0||l==null)){var{data:g}=c,b;if(g&&g.length>0?b=g:b=d?.slice(f,p+1),b!=null)return bTe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:b,chartBaseValue:u,bandSize:l})}}),eTe=["id"],tTe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function ef(){return ef=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},ef.apply(null,arguments)}function yQ(t,e){if(t==null)return{};var n,r,i=nTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function nTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function a$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function _p(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a$(Object(n),!0).forEach(function(r){rTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rTe(t,e,n){return(e=iTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function iTe(t){var e=aTe(t,"string");return typeof e=="symbol"?e:e+""}function aTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eS(t,e){return t&&t!=="none"?t:e}var sTe=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:eS(r,i),value:Gd(n,e),payload:t}]},oTe=S.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Gd(o,e),hide:l,type:u,color:eS(r,a),unit:c}};return S.createElement(pM,{tooltipEntrySettings:d})});function lTe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=Ha(r);return S.createElement(WY,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function cTe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return _p(_p({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return S.createElement(_4,{value:e?i:void 0},n)}function s$(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,p=yQ(a,eTe),g=Ha(p),b=ga(p);return S.createElement(S.Fragment,null,e?.length>1&&S.createElement(Or,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},S.createElement(Tp,ef({},b,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&S.createElement(Tp,ef({},g,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&S.createElement(Tp,ef({},g,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),S.createElement(lTe,{points:e,props:p,clipPathId:i}))}function uTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!er(a)||!er(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return Ot(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Ot(c)?S.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function dTe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!er(a)||!er(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return Ot(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Ot(c)?S.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function hTe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?S.createElement(uTe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):S.createElement(dTe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function fTe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:p,onAnimationEnd:g}=r,b=S.useMemo(()=>({points:o,baseLine:l}),[o,l]),v=Eg(b,"recharts-area-"),x=Gge(),[y,E]=S.useState(!1),w=!y,A=S.useCallback(()=>{typeof g=="function"&&g(),E(!1)},[g]),N=S.useCallback(()=>{typeof p=="function"&&p(),E(!0)},[p]);if(x==null)return null;var C=i.current,T=a.current;return S.createElement(cTe,{showLabels:w,points:o},r.children,S.createElement(Mg,{animationId:v,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:A,onAnimationStart:N,key:v},D=>{if(C){var k=C.length/o.length,P=D===1?o:o.map((L,X)=>{var R=Math.floor(X*k);if(C[R]){var Y=C[R];return _p(_p({},L),{},{x:Gn(Y.x,L.x,D),y:Gn(Y.y,L.y,D)})}return L}),z;return Ot(l)?z=Gn(T,l,D):Nr(l)||hs(l)?z=Gn(T,0,D):z=l.map((L,X)=>{var R=Math.floor(X*k);if(Array.isArray(T)&&T[R]){var Y=T[R];return _p(_p({},L),{},{x:Gn(Y.x,L.x,D),y:Gn(Y.y,L.y,D)})}return L}),D>0&&(i.current=P,a.current=z),S.createElement(s$,{points:P,baseLine:z,needClip:e,clipPathId:n,props:r})}return D>0&&(i.current=o,a.current=l),S.createElement(Or,null,c&&S.createElement("defs",null,S.createElement("clipPath",{id:"animationClipPath-".concat(n)},S.createElement(hTe,{alpha:D,points:o,baseLine:l,layout:x,strokeWidth:r.strokeWidth}))),S.createElement(Or,{clipPath:"url(#animationClipPath-".concat(n,")")},S.createElement(s$,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),S.createElement(hM,{label:r.label}))}function mTe(t){var{needClip:e,clipPathId:n,props:r}=t,i=S.useRef(null),a=S.useRef();return S.createElement(fTe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class pTe extends S.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:p,baseLine:g,zIndex:b}=this.props;if(e)return null;var v=On("recharts-area",i),x=p,{r:y,strokeWidth:E}=uQ(n),w=E4(n),A=y*2+E,N=l?"url(#clipPath-".concat(w?"":"dots-").concat(x,")"):void 0;return S.createElement(Ca,{zIndex:b},S.createElement(Or,{className:v},l&&S.createElement("defs",null,S.createElement(P4,{clipPathId:x,xAxisId:c,yAxisId:u}),!w&&S.createElement("clipPath",{id:"clipPath-dots-".concat(x)},S.createElement("rect",{x:o-A/2,y:a-A/2,width:d+A,height:f+A}))),S.createElement(mTe,{needClip:l,clipPathId:x,props:this.props})),S.createElement(S3,{points:r,mainColor:eS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:N}),this.props.isRange&&Array.isArray(g)&&S.createElement(S3,{points:g,mainColor:eS(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:N}))}}var vQ={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:Xr.area};function gTe(t){var e,n=Lr(t,vQ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:p,legendType:g,stroke:b,xAxisId:v,yAxisId:x}=n,y=yQ(n,tTe),E=Ff(),w=pY(),{needClip:A}=yM(v,x),N=Pi(),{points:C,isRange:T,baseLine:D}=(e=Pt(R=>JAe(R,v,x,N,t.id)))!==null&&e!==void 0?e:{},k=bM();if(E!=="horizontal"&&E!=="vertical"||k==null||w!=="AreaChart"&&w!=="ComposedChart")return null;var{height:P,width:z,x:L,y:X}=k;return!C||!C.length?null:S.createElement(pTe,ef({},y,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:D,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:P,hide:f,layout:E,isAnimationActive:p==="auto"?!Sg.isSsr:p,isRange:T,legendType:g,needClip:A,points:C,stroke:b,width:z,left:L,top:X,xAxisId:v,yAxisId:x}))}var xTe=(t,e,n,r,i)=>{var a=n??e;if(Ot(a))return a;var o=t==="horizontal"?i:r,l=o.scale.domain();if(o.type==="number"){var c=Math.max(l[0],l[1]),u=Math.min(l[0],l[1]);return a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function bTe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:p,bandSize:g}=t,b=i&&i.length,v=xTe(a,o,n,l,c),x=a==="horizontal",y=!1,E=u.map((A,N)=>{var C;b?C=i[d+N]:(C=Jn(A,r),Array.isArray(C)?y=!0:C=[v,C]);var T=C[1]==null||b&&!e&&Jn(A,r)==null;return x?{x:_w({axis:l,ticks:f,bandSize:g,entry:A,index:N}),y:T?null:c.scale(C[1]),value:C,payload:A}:{x:T?null:l.scale(C[1]),y:_w({axis:c,ticks:p,bandSize:g,entry:A,index:N}),value:C,payload:A}}),w;return b||y?w=E.map(A=>{var N=Array.isArray(A.value)?A.value[0]:null;return x?{x:A.x,y:N!=null&&A.y!=null?c.scale(N):null,payload:A.payload}:{x:N!=null?l.scale(N):null,y:A.y,payload:A.payload}}):w=x?c.scale(v):l.scale(v),{points:E,baseLine:w,isRange:y}}function yTe(t){var e=Lr(t,vQ),n=Pi();return S.createElement(gM,{id:e.id,type:"area"},r=>S.createElement(S.Fragment,null,S.createElement(k4,{legendPayload:sTe(e)}),S.createElement(oTe,{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}),S.createElement(j4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:Vq(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),S.createElement(gTe,ef({},e,{id:r}))))}var _Q=S.memo(yTe,gy);_Q.displayName="Area";var vTe=["domain","range"],_Te=["domain","range"];function o$(t,e){if(t==null)return{};var n,r,i=wTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function wTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function l$(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 wQ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=o$(t,vTe),{domain:a,range:o}=e,l=o$(e,_Te);return!l$(n,a)||!l$(r,o)?!1:gy(i,l)}var STe=["dangerouslySetInnerHTML","ticks"],MTe=["id"];function E3(){return E3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},E3.apply(null,arguments)}function c$(t,e){if(t==null)return{};var n,r,i=ETe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ETe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function NTe(t){var e=br(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(vMe(t)):n.current!==t&&e(_Me({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(wMe(n.current)),n.current=null)},[e]),null}var ATe=t=>{var{xAxisId:e,className:n}=t,r=Pt(iD),i=Pi(),a="xAxis",o=Pt(x=>Ld(x,a,e,i)),l=Pt(x=>qX(x,a,e,i)),c=Pt(x=>HX(x,e)),u=Pt(x=>M_e(x,e)),d=Pt(x=>MX(x,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:p}=t,g=c$(t,STe),{id:b}=d,v=c$(d,MTe);return S.createElement(D4,E3({},g,v,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:On("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},TTe={allowDataOverflow:$i.allowDataOverflow,allowDecimals:$i.allowDecimals,allowDuplicatedCategory:$i.allowDuplicatedCategory,angle:$i.angle,axisLine:Bc.axisLine,height:$i.height,hide:!1,includeHidden:$i.includeHidden,interval:$i.interval,minTickGap:$i.minTickGap,mirror:$i.mirror,orientation:$i.orientation,padding:$i.padding,reversed:$i.reversed,scale:$i.scale,tick:$i.tick,tickCount:$i.tickCount,tickLine:Bc.tickLine,tickSize:Bc.tickSize,type:$i.type,xAxisId:0},CTe=t=>{var e=Lr(t,TTe);return S.createElement(S.Fragment,null,S.createElement(NTe,{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}),S.createElement(ATe,e))},tS=S.memo(CTe,wQ);tS.displayName="XAxis";var kTe=["dangerouslySetInnerHTML","ticks"],jTe=["id"];function N3(){return N3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},N3.apply(null,arguments)}function u$(t,e){if(t==null)return{};var n,r,i=PTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function RTe(t){var e=br(),n=S.useRef(null);return S.useLayoutEffect(()=>{n.current===null?e(SMe(t)):n.current!==t&&e(MMe({prev:n.current,next:t})),n.current=t},[t,e]),S.useLayoutEffect(()=>()=>{n.current&&(e(EMe(n.current)),n.current=null)},[e]),null}var DTe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=S.useRef(null),o=S.useRef(null),l=Pt(iD),c=Pi(),u=br(),d="yAxis",f=Pt(N=>Ld(N,d,e,c)),p=Pt(N=>VX(N,e)),g=Pt(N=>N_e(N,e)),b=Pt(N=>qX(N,d,e,c)),v=Pt(N=>EX(N,e));if(S.useLayoutEffect(()=>{if(!(r!=="auto"||!p||v4(i)||S.isValidElement(i)||v==null)){var N=a.current;if(N){var C=N.getCalculatedWidth();Math.round(p.width)!==Math.round(C)&&u(NMe({id:e,width:C}))}}},[b,p,u,i,e,r,v]),p==null||g==null||v==null)return null;var{dangerouslySetInnerHTML:x,ticks:y}=t,E=u$(t,kTe),{id:w}=v,A=u$(v,jTe);return S.createElement(D4,N3({},E,A,{ref:a,labelRef:o,scale:f,x:g.x,y:g.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:p.width,height:p.height,className:On("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:b,axisType:d}))},OTe={allowDataOverflow:Hi.allowDataOverflow,allowDecimals:Hi.allowDecimals,allowDuplicatedCategory:Hi.allowDuplicatedCategory,angle:Hi.angle,axisLine:Bc.axisLine,hide:!1,includeHidden:Hi.includeHidden,interval:Hi.interval,minTickGap:Hi.minTickGap,mirror:Hi.mirror,orientation:Hi.orientation,padding:Hi.padding,reversed:Hi.reversed,scale:Hi.scale,tick:Hi.tick,tickCount:Hi.tickCount,tickLine:Bc.tickLine,tickSize:Bc.tickSize,type:Hi.type,width:Hi.width,yAxisId:0},LTe=t=>{var e=Lr(t,OTe);return S.createElement(S.Fragment,null,S.createElement(RTe,{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}),S.createElement(DTe,e))},nS=S.memo(LTe,wQ);nS.displayName="YAxis";var ITe=(t,e)=>e,L4=Ze([ITe,Tn,wX,Di,cY,hu,B1e,ji],K1e),I4=t=>{var e=t.currentTarget.getBoundingClientRect(),n=e.width/t.currentTarget.offsetWidth,r=e.height/t.currentTarget.offsetHeight;return{chartX:Math.round((t.clientX-e.left)/n),chartY:Math.round((t.clientY-e.top)/r)}},SQ=Ao("mouseClick"),MQ=X0();MQ.startListening({actionCreator:SQ,effect:(t,e)=>{var n=t.payload,r=L4(e.getState(),I4(n));r?.activeIndex!=null&&e.dispatch(z_e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var A3=Ao("mouseMove"),EQ=X0(),s_=null;EQ.startListening({actionCreator:A3,effect:(t,e)=>{var n=t.payload;s_!==null&&cancelAnimationFrame(s_);var r=I4(n);s_=requestAnimationFrame(()=>{var i=e.getState(),a=c4(i,i.tooltip.settings.shared);if(a==="axis"){var o=L4(i,r);o?.activeIndex!=null?e.dispatch(tY({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(eY())}s_=null})}});var d$={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},NQ=fs({name:"rootProps",initialState:d$,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:d$.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}}}),FTe=NQ.reducer,{updateOptions:UTe}=NQ.actions,AQ=fs({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:zTe}=AQ.actions,BTe=AQ.reducer,TQ=Ao("keyDown"),CQ=Ao("focus"),F4=X0();F4.startListening({actionCreator:TQ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=u4(i,Rg(n),cy(n),fy(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=hu(n);if(a==="Enter"){var u=Hw(n,"axis","hover",String(i.index));e.dispatch(x3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=k_e(n),f=d==="left-to-right"?1:-1,p=a==="ArrowRight"?1:-1,g=l+p*f;if(!(c==null||g>=c.length||g<0)){var b=Hw(n,"axis","hover",String(g));e.dispatch(x3({active:!0,activeIndex:g.toString(),activeDataKey:void 0,activeCoordinate:b}))}}}}}});F4.startListening({actionCreator:CQ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",o=Hw(n,"axis","hover",String(a));e.dispatch(x3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var ao=Ao("externalEvent"),kQ=X0(),XT=new Map;kQ.startListening({actionCreator:ao,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=XT.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:N1e(l),activeDataKey:p4(l),activeIndex:Id(l),activeLabel:hY(l),activeTooltipIndex:Id(l),isTooltipActive:A1e(l)};n(c,r)}finally{XT.delete(i)}});XT.set(i,o)}}});var $Te=Ze([Pg],t=>t.tooltipItemPayloads),HTe=Ze([$Te,dy,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var o=e(a,n);return o}}}),jQ=Ao("touchMove"),PQ=X0();PQ.startListening({actionCreator:jQ,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=c4(r,r.tooltip.settings.shared);if(i==="axis"){var a=L4(r,I4({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(tY({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.activeCoordinate}))}else if(i==="item"){var o,l=n.touches[0];if(document.elementFromPoint==null)return;var c=document.elementFromPoint(l.clientX,l.clientY);if(!c||!c.getAttribute)return;var u=c.getAttribute(Wq),d=(o=c.getAttribute(qq))!==null&&o!==void 0?o:void 0,f=HTe(e.getState(),u,d);e.dispatch(JX({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var VTe=fq({brush:mNe,cartesianAxis:AMe,chartData:Ewe,errorBars:WMe,graphicalItems:D2e,layout:Zpe,legend:sxe,options:vwe,polarAxis:XSe,polarOptions:BTe,referenceElements:ENe,rootProps:FTe,tooltip:B_e,zIndex:lwe}),GTe=function(e){return Spe({reducer:VTe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([MQ.middleware,EQ.middleware,F4.middleware,kQ.middleware,PQ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(Tq({type:"raf"}))},devTools:Sg.devToolsEnabled})};function RQ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=Pi(),a=S.useRef(null);if(i)return n;a.current==null&&(a.current=GTe(e));var o=XR;return S.createElement(gEe,{context:o,store:a.current},n)}function WTe(t){var{layout:e,margin:n}=t,r=br(),i=Pi();return S.useEffect(()=>{i||(r(Xpe(e)),r(Kpe(n)))},[r,i,e,n]),null}var DQ=S.memo(WTe,gy);function OQ(t){var e=br();return S.useEffect(()=>{e(UTe(t))},[e,t]),null}function h$(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=HY("".concat(r).concat(e)),a=br();return S.useLayoutEffect(()=>(a(swe({zIndex:e,elementId:i,isPanorama:n})),()=>{a(owe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),S.createElement("g",{tabIndex:-1,id:i})}function f$(t){var{children:e,isPanorama:n}=t,r=Pt(Y1e);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return S.createElement(S.Fragment,null,i.map(o=>S.createElement(h$,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>S.createElement(h$,{key:o,zIndex:o,isPanorama:n})))}var qTe=["children"];function KTe(t,e){if(t==null)return{};var n,r,i=XTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function XTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function rS(){return rS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},rS.apply(null,arguments)}var YTe={width:"100%",height:"100%",display:"block"},QTe=S.forwardRef((t,e)=>{var n=sD(),r=oD(),i=cK();if(!kl(n)||!kl(r))return null;var{children:a,otherAttributes:o,title:l,desc:c}=t,u,d;return o!=null&&(typeof o.tabIndex=="number"?u=o.tabIndex:u=i?0:void 0,typeof o.role=="string"?d=o.role:d=i?"application":void 0),S.createElement(UR,rS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:YTe,ref:e}),a)}),ZTe=t=>{var{children:e}=t,n=Pt(H2);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return S.createElement(UR,{width:r,height:i,x:o,y:a},e)},m$=S.forwardRef((t,e)=>{var{children:n}=t,r=KTe(t,qTe),i=Pi();return i?S.createElement(ZTe,null,S.createElement(f$,{isPanorama:!0},n)):S.createElement(QTe,rS({ref:e},r),S.createElement(f$,{isPanorama:!1},n))});function JTe(){var t=br(),[e,n]=S.useState(null),r=Pt(pge);return S.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;er(a)&&a!==r&&t(Qpe(a))}},[e,t,r]),n}function p$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function eCe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p$(Object(n),!0).forEach(function(r){tCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tCe(t,e,n){return(e=nCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nCe(t){var e=rCe(t,"string");return typeof e=="symbol"?e:e+""}function rCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ef(){return Ef=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Ef.apply(null,arguments)}var iCe=()=>(Dwe(),null);function iS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var aCe=S.forwardRef((t,e)=>{var n,r,i=S.useRef(null),[a,o]=S.useState({containerWidth:iS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:iS((r=t.style)===null||r===void 0?void 0:r.height)}),l=S.useCallback((u,d)=>{o(f=>{var p=Math.round(u),g=Math.round(d);return f.containerWidth===p&&f.containerHeight===g?f:{containerWidth:p,containerHeight:g}})},[]),c=S.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var p=b=>{var{width:v,height:x}=b[0].contentRect;l(v,x)},g=new ResizeObserver(p);g.observe(u),i.current=g}},[e,l]);return S.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),S.createElement(S.Fragment,null,S.createElement(V2,{width:a.containerWidth,height:a.containerHeight}),S.createElement("div",Ef({ref:c},t)))}),sCe=S.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=S.useState({containerWidth:iS(n),containerHeight:iS(r)}),o=S.useCallback((c,u)=>{a(d=>{var f=Math.round(c),p=Math.round(u);return d.containerWidth===f&&d.containerHeight===p?d:{containerWidth:f,containerHeight:p}})},[]),l=S.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return S.createElement(S.Fragment,null,S.createElement(V2,{width:i.containerWidth,height:i.containerHeight}),S.createElement("div",Ef({ref:l},t)))}),oCe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return S.createElement(S.Fragment,null,S.createElement(V2,{width:n,height:r}),S.createElement("div",Ef({ref:e},t)))}),lCe=S.forwardRef((t,e)=>{var{width:n,height:r}=t;return Jc(n)||Jc(r)?S.createElement(sCe,Ef({},t,{ref:e})):S.createElement(oCe,Ef({},t,{ref:e}))});function cCe(t){return t===!0?aCe:lCe}var uCe=S.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:p,onTouchEnd:g,onTouchMove:b,onTouchStart:v,style:x,width:y,responsive:E,dispatchTouchEvents:w=!0}=t,A=S.useRef(null),N=br(),[C,T]=S.useState(null),[D,k]=S.useState(null),P=JTe(),z=aD(),L=z?.width>0?z.width:y,X=z?.height>0?z.height:i,R=S.useCallback(oe=>{P(oe),typeof e=="function"&&e(oe),T(oe),k(oe),oe!=null&&(A.current=oe)},[P,e,T,k]),Y=S.useCallback(oe=>{N(SQ(oe)),N(ao({handler:a,reactEvent:oe}))},[N,a]),J=S.useCallback(oe=>{N(A3(oe)),N(ao({handler:u,reactEvent:oe}))},[N,u]),G=S.useCallback(oe=>{N(eY()),N(ao({handler:d,reactEvent:oe}))},[N,d]),W=S.useCallback(oe=>{N(A3(oe)),N(ao({handler:f,reactEvent:oe}))},[N,f]),ee=S.useCallback(()=>{N(CQ())},[N]),K=S.useCallback(oe=>{N(TQ(oe.key))},[N]),F=S.useCallback(oe=>{N(ao({handler:o,reactEvent:oe}))},[N,o]),q=S.useCallback(oe=>{N(ao({handler:l,reactEvent:oe}))},[N,l]),ne=S.useCallback(oe=>{N(ao({handler:c,reactEvent:oe}))},[N,c]),re=S.useCallback(oe=>{N(ao({handler:p,reactEvent:oe}))},[N,p]),se=S.useCallback(oe=>{N(ao({handler:v,reactEvent:oe}))},[N,v]),de=S.useCallback(oe=>{w&&N(jQ(oe)),N(ao({handler:b,reactEvent:oe}))},[N,w,b]),pe=S.useCallback(oe=>{N(ao({handler:g,reactEvent:oe}))},[N,g]),Ce=cCe(E);return S.createElement(vY.Provider,{value:C},S.createElement(TW.Provider,{value:D},S.createElement(Ce,{width:L??x?.width,height:X??x?.height,className:On("recharts-wrapper",r),style:eCe({position:"relative",cursor:"default",width:L,height:X},x),onClick:Y,onContextMenu:F,onDoubleClick:q,onFocus:ee,onKeyDown:K,onMouseDown:ne,onMouseEnter:J,onMouseLeave:G,onMouseMove:W,onMouseUp:re,onTouchEnd:pe,onTouchMove:de,onTouchStart:se,ref:R},S.createElement(iCe,null),n)))}),dCe=["width","height","responsive","children","className","style","compact","title","desc"];function hCe(t,e){if(t==null)return{};var n,r,i=fCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function fCe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var LQ=S.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=hCe(t,dCe),p=Ha(f);return c?S.createElement(S.Fragment,null,S.createElement(V2,{width:n,height:r}),S.createElement(m$,{otherAttributes:p,title:u,desc:d},a)):S.createElement(uCe,{className:o,style:l,width:n,height:r,responsive:i??!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},S.createElement(m$,{otherAttributes:p,title:u,desc:d,ref:e},S.createElement(NNe,null,a)))});function T3(){return T3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},T3.apply(null,arguments)}var mCe={top:5,right:5,bottom:5,left:5},pCe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:mCe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},U4=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,pCe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return S.createElement(RQ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},S.createElement(JY,{chartData:u.data}),S.createElement(DQ,{layout:i.layout,margin:i.margin}),S.createElement(OQ,{baseValue:i.baseValue,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),S.createElement(LQ,T3({},i,{ref:n})))}),gCe=["axis"],xCe=S.forwardRef((t,e)=>S.createElement(U4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:gCe,tooltipPayloadSearcher:uM,categoricalChartProps:t,ref:e})),bCe=["axis","item"],yCe=S.forwardRef((t,e)=>S.createElement(U4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:bCe,tooltipPayloadSearcher:uM,categoricalChartProps:t,ref:e}));function vCe(t){var e=br();return S.useEffect(()=>{e(zTe(t))},[e,t]),null}var _Ce=["layout"];function C3(){return C3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},C3.apply(null,arguments)}function wCe(t,e){if(t==null)return{};var n,r,i=SCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function SCe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var MCe={top:5,right:5,bottom:5,left:5},IQ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:MCe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},ECe=S.forwardRef(function(e,n){var r,i=Lr(e.categoricalChartProps,IQ),{layout:a}=i,o=wCe(i,_Ce),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return S.createElement(RQ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},S.createElement(JY,{chartData:i.data}),S.createElement(DQ,{layout:a,margin:i.margin}),S.createElement(OQ,{baseValue:void 0,accessibilityLayer:i.accessibilityLayer,barCategoryGap:i.barCategoryGap,maxBarSize:i.maxBarSize,stackOffset:i.stackOffset,barGap:i.barGap,barSize:i.barSize,syncId:i.syncId,syncMethod:i.syncMethod,className:i.className,reverseStackOrder:i.reverseStackOrder}),S.createElement(vCe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),S.createElement(LQ,C3({},o,{ref:n})))});function g$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function x$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?g$(Object(n),!0).forEach(function(r){NCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function NCe(t,e,n){return(e=ACe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ACe(t){var e=TCe(t,"string");return typeof e=="symbol"?e:e+""}function TCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var CCe=["item"],kCe=x$(x$({},IQ),{},{layout:"centric",startAngle:0,endAngle:360}),jCe=S.forwardRef((t,e)=>{var n=Lr(t,kCe);return S.createElement(ECe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:CCe,tooltipPayloadSearcher:uM,categoricalChartProps:n,ref:e})}),PCe=["axis"],RCe=S.forwardRef((t,e)=>S.createElement(U4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:PCe,tooltipPayloadSearcher:uM,categoricalChartProps:t,ref:e}));const b$=[{value:"6h",label:"6h",hours:6},{value:"24h",label:"24h",hours:24},{value:"48h",label:"48h",hours:48},{value:"7d",label:"7d",hours:168}];function DCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=xg(),{mode:u}=wg(),[d,f]=S.useState("24h"),[p,g]=S.useState(o),b=u==="dark",{data:v}=lt({queryKey:["settings"],queryFn:be.getSettings}),x=v?.time_format||"system";S.useEffect(()=>{if(!t)return;const re=se=>{se.key==="Escape"&&e()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[t,e]);const y=b$.find(re=>re.value===d)?.hours||24,{data:E,isLoading:w,error:A}=lt({queryKey:["ams-history",n,i,y],queryFn:()=>be.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const N=E?.data.map(re=>{const se=fi(re.recorded_at)||new Date,de={hour:"2-digit",minute:"2-digit",...y>24?{day:"numeric",month:"short"}:{}};return{time:se.getTime(),humidity:re.humidity,temperature:re.temperature,timeLabel:se.toLocaleTimeString([],_b(de,x))}})||[],C=l?.humidityGood||40,T=l?.humidityFair||60,D=l?.tempGood||30,k=l?.tempFair||35,P=N[N.length-1],z=P?.humidity,L=P?.temperature,X=re=>{const se=re.filter(ge=>ge!=null);if(se.length<4)return"stable";const de=se.slice(0,Math.floor(se.length/4)),pe=se.slice(-Math.floor(se.length/4)),Ce=de.reduce((ge,ue)=>ge+ue,0)/de.length,ae=pe.reduce((ge,ue)=>ge+ue,0)/pe.length-Ce;return Math.abs(ae)<2?"stable":ae>0?"up":"down"},R=X(N.map(re=>re.humidity)),Y=X(N.map(re=>re.temperature)),J=({trend:re})=>re==="up"?s.jsx(xW,{className:"w-4 h-4 text-red-400"}):re==="down"?s.jsx(gW,{className:"w-4 h-4 text-green-400"}):s.jsx(Mj,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),G=re=>re==null?"#9ca3af":re<=C?"#22a352":re<=T?"#d4a017":"#c62828",W=re=>re==null?"#9ca3af":re<=D?"#22a352":re<=k?"#d4a017":"#c62828",ee=b?"#2d2d2d":"#ffffff",K=b?"#1d1d1d":"#f3f4f6",F=b?"#3d3d3d":"#e5e7eb",q=b?"#ffffff":"#111827",ne=b?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:ee},onClick:re=>re.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:F},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:q},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:ne},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ne},children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:K},children:[s.jsxs("button",{onClick:()=>g("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="humidity"?"bg-blue-600 text-white":""}`,style:p!=="humidity"?{color:ne}:void 0,children:[s.jsx(jR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.jsxs("button",{onClick:()=>g("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="temperature"?"bg-orange-600 text-white":""}`,style:p!=="temperature"?{color:ne}:void 0,children:[s.jsx(N2,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:K},children:b$.map(re=>s.jsx("button",{onClick:()=>f(re.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===re.value?"bg-bambu-green text-white":""}`,style:d!==re.value?{color:ne}:void 0,children:re.label},re.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:G(z)},children:z!=null?`${z}%`:"—"}),s.jsx(J,{trend:R})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:q},children:E?.avg_humidity!=null?`${E.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:E?.min_humidity!=null?`${E.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:E?.max_humidity!=null?`${E.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:W(L)},children:L!=null?`${L}°C`:"—"}),s.jsx(J,{trend:Y})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:q},children:E?.avg_temperature!=null?`${E.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:E?.min_temperature!=null?`${E.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:[s.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:E?.max_temperature!=null?`${E.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:K},children:w?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.loading","Loading...")}):A?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):N.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.noData","No data available for this time range")}):s.jsx(j1,{width:"100%",height:300,children:s.jsxs(xCe,{data:N,children:[s.jsx(Jw,{strokeDasharray:"3 3",stroke:b?"#3d3d3d":"#e5e7eb"}),s.jsx(tS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:re=>{const se=new Date(re);return y>24?se.toLocaleDateString([],{day:"numeric",month:"short"}):se.toLocaleTimeString([],_b({hour:"2-digit",minute:"2-digit"},x))},stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(nS,{stroke:b?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:p==="humidity"?[0,100]:["auto","auto"],tickFormatter:re=>p==="humidity"?`${re}%`:`${re}°C`}),s.jsx(R1,{contentStyle:{backgroundColor:b?"#2d2d2d":"#ffffff",border:`1px solid ${b?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:b?"#fff":"#000"},labelFormatter:re=>new Date(re).toLocaleString(void 0,_b({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},x)),formatter:re=>[p==="humidity"?`${re}%`:`${re}°C`,p==="humidity"?"Humidity":"Temperature"]}),s.jsx(uD,{}),p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(lb,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(lb,{y:T,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(lb,{y:D,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(lb,{y:k,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(fQ,{type:"monotone",dataKey:p,name:p==="humidity"?"Humidity":"Temperature",stroke:p==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:ne},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function YT({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const[o,l]=S.useState(!1),[c,u]=S.useState("top"),[d,f]=S.useState(!1),p=S.useRef(null),g=S.useRef(null),b=S.useRef(null),v=()=>{const C=t.trayUuid;C&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(C).then(()=>{f(!0),setTimeout(()=>f(!1),2e3)}).catch(()=>{x(C)}):x(C))},x=C=>{const T=document.createElement("textarea");T.value=C,T.style.position="fixed",T.style.opacity="0",document.body.appendChild(T),T.select();try{document.execCommand("copy"),f(!0),setTimeout(()=>f(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(T)};S.useEffect(()=>{if(o&&p.current&&g.current){const C=p.current.getBoundingClientRect(),T=g.current.offsetHeight,D=C.top,k=window.innerHeight-C.bottom;D<T+12&&k>D?u("bottom"):u("top")}},[o]);const y=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!0),80))},E=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>l(!1),100)};S.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const w=C=>C<=15?"#ef4444":C<=30?"#f97316":C<=50?"#eab308":"#22c55e",A=C=>{if(!C)return!1;const T=C.replace("#",""),D=parseInt(T.slice(0,2),16),k=parseInt(T.slice(2,4),16),P=parseInt(T.slice(4,6),16);return(.299*D+.587*k+.114*P)/255>.6},N=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:p,className:`relative ${r}`,onMouseEnter:y,onMouseLeave:E,children:[e,o&&s.jsxs("div",{ref:g,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${c==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:N||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${A(N)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),s.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Profile"}),s.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"K Factor"}),s.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[s.jsx(jR,{className:"w-3 h-3"}),"Fill"]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:w(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Spool ID"}),s.jsxs("button",{onClick:C=>{C.stopPropagation(),v()},className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",title:"Copy spool UUID",children:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),d?s.jsx(Aa,{className:"w-3 h-3 text-bambu-green"}):s.jsx($s,{className:"w-3 h-3"})]})]}),i.onLinkSpool&&s.jsxs("button",{onClick:C=>{C.stopPropagation(),i.hasUnlinkedSpools!==!1&&i.onLinkSpool?.(t.trayUuid)},disabled:i.hasUnlinkedSpools===!1,className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors ${i.hasUnlinkedSpools===!1?"bg-bambu-gray/10 text-bambu-gray cursor-not-allowed":"bg-bambu-green/20 hover:bg-bambu-green/30 text-bambu-green"}`,title:i.hasUnlinkedSpools===!1?"No unlinked spools available":"Link this spool to a Spoolman spool",children:[s.jsx(El,{className:"w-3.5 h-3.5"}),"Link to Spoolman"]})]}),a?.enabled&&s.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("button",{onClick:C=>{C.stopPropagation(),a.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Pd,{className:"w-3.5 h-3.5"}),"Configure"]})})]})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${c==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function y$({children:t,className:e="",configureSlot:n}){const[r,i]=S.useState(!1),a=S.useRef(null),o=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!0),80)},l=()=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),100)};return S.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:o,onMouseLeave:l,children:[t,r&&s.jsxs("div",{className:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[s.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:"Empty slot"}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.jsxs("button",{onClick:c=>{c.stopPropagation(),n.onConfigure?.()},className:"w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue",title:"Configure slot with filament profile and K value",children:[s.jsx(Pd,{className:"w-3.5 h-3.5"}),"Configure"]})})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function OCe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const i=an(),[a,o]=S.useState(null),{data:l,isLoading:c}=lt({queryKey:["unlinked-spools"],queryFn:be.getUnlinkedSpools,enabled:t}),u=ht({mutationFn:f=>be.linkSpool(f,n),onSuccess:()=>{i.invalidateQueries({queryKey:["unlinked-spools"]}),i.invalidateQueries({queryKey:["spoolman-status"]}),e()}});if(!t)return null;const d=()=>{a&&u.mutate(a)};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(El,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Link to Spoolman"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[r&&s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),s.jsx("span",{className:"text-white font-medium",children:r.type}),s.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Spool UUID:"}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Select a Spoolman spool to link:"}),c?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):l&&l.length>0?s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:l.map(f=>s.jsx("button",{onClick:()=>o(f.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${a===f.id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[f.filament_color_hex&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${f.filament_color_hex}`}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:f.filament_name||"Unknown filament"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[f.filament_material||"Unknown",f.remaining_weight!==null&&` - ${Math.round(f.remaining_weight)}g`,f.location&&` - ${f.location}`]})]}),a===f.id&&s.jsx(Aa,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},f.id))}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx("p",{children:"No unlinked spools found in Spoolman."}),s.jsx("p",{className:"text-xs mt-1",children:"All spools are already linked to AMS trays."})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ee,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Ee,{onClick:d,disabled:!a||u.isPending,children:u.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Linking..."]}):s.jsxs(s.Fragment,{children:[s.jsx(El,{className:"w-4 h-4"}),"Link Spool"]})})]}),u.isError&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:u.error.message})]})]})}function LCe(t,e){if(t===255)return"External";let n,r=!1;t>=128&&t<=135?(n=t-128,r=!0):t>=0&&t<=3?(n=t,r=e===1):n=0,n=Math.max(0,Math.min(n,7));const i=String.fromCharCode(65+n);return r?`HT-${i}`:`AMS-${i}`}function v$(t){const e=t.includes("_")?t.split("_")[0]:t;return e.startsWith("GFS")?"GF"+e.slice(3):(e.startsWith("PFUS")||e.startsWith("PFSP"),e)}const ICe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function _$(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of ICe){const a=new RegExp(`\\b${i}\\b`,"i");if(a.test(n)){const o=e.split(a),l=o[0]?.trim()||"",c=o[1]?.trim()||"";return{material:i,brand:l,variant:c}}}const r=e.split(/\s+/);return r.length>=2?{material:r[1],brand:r[0],variant:r.slice(2).join(" ")}:{material:e,brand:"",variant:""}}function QT(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const FCe={white:"FFFFFF",black:"000000",red:"FF0000",green:"00FF00",blue:"0000FF",yellow:"FFFF00",cyan:"00FFFF",magenta:"FF00FF",orange:"FFA500",purple:"800080",pink:"FFC0CB",brown:"8B4513",gray:"808080",grey:"808080","jade white":"FFFEF2",ivory:"FFFFF0",beige:"F5F5DC",cream:"FFFDD0",silver:"C0C0C0",gold:"FFD700",bronze:"CD7F32",copper:"B87333",navy:"000080",teal:"008080",olive:"808000",maroon:"800000",coral:"FF7F50",salmon:"FA8072",lime:"32CD32",mint:"98FF98","forest green":"228B22","sky blue":"87CEEB","royal blue":"4169E1",turquoise:"40E0D0",lavender:"E6E6FA",violet:"EE82EE",plum:"DDA0DD",tan:"D2B48C",chocolate:"D2691E",charcoal:"36454F",slate:"708090",transparent:"000000",natural:"F5F5DC",wood:"DEB887"},UCe=[{name:"White",hex:"FFFFFF"},{name:"Black",hex:"000000"},{name:"Red",hex:"FF0000"},{name:"Blue",hex:"0000FF"},{name:"Green",hex:"00AA00"},{name:"Yellow",hex:"FFFF00"},{name:"Orange",hex:"FFA500"},{name:"Gray",hex:"808080"}],zCe=[{name:"Cyan",hex:"00FFFF"},{name:"Magenta",hex:"FF00FF"},{name:"Purple",hex:"800080"},{name:"Pink",hex:"FFC0CB"},{name:"Brown",hex:"8B4513"},{name:"Beige",hex:"F5F5DC"},{name:"Navy",hex:"000080"},{name:"Teal",hex:"008080"},{name:"Lime",hex:"32CD32"},{name:"Gold",hex:"FFD700"},{name:"Silver",hex:"C0C0C0"},{name:"Maroon",hex:"800000"},{name:"Olive",hex:"808000"},{name:"Coral",hex:"FF7F50"},{name:"Salmon",hex:"FA8072"},{name:"Turquoise",hex:"40E0D0"},{name:"Violet",hex:"EE82EE"},{name:"Indigo",hex:"4B0082"},{name:"Chocolate",hex:"D2691E"},{name:"Tan",hex:"D2B48C"},{name:"Slate",hex:"708090"},{name:"Charcoal",hex:"36454F"},{name:"Ivory",hex:"FFFFF0"},{name:"Cream",hex:"FFFDD0"}];function BCe(t){const e=t.toLowerCase().trim();return FCe[e]||null}function $Ce({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=S.useState(""),[c,u]=S.useState(null),[d,f]=S.useState(""),[p,g]=S.useState(""),[b,v]=S.useState(""),[x,y]=S.useState(!1),[E,w]=S.useState(!1),{data:A,isLoading:N}=lt({queryKey:["cloudSettings"],queryFn:()=>be.getCloudSettings(),enabled:t}),{data:C,isLoading:T}=lt({queryKey:["kprofiles",n,i],queryFn:()=>be.getKProfiles(n,i),enabled:t&&!!n}),D=ht({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const W=A?.filament.find(oe=>oe.setting_id===o);if(!W)throw new Error("Selected preset not found");const ee=_$(W.name),K=c?.slot_id??-1,F=d||r.trayColor?.slice(0,6)||"FFFFFF",q=W.name.replace(/@.+$/,"").trim();let ne=v$(o);if(!o.startsWith("GFS"))try{const oe=await be.getCloudSettingDetail(o);oe.filament_id?ne=oe.filament_id:oe.base_id&&(ne=v$(oe.base_id),console.log(`Derived tray_info_idx from base_id: ${oe.base_id} -> ${ne}`))}catch(oe){console.warn("Failed to fetch preset detail for filament_id:",oe)}let re=190,se=230;const de=ee.material.toUpperCase();de.includes("PLA")?(re=190,se=230):de.includes("PETG")?(re=220,se=260):de.includes("ABS")||de.includes("ASA")?(re=240,se=280):de.includes("TPU")?(re=200,se=240):de.includes("PC")?(re=260,se=300):(de.includes("PA")||de.includes("NYLON"))&&(re=250,se=290);const pe=c?.k_value?parseFloat(c.k_value):0,Ce=await be.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:ee.material||"PLA",tray_sub_brands:q,tray_color:F+"FF",nozzle_temp_min:re,nozzle_temp_max:se,cali_idx:K,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:pe});try{await be.saveSlotPreset(n,r.amsId,r.trayId,o,q)}catch(oe){console.warn("Failed to save slot preset mapping:",oe)}return Ce},onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),k=ht({mutationFn:async()=>be.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),P=S.useMemo(()=>{if(!A?.filament)return[];const W=b.toLowerCase();return A.filament.filter(ee=>W?ee.name.toLowerCase().includes(W):!0).sort((ee,K)=>{const F=QT(ee.setting_id),q=QT(K.setting_id);return F&&!q?-1:!F&&q?1:ee.name.localeCompare(K.name)})},[A?.filament,b]),z=S.useMemo(()=>{if(!o||!A?.filament)return null;const W=A.filament.find(F=>F.setting_id===o);if(!W)return null;let ee=W.name.replace(/@.+$/,"").trim();ee.startsWith("# ")&&(ee=ee.slice(2).trim());const K=_$(ee);return{fullName:ee,material:K.material,brand:K.brand}},[o,A?.filament]),L=z?.fullName||"",X=S.useMemo(()=>{if(!C?.profiles||!z)return[];const{fullName:W,material:ee,brand:K}=z,F=W.toUpperCase(),q=ee.toUpperCase(),ne=K.toUpperCase();if(!q||q.length<2)return[];const re=C.profiles.filter(de=>{const pe=de.name.toUpperCase();if(ne)return!(!pe.includes(ne)||!pe.includes(q));if(pe.includes(F)||pe.includes(q))return!0;const oe={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[q]||[];for(const ae of oe)if(pe.includes(ae))return!0;return!1}),se=new Map;for(const de of re){const pe=`${de.name}|${de.k_value}`,Ce=se.get(pe);Ce?de.extruder_id===1&&Ce.extruder_id===0&&se.set(pe,de):se.set(pe,de)}return Array.from(se.values())},[C?.profiles,z]);S.useEffect(()=>{if(t&&A?.filament){if(r.trayInfoIdx){const W=A.filament.find(ee=>ee.setting_id===r.trayInfoIdx);W&&l(W.setting_id)}}else t||(l(""),u(null),f(""),g(""),v(""),y(!1))},[t,A?.filament,r.trayInfoIdx]),S.useEffect(()=>{X.length>0?u(X[0]):u(null)},[o,X.length]);const R=S.useCallback(W=>{W.key==="Escape"&&e()},[e]);if(S.useEffect(()=>{if(t)return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[t,R]),!t)return null;const Y=N||T,J=o&&!D.isPending,G=d||r.trayColor?.slice(0,6)||"FFFFFF";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pd,{className:"w-5 h-5 text-bambu-blue"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[x&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx(p2,{className:"w-16 h-16 text-bambu-green mx-auto"}),s.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),s.jsxs("span",{className:"text-white font-medium",children:[LCe(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),Y?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Search presets...",value:b,onChange:W=>v(W.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2"}),s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:P.length===0?s.jsx("p",{className:"text-center py-4 text-bambu-gray",children:A?.filament?.length===0?"No cloud presets. Login to Bambu Cloud to sync.":"No matching presets found."}):P.map(W=>s.jsx("button",{onClick:()=>l(W.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===W.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-white text-sm truncate",children:W.name}),QT(W.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},W.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",L&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",L]})]}),X.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:W=>{const ee=X.find(K=>K.name===W.target.value);u(ee||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 appearance-none pr-10",children:[s.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),X.map(W=>s.jsxs("option",{value:W.name,children:[W.name," (K=",W.k_value,")"]},`${W.name}-${W.extruder_id}`))]}),s.jsx(Qi,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?s.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):s.jsx("span",{className:"inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30",children:"Select a filament profile first"}),c&&s.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[UCe.map(W=>s.jsx("button",{onClick:()=>{f(W.hex),g(W.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===W.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${W.hex}`},title:W.name},W.hex)),s.jsx("button",{onClick:()=>w(!E),className:"w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs",title:E?"Show less colors":"Show more colors",children:E?"−":"+"})]}),E&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:zCe.map(W=>s.jsx("button",{onClick:()=>{f(W.hex),g(W.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===W.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${W.hex}`},title:W.name},W.hex))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${G}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:p,onChange:W=>{const ee=W.target.value;g(ee);const K=BCe(ee);if(K)f(K);else{const F=ee.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();F.length===6?f(F):F.length===3&&f(F.split("").map(q=>q+q).join(""))}},className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm"}),d&&s.jsx("button",{onClick:()=>{f(""),g("")},className:"px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded",title:"Clear custom color",children:"Clear"})]}),d&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),s.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ee,{variant:"secondary",onClick:()=>k.mutate(),disabled:k.isPending||D.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:k.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(If,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ee,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Ee,{onClick:()=>D.mutate(),disabled:!J,children:D.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Pd,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(D.isError||k.isError)&&s.jsx("div",{className:"mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:D.error?.message||k.error?.message})]})]})}function HCe({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return s.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsxs("g",{stroke:r,opacity:i,children:[s.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),s.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),s.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),s.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),s.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),s.jsx("path",{d:"M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24",fill:n,stroke:r}),s.jsx("path",{d:"M12 24h8",stroke:r}),s.jsx("path",{d:"M12 27h8",stroke:r}),s.jsx("path",{d:"M13 30h6",stroke:r})]})}const w$=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),S$={"A00-W1":"Jade White","A00-P0":"Beige","A00-D2":"Light Gray","A00-Y0":"Yellow","A00-Y2":"Sunflower Yellow","A00-A1":"Pumpkin Orange","A00-A0":"Orange","A00-Y4":"Gold","A00-G3":"Bright Green","A00-G1":"Bambu Green","A00-G2":"Mistletoe Green","A00-R3":"Hot Pink","A00-P6":"Magenta","A00-R0":"Red","A00-R2":"Maroon Red","A00-P5":"Purple","A00-P2":"Indigo Purple","A00-B5":"Turquoise","A00-B8":"Cyan","A00-B3":"Cobalt Blue","A00-N0":"Brown","A00-N1":"Cocoa Brown","A00-Y3":"Bronze","A00-D0":"Gray","A00-D1":"Silver","A00-B1":"Blue Grey","A00-D3":"Dark Gray","A00-K0":"Black","A00-M3":"Pink Citrus","A00-M6":"Dusk Glare","A00-M0":"Arctic Whisper","A00-M1":"Solar Breeze","A00-M5":"Blueberry Bubblegum","A00-M4":"Mint Lime","A00-M2":"Ocean to Meadow","A00-M7":"Cotton Candy Cloud","A18-K0":"Black","A18-D0":"Gray","A18-W0":"White","A18-R0":"Red","A18-Y0":"Yellow","A18-B0":"Cyan","A18-B1":"Blue","A18-P0":"Matte Beige","A01-W2":"Ivory White","A01-W3":"Bone White","A01-Y2":"Lemon Yellow","A01-A2":"Mandarin Orange","A01-P3":"Sakura Pink","A01-P4":"Lilac Purple","A01-R3":"Plum","A01-R1":"Scarlet Red","A01-R4":"Dark Red","A01-G0":"Apple Green","A01-G1":"Grass Green","A01-G7":"Dark Green","A01-B4":"Ice Blue","A01-B0":"Sky Blue","A01-B3":"Marine Blue","A01-B6":"Dark Blue","A01-Y3":"Desert Tan","A01-N1":"Latte Brown","A01-N3":"Caramel","A01-R2":"Terracotta","A01-N2":"Dark Brown","A01-N0":"Dark Chocolate","A01-D3":"Ash Gray","A01-D0":"Nardo Gray","A01-K1":"Charcoal","A12-G0":"Green","A12-R0":"Pink","A12-A0":"Orange","A12-Y0":"Yellow","A12-B0":"Blue","A07-R5":"Red Granite","A07-D4":"White Marble","A11-W0":"White","A11-K0":"Black","A08-G3":"Alpine Green Sparkle","A08-D5":"Slate Gray Sparkle","A08-B7":"Royal Purple Sparkle","A08-R2":"Crimson Red Sparkle","A08-K2":"Onyx Black Sparkle","A08-Y1":"Classic Gold Sparkle","A02-B2":"Cobalt Blue Metallic","A02-G2":"Oxide Green Metallic","A02-Y1":"Iridium Gold Metallic","A02-D2":"Iron Gray Metallic","A17-B1":"Blue","A17-A0":"Orange","A17-P0":"Purple","A06-Y1":"Gold","A06-D0":"Titan Gray","A06-D1":"Silver","A06-W0":"White","A06-R0":"Candy Red","A06-G0":"Candy Green","A06-G1":"Mint","A06-B1":"Blue","A06-B0":"Baby Blue","A06-P0":"Purple","A06-R1":"Rose Gold","A06-R2":"Pink","A06-Y0":"Champagne","A05-M8":"Dawn Radiance","A05-M4":"Aurora Purple","A05-M1":"South Beach","A05-T3":"Neon City","A05-T2":"Midnight Blaze","A05-T1":"Gilded Rose","A05-T4":"Blue Hawaii","A05-T5":"Velvet Eclipse","A15-B0":"Purple","A15-G0":"Green","A15-G1":"Nebulae","A15-R0":"Brown","A16-K0":"Black Walnut","A16-R0":"Rosewood","A16-N0":"Clay Brown","A16-G0":"Classic Birch","A16-W0":"White Oak","A16-Y0":"Ochre Yellow","A50-D6":"Lava Gray","A50-K0":"Black","A50-B6":"Royal Blue","A10-W0":"White","A10-D0":"Gray","A09-B5":"Lavender Blue","A09-B4":"Light Blue","A09-A0":"Orange","A09-D1":"Silver","A09-R3":"Vermilion Red","A09-Y0":"Yellow","G02-K0":"Black","G02-W0":"White","G02-R0":"Red","G02-D0":"Gray","G02-D1":"Dark Gray","G02-Y1":"Cream","G02-Y0":"Yellow","G02-A0":"Orange","G02-N1":"Peanut Brown","G02-G1":"Lime Green","G02-G0":"Green","G02-G2":"Forest Green","G02-B1":"Lake Blue","G02-B0":"Blue","G01-G1":"Translucent Teal","G01-B0":"Translucent Light Blue","G01-C0":"Clear","G01-D0":"Translucent Gray","G01-G0":"Translucent Olive","G01-N0":"Translucent Brown","G01-A0":"Translucent Orange","G01-P1":"Translucent Pink","G01-P0":"Translucent Purple","G50-P7":"Violet Purple","G50-K0":"Black","B00-D1":"Silver","B00-K0":"Black","B00-W0":"White","B00-G6":"Bambu Green","B00-G7":"Olive","B00-Y1":"Tangerine Yellow","B00-A0":"Orange","B00-R0":"Red","B00-B4":"Azure","B00-B0":"Blue","B00-B6":"Navy Blue","B50-A0":"Orange","B50-K0":"Black","B01-W0":"White","B01-K0":"Black","B01-D0":"Gray","B02-W0":"White","C00-C1":"Transparent","C00-C0":"Clear Black","C00-K0":"Black","C00-W0":"White","C01-K0":"Black","U02-B0":"Blue","U02-D0":"Gray","U02-K0":"Black","N04-K0":"Black","N08-K0":"Black","S02-W0":"Nature","S02-W1":"White","S05-C0":"Black","S06-W0":"White","S03-G1":"Green","S04-Y0":"Clear"},VCe={W0:"White",W1:"Jade White",W2:"Ivory White",W3:"Bone White",Y0:"Yellow",Y1:"Gold",Y2:"Sunflower Yellow",Y3:"Bronze",Y4:"Gold",A0:"Orange",A1:"Pumpkin Orange",A2:"Mandarin Orange",R0:"Red",R1:"Scarlet Red",R2:"Maroon Red",R3:"Hot Pink",R4:"Dark Red",R5:"Red Granite",P0:"Beige",P1:"Pink",P2:"Indigo Purple",P3:"Sakura Pink",P4:"Lilac Purple",P5:"Purple",P6:"Magenta",P7:"Violet Purple",B0:"Blue",B1:"Blue Grey",B2:"Cobalt Blue",B3:"Cobalt Blue",B4:"Ice Blue",B5:"Turquoise",B6:"Navy Blue",B7:"Royal Purple",B8:"Cyan",G0:"Green",G1:"Grass Green",G2:"Mistletoe Green",G3:"Bright Green",G6:"Bambu Green",G7:"Dark Green",N0:"Brown",N1:"Peanut Brown",N2:"Dark Brown",N3:"Caramel",D0:"Gray",D1:"Silver",D2:"Light Gray",D3:"Dark Gray",D4:"White Marble",D5:"Slate Gray",D6:"Lava Gray",K0:"Black",K1:"Charcoal",K2:"Onyx Black",C0:"Clear Black",C1:"Transparent",M0:"Arctic Whisper",M1:"Solar Breeze",M2:"Ocean to Meadow",M3:"Pink Citrus",M4:"Aurora Purple",M5:"Blueberry Bubblegum",M6:"Dusk Glare",M7:"Cotton Candy Cloud",M8:"Dawn Radiance",T1:"Gilded Rose",T2:"Midnight Blaze",T3:"Neon City",T4:"Blue Hawaii",T5:"Velvet Eclipse"};function ZT(t){if(!t)return null;if(S$[t])return S$[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return VCe[n]||null}function JT(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,p=r/255;i===d?l=((f-p)/u+(f<p?6:0))/6:i===f?l=((p-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function eC(t){return(t??.02).toFixed(3)}function M$({side:t}){const{mode:e}=wg(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.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 E$({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.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 GCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 WCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 qCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function KCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),s.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 XCe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),s.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 tC({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.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:i,strokeWidth:"1",fill:"none"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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:i,strokeWidth:"1",fill:"none"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function N$({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=E$:a<=l?d=GCe:d=WCe,s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[s.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function A$({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=qCe):t<=o?(l="#d4a017",c="Fair",u=KCe):(l="#c62828",c="Bad",u=XCe),s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Temperature: ${t}°C - ${c}${r?" (click for history)":""}`,children:[s.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function Iu(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function T$(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function YCe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function QCe(t,e="system"){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const a=new Date(r);a.setHours(0,0,0,0);const o={hour:"2-digit",minute:"2-digit"};e==="12h"?o.hour12=!0:e==="24h"&&(o.hour12=!1);const l=r.toLocaleTimeString([],o),c=Math.floor((a.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function ZCe(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 JCe(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 nC(t){return t?!!(t.tray_info_idx&&t.tray_info_idx.startsWith("GF")||t.tray_uuid&&t.tray_uuid!=="00000000000000000000000000000000"||t.tag_uid&&t.tag_uid!=="0000000000000000"):!1}function eke({url:t,printName:e}){const[n,r]=S.useState(!1),[i,a]=S.useState(!1),[o,l]=S.useState(!1);return s.jsxs(s.Fragment,{children:[s.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&&l(!0),children:t&&!i?s.jsxs(s.Fragment,{children:[s.jsx("img",{src:t,alt:"Print preview",className:`w-full h-full object-cover ${n?"block":"hidden"}`,onLoad:()=>r(!0),onError:()=>a(!0)}),!n&&s.jsx(ks,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(ks,{className:"w-8 h-8 text-bambu-gray"})}),o&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>l(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:"Print preview",className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function tke({printers:t}){const e=an(),n=S.useMemo(()=>{let i=0,a=0,o=0,l=0;return t?.forEach(c=>{const u=e.getQueryData(["printerStatus",c.id]);u===void 0?l++:u.connected?u.state==="RUNNING"?i++:a++:o++}),{printing:i,idle:a,offline:o,loading:l,total:t?.length||0}},[t,e]),[,r]=S.useState(0);return S.useEffect(()=>{let i=!1;const a=e.getQueryCache().subscribe(()=>{i||(i=!0,requestAnimationFrame(()=>{r(o=>o+1),i=!1}))});return()=>a()},[e]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[n.printing>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.printing})," printing"]})]}),n.idle>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.idle})," idle"]})]}),n.offline>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:n.offline})," offline"]})]})]}):null}function C$(t,e){if(e)return e;switch(t){case"RUNNING":return"Printing";case"PAUSE":return"Paused";case"FINISH":return"Finished";case"FAILED":return"Failed";case"IDLE":return"Idle";default:return t?t.charAt(0)+t.slice(1).toLowerCase():"Idle"}}function k$({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,timeFormat:c="system"}){const u=an(),d=vg(),{showToast:f}=Wn(),[p,g]=S.useState(!1),[b,v]=S.useState(!1),[x,y]=S.useState(!0),[E,w]=S.useState(!1),[A,N]=S.useState(!1),[C,T]=S.useState(!1),[D,k]=S.useState(!1),[P,z]=S.useState(!1),[L,X]=S.useState(!1),[R,Y]=S.useState(!1),[J,G]=S.useState(!1),[W,ee]=S.useState(!1),[K,F]=S.useState(!1),[q,ne]=S.useState(null),[re,se]=S.useState(null),[de,pe]=S.useState(null),[Ce,oe]=S.useState(!1),{data:ae}=lt({queryKey:["printerStatus",t.id],queryFn:()=>be.getPrinterStatus(t.id),refetchInterval:3e4}),{data:ge}=lt({queryKey:["firmwareUpdate",t.id],queryFn:()=>N1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3}),ue=S.useMemo(()=>{const yt=new Set;if(ae?.ams)for(const Ft of ae.ams)for(const qt of Ft.tray||[])qt.tray_info_idx&&yt.add(qt.tray_info_idx);return ae?.vt_tray?.tray_info_idx&&yt.add(ae.vt_tray.tray_info_idx),Array.from(yt)},[ae?.ams,ae?.vt_tray]),{data:Le}=lt({queryKey:["filamentInfo",ue],queryFn:()=>be.getFilamentInfo(ue),enabled:ue.length>0,staleTime:300*1e3}),{data:V}=lt({queryKey:["slotPresets",t.id],queryFn:()=>be.getSlotPresets(t.id),staleTime:120*1e3}),[$,Z]=S.useState(null);S.useEffect(()=>{ae?.wifi_signal!=null&&Z(ae.wifi_signal)},[ae?.wifi_signal]);const B=ae?.wifi_signal??$,U=S.useRef(void 0);S.useEffect(()=>{ae?.connected!==void 0&&(U.current=ae.connected)},[ae?.connected]);const Q=ae?.connected??U.current,Me=S.useRef({});S.useEffect(()=>{ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0&&(Me.current=ae.ams_extruder_map)},[ae?.ams_extruder_map]);const Te=ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0?ae.ams_extruder_map:Me.current,fe=S.useRef([]);S.useEffect(()=>{ae?.ams&&ae.ams.length>0&&(fe.current=ae.ams)},[ae?.ams]);const H=ae?.ams&&ae.ams.length>0?ae.ams:fe.current,I=S.useRef(255),ce=ae?.tray_now;ce!==void 0&&ce!==255&&(I.current=ce);const we=ce===void 0||ce===255?I.current:ce,{data:Se}=lt({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>be.getSmartPlugByPrinter(t.id)}),{data:_e}=lt({queryKey:["smartPlugStatus",Se?.id],queryFn:()=>Se?be.getSmartPlugStatus(Se.id):null,enabled:!!Se,refetchInterval:1e4}),{data:st}=lt({queryKey:["queue",t.id,"pending"],queryFn:()=>be.getQueue(t.id,"pending")}),Ve=st?.length||0,{data:it}=lt({queryKey:["archives",t.id,"last"],queryFn:()=>be.getArchives(t.id,1,0),enabled:ae?.connected&&ae?.state!=="RUNNING"}),ct=it?.[0],Fe=e&&Q===!1,me=ht({mutationFn:yt=>be.deletePrinter(t.id,yt.deleteArchives),onSuccess:()=>{u.invalidateQueries({queryKey:["printers"]}),u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["maintenanceOverview"]})}}),Ke=ht({mutationFn:()=>be.connectPrinter(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["printerStatus",t.id]})}}),qe=ht({mutationFn:yt=>Se?be.controlSmartPlug(Se.id,yt):Promise.reject("No plug"),onSuccess:()=>{u.invalidateQueries({queryKey:["smartPlugStatus",Se?.id]})}}),Qe=ht({mutationFn:yt=>Se?be.updateSmartPlug(Se.id,{auto_off:yt}):Promise.reject("No plug"),onSuccess:()=>{u.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),u.invalidateQueries({queryKey:["smart-plugs"]})}}),ut=ht({mutationFn:()=>be.stopPrint(t.id),onSuccess:()=>{f("Print stopped"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:yt=>f(yt.message||"Failed to stop print","error")}),ie=ht({mutationFn:()=>be.pausePrint(t.id),onSuccess:()=>{f("Print paused"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:yt=>f(yt.message||"Failed to pause print","error")}),He=ht({mutationFn:()=>be.resumePrint(t.id),onSuccess:()=>{f("Print resumed"),u.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:yt=>f(yt.message||"Failed to resume print","error")}),ve=ht({mutationFn:yt=>be.setChamberLight(t.id,yt),onMutate:async yt=>{await u.cancelQueries({queryKey:["printerStatus",t.id]});const Ft=u.getQueryData(["printerStatus",t.id]);return u.setQueryData(["printerStatus",t.id],qt=>({...qt,chamber_light:yt})),{previousStatus:Ft}},onSuccess:(yt,Ft)=>{f(`Chamber light ${Ft?"on":"off"}`)},onError:(yt,Ft,qt)=>{qt?.previousStatus&&u.setQueryData(["printerStatus",t.id],qt.previousStatus),f(yt.message||"Failed to control chamber light","error")}}),Be=(ae?.state==="RUNNING"||ae?.state==="PAUSE"||ae?.state==="PAUSED")&&(ae?.printable_objects_count??0)>=2,{data:je,refetch:Ne}=lt({queryKey:["printableObjects",t.id],queryFn:()=>be.getPrintableObjects(t.id),enabled:K||Be,refetchInterval:K?5e3:Be?3e4:!1}),Xe=ht({mutationFn:yt=>be.skipObjects(t.id,yt),onSuccess:yt=>{f(yt.message||"Objects skipped"),Ne()},onError:yt=>f(yt.message||"Failed to skip objects","error")}),[mt,At]=S.useState(null),Rt=S.useRef(!1),Xt=S.useRef(null),Lt=S.useRef(!1),Sn=ht({mutationFn:({amsId:yt,slotId:Ft})=>be.refreshAmsSlot(t.id,yt,Ft),onMutate:({amsId:yt,slotId:Ft})=>{Xt.current&&clearTimeout(Xt.current),Rt.current=!1,Lt.current=!1,At({amsId:yt,slotId:Ft}),setTimeout(()=>{Lt.current=!0},2e3),Xt.current=setTimeout(()=>{At(null)},3e4)},onSuccess:yt=>{f(yt.message||"RFID re-read initiated")},onError:yt=>{f(yt.message||"Failed to re-read RFID","error"),Xt.current&&clearTimeout(Xt.current),At(null)}}),$t=S.useRef(null);S.useEffect(()=>{if(!mt)return;const yt=ae?.ams_status_main??0;return yt!==0&&(Rt.current=!0,$t.current&&(clearTimeout($t.current),$t.current=null)),Rt.current&&yt===0&&(Lt.current?(Xt.current&&clearTimeout(Xt.current),At(null)):$t.current||($t.current=setTimeout(()=>{Xt.current&&clearTimeout(Xt.current),At(null)},2e3))),()=>{$t.current&&clearTimeout($t.current)}},[ae?.ams_status_main,mt]);const[Cn,nr]=S.useState(null);if(Fe)return null;const Hn=()=>{switch(i){case 1:return"w-10 h-10";case 2:return"w-14 h-14";case 3:return"w-16 h-16";case 4:return"w-20 h-20";default:return"w-14 h-14"}},Jr=()=>{switch(i){case 1:return"text-base truncate";case 2:return"text-lg";case 3:return"text-xl";case 4:return"text-2xl";default:return"text-lg"}},qn=()=>{switch(i){case 1:return"mb-2";case 2:return"mb-4";case 3:return"mb-5";case 4:return"mb-6";default:return"mb-4"}};return s.jsxs(_t,{className:"relative",children:[s.jsxs(Mt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:qn(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("img",{src:ZCe(t.model),alt:t.model||"Printer",className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${Hn()}`}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-semibold text-white ${Jr()}`,children:t.name}),r==="compact"&&s.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ae?.connected?"bg-bambu-green":"bg-red-500"}`,title:ae?.connected?"Connected":"Offline"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ae?.nozzles&&ae.nozzles[0]?.nozzle_diameter&&s.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ae.nozzles[0].nozzle_type||"Nozzle",children:["• ",ae.nozzles[0].nozzle_diameter,"mm"]}),r==="expanded"&&n&&n.total_print_hours>0&&s.jsxs("span",{className:"ml-2 text-bambu-gray",children:[s.jsx(tr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>g(!p),children:s.jsx(vd,{className:"w-4 h-4"})}),p&&s.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:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{w(!0),g(!1)},children:[s.jsx(Jo,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{Ke.mutate(),g(!1)},children:[s.jsx(Rr,{className:"w-4 h-4"}),"Reconnect"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{T(!0),g(!1)},children:[s.jsx(pW,{className:"w-4 h-4"}),"MQTT Debug"]}),s.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:()=>{v(!0),g(!1)},children:[s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]})]})]}),r==="expanded"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[s.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${ae?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[ae?.connected?s.jsx(B0,{className:"w-3 h-3"}):s.jsx(IR,{className:"w-3 h-3"}),ae?.connected?"Connected":"Offline"]}),ae?.connected&&B!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${B>=-50||B>=-60?"bg-bambu-green/20 text-bambu-green":B>=-70?"bg-amber-500/20 text-amber-600":B>=-80?"bg-orange-500/20 text-orange-600":"bg-red-500/20 text-red-600"}`,title:`WiFi: ${B} dBm - ${JCe(B).label}`,children:[s.jsx(Nde,{className:"w-3 h-3"}),B,"dBm"]}),ae?.connected&&(()=>{const yt=ae.hms_errors?Fhe(ae.hms_errors):[];return s.jsxs("button",{onClick:()=>X(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${yt.length>0?yt.some(Ft=>Ft.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:[s.jsx(yn,{className:"w-3 h-3"}),yt.length>0?yt.length:"OK"]})})(),n&&s.jsxs("button",{onClick:()=>d("/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:[s.jsx(Rd,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Ve>0&&s.jsxs("button",{onClick:()=>d("/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:`${Ve} print${Ve>1?"s":""} in queue`,children:[s.jsx(Hs,{className:"w-3 h-3"}),Ve]}),ge?.update_available&&s.jsxs("button",{onClick:()=>oe(!0),className:"flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-orange-500/20 text-orange-400 hover:opacity-80 transition-opacity",title:`Firmware update available: ${ge.current_version} → ${ge.latest_version}`,children:[s.jsx(Yr,{className:"w-3 h-3"}),"Update"]})]})]}),b&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(_t,{className:"w-full max-w-md mx-4",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:s.jsx(yn,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Printer"}),s.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:['Are you sure you want to delete "',t.name,'"? This will remove all connection settings.']})]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:yt=>y(yt.target.checked),className:"mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Delete print archives"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:x?"All print history for this printer will be permanently deleted.":"Print history will be kept but no longer associated with this printer."})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Ee,{variant:"secondary",onClick:()=>{v(!1),y(!0)},children:"Cancel"}),s.jsx(Ee,{variant:"danger",onClick:()=>{me.mutate({deleteArchives:x}),v(!1),y(!0)},children:"Delete"})]})]})})}),ae?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:ae.state==="RUNNING"?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:s.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(ae.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:C$(ae.state,ae.stg_cur_name)})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[s.jsxs("button",{onClick:()=>F(!0),disabled:!(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")||(ae.printable_objects_count??0)<2,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")&&(ae.printable_objects_count??0)>=2?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED"?(ae.printable_objects_count??0)>=2?"Skip objects":"Skip objects (requires 2+ objects)":"Skip objects (only while printing)",children:[s.jsx(w$,{className:"w-4 h-4"}),je&&je.skipped_count>0&&s.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full",children:je.skipped_count})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(eke,{url:ae.state==="RUNNING"?ae.cover_url:null,printName:ae.state==="RUNNING"&&(ae.subtask_name||ae.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:ae.current_print&&ae.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ae.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ae.subtask_name||ae.current_print}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(ae.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ae.remaining_time!=null&&ae.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),YCe(ae.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:"Estimated completion time",children:["ETA ",QCe(ae.remaining_time,c)]})]}),ae.layer_num!=null&&ae.total_layers!=null&&ae.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(Hs,{className:"w-3 h-3"}),ae.layer_num,"/",ae.total_layers]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("p",{className:"text-white text-sm mb-2",children:C$(ae.state,ae.stg_cur_name)}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),s.jsx("span",{className:"text-bambu-gray",children:"—"})]}),ct?s.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:ct.print_name||ct.filename,children:["Last: ",ct.print_name||ct.filename,ct.completed_at&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Hp(ct.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:"Ready to print"})]})})]})]}),ae.state!=="RUNNING"&&s.jsx($he,{printerId:t.id})]}),ae.temperatures&&r==="expanded"&&(()=>{const yt=ae.temperatures.nozzle_heating||ae.temperatures.nozzle_2_heating||!1,Ft=ae.temperatures.bed_heating||!1,qt=ae.temperatures.chamber_heating||!1,gt=t.nozzle_count===2||ae.temperatures.nozzle_2!==void 0,en=ae.active_extruder===1?"L":"R";return s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(tC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:yt}),ae.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"° / ",Math.round(ae.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(tC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Ft}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Bed"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.bed||0),"°C"]})]}),ae.temperatures.chamber!==void 0&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx(tC,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:qt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Chamber"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.chamber||0),"°C"]})]}),gt&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:`Active: ${en==="L"?"Left":"Right"} nozzle`,children:[s.jsx("p",{className:`text-[11px] font-bold ${en==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"Nozzle"}),s.jsx("p",{className:`text-[11px] font-bold ${en==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const yt=ae.state==="RUNNING",Ft=ae.state==="PAUSED"||ae.state==="PAUSE",qt=yt||Ft,gt=ut.isPending||ie.isPending||He.isPending,en=ae.cooling_fan_speed,ye=ae.big_fan1_speed,$e=ae.big_fan2_speed;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Controls"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${en&&en>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:"Part Cooling Fan",children:[s.jsx(oW,{className:`w-3.5 h-3.5 ${en&&en>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${en&&en>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[en??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${ye&&ye>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:"Auxiliary Fan",children:[s.jsx(yW,{className:`w-3.5 h-3.5 ${ye&&ye>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${ye&&ye>0?"text-blue-400":"text-bambu-gray/50"}`,children:[ye??0,"%"]})]}),s.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${$e&&$e>0?"bg-green-500/10":"bg-bambu-dark"}`,title:"Chamber Fan",children:[s.jsx(ole,{className:`w-3.5 h-3.5 ${$e&&$e>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${$e&&$e>0?"text-green-400":"text-bambu-gray/50"}`,children:[$e??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>Y(!0),disabled:!qt||gt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${qt?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:"Stop print",children:[s.jsx(Zc,{className:"w-3 h-3"}),"Stop"]}),s.jsxs("button",{onClick:()=>Ft?ee(!0):G(!0),disabled:!qt||gt,className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${qt?Ft?"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30":"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
- `,title:Ft?"Resume print":"Pause print",children:[Ft?s.jsx(Yc,{className:"w-3 h-3"}):s.jsx(DR,{className:"w-3 h-3"}),Ft?"Resume":"Pause"]})]})]})]})})(),H&&H.length>0&&r==="expanded"&&(()=>{const yt=H.filter(gt=>gt.tray.length>1),Ft=H.filter(gt=>gt.tray.length===1),qt=t.nozzle_count===2||ae?.temperatures?.nozzle_2!==void 0;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:"Filaments"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"space-y-3",children:[yt.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:yt.map(gt=>{const en=Te[String(gt.id)],ye=gt.id>=128?gt.id-128:gt.id,$e=en!==void 0?en:ye,Ye=$e===1,nt=$e===0;return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:Iu(gt.id,gt.tray.length)}),qt&&(Ye||nt)&&s.jsx(M$,{side:Ye?"L":"R"})]}),(gt.humidity!=null||gt.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[gt.humidity!=null&&s.jsx(N$,{humidity:gt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ne({amsId:gt.id,amsLabel:Iu(gt.id,gt.tray.length),mode:"humidity"}),compact:!0}),gt.temp!=null&&s.jsx(A$,{temp:gt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ne({amsId:gt.id,amsLabel:Iu(gt.id,gt.tray.length),mode:"temperature"}),compact:!0})]})]}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(ke=>{const xe=gt.tray[ke]||gt.tray.find(Ct=>Ct.id===ke),le=xe?.tray_type&&xe.remain>=0,Ae=!xe?.tray_type,Oe=gt.id*4+ke,Ie=we===Oe,Re=xe?.tray_info_idx?Le?.[xe.tray_info_idx]:null,Je=V?.[Oe],xt=xe?.tray_type?{vendor:nC(xe)?"Bambu Lab":"Generic",profile:Re?.name||Je?.preset_name||xe.tray_sub_brands||xe.tray_type,colorName:ZT(xe.tray_id_name)||JT(xe.tray_color),colorHex:xe.tray_color||null,kFactor:eC(xe.k),fillLevel:le?xe.remain:null,trayUuid:xe.tray_uuid||null}:null,Nt=mt?.amsId===gt.id&&mt?.slotId===ke,Et=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ae?"opacity-50":""} ${Ie?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:xe?.tray_color?`#${xe.tray_color}`:xe?.tray_type?"#333":"transparent",borderColor:Ae?"#666":"rgba(255,255,255,0.1)",borderStyle:Ae?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:xe?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:le&&xe?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${xe.remain}%`,backgroundColor:T$(xe.remain)}}):xe?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"relative group",children:[Nt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Rr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ae?.state!=="RUNNING"&&s.jsx("button",{onClick:Ct=>{Ct.stopPropagation(),nr(Cn?.amsId===gt.id&&Cn?.slotId===ke?null:{amsId:gt.id,slotId:ke})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:s.jsx(vd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ae?.state!=="RUNNING"&&Cn?.amsId===gt.id&&Cn?.slotId===ke&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:Ct=>{Ct.stopPropagation(),Sn.mutate({amsId:gt.id,slotId:ke}),nr(null)},disabled:Nt,children:[s.jsx(Rr,{className:`w-3 h-3 ${Nt?"animate-spin":""}`}),"Re-read RFID"]})}),xt?s.jsx(YT,{data:xt,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&xt.trayUuid?Ct=>{se({trayUuid:Ct,trayInfo:{type:xt.profile,color:xt.colorHex||"",location:`${Iu(gt.id,gt.tray.length)} Slot ${ke+1}`}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>pe({amsId:gt.id,trayId:ke,trayCount:gt.tray.length,trayType:xe?.tray_type||void 0,trayColor:xe?.tray_color||void 0,traySubBrands:xe?.tray_sub_brands||void 0,trayInfoIdx:xe?.tray_info_idx||void 0})},children:Et}):s.jsx(y$,{configureSlot:{enabled:!0,onConfigure:()=>pe({amsId:gt.id,trayId:ke,trayCount:gt.tray.length})},children:Et})]},ke)})})]},gt.id)})}),(Ft.length>0||ae.vt_tray&&ae.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Ft.map(gt=>{const en=Te[String(gt.id)],ye=gt.id>=128?gt.id-128:gt.id,$e=en!==void 0?en:ye,Ye=$e===1,nt=$e===0,ke=gt.tray[0],xe=ke?.tray_type&&ke.remain>=0,le=!ke?.tray_type,Ae=gt.id*4+(ke?.id??0),Oe=we===Ae,Ie=ke?.tray_info_idx?Le?.[ke.tray_info_idx]:null,Re=V?.[Ae],Je=ke?.tray_type?{vendor:nC(ke)?"Bambu Lab":"Generic",profile:Ie?.name||Re?.preset_name||ke.tray_sub_brands||ke.tray_type,colorName:ZT(ke.tray_id_name)||JT(ke.tray_color),colorHex:ke.tray_color||null,kFactor:eC(ke.k),fillLevel:xe?ke.remain:null,trayUuid:ke.tray_uuid||null}:null,xt=ke?.id??0,Nt=mt?.amsId===gt.id&&mt?.slotId===xt,Et=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${le?"opacity-50":""} ${Oe?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:ke?.tray_color?`#${ke.tray_color}`:ke?.tray_type?"#333":"transparent",borderColor:le?"#666":"rgba(255,255,255,0.1)",borderStyle:le?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ke?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:xe?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ke.remain}%`,backgroundColor:T$(ke.remain)}}):ke?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:Iu(gt.id,gt.tray.length)}),qt&&(Ye||nt)&&s.jsx(M$,{side:Ye?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[Nt&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Rr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ae?.state!=="RUNNING"&&s.jsx("button",{onClick:Ct=>{Ct.stopPropagation(),nr(Cn?.amsId===gt.id&&Cn?.slotId===xt?null:{amsId:gt.id,slotId:xt})},className:"absolute -top-1 -right-1 w-4 h-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:bg-bambu-dark-tertiary",title:"Slot options",children:s.jsx(vd,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ae?.state!=="RUNNING"&&Cn?.amsId===gt.id&&Cn?.slotId===xt&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-xs text-white hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:Ct=>{Ct.stopPropagation(),Sn.mutate({amsId:gt.id,slotId:xt}),nr(null)},disabled:Nt,children:[s.jsx(Rr,{className:`w-3 h-3 ${Nt?"animate-spin":""}`}),"Re-read RFID"]})}),Je?s.jsx(YT,{data:Je,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Je.trayUuid?Ct=>{se({trayUuid:Ct,trayInfo:{type:Je.profile,color:Je.colorHex||"",location:Iu(gt.id,gt.tray.length)}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>pe({amsId:gt.id,trayId:xt,trayCount:gt.tray.length,trayType:ke?.tray_type||void 0,trayColor:ke?.tray_color||void 0,traySubBrands:ke?.tray_sub_brands||void 0,trayInfoIdx:ke?.tray_info_idx||void 0})},children:Et}):s.jsx(y$,{configureSlot:{enabled:!0,onConfigure:()=>pe({amsId:gt.id,trayId:xt,trayCount:gt.tray.length})},children:Et})]}),(gt.humidity!=null||gt.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[gt.temp!=null&&s.jsx(A$,{temp:gt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ne({amsId:gt.id,amsLabel:Iu(gt.id,gt.tray.length),mode:"temperature"}),compact:!0}),gt.humidity!=null&&s.jsx(N$,{humidity:gt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ne({amsId:gt.id,amsLabel:Iu(gt.id,gt.tray.length),mode:"humidity"}),compact:!0})]})]})]},gt.id)}),ae.vt_tray&&ae.vt_tray.tray_type&&(()=>{const gt=ae.vt_tray,en=we===254,ye=gt.tray_info_idx?Le?.[gt.tray_info_idx]:null,$e=V?.[1020],Ye={vendor:nC(gt)?"Bambu Lab":"Generic",profile:ye?.name||$e?.preset_name||gt.tray_sub_brands||gt.tray_type||"Unknown",colorName:ZT(gt.tray_id_name)||JT(gt.tray_color),colorHex:gt.tray_color||null,kFactor:eC(gt.k),fillLevel:null,trayUuid:gt.tray_uuid||null},nt=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${en?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2",style:{backgroundColor:gt.tray_color?`#${gt.tray_color}`:"#333",borderColor:en?"var(--accent)":"rgba(255,255,255,0.1)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:gt.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:"External"})}),s.jsx(YT,{data:Ye,spoolman:{enabled:o,hasUnlinkedSpools:l,onLinkSpool:o&&Ye.trayUuid?ke=>{se({trayUuid:ke,trayInfo:{type:Ye.profile,color:Ye.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:!0,onConfigure:()=>pe({amsId:255,trayId:0,trayCount:1,trayType:gt.tray_type||void 0,trayColor:gt.tray_color||void 0,traySubBrands:gt.tray_sub_brands||void 0,trayInfoIdx:gt.tray_info_idx||void 0})},children:nt})]})})()]})]})]})})()]}),Se&&r==="expanded"&&s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(bf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:Se.name}),_e&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${_e.state==="ON"?"bg-bambu-green/20 text-bambu-green":_e.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[_e.state||"?",_e.state==="ON"&&_e.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",_e.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>k(!0),disabled:qe.isPending||_e?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${_e?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(zl,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>z(!0),disabled:qe.isPending||_e?.state==="OFF",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${_e?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:[s.jsx(E2,{className:"w-3 h-3"}),"Off"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:`text-xs hidden sm:inline ${Se.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:Se.auto_off_executed?"Auto-off done":"Auto-off"}),s.jsx("button",{onClick:()=>Qe.mutate(!Se.auto_off),disabled:Qe.isPending||Se.auto_off_executed,title:Se.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 ${Se.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":Se.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${Se.auto_off||Se.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]})}),r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"text-xs text-bambu-gray",children:[s.jsx("p",{children:t.ip_address}),s.jsx("p",{className:"truncate",children:t.serial_number})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>ve.mutate(!ae?.chamber_light),disabled:!ae?.connected||ve.isPending,title:ae?.chamber_light?"Turn off chamber light":"Turn on chamber light",className:ae?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:s.jsx(HCe,{on:ae?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>{const yt=localStorage.getItem("cameraWindowState"),Ft=yt?JSON.parse(yt):{width:640,height:400},qt=[`width=${Ft.width}`,`height=${Ft.height}`,Ft.left!==void 0?`left=${Ft.left}`:"",Ft.top!==void 0?`top=${Ft.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,qt)},disabled:!ae?.connected,title:"Open camera in new window",children:s.jsx(bW,{className:"w-4 h-4"})}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>N(!0),title:"Browse printer files",children:[s.jsx(_2,{className:"w-4 h-4"}),"Files"]})]})]})]}),A&&s.jsx(Ohe,{printerId:t.id,printerName:t.name,onClose:()=>N(!1)}),C&&s.jsx(Lhe,{printerId:t.id,printerName:t.name,onClose:()=>T(!1)}),D&&Se&&s.jsx(Un,{title:"Power On Printer",message:`Are you sure you want to turn ON the power for "${t.name}"?`,confirmText:"Power On",variant:"default",onConfirm:()=>{qe.mutate("on"),k(!1)},onCancel:()=>k(!1)}),P&&Se&&s.jsx(Un,{title:"Power Off Printer",message:ae?.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:()=>{qe.mutate("off"),z(!1)},onCancel:()=>z(!1)}),R&&s.jsx(Un,{title:"Stop Print",message:`Are you sure you want to stop the current print on "${t.name}"? This will cancel the print job.`,confirmText:"Stop Print",variant:"danger",onConfirm:()=>{ut.mutate(),Y(!1)},onCancel:()=>Y(!1)}),J&&s.jsx(Un,{title:"Pause Print",message:`Are you sure you want to pause the current print on "${t.name}"?`,confirmText:"Pause Print",variant:"default",onConfirm:()=>{ie.mutate(),G(!1)},onCancel:()=>G(!1)}),W&&s.jsx(Un,{title:"Resume Print",message:`Are you sure you want to resume the print on "${t.name}"?`,confirmText:"Resume Print",variant:"default",onConfirm:()=>{He.mutate(),ee(!1)},onCancel:()=>ee(!1)}),K&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>F(!1),onKeyDown:yt=>yt.key==="Escape"&&F(!1),tabIndex:-1,ref:yt=>yt?.focus(),children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),s.jsxs("div",{className:"relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] overflow-hidden",onClick:yt=>yt.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(w$,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Skip Objects"})]}),s.jsx("button",{onClick:()=>F(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(zt,{className:"w-4 h-4"})})]}),je?je.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:"No objects found"}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:"Objects are loaded when a print starts"})]}):s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:s.jsx(Hue,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:"Match IDs with your printer display"}),s.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:"The printer screen shows object IDs on the build plate"})]}),s.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[je.skipped_count,"/",je.total," skipped"]})]}),(ae?.layer_num??0)<=1&&s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary",children:[s.jsx(pa,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsxs("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:["Wait for layer 2+ to skip objects (currently layer ",ae?.layer_num??0,")"]})]}),s.jsxs("div",{className:"flex",children:[s.jsx("div",{className:"w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary",children:s.jsxs("div",{className:"relative",children:[ae?.cover_url?s.jsx("img",{src:`${ae.cover_url}?view=top`,alt:"Print preview",className:"w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600"}):s.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:s.jsx(ks,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),je.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:je.objects.map((yt,Ft)=>{let qt,gt;if(yt.x!=null&&yt.y!=null&&je.bbox_all){const[en,ye,$e,Ye]=je.bbox_all,nt=$e-en,ke=Ye-ye,xe=8,le=100-xe*2;qt=xe+(yt.x-en)/nt*le,gt=xe+(Ye-yt.y)/ke*le,qt=Math.max(5,Math.min(95,qt)),gt=Math.max(5,Math.min(95,gt))}else if(yt.x!=null&&yt.y!=null)qt=yt.x/256*100,gt=100-yt.y/256*100,qt=Math.max(5,Math.min(95,qt)),gt=Math.max(5,Math.min(95,gt));else{const en=Math.ceil(Math.sqrt(je.objects.length)),ye=Math.floor(Ft/en),$e=Ft%en,Ye=Math.ceil(je.objects.length/en);qt=15+$e*(70/en)+35/en,gt=15+ye*(70/Ye)+35/Ye}return s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${yt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${qt}%`,top:`${gt}%`,transform:"translate(-50%, -50%)"},title:yt.name,children:yt.id},yt.id)})}),s.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm",children:[je.objects.filter(yt=>!yt.skipped).length," active"]})]})}),s.jsx("div",{className:"flex-1 min-w-0",children:je.objects.map(yt=>s.jsxs("div",{className:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${yt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[s.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${yt.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
- `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${yt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:yt.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${yt.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:`block text-sm truncate ${yt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:yt.name}),yt.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:"Will be skipped"})]}),yt.skipped?s.jsx("span",{className:"px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg",children:"Skipped"}):s.jsx("button",{onClick:()=>Xe.mutate([yt.id]),disabled:Xe.isPending||(ae?.layer_num??0)<=1,className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(ae?.layer_num??0)<=1?"bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed":"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30"}`,title:(ae?.layer_num??0)<=1?"Wait for layer 2+":"Skip this object",children:"Skip"})]},yt.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ft,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),L&&s.jsx(zhe,{printerName:t.name,errors:ae?.hms_errors||[],onClose:()=>X(!1)}),q&&s.jsx(DCe,{isOpen:!!q,onClose:()=>ne(null),printerId:t.id,printerName:t.name,amsId:q.amsId,amsLabel:q.amsLabel,initialMode:q.mode,thresholds:a}),re&&s.jsx(OCe,{isOpen:!!re,onClose:()=>se(null),trayUuid:re.trayUuid,trayInfo:re.trayInfo}),de&&s.jsx($Ce,{isOpen:!!de,onClose:()=>pe(null),printerId:t.id,slotInfo:de,onSuccess:()=>{u.invalidateQueries({queryKey:["slotPresets",t.id]}),u.invalidateQueries({queryKey:["printerStatus",t.id]})}}),E&&s.jsx(ike,{printer:t,onClose:()=>w(!1)}),Ce&&ge&&s.jsx(rke,{printer:t,firmwareInfo:ge,onClose:()=>oe(!1)}),Cn&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>nr(null)})]})}function nke({onClose:t,onAdd:e,existingSerials:n}){const[r,i]=S.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",auto_archive:!0}),[a,o]=S.useState(!1),[l,c]=S.useState([]),[u,d]=S.useState(""),[f,p]=S.useState(!1),[g,b]=S.useState(!1),[v,x]=S.useState("192.168.1.0/24"),[y,E]=S.useState({scanned:0,total:0});S.useEffect(()=>{ul.getInfo().then(T=>{b(T.is_docker)}).catch(()=>{})},[]);const w=l.filter(T=>!n.includes(T.serial)),A=async()=>{d(""),c([]),o(!0),p(!1),E({scanned:0,total:0});try{if(g){await ul.startSubnetScan(v);const T=setInterval(async()=>{try{const D=await ul.getScanStatus();E({scanned:D.scanned,total:D.total});const k=await ul.getDiscoveredPrinters();c(k),D.running||(clearInterval(T),o(!1),p(!0))}catch(D){console.error("Failed to get scan status:",D)}},500)}else{await ul.startDiscovery(10);const T=setInterval(async()=>{try{const D=await ul.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get discovered printers:",D)}},1e3);setTimeout(async()=>{clearInterval(T);try{await ul.stopDiscovery()}catch{}o(!1),p(!0);try{const D=await ul.getDiscoveredPrinters();c(D)}catch(D){console.error("Failed to get final discovered printers:",D)}},1e4)}}catch(T){console.error("Failed to start discovery:",T),d(T instanceof Error?T.message:"Failed to start discovery"),o(!1),p(!0)}},N=T=>T?{O1D:"H2D",O1C:"H2C",O1S:"H2S","BL-P001":"X1C","BL-P002":"X1","BL-P003":"X1E",C11:"P1S",C12:"P1P",C13:"P2S",N2S:"A1",N1:"A1 Mini",X1C:"X1C",X1:"X1",X1E:"X1E",P1S:"P1S",P1P:"P1P",P2S:"P2S",A1:"A1","A1 Mini":"A1 Mini",H2D:"H2D",H2C:"H2C",H2S:"H2S"}[T]||T:"",C=T=>{i({...r,name:T.name||"",serial_number:T.serial,ip_address:T.ip_address,model:N(T.model)}),c([])};return S.useEffect(()=>()=>{ul.stopDiscovery().catch(()=>{}),ul.stopSubnetScan().catch(()=>{})},[]),S.useEffect(()=>{const T=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(_t,{className:"w-full max-w-md",onClick:T=>T.stopPropagation(),children:s.jsxs(Mt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Add Printer"}),s.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[g&&s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Subnet to scan"}),s.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 text-sm",value:v,onChange:T=>x(T.target.value),placeholder:"192.168.1.0/24",disabled:a}),s.jsxs("p",{className:"mt-1 text-xs text-bambu-gray",children:["Docker detected. Enter your printer's subnet in CIDR notation. Requires ",s.jsx("code",{className:"text-bambu-green",children:"network_mode: host"})," in docker-compose.yml."]})]}),s.jsx(Ee,{type:"button",variant:"secondary",onClick:A,disabled:a,className:"w-full",children:a?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),g&&y.total>0?`Scanning... ${y.scanned}/${y.total}`:"Scanning..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Eo,{className:"w-4 h-4"}),g?"Scan Subnet for Printers":"Discover Printers on Network"]})}),u&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:u}),w.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:w.map(T=>s.jsxs("div",{className:"flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors",onClick:()=>C(T),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:T.name||T.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[N(T.model)||"Unknown"," • ",T.ip_address]})]}),s.jsx(Qi,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},T.serial))}),a&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:g?"Scanning subnet for Bambu printers...":"Scanning network..."}),f&&!a&&l.length===0&&s.jsxs("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:["No printers found",g?" in the specified subnet":" on the network","."]}),f&&!a&&l.length>0&&w.length===0&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:"All discovered printers are already configured."})]}),s.jsxs("form",{onSubmit:T=>{T.preventDefault(),e(r)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.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:r.name,onChange:T=>i({...r,name:T.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.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:r.ip_address,onChange:T=>i({...r,ip_address:T.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.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:r.serial_number,onChange:T=>i({...r,serial_number:T.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.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:r.access_code,onChange:T=>i({...r,access_code:T.target.value}),placeholder:"From printer settings"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model (optional)"}),s.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:r.model||"",onChange:T=>i({...r,model:T.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:r.auto_archive,onChange:T=>i({...r,auto_archive:T.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsx(Ee,{type:"submit",className:"flex-1",children:"Add Printer"})]})]})]})})})}function rke({printer:t,firmwareInfo:e,onClose:n}){const r=an(),{showToast:i}=Wn(),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),{data:f,isLoading:p}=lt({queryKey:["firmwarePrepare",t.id],queryFn:()=>N1.prepareUpload(t.id),staleTime:3e4}),g=ht({mutationFn:()=>N1.startUpload(t.id),onSuccess:()=>{c(!0);const v=setInterval(async()=>{try{const x=await N1.getUploadStatus(t.id);o(x),(x.status==="complete"||x.status==="error")&&(clearInterval(v),d(null),c(!1),x.status==="complete"&&(i("Firmware uploaded! Trigger update from printer screen.","success"),r.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);d(v)},onError:v=>{i(`Failed to start upload: ${v.message}`,"error"),c(!1)}});S.useEffect(()=>()=>{u&&clearInterval(u)},[u]);const b=()=>{o(null),g.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(_t,{className:"w-full max-w-md mx-4",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:s.jsx(Yr,{className:"w-5 h-5 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Firmware Update"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[s.jsxs("div",{className:"flex justify-between items-center text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Current:"}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||"Unknown"})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Latest:"}),s.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&s.jsxs("details",{className:"mt-3 text-sm",children:[s.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:"Release Notes"}),s.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),p?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Checking prerequisites..."]}):f&&!l&&!a?s.jsx("div",{className:"mb-4",children:f.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(ks,{className:"w-4 h-4"}),"SD card ready. Click below to upload firmware."]}):s.jsx("div",{className:"space-y-1",children:f.errors.map((v,x)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(pa,{className:"w-4 h-4 flex-shrink-0"}),v]},x))})}):null,(l||a)&&a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:a.status}),s.jsxs("span",{className:"text-white",children:[a.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:`h-2 rounded-full transition-all ${a.status==="error"?"bg-red-500":a.status==="complete"?"bg-bambu-green":"bg-orange-500"} ${a.status==="uploading"?"animate-pulse":""}`,style:{width:`${a.progress}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a.message}),a.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:a.error})]}),a?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:"Firmware uploaded to SD card!"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"To apply the update on your printer:"}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["On the printer's touchscreen, go to ",s.jsx("strong",{className:"text-white",children:"Settings"})]}),s.jsxs("li",{children:["Navigate to ",s.jsx("strong",{className:"text-white",children:"Firmware"})]}),s.jsxs("li",{children:["Select ",s.jsx("strong",{className:"text-white",children:"Update from SD card"})]}),s.jsx("li",{children:"The update will take 10-20 minutes"})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Ee,{variant:"secondary",onClick:n,children:a?.status==="complete"?"Done":"Cancel"}),f?.can_proceed&&!l&&a?.status!=="complete"&&s.jsx(Ee,{onClick:b,disabled:g.isPending,children:g.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}),"Starting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Yr,{className:"w-4 h-4 mr-2"}),"Upload Firmware"]})})]})]})})})}function ike({printer:t,onClose:e}){const n=an(),[r,i]=S.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),a=ht({mutationFn:l=>be.updatePrinter(t.id,l),onSuccess:()=>{n.invalidateQueries({queryKey:["printers"]}),n.invalidateQueries({queryKey:["printerStatus",t.id]}),e()}});S.useEffect(()=>{const l=c=>{c.key==="Escape"&&e()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e]);const o=l=>{l.preventDefault();const c={name:r.name,ip_address:r.ip_address,model:r.model||void 0,location:r.location||void 0,auto_archive:r.auto_archive};r.access_code&&(c.access_code=r.access_code),a.mutate(c)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(_t,{className:"w-full max-w-md",onClick:l=>l.stopPropagation(),children:s.jsxs(Mt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Edit Printer"}),s.jsxs("form",{onSubmit:o,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.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:r.name,onChange:l=>i({...r,name:l.target.value}),placeholder:"My Printer"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address"}),s.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:r.ip_address,onChange:l=>i({...r,ip_address:l.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Serial Number"}),s.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}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Serial number cannot be changed"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Code"}),s.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:r.access_code,onChange:l=>i({...r,access_code:l.target.value}),placeholder:"Leave empty to keep current"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Model"}),s.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:r.model,onChange:l=>i({...r,model:l.target.value}),children:[s.jsx("option",{value:"",children:"Select model..."}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),s.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:r.location,onChange:l=>i({...r,location:l.target.value}),placeholder:"e.g., Workshop, Office, Basement"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Used to group printers on the dashboard"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:r.auto_archive,onChange:l=>i({...r,auto_archive:l.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:"Auto-archive completed prints"})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Ee,{type:"submit",className:"flex-1",disabled:a.isPending,children:a.isPending?"Saving...":"Save Changes"})]})]})]})})})}function ake(t){const{data:e}=lt({queryKey:["printerStatus",t],queryFn:()=>be.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function ske({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=ake(t.id),{data:a}=lt({queryKey:["smartPlugStatus",e.id],queryFn:()=>be.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.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||"?"})]}),s.jsxs("button",{onClick:()=>n(e.id),disabled:r||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:[s.jsx(zl,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function oke(){const[t,e]=S.useState(!1),[n,r]=S.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[i,a]=S.useState(!1),[o,l]=S.useState(null),[c,u]=S.useState(()=>localStorage.getItem("printerSortBy")||"name"),[d,f]=S.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[p,g]=S.useState(()=>{const K=localStorage.getItem("printerCardSize");return K?parseInt(K,10):2}),b=p===1?"compact":"expanded",v=an(),{data:x,isLoading:y}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:E}=lt({queryKey:["settings"],queryFn:be.getSettings}),{data:w}=lt({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs}),{data:A}=lt({queryKey:["maintenanceOverview"],queryFn:be.getMaintenanceOverview,staleTime:60*1e3}),{data:N}=lt({queryKey:["spoolman-status"],queryFn:be.getSpoolmanStatus,staleTime:60*1e3}),C=N?.enabled&&N?.connected,{data:T}=lt({queryKey:["unlinked-spools"],queryFn:be.getUnlinkedSpools,enabled:!!C,staleTime:30*1e3}),D=T&&T.length>0,k=A?.reduce((K,F)=>(K[F.printer_id]={due_count:F.due_count,warning_count:F.warning_count,total_print_hours:F.total_print_hours},K),{})||{},P=w?.reduce((K,F)=>(F.printer_id&&(K[F.printer_id]=F),K),{})||{},z=ht({mutationFn:be.createPrinter,onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),v.invalidateQueries({queryKey:["maintenanceOverview"]}),e(!1)}}),L=ht({mutationFn:K=>be.controlSmartPlug(K,"on"),onSuccess:()=>{v.invalidateQueries({queryKey:["smart-plugs"]}),l(null)},onError:()=>{l(null)}}),X=()=>{const K=!n;r(K),localStorage.setItem("hideDisconnectedPrinters",String(K))},R=K=>{u(K),localStorage.setItem("printerSortBy",K)},Y=()=>{const K=!d;f(K),localStorage.setItem("printerSortAsc",String(K))},J=()=>{switch(p){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},G=["S","M","L","XL"],W=S.useMemo(()=>{if(!x)return[];const K=[...x];switch(c){case"name":K.sort((F,q)=>F.name.localeCompare(q.name));break;case"model":K.sort((F,q)=>(F.model||"").localeCompare(q.model||""));break;case"location":K.sort((F,q)=>{const ne=F.location||"",re=q.location||"";return!ne&&re?1:ne&&!re?-1:ne.localeCompare(re)||F.name.localeCompare(q.name)});break;case"status":K.sort((F,q)=>{const ne=v.getQueryData(["printerStatus",F.id]),re=v.getQueryData(["printerStatus",q.id]),se=de=>de?.connected?de.state==="RUNNING"?0:1:2;return se(ne)-se(re)});break}return d||K.reverse(),K},[x,c,d,v]),ee=S.useMemo(()=>{if(c!=="location")return null;const K={};return W.forEach(F=>{const q=F.location||"Ungrouped";K[q]||(K[q]=[]),K[q].push(F)}),K},[c,W]);return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Printers"}),s.jsx(tke,{printers:x})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:c,onChange:K=>R(K.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:[s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"status",children:"Status"}),s.jsx("option",{value:"model",children:"Model"}),s.jsx("option",{value:"location",children:"Location"})]}),s.jsx("button",{onClick:Y,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:d?"Sort descending":"Sort ascending",children:d?s.jsx(Up,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Wb,{className:"w-4 h-4 text-bambu-gray"})})]}),s.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:G.map((K,F)=>{const q=F+1,ne=p===q;return s.jsx("button",{onClick:()=>{g(q),localStorage.setItem("printerCardSize",String(q))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${F===0?"rounded-l-lg":""} ${F===G.length-1?"rounded-r-lg":""} ${ne?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:`${K==="S"?"Small":K==="M"?"Medium":K==="L"?"Large":"Extra large"} cards`,children:K},K)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:n,onChange:X,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Hide offline"]}),n&&Object.keys(P).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),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:[s.jsx(zl,{className:"w-4 h-4"}),"Power On",s.jsx(Qi,{className:`w-3 h-3 transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.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:[s.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"}),x?.filter(K=>P[K.id]).map(K=>s.jsx(ske,{printer:K,plug:P[K.id],onPowerOn:F=>{l(F),L.mutate(F)},isPowering:o===P[K.id]?.id},K.id)),x?.filter(K=>P[K.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Ee,{onClick:()=>e(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Printer"]})]})]}),y?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading printers..."}):x?.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"No printers configured yet"}),s.jsxs(Ee,{onClick:()=>e(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Your First Printer"]})]})}):ee?s.jsx("div",{className:"space-y-6",children:Object.entries(ee).map(([K,F])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),K,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",F.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${p>=3?"gap-6":""} ${J()}`,children:F.map(q=>s.jsx(k$,{printer:q,hideIfDisconnected:n,maintenanceInfo:k[q.id],viewMode:b,cardSize:p,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,spoolmanEnabled:C,hasUnlinkedSpools:D,timeFormat:E?.time_format||"system"},q.id))})]},K))}):s.jsx("div",{className:`grid gap-4 ${p>=3?"gap-6":""} ${J()}`,children:W.map(K=>s.jsx(k$,{printer:K,hideIfDisconnected:n,maintenanceInfo:k[K.id],viewMode:b,cardSize:p,spoolmanEnabled:C,hasUnlinkedSpools:D,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,timeFormat:E?.time_format||"system"},K.id))}),t&&s.jsx(nke,{onClose:()=>e(!1),onAdd:K=>z.mutate(K),existingSerials:x?.map(K=>K.serial_number)||[]})]})}function lke(){const t=navigator.userAgent.toLowerCase(),e=navigator.platform?.toLowerCase()||"";return t.includes("win")||e.includes("win")?"windows":t.includes("mac")||e.includes("mac")?"macos":t.includes("linux")||e.includes("linux")?"linux":"unknown"}function cke(){switch(lke()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function kc(t){const e=cke();window.location.href=`${e}${encodeURIComponent(t)}`}const z4="181",kp={ROTATE:0,DOLLY:1,PAN:2},wp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},uke=0,j$=1,dke=2,FQ=1,hke=2,Sc=3,Ud=0,ls=1,yl=2,$c=0,jp=1,P$=2,R$=3,D$=4,fke=5,jh=100,mke=101,pke=102,gke=103,xke=104,bke=200,yke=201,vke=202,_ke=203,k3=204,j3=205,wke=206,Ske=207,Mke=208,Eke=209,Nke=210,Ake=211,Tke=212,Cke=213,kke=214,P3=0,R3=1,D3=2,Jp=3,O3=4,L3=5,I3=6,F3=7,B4=0,jke=1,Pke=2,Sd=0,Rke=1,Dke=2,Oke=3,Lke=4,Ike=5,Fke=6,Uke=7,UQ=300,eg=301,tg=302,U3=303,z3=304,_M=306,B3=1e3,Oc=1001,$3=1002,Fs=1003,zke=1004,o_=1005,yo=1006,rC=1007,Hh=1008,Dl=1009,zQ=1010,BQ=1011,f0=1012,$4=1013,Nf=1014,Lc=1015,Dg=1016,H4=1017,V4=1018,m0=1020,$Q=35902,HQ=35899,VQ=1021,GQ=1022,qo=1023,p0=1026,g0=1027,WQ=1028,G4=1029,W4=1030,q4=1031,K4=1033,O1=33776,L1=33777,I1=33778,F1=33779,H3=35840,V3=35841,G3=35842,W3=35843,q3=36196,K3=37492,X3=37496,Y3=37808,Q3=37809,Z3=37810,J3=37811,eP=37812,tP=37813,nP=37814,rP=37815,iP=37816,aP=37817,sP=37818,oP=37819,lP=37820,cP=37821,uP=36492,dP=36494,hP=36495,fP=36283,mP=36284,pP=36285,gP=36286,Bke=3200,$ke=3201,qQ=0,Hke=1,cd="",co="srgb",ng="srgb-linear",aS="linear",or="srgb",Am=7680,O$=519,Vke=512,Gke=513,Wke=514,KQ=515,qke=516,Kke=517,Xke=518,Yke=519,L$=35044,I$="300 es",Sl=2e3,sS=2001;function XQ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function oS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Qke(){const t=oS("canvas");return t.style.display="block",t}const F$={};function U$(...t){const e="THREE."+t.shift();console.log(e,...t)}function nn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function ii(...t){const e="THREE."+t.shift();console.error(e,...t)}function x0(...t){const e=t.join(" ");e in F$||(F$[e]=!0,nn(...t))}function Zke(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let Bf=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}};const ba=["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"],U1=Math.PI/180,xP=180/Math.PI;function by(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(ba[t&255]+ba[t>>8&255]+ba[t>>16&255]+ba[t>>24&255]+"-"+ba[e&255]+ba[e>>8&255]+"-"+ba[e>>16&15|64]+ba[e>>24&255]+"-"+ba[n&63|128]+ba[n>>8&255]+"-"+ba[n>>16&255]+ba[n>>24&255]+ba[r&255]+ba[r>>8&255]+ba[r>>16&255]+ba[r>>24&255]).toLowerCase()}function Nn(t,e,n){return Math.max(e,Math.min(n,t))}function Jke(t,e){return(t%e+e)%e}function iC(t,e,n){return(1-n)*t+n*e}function $x(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 ts(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 eje={DEG2RAD:U1};let xn=class YQ{constructor(e=0,n=0){YQ.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,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[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=Nn(this.x,e.x,n.x),this.y=Nn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Nn(this.x,e,n),this.y=Nn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Nn(r,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 r=this.dot(e)/n;return Math.acos(Nn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,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 r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Af=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],p=a[o+0],g=a[o+1],b=a[o+2],v=a[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=p,e[n+1]=g,e[n+2]=b,e[n+3]=v;return}if(f!==v||c!==p||u!==g||d!==b){let x=c*p+u*g+d*b+f*v;x<0&&(p=-p,g=-g,b=-b,v=-v,x=-x);let y=1-l;if(x<.9995){const E=Math.acos(x),w=Math.sin(E);y=Math.sin(y*E)/w,l=Math.sin(l*E)/w,c=c*y+p*l,u=u*y+g*l,d=d*y+b*l,f=f*y+v*l}else{c=c*y+p*l,u=u*y+g*l,d=d*y+b*l,f=f*y+v*l;const E=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=E,u*=E,d*=E,f*=E}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],g=a[o+2],b=a[o+3];return e[n]=l*b+d*f+c*g-u*p,e[n+1]=c*b+d*p+u*f-l*g,e[n+2]=u*b+d*g+l*p-c*f,e[n+3]=d*b-l*f-c*p-u*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,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,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 r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),g=c(i/2),b=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*g*b,this._y=u*g*f-p*d*b,this._z=u*d*b+p*g*f,this._w=u*d*f-p*g*b;break;case"YXZ":this._x=p*d*f+u*g*b,this._y=u*g*f-p*d*b,this._z=u*d*b-p*g*f,this._w=u*d*f+p*g*b;break;case"ZXY":this._x=p*d*f-u*g*b,this._y=u*g*f+p*d*b,this._z=u*d*b+p*g*f,this._w=u*d*f-p*g*b;break;case"ZYX":this._x=p*d*f-u*g*b,this._y=u*g*f+p*d*b,this._z=u*d*b-p*g*f,this._w=u*d*f+p*g*b;break;case"YZX":this._x=p*d*f+u*g*b,this._y=u*g*f+p*d*b,this._z=u*d*b-p*g*f,this._w=u*d*f-p*g*b;break;case"XZY":this._x=p*d*f-u*g*b,this._y=u*g*f-p*d*b,this._z=u*d*b+p*g*f,this._w=u*d*f+p*g*b;break;default:nn("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const g=.5/Math.sqrt(p+1);this._w=.25/g,this._x=(d-c)*g,this._y=(a-u)*g,this._z=(o-i)*g}else if(r>l&&r>f){const g=2*Math.sqrt(1+r-l-f);this._w=(d-c)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(a+u)/g}else if(l>f){const g=2*Math.sqrt(1+l-r-f);this._w=(a-u)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(c+d)/g}else{const g=2*Math.sqrt(1+f-r-l);this._w=(o-i)/g,this._x=(a+u)/g,this._y=(c+d)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Nn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),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 r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,o=-o,l=-l);let c=1-n;if(l<.9995){const u=Math.acos(l),d=Math.sin(u);c=Math.sin(c*u)/d,n=Math.sin(n*u)/d,this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this._onChangeCallback()}else this._x=this._x*c+r*n,this._y=this._y*c+i*n,this._z=this._z*c+a*n,this._w=this._w*c+o*n,this.normalize();return this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*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}},at=class QQ{constructor(e=0,n=0,r=0){QQ.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,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(z$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(z$.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,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,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,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=Nn(this.x,e.x,n.x),this.y=Nn(this.y,e.y,n.y),this.z=Nn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Nn(this.x,e,n),this.y=Nn(this.y,e,n),this.z=Nn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Nn(r,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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return aC.copy(this).projectOnVector(e),this.sub(aC)}reflect(e){return this.sub(aC.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 r=this.dot(e)/n;return Math.acos(Nn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}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,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,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,r=Math.sqrt(1-n*n);return this.x=r*Math.cos(e),this.y=n,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const aC=new at,z$=new Af;let vn=class ZQ{constructor(e,n,r,i,a,o,l,c,u){ZQ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.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 r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],g=r[5],b=r[8],v=i[0],x=i[3],y=i[6],E=i[1],w=i[4],A=i[7],N=i[2],C=i[5],T=i[8];return a[0]=o*v+l*E+c*N,a[3]=o*x+l*w+c*C,a[6]=o*y+l*A+c*T,a[1]=u*v+d*E+f*N,a[4]=u*x+d*w+f*C,a[7]=u*y+d*A+f*T,a[2]=p*v+g*E+b*N,a[5]=p*x+g*w+b*C,a[8]=p*y+g*A+b*T,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],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,g=u*a-o*c,b=n*f+r*p+i*g;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/b;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=p*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=g*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*a)*v,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,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply(sC.makeScale(e,n)),this}rotate(e){return this.premultiply(sC.makeRotation(-e)),this}translate(e,n){return this.premultiply(sC.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),r=Math.sin(e);return this.set(n,-r,0,r,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,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const sC=new vn,B$=new vn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),$$=new vn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function tje(){const t={enabled:!0,workingColorSpace:ng,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===or&&(i.r=Hc(i.r),i.g=Hc(i.g),i.b=Hc(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===or&&(i.r=Pp(i.r),i.g=Pp(i.g),i.b=Pp(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===cd?aS:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,o){return i.copy(this.spaces[a].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,a){return x0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return x0("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[ng]:{primaries:e,whitePoint:r,transfer:aS,toXYZ:B$,fromXYZ:$$,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:co},outputColorSpaceConfig:{drawingBufferColorSpace:co}},[co]:{primaries:e,whitePoint:r,transfer:or,toXYZ:B$,fromXYZ:$$,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:co}}}),t}const Fn=tje();function Hc(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Pp(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Tm,nje=class{static getDataURL(e,n="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{Tm===void 0&&(Tm=oS("canvas")),Tm.width=e.width,Tm.height=e.height;const i=Tm.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Tm}return r.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=oS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Hc(a[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Hc(n[r]/255)*255):n[r]=Hc(n[r]);return{data:n,width:e.width,height:e.height}}else return nn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},rje=0,X4=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:rje++}),this.uuid=by(),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 r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(oC(i[o].image)):a.push(oC(i[o]))}else a=oC(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function oC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?nje.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(nn("Texture: Unable to serialize Texture."),{})}let ije=0;const lC=new at;let il=class z1 extends Bf{constructor(e=z1.DEFAULT_IMAGE,n=z1.DEFAULT_MAPPING,r=Oc,i=Oc,a=yo,o=Hh,l=qo,c=Dl,u=z1.DEFAULT_ANISOTROPY,d=cd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ije++}),this.uuid=by(),this.name="",this.source=new X4(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new xn(0,0),this.repeat=new xn(1,1),this.center=new xn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(lC).x}get height(){return this.source.getSize(lC).y}get depth(){return this.source.getSize(lC).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 r=e[n];if(r===void 0){nn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){nn(`Texture.setValues(): property '${n}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={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&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==UQ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case B3:e.x=e.x-Math.floor(e.x);break;case Oc:e.x=e.x<0?0:1;break;case $3: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 B3:e.y=e.y-Math.floor(e.y);break;case Oc:e.y=e.y<0?0:1;break;case $3: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++}};il.DEFAULT_IMAGE=null;il.DEFAULT_MAPPING=UQ;il.DEFAULT_ANISOTROPY=1;let mi=class JQ{constructor(e=0,n=0,r=0,i=1){JQ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,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,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[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,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],g=c[5],b=c[9],v=c[2],x=c[6],y=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-v)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+v)<.1&&Math.abs(b+x)<.1&&Math.abs(u+g+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(g+1)/2,N=(y+1)/2,C=(d+p)/4,T=(f+v)/4,D=(b+x)/4;return w>A&&w>N?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=T/r):A>N?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=D/i):N<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(N),r=T/a,i=D/a),this.set(r,i,a,n),this}let E=Math.sqrt((x-b)*(x-b)+(f-v)*(f-v)+(p-d)*(p-d));return Math.abs(E)<.001&&(E=1),this.x=(x-b)/E,this.y=(f-v)/E,this.z=(p-d)/E,this.w=Math.acos((u+g+y-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=Nn(this.x,e.x,n.x),this.y=Nn(this.y,e.y,n.y),this.z=Nn(this.z,e.z,n.z),this.w=Nn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Nn(this.x,e,n),this.y=Nn(this.y,e,n),this.z=Nn(this.z,e,n),this.w=Nn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Nn(r,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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,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}},aje=class extends Bf{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:yo,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},r),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=r.depth,this.scissor=new mi(0,0,e,n),this.scissorTest=!1,this.viewport=new mi(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new il(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:yo,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 r=0;r<this.textures.length;r++)this.textures[r].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,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].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,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new X4(i)}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"})}},Tf=class extends aje{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},eZ=class extends il{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Fs,this.minFilter=Fs,this.wrapR=Oc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},sje=class extends il{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=Fs,this.minFilter=Fs,this.wrapR=Oc,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Cf=class{constructor(e=new at(1/0,1/0,1/0),n=new at(-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,r=e.length;n<r;n+=3)this.expandByPoint(Oo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Oo.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Oo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),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 r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Oo):Oo.fromBufferAttribute(a,o),Oo.applyMatrix4(e.matrixWorld),this.expandByPoint(Oo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),l_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),l_.copy(r.boundingBox)),l_.applyMatrix4(e.matrixWorld),this.union(l_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[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,Oo),Oo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Hx),c_.subVectors(this.max,Hx),Cm.subVectors(e.a,Hx),km.subVectors(e.b,Hx),jm.subVectors(e.c,Hx),Fu.subVectors(km,Cm),Uu.subVectors(jm,km),mh.subVectors(Cm,jm);let n=[0,-Fu.z,Fu.y,0,-Uu.z,Uu.y,0,-mh.z,mh.y,Fu.z,0,-Fu.x,Uu.z,0,-Uu.x,mh.z,0,-mh.x,-Fu.y,Fu.x,0,-Uu.y,Uu.x,0,-mh.y,mh.x,0];return!cC(n,Cm,km,jm,c_)||(n=[1,0,0,0,1,0,0,0,1],!cC(n,Cm,km,jm,c_))?!1:(u_.crossVectors(Fu,Uu),n=[u_.x,u_.y,u_.z],cC(n,Cm,km,jm,c_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Oo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Oo).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:(cc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),cc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),cc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),cc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),cc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),cc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),cc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),cc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(cc),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 cc=[new at,new at,new at,new at,new at,new at,new at,new at],Oo=new at,l_=new Cf,Cm=new at,km=new at,jm=new at,Fu=new at,Uu=new at,mh=new at,Hx=new at,c_=new at,u_=new at,ph=new at;function cC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){ph.fromArray(t,a);const l=i.x*Math.abs(ph.x)+i.y*Math.abs(ph.y)+i.z*Math.abs(ph.z),c=e.dot(ph),u=n.dot(ph),d=r.dot(ph);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const oje=new Cf,Vx=new at,uC=new at;let wM=class{constructor(e=new at,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 r=this.center;n!==void 0?r.copy(n):oje.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),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 r=this.center.distanceToSquared(e);return n.copy(e),r>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;Vx.subVectors(e,this.center);const n=Vx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Vx,i/r),this.radius+=i}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):(uC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Vx.copy(e.center).add(uC)),this.expandByPoint(Vx.copy(e.center).sub(uC))),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 uc=new at,dC=new at,d_=new at,zu=new at,hC=new at,h_=new at,fC=new at;let Y4=class{constructor(e=new at,n=new at(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,uc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=uc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(uc.copy(this.origin).addScaledVector(this.direction,n),uc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){dC.copy(e).add(n).multiplyScalar(.5),d_.copy(n).sub(e).normalize(),zu.copy(this.origin).sub(dC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(d_),l=zu.dot(this.direction),c=-zu.dot(d_),u=zu.lengthSq(),d=Math.abs(1-o*o);let f,p,g,b;if(d>0)if(f=o*c-l,p=o*l-c,b=a*d,f>=0)if(p>=-b)if(p<=b){const v=1/d;f*=v,p*=v,g=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),g=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),g=-f*f+p*(p+2*c)+u;else p<=-b?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),g=-f*f+p*(p+2*c)+u):p<=b?(f=0,p=Math.min(Math.max(-a,-c),a),g=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),g=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),g=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(dC).addScaledVector(d_,p),g}intersectSphere(e,n){uc.subVectors(e.center,this.origin);const r=uc.dot(this.direction),i=uc.dot(uc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,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 r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,uc)!==null}intersectTriangle(e,n,r,i,a){hC.subVectors(n,e),h_.subVectors(r,e),fC.crossVectors(hC,h_);let o=this.direction.dot(fC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;zu.subVectors(this.origin,e);const c=l*this.direction.dot(h_.crossVectors(zu,h_));if(c<0)return null;const u=l*this.direction.dot(hC.cross(zu));if(u<0||c+u>o)return null;const d=-l*zu.dot(fC);return d<0?null:this.at(d/o,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)}},yi=class bP{constructor(e,n,r,i,a,o,l,c,u,d,f,p,g,b,v,x){bP.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,r,i,a,o,l,c,u,d,f,p,g,b,v,x)}set(e,n,r,i,a,o,l,c,u,d,f,p,g,b,v,x){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=p,y[3]=g,y[7]=b,y[11]=v,y[15]=x,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 bP().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[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,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Pm.setFromMatrixColumn(e,0).length(),a=1/Pm.setFromMatrixColumn(e,1).length(),o=1/Pm.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,g=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=g+b*u,n[5]=p-v*u,n[9]=-l*c,n[2]=v-p*u,n[6]=b+g*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,g=c*f,b=u*d,v=u*f;n[0]=p+v*l,n[4]=b*l-g,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=g*l-b,n[6]=v+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,g=c*f,b=u*d,v=u*f;n[0]=p-v*l,n[4]=-o*f,n[8]=b+g*l,n[1]=g+b*l,n[5]=o*d,n[9]=v-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,g=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=b*u-g,n[8]=p*u+v,n[1]=c*f,n[5]=v*u+p,n[9]=g*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,g=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=v-p*f,n[8]=b*f+g,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=g*f+b,n[10]=p-v*f}else if(e.order==="XZY"){const p=o*c,g=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+v,n[5]=o*d,n[9]=g*f-b,n[2]=b*f-g,n[6]=l*d,n[10]=v*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(lje,e,cje)}lookAt(e,n,r){const i=this.elements;return Ss.subVectors(e,n),Ss.lengthSq()===0&&(Ss.z=1),Ss.normalize(),Bu.crossVectors(r,Ss),Bu.lengthSq()===0&&(Math.abs(r.z)===1?Ss.x+=1e-4:Ss.z+=1e-4,Ss.normalize(),Bu.crossVectors(r,Ss)),Bu.normalize(),f_.crossVectors(Ss,Bu),i[0]=Bu.x,i[4]=f_.x,i[8]=Ss.x,i[1]=Bu.y,i[5]=f_.y,i[9]=Ss.y,i[2]=Bu.z,i[6]=f_.z,i[10]=Ss.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],g=r[13],b=r[2],v=r[6],x=r[10],y=r[14],E=r[3],w=r[7],A=r[11],N=r[15],C=i[0],T=i[4],D=i[8],k=i[12],P=i[1],z=i[5],L=i[9],X=i[13],R=i[2],Y=i[6],J=i[10],G=i[14],W=i[3],ee=i[7],K=i[11],F=i[15];return a[0]=o*C+l*P+c*R+u*W,a[4]=o*T+l*z+c*Y+u*ee,a[8]=o*D+l*L+c*J+u*K,a[12]=o*k+l*X+c*G+u*F,a[1]=d*C+f*P+p*R+g*W,a[5]=d*T+f*z+p*Y+g*ee,a[9]=d*D+f*L+p*J+g*K,a[13]=d*k+f*X+p*G+g*F,a[2]=b*C+v*P+x*R+y*W,a[6]=b*T+v*z+x*Y+y*ee,a[10]=b*D+v*L+x*J+y*K,a[14]=b*k+v*X+x*G+y*F,a[3]=E*C+w*P+A*R+N*W,a[7]=E*T+w*z+A*Y+N*ee,a[11]=E*D+w*L+A*J+N*K,a[15]=E*k+w*X+A*G+N*F,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],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],g=e[14],b=e[3],v=e[7],x=e[11],y=e[15];return b*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*g-r*c*g)+v*(+n*c*g-n*u*p+a*o*p-i*o*g+i*u*d-a*c*d)+x*(+n*u*f-n*l*g-a*o*f+r*o*g+a*l*d-r*u*d)+y*(-i*l*d-n*c*f+n*l*p+i*o*f-r*o*p+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],g=e[11],b=e[12],v=e[13],x=e[14],y=e[15],E=f*x*u-v*p*u+v*c*g-l*x*g-f*c*y+l*p*y,w=b*p*u-d*x*u-b*c*g+o*x*g+d*c*y-o*p*y,A=d*v*u-b*f*u+b*l*g-o*v*g-d*l*y+o*f*y,N=b*f*c-d*v*c-b*l*p+o*v*p+d*l*x-o*f*x,C=n*E+r*w+i*A+a*N;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/C;return e[0]=E*T,e[1]=(v*p*a-f*x*a-v*i*g+r*x*g+f*i*y-r*p*y)*T,e[2]=(l*x*a-v*c*a+v*i*u-r*x*u-l*i*y+r*c*y)*T,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*g-r*c*g)*T,e[4]=w*T,e[5]=(d*x*a-b*p*a+b*i*g-n*x*g-d*i*y+n*p*y)*T,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*y-n*c*y)*T,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*g+n*c*g)*T,e[8]=A*T,e[9]=(b*f*a-d*v*a-b*r*g+n*v*g+d*r*y-n*f*y)*T,e[10]=(o*v*a-b*l*a+b*r*u-n*v*u-o*r*y+n*l*y)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*g-n*l*g)*T,e[12]=N*T,e[13]=(d*v*i-b*f*i+b*r*p-n*v*p-d*r*x+n*f*x)*T,e[14]=(b*l*i-o*v*i-b*r*c+n*v*c+o*r*x-n*l*x)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*T,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){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,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,g=a*d,b=a*f,v=o*d,x=o*f,y=l*f,E=c*u,w=c*d,A=c*f,N=r.x,C=r.y,T=r.z;return i[0]=(1-(v+y))*N,i[1]=(g+A)*N,i[2]=(b-w)*N,i[3]=0,i[4]=(g-A)*C,i[5]=(1-(p+y))*C,i[6]=(x+E)*C,i[7]=0,i[8]=(b+w)*T,i[9]=(x-E)*T,i[10]=(1-(p+v))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Pm.set(i[0],i[1],i[2]).length();const o=Pm.set(i[4],i[5],i[6]).length(),l=Pm.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Lo.copy(this);const u=1/a,d=1/o,f=1/l;return Lo.elements[0]*=u,Lo.elements[1]*=u,Lo.elements[2]*=u,Lo.elements[4]*=d,Lo.elements[5]*=d,Lo.elements[6]*=d,Lo.elements[8]*=f,Lo.elements[9]*=f,Lo.elements[10]*=f,n.setFromRotationMatrix(Lo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Sl,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),p=(n+e)/(n-e),g=(r+i)/(r-i);let b,v;if(c)b=a/(o-a),v=o*a/(o-a);else if(l===Sl)b=-(o+a)/(o-a),v=-2*o*a/(o-a);else if(l===sS)b=-o/(o-a),v=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=p,u[12]=0,u[1]=0,u[5]=f,u[9]=g,u[13]=0,u[2]=0,u[6]=0,u[10]=b,u[14]=v,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Sl,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),p=-(n+e)/(n-e),g=-(r+i)/(r-i);let b,v;if(c)b=1/(o-a),v=o/(o-a);else if(l===Sl)b=-2/(o-a),v=-(o+a)/(o-a);else if(l===sS)b=-1/(o-a),v=-a/(o-a);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return u[0]=d,u[4]=0,u[8]=0,u[12]=p,u[1]=0,u[5]=f,u[9]=0,u[13]=g,u[2]=0,u[6]=0,u[10]=b,u[14]=v,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}};const Pm=new at,Lo=new yi,lje=new at(0,0,0),cje=new at(1,1,1),Bu=new at,f_=new at,Ss=new at,H$=new yi,V$=new Af;let zd=class tZ{constructor(e=0,n=0,r=0,i=tZ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}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,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,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,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(Nn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Nn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Nn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Nn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,g),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Nn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,g));break;case"XZY":this._z=Math.asin(-Nn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,g),this._y=0);break;default:nn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return H$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(H$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return V$.setFromEuler(this),this.setFromQuaternion(V$,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}};zd.DEFAULT_ORDER="XYZ";let nZ=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}},uje=0;const G$=new at,Rm=new Af,dc=new yi,m_=new at,Gx=new at,dje=new at,hje=new Af,W$=new at(1,0,0),q$=new at(0,1,0),K$=new at(0,0,1),X$={type:"added"},fje={type:"removed"},Dm={type:"childadded",child:null},mC={type:"childremoved",child:null};let Gs=class B1 extends Bf{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:uje++}),this.uuid=by(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=B1.DEFAULT_UP.clone();const e=new at,n=new zd,r=new Af,i=new at(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new yi},normalMatrix:{value:new vn}}),this.matrix=new yi,this.matrixWorld=new yi,this.matrixAutoUpdate=B1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=B1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nZ,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 Rm.setFromAxisAngle(e,n),this.quaternion.multiply(Rm),this}rotateOnWorldAxis(e,n){return Rm.setFromAxisAngle(e,n),this.quaternion.premultiply(Rm),this}rotateX(e){return this.rotateOnAxis(W$,e)}rotateY(e){return this.rotateOnAxis(q$,e)}rotateZ(e){return this.rotateOnAxis(K$,e)}translateOnAxis(e,n){return G$.copy(e).applyQuaternion(this.quaternion),this.position.add(G$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(W$,e)}translateY(e){return this.translateOnAxis(q$,e)}translateZ(e){return this.translateOnAxis(K$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(dc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?m_.copy(e):m_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Gx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?dc.lookAt(Gx,m_,this.up):dc.lookAt(m_,Gx,this.up),this.quaternion.setFromRotationMatrix(dc),i&&(dc.extractRotation(i.matrixWorld),Rm.setFromRotationMatrix(dc),this.quaternion.premultiply(Rm.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(ii("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(X$),Dm.child=e,this.dispatchEvent(Dm),Dm.child=null):ii("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(fje),mC.child=e,this.dispatchEvent(mC),mC.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),dc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),dc.multiply(e.parent.matrixWorld)),e.applyMatrix4(dc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(X$),Dm.child=e,this.dispatchEvent(Dm),Dm.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 r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gx,e,dje),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gx,hje,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 r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].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 r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.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 i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),p=o(e.skeletons),g=o(e.animations),b=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),p.length>0&&(r.skeletons=p),g.length>0&&(r.animations=g),b.length>0&&(r.nodes=b)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}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 r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}};Gs.DEFAULT_UP=new at(0,1,0);Gs.DEFAULT_MATRIX_AUTO_UPDATE=!0;Gs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Io=new at,hc=new at,pC=new at,fc=new at,Om=new at,Lm=new at,Y$=new at,gC=new at,xC=new at,bC=new at,yC=new mi,vC=new mi,_C=new mi;let Wx=class fp{constructor(e=new at,n=new at,r=new at){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Io.subVectors(e,n),i.cross(Io);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Io.subVectors(i,n),hc.subVectors(r,n),pC.subVectors(e,n);const o=Io.dot(Io),l=Io.dot(hc),c=Io.dot(pC),u=hc.dot(hc),d=hc.dot(pC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const p=1/f,g=(u*c-l*d)*p,b=(o*d-l*c)*p;return a.set(1-g-b,b,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,fc)===null?!1:fc.x>=0&&fc.y>=0&&fc.x+fc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,fc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,fc.x),c.addScaledVector(o,fc.y),c.addScaledVector(l,fc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return yC.setScalar(0),vC.setScalar(0),_C.setScalar(0),yC.fromBufferAttribute(e,n),vC.fromBufferAttribute(e,r),_C.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(yC,a.x),o.addScaledVector(vC,a.y),o.addScaledVector(_C,a.z),o}static isFrontFacing(e,n,r,i){return Io.subVectors(r,n),hc.subVectors(e,n),Io.cross(hc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 Io.subVectors(this.c,this.b),hc.subVectors(this.a,this.b),Io.cross(hc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return fp.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return fp.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,a){return fp.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return fp.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return fp.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;Om.subVectors(i,r),Lm.subVectors(a,r),gC.subVectors(e,r);const c=Om.dot(gC),u=Lm.dot(gC);if(c<=0&&u<=0)return n.copy(r);xC.subVectors(e,i);const d=Om.dot(xC),f=Lm.dot(xC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Om,o);bC.subVectors(e,a);const g=Om.dot(bC),b=Lm.dot(bC);if(b>=0&&g<=b)return n.copy(a);const v=g*u-c*b;if(v<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Lm,l);const x=d*b-g*f;if(x<=0&&f-d>=0&&g-b>=0)return Y$.subVectors(a,i),l=(f-d)/(f-d+(g-b)),n.copy(i).addScaledVector(Y$,l);const y=1/(x+v+p);return o=v*y,l=p*y,n.copy(r).addScaledVector(Om,o).addScaledVector(Lm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const rZ={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},$u={h:0,s:0,l:0},p_={h:0,s:0,l:0};function wC(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 An=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=co){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Fn.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=Fn.workingColorSpace){return this.r=e,this.g=n,this.b=r,Fn.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=Fn.workingColorSpace){if(e=Jke(e,1),n=Nn(n,0,1),r=Nn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=wC(o,a,e+1/3),this.g=wC(o,a,e),this.b=wC(o,a,e-1/3)}return Fn.colorSpaceToWorking(this,i),this}setStyle(e,n=co){function r(a){a!==void 0&&parseFloat(a)<1&&nn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(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(l))return r(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(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:nn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);nn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=co){const r=rZ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):nn("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=Hc(e.r),this.g=Hc(e.g),this.b=Hc(e.b),this}copyLinearToSRGB(e){return this.r=Pp(e.r),this.g=Pp(e.g),this.b=Pp(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=co){return Fn.workingToColorSpace(ya.copy(this),e),Math.round(Nn(ya.r*255,0,255))*65536+Math.round(Nn(ya.g*255,0,255))*256+Math.round(Nn(ya.b*255,0,255))}getHexString(e=co){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Fn.workingColorSpace){Fn.workingToColorSpace(ya.copy(this),n);const r=ya.r,i=ya.g,a=ya.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Fn.workingColorSpace){return Fn.workingToColorSpace(ya.copy(this),n),e.r=ya.r,e.g=ya.g,e.b=ya.b,e}getStyle(e=co){Fn.workingToColorSpace(ya.copy(this),e);const n=ya.r,r=ya.g,i=ya.b;return e!==co?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL($u),this.setHSL($u.h+e,$u.s+n,$u.l+r)}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,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL($u),e.getHSL(p_);const r=iC($u.h,p_.h,n),i=iC($u.s,p_.s,n),a=iC($u.l,p_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,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 ya=new An;An.NAMES=rZ;let mje=0,Og=class extends Bf{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:mje++}),this.uuid=by(),this.name="",this.type="Material",this.blending=jp,this.side=Ud,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=k3,this.blendDst=j3,this.blendEquation=jh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new An(0,0,0),this.blendAlpha=0,this.depthFunc=Jp,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=O$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Am,this.stencilZFail=Am,this.stencilZPass=Am,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 r=e[n];if(r===void 0){nn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){nn(`Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==jp&&(r.blending=this.blending),this.side!==Ud&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==k3&&(r.blendSrc=this.blendSrc),this.blendDst!==j3&&(r.blendDst=this.blendDst),this.blendEquation!==jh&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Jp&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==O$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Am&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Am&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Am&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r}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 r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,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++}},Q4=class extends Og{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new An(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 zd,this.combine=B4,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 ui=new at,g_=new xn;let pje=0,vo=class{constructor(e,n,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:pje++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=L$,this.updateRanges=[],this.gpuType=Lc,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,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)g_.fromBufferAttribute(this,n),g_.applyMatrix3(e),this.setXY(n,g_.x,g_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)ui.fromBufferAttribute(this,n),ui.applyMatrix3(e),this.setXYZ(n,ui.x,ui.y,ui.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)ui.fromBufferAttribute(this,n),ui.applyMatrix4(e),this.setXYZ(n,ui.x,ui.y,ui.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ui.fromBufferAttribute(this,n),ui.applyNormalMatrix(e),this.setXYZ(n,ui.x,ui.y,ui.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ui.fromBufferAttribute(this,n),ui.transformDirection(e),this.setXYZ(n,ui.x,ui.y,ui.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=$x(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=ts(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=$x(n,this.array)),n}setX(e,n){return this.normalized&&(n=ts(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=$x(n,this.array)),n}setY(e,n){return this.normalized&&(n=ts(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=$x(n,this.array)),n}setZ(e,n){return this.normalized&&(n=ts(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=$x(n,this.array)),n}setW(e,n){return this.normalized&&(n=ts(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=ts(n,this.array),r=ts(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=ts(n,this.array),r=ts(r,this.array),i=ts(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=ts(n,this.array),r=ts(r,this.array),i=ts(i,this.array),a=ts(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,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!==L$&&(e.usage=this.usage),e}},iZ=class extends vo{constructor(e,n,r){super(new Uint16Array(e),n,r)}},aZ=class extends vo{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Qo=class extends vo{constructor(e,n,r){super(new Float32Array(e),n,r)}},gje=0;const no=new yi,SC=new Gs,Im=new at,Ms=new Cf,qx=new Cf,zi=new at;let Vl=class sZ extends Bf{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:gje++}),this.uuid=by(),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(XQ(e)?aZ:iZ)(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,r=0){this.groups.push({start:e,count:n,materialIndex:r})}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 r=this.attributes.normal;if(r!==void 0){const a=new vn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return no.makeRotationFromQuaternion(e),this.applyMatrix4(no),this}rotateX(e){return no.makeRotationX(e),this.applyMatrix4(no),this}rotateY(e){return no.makeRotationY(e),this.applyMatrix4(no),this}rotateZ(e){return no.makeRotationZ(e),this.applyMatrix4(no),this}translate(e,n,r){return no.makeTranslation(e,n,r),this.applyMatrix4(no),this}scale(e,n,r){return no.makeScale(e,n,r),this.applyMatrix4(no),this}lookAt(e){return SC.lookAt(e),SC.updateMatrix(),this.applyMatrix4(SC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Im).negate(),this.translate(Im.x,Im.y,Im.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Qo(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&nn("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 Cf);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ii("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new at(-1/0,-1/0,-1/0),new at(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];Ms.setFromBufferAttribute(a),this.morphTargetsRelative?(zi.addVectors(this.boundingBox.min,Ms.min),this.boundingBox.expandByPoint(zi),zi.addVectors(this.boundingBox.max,Ms.max),this.boundingBox.expandByPoint(zi)):(this.boundingBox.expandByPoint(Ms.min),this.boundingBox.expandByPoint(Ms.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ii('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 wM);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ii("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new at,1/0);return}if(e){const r=this.boundingSphere.center;if(Ms.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];qx.setFromBufferAttribute(l),this.morphTargetsRelative?(zi.addVectors(Ms.min,qx.min),Ms.expandByPoint(zi),zi.addVectors(Ms.max,qx.max),Ms.expandByPoint(zi)):(Ms.expandByPoint(qx.min),Ms.expandByPoint(qx.max))}Ms.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)zi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(zi));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)zi.fromBufferAttribute(l,u),c&&(Im.fromBufferAttribute(e,u),zi.add(Im)),i=Math.max(i,r.distanceToSquared(zi))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ii('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){ii("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=n.position,i=n.normal,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new vo(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let D=0;D<r.count;D++)l[D]=new at,c[D]=new at;const u=new at,d=new at,f=new at,p=new xn,g=new xn,b=new xn,v=new at,x=new at;function y(D,k,P){u.fromBufferAttribute(r,D),d.fromBufferAttribute(r,k),f.fromBufferAttribute(r,P),p.fromBufferAttribute(a,D),g.fromBufferAttribute(a,k),b.fromBufferAttribute(a,P),d.sub(u),f.sub(u),g.sub(p),b.sub(p);const z=1/(g.x*b.y-b.x*g.y);isFinite(z)&&(v.copy(d).multiplyScalar(b.y).addScaledVector(f,-g.y).multiplyScalar(z),x.copy(f).multiplyScalar(g.x).addScaledVector(d,-b.x).multiplyScalar(z),l[D].add(v),l[k].add(v),l[P].add(v),c[D].add(x),c[k].add(x),c[P].add(x))}let E=this.groups;E.length===0&&(E=[{start:0,count:e.count}]);for(let D=0,k=E.length;D<k;++D){const P=E[D],z=P.start,L=P.count;for(let X=z,R=z+L;X<R;X+=3)y(e.getX(X+0),e.getX(X+1),e.getX(X+2))}const w=new at,A=new at,N=new at,C=new at;function T(D){N.fromBufferAttribute(i,D),C.copy(N);const k=l[D];w.copy(k),w.sub(N.multiplyScalar(N.dot(k))).normalize(),A.crossVectors(C,k);const z=A.dot(c[D])<0?-1:1;o.setXYZW(D,w.x,w.y,w.z,z)}for(let D=0,k=E.length;D<k;++D){const P=E[D],z=P.start,L=P.count;for(let X=z,R=z+L;X<R;X+=3)T(e.getX(X+0)),T(e.getX(X+1)),T(e.getX(X+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new vo(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,g=r.count;p<g;p++)r.setXYZ(p,0,0,0);const i=new at,a=new at,o=new at,l=new at,c=new at,u=new at,d=new at,f=new at;if(e)for(let p=0,g=e.count;p<g;p+=3){const b=e.getX(p+0),v=e.getX(p+1),x=e.getX(p+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,v),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let p=0,g=n.count;p<g;p+=3)i.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)zi.fromBufferAttribute(e,n),zi.normalize(),e.setXYZ(n,zi.x,zi.y,zi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let g=0,b=0;for(let v=0,x=c.length;v<x;v++){l.isInterleavedBufferAttribute?g=c[v]*l.data.stride+l.offset:g=c[v]*d;for(let y=0;y<d;y++)p[b++]=u[g++]}return new vo(p,d,f)}if(this.index===null)return nn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new sZ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const p=u[d],g=e(p,r);c.push(g)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.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 c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);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 r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const g=u[f];d.push(g.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere=l.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 r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,g=f.length;p<g;p++)d.push(f[p].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const Q$=new yi,gh=new Y4,x_=new wM,Z$=new at,b_=new at,y_=new at,v_=new at,MC=new at,__=new at,J$=new at,w_=new at;let Ol=class extends Gs{constructor(e=new Vl,n=new Q4){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,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){__.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(MC.fromBufferAttribute(f,e),o?__.addScaledVector(MC,d):__.addScaledVector(MC.sub(n),d))}n.add(__)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),x_.copy(r.boundingSphere),x_.applyMatrix4(a),gh.copy(e.ray).recast(e.near),!(x_.containsPoint(gh.origin)===!1&&(gh.intersectSphere(x_,Z$)===null||gh.origin.distanceToSquared(Z$)>(e.far-e.near)**2))&&(Q$.copy(a).invert(),gh.copy(e.ray).applyMatrix4(Q$),!(r.boundingBox!==null&&gh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,gh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,g=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,v=p.length;b<v;b++){const x=p[b],y=o[x.materialIndex],E=Math.max(x.start,g.start),w=Math.min(l.count,Math.min(x.start+x.count,g.start+g.count));for(let A=E,N=w;A<N;A+=3){const C=l.getX(A),T=l.getX(A+1),D=l.getX(A+2);i=S_(this,y,e,r,u,d,f,C,T,D),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,g.start),v=Math.min(l.count,g.start+g.count);for(let x=b,y=v;x<y;x+=3){const E=l.getX(x),w=l.getX(x+1),A=l.getX(x+2);i=S_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,v=p.length;b<v;b++){const x=p[b],y=o[x.materialIndex],E=Math.max(x.start,g.start),w=Math.min(c.count,Math.min(x.start+x.count,g.start+g.count));for(let A=E,N=w;A<N;A+=3){const C=A,T=A+1,D=A+2;i=S_(this,y,e,r,u,d,f,C,T,D),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,g.start),v=Math.min(c.count,g.start+g.count);for(let x=b,y=v;x<y;x+=3){const E=x,w=x+1,A=x+2;i=S_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}};function xje(t,e,n,r,i,a,o,l){let c;if(e.side===ls?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Ud,l),c===null)return null;w_.copy(l),w_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(w_);return u<n.near||u>n.far?null:{distance:u,point:w_.clone(),object:t}}function S_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,b_),t.getVertexPosition(c,y_),t.getVertexPosition(u,v_);const d=xje(t,e,n,r,b_,y_,v_,J$);if(d){const f=new at;Wx.getBarycoord(J$,b_,y_,v_,f),i&&(d.uv=Wx.getInterpolatedAttribute(i,l,c,u,f,new xn)),a&&(d.uv1=Wx.getInterpolatedAttribute(a,l,c,u,f,new xn)),o&&(d.normal=Wx.getInterpolatedAttribute(o,l,c,u,f,new at),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:c,c:u,normal:new at,materialIndex:0};Wx.getNormal(b_,y_,v_,p.normal),d.face=p,d.barycoord=f}return d}let Z4=class oZ extends Vl{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,g=0;b("z","y","x",-1,-1,r,n,e,o,a,0),b("z","y","x",1,-1,r,n,-e,o,a,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Qo(u,3)),this.setAttribute("normal",new Qo(d,3)),this.setAttribute("uv",new Qo(f,2));function b(v,x,y,E,w,A,N,C,T,D,k){const P=A/T,z=N/D,L=A/2,X=N/2,R=C/2,Y=T+1,J=D+1;let G=0,W=0;const ee=new at;for(let K=0;K<J;K++){const F=K*z-X;for(let q=0;q<Y;q++){const ne=q*P-L;ee[v]=ne*E,ee[x]=F*w,ee[y]=R,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[x]=0,ee[y]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(q/T),f.push(1-K/D),G+=1}}for(let K=0;K<D;K++)for(let F=0;F<T;F++){const q=p+F+Y*K,ne=p+F+Y*(K+1),re=p+(F+1)+Y*(K+1),se=p+(F+1)+Y*K;c.push(q,ne,se),c.push(ne,re,se),W+=6}l.addGroup(g,W,k),g+=W,p+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oZ(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function rg(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(nn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function Oa(t){const e={};for(let n=0;n<t.length;n++){const r=rg(t[n]);for(const i in r)e[i]=r[i]}return e}function bje(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function lZ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Fn.workingColorSpace}const yje={clone:rg,merge:Oa};var vje=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,_je=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let su=class extends Og{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=vje,this.fragmentShader=_je,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=rg(e.uniforms),this.uniformsGroups=bje(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 i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}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 r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}},cZ=class extends Gs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new yi,this.projectionMatrix=new yi,this.projectionMatrixInverse=new yi,this.coordinateSystem=Sl,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 Hu=new at,eH=new xn,tH=new xn;let fo=class extends cZ{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,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=xP*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(U1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return xP*2*Math.atan(Math.tan(U1*.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,r){Hu.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Hu.x,Hu.y).multiplyScalar(-e/Hu.z),Hu.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Hu.x,Hu.y).multiplyScalar(-e/Hu.z)}getViewSize(e,n){return this.getViewBounds(e,eH,tH),n.subVectors(tH,eH)}setViewOffset(e,n,r,i,a,o){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=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(U1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,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 Fm=-90,Um=1;let wje=class extends Gs{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new fo(Fm,Um,e,n);i.layers=this.layers,this.add(i);const a=new fo(Fm,Um,e,n);a.layers=this.layers,this.add(a);const o=new fo(Fm,Um,e,n);o.layers=this.layers,this.add(o);const l=new fo(Fm,Um,e,n);l.layers=this.layers,this.add(l);const c=new fo(Fm,Um,e,n);c.layers=this.layers,this.add(c);const u=new fo(Fm,Um,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===Sl)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===sS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,p,g),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}},uZ=class extends il{constructor(e=[],n=eg,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Sje=class extends Tf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new uZ(i),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 r={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 );
- }
- `},i=new Z4(5,5,5),a=new su({name:"CubemapFromEquirect",uniforms:rg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:ls,blending:$c});a.uniforms.tEquirect.value=n;const o=new Ol(i,a),l=n.minFilter;return n.minFilter===Hh&&(n.minFilter=yo),new wje(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n=!0,r=!0,i=!0){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}},cb=class extends Gs{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Mje={type:"move"};let EC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new cb,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 cb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new at,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new at),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new cb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new at,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new at),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 r of e.hand.values())this._getHandJoint(n,r)}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,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const v of e.hand.values()){const x=n.getJointPose(v,r),y=this._getHandJoint(u,v);x!==null&&(y.matrix.fromArray(x.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=x.radius),y.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],p=d.position.distanceTo(f.position),g=.02,b=.005;u.inputState.pinching&&p>g+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=g-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(Mje)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new cb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},Eje=class extends Gs{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 zd,this.environmentIntensity=1,this.environmentRotation=new zd,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}},Nje=class extends il{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Fs,d=Fs,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const NC=new at,Aje=new at,Tje=new vn;let nd=class{constructor(e=new at(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,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=NC.subVectors(r,n).cross(Aje.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,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 r=e.delta(NC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<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 r=n||Tje.getNormalMatrix(e),i=this.coplanarPoint(NC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.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 xh=new wM,Cje=new xn(.5,.5),M_=new at;let J4=class{constructor(e=new nd,n=new nd,r=new nd,i=new nd,a=new nd,o=new nd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Sl,r=!1){const i=this.planes,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],p=a[6],g=a[7],b=a[8],v=a[9],x=a[10],y=a[11],E=a[12],w=a[13],A=a[14],N=a[15];if(i[0].setComponents(u-o,g-d,y-b,N-E).normalize(),i[1].setComponents(u+o,g+d,y+b,N+E).normalize(),i[2].setComponents(u+l,g+f,y+v,N+w).normalize(),i[3].setComponents(u-l,g-f,y-v,N-w).normalize(),r)i[4].setComponents(c,p,x,A).normalize(),i[5].setComponents(u-c,g-p,y-x,N-A).normalize();else if(i[4].setComponents(u-c,g-p,y-x,N-A).normalize(),n===Sl)i[5].setComponents(u+c,g+p,y+x,N+A).normalize();else if(n===sS)i[5].setComponents(c,p,x,A).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(),xh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),xh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xh)}intersectsSprite(e){xh.center.set(0,0,0);const n=Cje.distanceTo(e.center);return xh.radius=.7071067811865476+n,xh.applyMatrix4(e.matrixWorld),this.intersectsSphere(xh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(M_.x=i.normal.x>0?e.max.x:e.min.x,M_.y=i.normal.y>0?e.max.y:e.min.y,M_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(M_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},dZ=class extends Og{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new An(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 lS=new at,cS=new at,nH=new yi,Kx=new Y4,E_=new wM,AC=new at,rH=new at;let kje=class extends Gs{constructor(e=new Vl,n=new dZ){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,r=[0];for(let i=1,a=n.count;i<a;i++)lS.fromBufferAttribute(n,i-1),cS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=lS.distanceTo(cS);e.setAttribute("lineDistance",new Qo(r,1))}else nn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),E_.copy(r.boundingSphere),E_.applyMatrix4(i),E_.radius+=a,e.ray.intersectsSphere(E_)===!1)return;nH.copy(i).invert(),Kx.copy(e.ray).applyMatrix4(nH);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,p=r.attributes.position;if(d!==null){const g=Math.max(0,o.start),b=Math.min(d.count,o.start+o.count);for(let v=g,x=b-1;v<x;v+=u){const y=d.getX(v),E=d.getX(v+1),w=N_(this,e,Kx,c,y,E,v);w&&n.push(w)}if(this.isLineLoop){const v=d.getX(b-1),x=d.getX(g),y=N_(this,e,Kx,c,v,x,b-1);y&&n.push(y)}}else{const g=Math.max(0,o.start),b=Math.min(p.count,o.start+o.count);for(let v=g,x=b-1;v<x;v+=u){const y=N_(this,e,Kx,c,v,v+1,v);y&&n.push(y)}if(this.isLineLoop){const v=N_(this,e,Kx,c,b-1,g,b-1);v&&n.push(v)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function N_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(lS.fromBufferAttribute(l,i),cS.fromBufferAttribute(l,a),n.distanceSqToSegment(lS,cS,AC,rH)>r)return;AC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(AC);if(!(u<e.near||u>e.far))return{distance:u,point:rH.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const iH=new at,aH=new at;let jje=class extends kje{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,r=[];for(let i=0,a=n.count;i<a;i+=2)iH.fromBufferAttribute(n,i),aH.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+iH.distanceTo(aH);e.setAttribute("lineDistance",new Qo(r,1))}else nn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},hZ=class extends il{constructor(e,n,r=Nf,i,a,o,l=Fs,c=Fs,u,d=p0,f=1){if(d!==p0&&d!==g0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:f};super(p,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new X4(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 fZ extends il{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let eO=class mZ extends Vl{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,g=[],b=[],v=[],x=[];for(let y=0;y<d;y++){const E=y*p-o;for(let w=0;w<u;w++){const A=w*f-a;b.push(A,-E,0),v.push(0,0,1),x.push(w/l),x.push(1-y/c)}}for(let y=0;y<c;y++)for(let E=0;E<l;E++){const w=E+u*y,A=E+u*(y+1),N=E+1+u*(y+1),C=E+1+u*y;g.push(w,A,C),g.push(A,N,C)}this.setIndex(g),this.setAttribute("position",new Qo(b,3)),this.setAttribute("normal",new Qo(v,3)),this.setAttribute("uv",new Qo(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mZ(e.width,e.height,e.widthSegments,e.heightSegments)}};class Pje extends Og{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new An(16777215),this.specular=new An(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new An(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qQ,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new zd,this.combine=B4,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 Rje=class extends Og{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bke,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}},Dje=class extends Og{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}},pZ=class extends Gs{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new An(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 TC=new yi,sH=new at,oH=new at;let Oje=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xn(512,512),this.mapType=Dl,this.map=null,this.mapPass=null,this.matrix=new yi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new J4,this._frameExtents=new xn(1,1),this._viewportCount=1,this._viewports=[new mi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;sH.setFromMatrixPosition(e.matrixWorld),n.position.copy(sH),oH.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(oH),n.updateMatrixWorld(),TC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(TC,n.coordinateSystem,n.reversedDepth),n.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(TC)}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}},gZ=class extends cZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=o,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,r,i,a,o){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=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,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),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,l,c,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 Lje extends Oje{constructor(){super(new gZ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class lH extends pZ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Gs.DEFAULT_UP),this.updateMatrix(),this.target=new Gs,this.shadow=new Lje}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Ije=class extends pZ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},Fje=class extends fo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},cH=class{constructor(e=1,n=0,r=0){this.radius=e,this.phi=n,this.theta=r}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Nn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Nn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Uje extends jje{constructor(e=10,n=10,r=4473924,i=8947848){r=new An(r),i=new An(i);const a=n/2,o=e/n,l=e/2,c=[],u=[];for(let p=0,g=0,b=-l;p<=n;p++,b+=o){c.push(-l,0,b,l,0,b),c.push(b,0,-l,b,0,l);const v=p===a?r:i;v.toArray(u,g),g+=3,v.toArray(u,g),g+=3,v.toArray(u,g),g+=3,v.toArray(u,g),g+=3}const d=new Vl;d.setAttribute("position",new Qo(c,3)),d.setAttribute("color",new Qo(u,3));const f=new dZ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class zje extends Bf{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){nn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function uH(t,e,n,r){const i=Bje(r);switch(n){case VQ:return t*e;case WQ:return t*e/i.components*i.byteLength;case G4:return t*e/i.components*i.byteLength;case W4:return t*e*2/i.components*i.byteLength;case q4:return t*e*2/i.components*i.byteLength;case GQ:return t*e*3/i.components*i.byteLength;case qo:return t*e*4/i.components*i.byteLength;case K4:return t*e*4/i.components*i.byteLength;case O1:case L1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case I1:case F1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case V3:case W3:return Math.max(t,16)*Math.max(e,8)/4;case H3:case G3:return Math.max(t,8)*Math.max(e,8)/2;case q3:case K3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case X3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Y3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case Q3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case Z3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case J3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case eP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case tP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case nP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case rP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case iP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case aP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case sP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case oP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case lP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case cP:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case uP:case dP:case hP:return Math.ceil(t/4)*Math.ceil(e/4)*16;case fP:case mP:return Math.ceil(t/4)*Math.ceil(e/4)*8;case pP:case gP:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function Bje(t){switch(t){case Dl:case zQ:return{byteLength:1,components:1};case f0:case BQ:case Dg:return{byteLength:2,components:1};case H4:case V4:return{byteLength:2,components:4};case Nf:case $4:case Lc:return{byteLength:4,components:1};case $Q:case HQ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:z4}}));typeof window<"u"&&(window.__THREE__?nn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=z4);function xZ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function $je(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=u.byteLength,p=t.createBuffer();t.bindBuffer(c,p),t.bufferData(c,u,d),l.onUploadCallback();let g;if(u instanceof Float32Array)g=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)g=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?g=t.HALF_FLOAT:g=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)g=t.SHORT;else if(u instanceof Uint32Array)g=t.UNSIGNED_INT;else if(u instanceof Int32Array)g=t.INT;else if(u instanceof Int8Array)g=t.BYTE;else if(u instanceof Uint8Array)g=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)g=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:p,type:g,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((g,b)=>g.start-b.start);let p=0;for(let g=1;g<f.length;g++){const b=f[p],v=f[g];v.start<=b.start+b.count+1?b.count=Math.max(b.count,v.start+v.count-b.start):(++p,f[p]=v)}f.length=p+1;for(let g=0,b=f.length;g<b;g++){const v=f[g];t.bufferSubData(u,v.start*d.BYTES_PER_ELEMENT,d,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function o(l,c){if(l.isInterleavedBufferAttribute&&(l=l.data),l.isGLBufferAttribute){const d=e.get(l);(!d||d.version<l.version)&&e.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}const u=e.get(l);if(u===void 0)e.set(l,n(l,c));else if(u.version<l.version){if(u.size!==l.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.");r(u.buffer,l,c),u.version=l.version}}return{get:i,remove:a,update:o}}var Hje=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,Vje=`#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`,Gje=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,Wje=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,qje=`#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`,Kje=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,Xje=`#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`,Yje=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,Qje=`#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`,Zje=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,Jje=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,e3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,t3e=`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`,n3e=`#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`,r3e=`#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`,i3e=`#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`,a3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,s3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,o3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,l3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,c3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,u3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,d3e=`#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`,h3e=`#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`,f3e=`#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`,m3e=`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`,p3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,g3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,x3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,b3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,y3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",v3e=`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 );
- }`,_3e=`#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`,w3e=`#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`,S3e=`#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`,M3e=`#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`,E3e=`#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`,N3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,A3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,T3e=`#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`,C3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,k3e=`#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
- }`,j3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,P3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,R3e=`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`,D3e=`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`,O3e=`#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`,L3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,I3e=`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`,F3e=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,U3e=`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`,z3e=`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`,B3e=`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 );
- }`,$3e=`
- 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`,H3e=`#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`,V3e=`#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`,G3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,W3e=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,q3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,K3e=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,X3e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,Y3e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,Q3e=`#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`,Z3e=`#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`,J3e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,ePe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,tPe=`#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`,nPe=`#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`,rPe=`#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`,iPe=`#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`,aPe=`#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`,sPe=`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;`,oPe=`#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`,lPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,cPe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,uPe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,dPe=`#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`,hPe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,fPe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,mPe=`#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`,pPe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,gPe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,xPe=`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 );
- }`,bPe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,yPe=`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;`,vPe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,_Pe=`#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`,wPe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,SPe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,MPe=`#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`,EPe=`#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`,NPe=`#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`,APe=`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;
- }`,TPe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,CPe=`#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`,kPe=`#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`,jPe=`#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`,PPe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,RPe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,DPe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,OPe=`#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; }`,LPe=`#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`,IPe=`#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`,FPe=`#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`,UPe=`#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`,zPe=`#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`,BPe=`#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 $Pe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,HPe=`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>
- }`,VPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,GPe=`#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>
- }`,WPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,qPe=`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>
- }`,KPe=`#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;
- }`,XPe=`#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
- }`,YPe=`#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;
- }`,QPe=`#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 );
- }`,ZPe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,JPe=`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>
- }`,eRe=`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>
- }`,tRe=`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>
- }`,nRe=`#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>
- }`,rRe=`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>
- }`,iRe=`#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>
- }`,aRe=`#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>
- }`,sRe=`#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;
- }`,oRe=`#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>
- }`,lRe=`#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
- }`,cRe=`#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
- }`,uRe=`#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>
- }`,dRe=`#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>
- }`,hRe=`#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
- }`,fRe=`#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>
- }`,mRe=`#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>
- }`,pRe=`#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>
- }`,gRe=`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>
- }`,xRe=`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>
- }`,bRe=`#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>
- }`,yRe=`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>
- }`,vRe=`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>
- }`,_Re=`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>
- }`,pn={alphahash_fragment:Hje,alphahash_pars_fragment:Vje,alphamap_fragment:Gje,alphamap_pars_fragment:Wje,alphatest_fragment:qje,alphatest_pars_fragment:Kje,aomap_fragment:Xje,aomap_pars_fragment:Yje,batching_pars_vertex:Qje,batching_vertex:Zje,begin_vertex:Jje,beginnormal_vertex:e3e,bsdfs:t3e,iridescence_fragment:n3e,bumpmap_pars_fragment:r3e,clipping_planes_fragment:i3e,clipping_planes_pars_fragment:a3e,clipping_planes_pars_vertex:s3e,clipping_planes_vertex:o3e,color_fragment:l3e,color_pars_fragment:c3e,color_pars_vertex:u3e,color_vertex:d3e,common:h3e,cube_uv_reflection_fragment:f3e,defaultnormal_vertex:m3e,displacementmap_pars_vertex:p3e,displacementmap_vertex:g3e,emissivemap_fragment:x3e,emissivemap_pars_fragment:b3e,colorspace_fragment:y3e,colorspace_pars_fragment:v3e,envmap_fragment:_3e,envmap_common_pars_fragment:w3e,envmap_pars_fragment:S3e,envmap_pars_vertex:M3e,envmap_physical_pars_fragment:O3e,envmap_vertex:E3e,fog_vertex:N3e,fog_pars_vertex:A3e,fog_fragment:T3e,fog_pars_fragment:C3e,gradientmap_pars_fragment:k3e,lightmap_pars_fragment:j3e,lights_lambert_fragment:P3e,lights_lambert_pars_fragment:R3e,lights_pars_begin:D3e,lights_toon_fragment:L3e,lights_toon_pars_fragment:I3e,lights_phong_fragment:F3e,lights_phong_pars_fragment:U3e,lights_physical_fragment:z3e,lights_physical_pars_fragment:B3e,lights_fragment_begin:$3e,lights_fragment_maps:H3e,lights_fragment_end:V3e,logdepthbuf_fragment:G3e,logdepthbuf_pars_fragment:W3e,logdepthbuf_pars_vertex:q3e,logdepthbuf_vertex:K3e,map_fragment:X3e,map_pars_fragment:Y3e,map_particle_fragment:Q3e,map_particle_pars_fragment:Z3e,metalnessmap_fragment:J3e,metalnessmap_pars_fragment:ePe,morphinstance_vertex:tPe,morphcolor_vertex:nPe,morphnormal_vertex:rPe,morphtarget_pars_vertex:iPe,morphtarget_vertex:aPe,normal_fragment_begin:sPe,normal_fragment_maps:oPe,normal_pars_fragment:lPe,normal_pars_vertex:cPe,normal_vertex:uPe,normalmap_pars_fragment:dPe,clearcoat_normal_fragment_begin:hPe,clearcoat_normal_fragment_maps:fPe,clearcoat_pars_fragment:mPe,iridescence_pars_fragment:pPe,opaque_fragment:gPe,packing:xPe,premultiplied_alpha_fragment:bPe,project_vertex:yPe,dithering_fragment:vPe,dithering_pars_fragment:_Pe,roughnessmap_fragment:wPe,roughnessmap_pars_fragment:SPe,shadowmap_pars_fragment:MPe,shadowmap_pars_vertex:EPe,shadowmap_vertex:NPe,shadowmask_pars_fragment:APe,skinbase_vertex:TPe,skinning_pars_vertex:CPe,skinning_vertex:kPe,skinnormal_vertex:jPe,specularmap_fragment:PPe,specularmap_pars_fragment:RPe,tonemapping_fragment:DPe,tonemapping_pars_fragment:OPe,transmission_fragment:LPe,transmission_pars_fragment:IPe,uv_pars_fragment:FPe,uv_pars_vertex:UPe,uv_vertex:zPe,worldpos_vertex:BPe,background_vert:$Pe,background_frag:HPe,backgroundCube_vert:VPe,backgroundCube_frag:GPe,cube_vert:WPe,cube_frag:qPe,depth_vert:KPe,depth_frag:XPe,distanceRGBA_vert:YPe,distanceRGBA_frag:QPe,equirect_vert:ZPe,equirect_frag:JPe,linedashed_vert:eRe,linedashed_frag:tRe,meshbasic_vert:nRe,meshbasic_frag:rRe,meshlambert_vert:iRe,meshlambert_frag:aRe,meshmatcap_vert:sRe,meshmatcap_frag:oRe,meshnormal_vert:lRe,meshnormal_frag:cRe,meshphong_vert:uRe,meshphong_frag:dRe,meshphysical_vert:hRe,meshphysical_frag:fRe,meshtoon_vert:mRe,meshtoon_frag:pRe,points_vert:gRe,points_frag:xRe,shadow_vert:bRe,shadow_frag:yRe,sprite_vert:vRe,sprite_frag:_Re},kt={common:{diffuse:{value:new An(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new vn}},envmap:{envMap:{value:null},envMapRotation:{value:new vn},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 vn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new vn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new vn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new vn},normalScale:{value:new xn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new vn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new vn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new vn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new vn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new An(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 An(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0},uvTransform:{value:new vn}},sprite:{diffuse:{value:new An(16777215)},opacity:{value:1},center:{value:new xn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new vn},alphaMap:{value:null},alphaMapTransform:{value:new vn},alphaTest:{value:0}}},bl={basic:{uniforms:Oa([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.fog]),vertexShader:pn.meshbasic_vert,fragmentShader:pn.meshbasic_frag},lambert:{uniforms:Oa([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new An(0)}}]),vertexShader:pn.meshlambert_vert,fragmentShader:pn.meshlambert_frag},phong:{uniforms:Oa([kt.common,kt.specularmap,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,kt.lights,{emissive:{value:new An(0)},specular:{value:new An(1118481)},shininess:{value:30}}]),vertexShader:pn.meshphong_vert,fragmentShader:pn.meshphong_frag},standard:{uniforms:Oa([kt.common,kt.envmap,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.roughnessmap,kt.metalnessmap,kt.fog,kt.lights,{emissive:{value:new An(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag},toon:{uniforms:Oa([kt.common,kt.aomap,kt.lightmap,kt.emissivemap,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.gradientmap,kt.fog,kt.lights,{emissive:{value:new An(0)}}]),vertexShader:pn.meshtoon_vert,fragmentShader:pn.meshtoon_frag},matcap:{uniforms:Oa([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,kt.fog,{matcap:{value:null}}]),vertexShader:pn.meshmatcap_vert,fragmentShader:pn.meshmatcap_frag},points:{uniforms:Oa([kt.points,kt.fog]),vertexShader:pn.points_vert,fragmentShader:pn.points_frag},dashed:{uniforms:Oa([kt.common,kt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:pn.linedashed_vert,fragmentShader:pn.linedashed_frag},depth:{uniforms:Oa([kt.common,kt.displacementmap]),vertexShader:pn.depth_vert,fragmentShader:pn.depth_frag},normal:{uniforms:Oa([kt.common,kt.bumpmap,kt.normalmap,kt.displacementmap,{opacity:{value:1}}]),vertexShader:pn.meshnormal_vert,fragmentShader:pn.meshnormal_frag},sprite:{uniforms:Oa([kt.sprite,kt.fog]),vertexShader:pn.sprite_vert,fragmentShader:pn.sprite_frag},background:{uniforms:{uvTransform:{value:new vn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:pn.background_vert,fragmentShader:pn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new vn}},vertexShader:pn.backgroundCube_vert,fragmentShader:pn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:pn.cube_vert,fragmentShader:pn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:pn.equirect_vert,fragmentShader:pn.equirect_frag},distanceRGBA:{uniforms:Oa([kt.common,kt.displacementmap,{referencePosition:{value:new at},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:pn.distanceRGBA_vert,fragmentShader:pn.distanceRGBA_frag},shadow:{uniforms:Oa([kt.lights,kt.fog,{color:{value:new An(0)},opacity:{value:1}}]),vertexShader:pn.shadow_vert,fragmentShader:pn.shadow_frag}};bl.physical={uniforms:Oa([bl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new vn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new vn},clearcoatNormalScale:{value:new xn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new vn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new vn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new vn},sheen:{value:0},sheenColor:{value:new An(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new vn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new vn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new vn},transmissionSamplerSize:{value:new xn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new vn},attenuationDistance:{value:0},attenuationColor:{value:new An(0)},specularColor:{value:new An(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new vn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new vn},anisotropyVector:{value:new xn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new vn}}]),vertexShader:pn.meshphysical_vert,fragmentShader:pn.meshphysical_frag};const A_={r:0,b:0,g:0},bh=new zd,wRe=new yi;function SRe(t,e,n,r,i,a,o){const l=new An(0);let c=a===!0?0:1,u,d,f=null,p=0,g=null;function b(w){let A=w.isScene===!0?w.background:null;return A&&A.isTexture&&(A=(w.backgroundBlurriness>0?n:e).get(A)),A}function v(w){let A=!1;const N=b(w);N===null?y(l,c):N&&N.isColor&&(y(N,1),A=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,o):C==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||A)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil))}function x(w,A){const N=b(A);N&&(N.isCubeTexture||N.mapping===_M)?(d===void 0&&(d=new Ol(new Z4(1,1,1),new su({name:"BackgroundCubeMaterial",uniforms:rg(bl.backgroundCube.uniforms),vertexShader:bl.backgroundCube.vertexShader,fragmentShader:bl.backgroundCube.fragmentShader,side:ls,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,T,D){this.matrixWorld.copyPosition(D.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),bh.copy(A.backgroundRotation),bh.x*=-1,bh.y*=-1,bh.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(bh.y*=-1,bh.z*=-1),d.material.uniforms.envMap.value=N,d.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(wRe.makeRotationFromEuler(bh)),d.material.toneMapped=Fn.getTransfer(N.colorSpace)!==or,(f!==N||p!==N.version||g!==t.toneMapping)&&(d.material.needsUpdate=!0,f=N,p=N.version,g=t.toneMapping),d.layers.enableAll(),w.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new Ol(new eO(2,2),new su({name:"BackgroundMaterial",uniforms:rg(bl.background.uniforms),vertexShader:bl.background.vertexShader,fragmentShader:bl.background.fragmentShader,side:Ud,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=N,u.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,u.material.toneMapped=Fn.getTransfer(N.colorSpace)!==or,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(f!==N||p!==N.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=N,p=N.version,g=t.toneMapping),u.layers.enableAll(),w.unshift(u,u.geometry,u.material,0,0,null))}function y(w,A){w.getRGB(A_,lZ(t)),r.buffers.color.setClear(A_.r,A_.g,A_.b,A,o)}function E(){d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0),u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0)}return{getClearColor:function(){return l},setClearColor:function(w,A=1){l.set(w),c=A,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(w){c=w,y(l,c)},render:v,addToRenderList:x,dispose:E}}function MRe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=p(null);let a=i,o=!1;function l(P,z,L,X,R){let Y=!1;const J=f(X,L,z);a!==J&&(a=J,u(a.object)),Y=g(P,X,L,R),Y&&b(P,X,L,R),R!==null&&e.update(R,t.ELEMENT_ARRAY_BUFFER),(Y||o)&&(o=!1,A(P,z,L,X),R!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(R).buffer))}function c(){return t.createVertexArray()}function u(P){return t.bindVertexArray(P)}function d(P){return t.deleteVertexArray(P)}function f(P,z,L){const X=L.wireframe===!0;let R=r[P.id];R===void 0&&(R={},r[P.id]=R);let Y=R[z.id];Y===void 0&&(Y={},R[z.id]=Y);let J=Y[X];return J===void 0&&(J=p(c()),Y[X]=J),J}function p(P){const z=[],L=[],X=[];for(let R=0;R<n;R++)z[R]=0,L[R]=0,X[R]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:L,attributeDivisors:X,object:P,attributes:{},index:null}}function g(P,z,L,X){const R=a.attributes,Y=z.attributes;let J=0;const G=L.getAttributes();for(const W in G)if(G[W].location>=0){const K=R[W];let F=Y[W];if(F===void 0&&(W==="instanceMatrix"&&P.instanceMatrix&&(F=P.instanceMatrix),W==="instanceColor"&&P.instanceColor&&(F=P.instanceColor)),K===void 0||K.attribute!==F||F&&K.data!==F.data)return!0;J++}return a.attributesNum!==J||a.index!==X}function b(P,z,L,X){const R={},Y=z.attributes;let J=0;const G=L.getAttributes();for(const W in G)if(G[W].location>=0){let K=Y[W];K===void 0&&(W==="instanceMatrix"&&P.instanceMatrix&&(K=P.instanceMatrix),W==="instanceColor"&&P.instanceColor&&(K=P.instanceColor));const F={};F.attribute=K,K&&K.data&&(F.data=K.data),R[W]=F,J++}a.attributes=R,a.attributesNum=J,a.index=X}function v(){const P=a.newAttributes;for(let z=0,L=P.length;z<L;z++)P[z]=0}function x(P){y(P,0)}function y(P,z){const L=a.newAttributes,X=a.enabledAttributes,R=a.attributeDivisors;L[P]=1,X[P]===0&&(t.enableVertexAttribArray(P),X[P]=1),R[P]!==z&&(t.vertexAttribDivisor(P,z),R[P]=z)}function E(){const P=a.newAttributes,z=a.enabledAttributes;for(let L=0,X=z.length;L<X;L++)z[L]!==P[L]&&(t.disableVertexAttribArray(L),z[L]=0)}function w(P,z,L,X,R,Y,J){J===!0?t.vertexAttribIPointer(P,z,L,R,Y):t.vertexAttribPointer(P,z,L,X,R,Y)}function A(P,z,L,X){v();const R=X.attributes,Y=L.getAttributes(),J=z.defaultAttributeValues;for(const G in Y){const W=Y[G];if(W.location>=0){let ee=R[G];if(ee===void 0&&(G==="instanceMatrix"&&P.instanceMatrix&&(ee=P.instanceMatrix),G==="instanceColor"&&P.instanceColor&&(ee=P.instanceColor)),ee!==void 0){const K=ee.normalized,F=ee.itemSize,q=e.get(ee);if(q===void 0)continue;const ne=q.buffer,re=q.type,se=q.bytesPerElement,de=re===t.INT||re===t.UNSIGNED_INT||ee.gpuType===$4;if(ee.isInterleavedBufferAttribute){const pe=ee.data,Ce=pe.stride,oe=ee.offset;if(pe.isInstancedInterleavedBuffer){for(let ae=0;ae<W.locationSize;ae++)y(W.location+ae,pe.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=pe.meshPerAttribute*pe.count)}else for(let ae=0;ae<W.locationSize;ae++)x(W.location+ae);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let ae=0;ae<W.locationSize;ae++)w(W.location+ae,F/W.locationSize,re,K,Ce*se,(oe+F/W.locationSize*ae)*se,de)}else{if(ee.isInstancedBufferAttribute){for(let pe=0;pe<W.locationSize;pe++)y(W.location+pe,ee.meshPerAttribute);P.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let pe=0;pe<W.locationSize;pe++)x(W.location+pe);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let pe=0;pe<W.locationSize;pe++)w(W.location+pe,F/W.locationSize,re,K,F*se,F/W.locationSize*pe*se,de)}}else if(J!==void 0){const K=J[G];if(K!==void 0)switch(K.length){case 2:t.vertexAttrib2fv(W.location,K);break;case 3:t.vertexAttrib3fv(W.location,K);break;case 4:t.vertexAttrib4fv(W.location,K);break;default:t.vertexAttrib1fv(W.location,K)}}}}E()}function N(){D();for(const P in r){const z=r[P];for(const L in z){const X=z[L];for(const R in X)d(X[R].object),delete X[R];delete z[L]}delete r[P]}}function C(P){if(r[P.id]===void 0)return;const z=r[P.id];for(const L in z){const X=z[L];for(const R in X)d(X[R].object),delete X[R];delete z[L]}delete r[P.id]}function T(P){for(const z in r){const L=r[z];if(L[P.id]===void 0)continue;const X=L[P.id];for(const R in X)d(X[R].object),delete X[R];delete L[P.id]}}function D(){k(),o=!0,a!==i&&(a=i,u(a.object))}function k(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:D,resetDefaultState:k,dispose:N,releaseStatesOfGeometry:C,releaseStatesOfProgram:T,initAttributes:v,enableAttribute:x,disableUnusedAttributes:E}}function ERe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let g=0;for(let b=0;b<f;b++)g+=d[b];n.update(g,r,1)}function c(u,d,f,p){if(f===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let b=0;b<u.length;b++)o(u[b],d[b],p[b]);else{g.multiDrawArraysInstancedWEBGL(r,u,0,d,0,p,0,f);let b=0;for(let v=0;v<f;v++)b+=d[v]*p[v];n.update(b,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function NRe(t,e,n,r){let i;function a(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(T){return!(T!==qo&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(T){const D=T===Dg&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(T!==Dl&&r.convert(T)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Lc&&!D)}function c(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let u=n.precision!==void 0?n.precision:"highp";const d=c(u);d!==u&&(nn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=n.logarithmicDepthBuffer===!0,p=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),g=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),b=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),E=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),w=t.getParameter(t.MAX_VARYING_VECTORS),A=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=b>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:p,maxTextures:g,maxVertexTextures:b,maxTextureSize:v,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:E,maxVaryings:w,maxFragmentUniforms:A,vertexTextures:N,maxSamples:C}}function ARe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new nd,l=new vn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const g=f.length!==0||p||r!==0||i;return i=p,r=f.length,g},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,g){const b=f.clippingPlanes,v=f.clipIntersection,x=f.clipShadows,y=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const E=a?0:r,w=E*4;let A=y.clippingState||null;c.value=A,A=d(b,p,w,g);for(let N=0;N!==w;++N)A[N]=n[N];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,p,g,b){const v=f!==null?f.length:0;let x=null;if(v!==0){if(x=c.value,b!==!0||x===null){const y=g+v*4,E=p.matrixWorldInverse;l.getNormalMatrix(E),(x===null||x.length<y)&&(x=new Float32Array(y));for(let w=0,A=g;w!==v;++w,A+=4)o.copy(f[w]).applyMatrix4(E,l),o.normal.toArray(x,A),x[A+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,x}}function TRe(t){let e=new WeakMap;function n(o,l){return l===U3?o.mapping=eg:l===z3&&(o.mapping=tg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===U3||l===z3)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new Sje(c.height);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const fd=4,dH=[.125,.215,.35,.446,.526,.582],Ph=20,CRe=256,Xx=new gZ,hH=new An;let CC=null,kC=0,jC=0,PC=!1;const kRe=new at;let fH=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,r=.1,i=100,a={}){const{size:o=256,position:l=kRe}=a;CC=this._renderer.getRenderTarget(),kC=this._renderer.getActiveCubeFace(),jC=this._renderer.getActiveMipmapLevel(),PC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,r,i,c,l),n>0&&this._blur(c,0,0,n),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=gH(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=pH(),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(CC,kC,jC),this._renderer.xr.enabled=PC,e.scissorTest=!1,zm(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===eg||e.mapping===tg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),CC=this._renderer.getRenderTarget(),kC=this._renderer.getActiveCubeFace(),jC=this._renderer.getActiveMipmapLevel(),PC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:yo,minFilter:yo,generateMipmaps:!1,type:Dg,format:qo,colorSpace:ng,depthBuffer:!1},i=mH(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=mH(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=jRe(a)),this._blurMaterial=RRe(a,e,n),this._ggxMaterial=PRe(a,e,n)}return i}_compileMaterial(e){const n=new Ol(new Vl,e);this._renderer.compile(n,Xx)}_sceneToCubeUV(e,n,r,i,a){const c=new fo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,p=f.autoClear,g=f.toneMapping;f.getClearColor(hH),f.toneMapping=Sd,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ol(new Z4,new Q4({name:"PMREM.Background",side:ls,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,x=v.material;let y=!1;const E=e.background;E?E.isColor&&(x.color.copy(E),e.background=null,y=!0):(x.color.copy(hH),y=!0);for(let w=0;w<6;w++){const A=w%3;A===0?(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[w],a.y,a.z)):A===1?(c.up.set(0,0,u[w]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[w],a.z)):(c.up.set(0,u[w],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[w]));const N=this._cubeSize;zm(i,A*N,w>2?N:0,N,N),f.setRenderTarget(i),y&&f.render(v,c),f.render(e,c)}f.toneMapping=g,f.autoClear=p,e.background=E}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===eg||e.mapping===tg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=gH()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=pH());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;zm(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,Xx)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),p=.05+u*.95,g=f*p,{_lodMax:b}=this,v=this._sizeLods[r],x=3*v*(r>b-fd?r-b+fd:0),y=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=g,c.mipInt.value=b-n,zm(a,x,y,3*v,2*v),i.setRenderTarget(a),i.render(l,Xx),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=b-r,zm(e,x,y,3*v,2*v),i.setRenderTarget(e),i.render(l,Xx)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&ii("blur direction must be either latitudinal or longitudinal!");const d=3,f=this._lodMeshes[i];f.material=u;const p=u.uniforms,g=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*g):2*Math.PI/(2*Ph-1),v=a/b,x=isFinite(a)?1+Math.floor(d*v):Ph;x>Ph&&nn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Ph}`);const y=[];let E=0;for(let T=0;T<Ph;++T){const D=T/v,k=Math.exp(-D*D/2);y.push(k),T===0?E+=k:T<x&&(E+=2*k)}for(let T=0;T<y.length;T++)y[T]=y[T]/E;p.envMap.value=e.texture,p.samples.value=x,p.weights.value=y,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:w}=this;p.dTheta.value=b,p.mipInt.value=w-r;const A=this._sizeLods[i],N=3*A*(i>w-fd?i-w+fd:0),C=4*(this._cubeSize-A);zm(n,N,C,3*A,2*A),c.setRenderTarget(n),c.render(f,Xx)}};function jRe(t){const e=[],n=[],r=[];let i=t;const a=t-fd+1+dH.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-fd?c=dH[o-t+fd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],g=6,b=6,v=3,x=2,y=1,E=new Float32Array(v*b*g),w=new Float32Array(x*b*g),A=new Float32Array(y*b*g);for(let C=0;C<g;C++){const T=C%3*2/3-1,D=C>2?0:-1,k=[T,D,0,T+2/3,D,0,T+2/3,D+1,0,T,D,0,T+2/3,D+1,0,T,D+1,0];E.set(k,v*b*C),w.set(p,x*b*C);const P=[C,C,C,C,C,C];A.set(P,y*b*C)}const N=new Vl;N.setAttribute("position",new vo(E,v)),N.setAttribute("uv",new vo(w,x)),N.setAttribute("faceIndex",new vo(A,y)),r.push(new Ol(N,null)),i>fd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function mH(t,e,n){const r=new Tf(t,e,n);return r.texture.mapping=_M,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function zm(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function PRe(t,e,n){return new su({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:CRe,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:SM(),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:$c,depthTest:!1,depthWrite:!1})}function RRe(t,e,n){const r=new Float32Array(Ph),i=new at(0,1,0);return new su({name:"SphericalGaussianBlur",defines:{n:Ph,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:SM(),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:$c,depthTest:!1,depthWrite:!1})}function pH(){return new su({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:SM(),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:$c,depthTest:!1,depthWrite:!1})}function gH(){return new su({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:SM(),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:$c,depthTest:!1,depthWrite:!1})}function SM(){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 DRe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===U3||c===z3,d=c===eg||c===tg;if(u||d){let f=e.get(l);const p=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==p)return n===null&&(n=new fH(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const g=l.image;return u&&g&&g.height>0||d&&g&&i(g)?(n===null&&(n=new fH(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function ORe(t){const e={};function n(r){if(e[r]!==void 0)return e[r];const i=t.getExtension(r);return e[r]=i,i}return{has:function(r){return n(r)!==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(r){const i=n(r);return i===null&&x0("WebGLRenderer: "+r+" extension not supported."),i}}}function LRe(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const b in p.attributes)e.remove(p.attributes[b]);p.removeEventListener("dispose",o),delete i[p.id];const g=a.get(p);g&&(e.remove(g),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const g in p)e.update(p[g],t.ARRAY_BUFFER)}function u(f){const p=[],g=f.index,b=f.attributes.position;let v=0;if(g!==null){const E=g.array;v=g.version;for(let w=0,A=E.length;w<A;w+=3){const N=E[w+0],C=E[w+1],T=E[w+2];p.push(N,C,C,T,T,N)}}else if(b!==void 0){const E=b.array;v=b.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const N=w+0,C=w+1,T=w+2;p.push(N,C,C,T,T,N)}}else return;const x=new(XQ(p)?aZ:iZ)(p,1);x.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,x)}function d(f){const p=a.get(f);if(p){const g=f.index;g!==null&&p.version<g.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function IRe(t,e,n){let r;function i(p){r=p}let a,o;function l(p){a=p.type,o=p.bytesPerElement}function c(p,g){t.drawElements(r,g,a,p*o),n.update(g,r,1)}function u(p,g,b){b!==0&&(t.drawElementsInstanced(r,g,a,p*o,b),n.update(g,r,b))}function d(p,g,b){if(b===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,g,0,a,p,0,b);let x=0;for(let y=0;y<b;y++)x+=g[y];n.update(x,r,1)}function f(p,g,b,v){if(b===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let y=0;y<p.length;y++)u(p[y]/o,g[y],v[y]);else{x.multiDrawElementsInstancedWEBGL(r,g,0,a,p,0,v,0,b);let y=0;for(let E=0;E<b;E++)y+=g[E]*v[E];n.update(y,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function FRe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:ii("WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function URe(t,e,n){const r=new WeakMap,i=new mi;function a(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let p=r.get(l);if(p===void 0||p.count!==f){let P=function(){D.dispose(),r.delete(l),l.removeEventListener("dispose",P)};var g=P;p!==void 0&&p.texture.dispose();const b=l.morphAttributes.position!==void 0,v=l.morphAttributes.normal!==void 0,x=l.morphAttributes.color!==void 0,y=l.morphAttributes.position||[],E=l.morphAttributes.normal||[],w=l.morphAttributes.color||[];let A=0;b===!0&&(A=1),v===!0&&(A=2),x===!0&&(A=3);let N=l.attributes.position.count*A,C=1;N>e.maxTextureSize&&(C=Math.ceil(N/e.maxTextureSize),N=e.maxTextureSize);const T=new Float32Array(N*C*4*f),D=new eZ(T,N,C,f);D.type=Lc,D.needsUpdate=!0;const k=A*4;for(let z=0;z<f;z++){const L=y[z],X=E[z],R=w[z],Y=N*C*4*z;for(let J=0;J<L.count;J++){const G=J*k;b===!0&&(i.fromBufferAttribute(L,J),T[Y+G+0]=i.x,T[Y+G+1]=i.y,T[Y+G+2]=i.z,T[Y+G+3]=0),v===!0&&(i.fromBufferAttribute(X,J),T[Y+G+4]=i.x,T[Y+G+5]=i.y,T[Y+G+6]=i.z,T[Y+G+7]=0),x===!0&&(i.fromBufferAttribute(R,J),T[Y+G+8]=i.x,T[Y+G+9]=i.y,T[Y+G+10]=i.z,T[Y+G+11]=R.itemSize===4?i.w:1)}}p={count:f,texture:D,size:new xn(N,C)},r.set(l,p),l.addEventListener("dispose",P)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let b=0;for(let x=0;x<u.length;x++)b+=u[x];const v=l.morphTargetsRelative?1:1-b;c.getUniforms().setValue(t,"morphTargetBaseInfluence",v),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:a}}function zRe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}const bZ=new il,xH=new hZ(1,1),yZ=new eZ,vZ=new sje,_Z=new uZ,bH=[],yH=[],vH=new Float32Array(16),_H=new Float32Array(9),wH=new Float32Array(4);function Lg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=bH[i];if(a===void 0&&(a=new Float32Array(i),bH[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ai(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Ti(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function MM(t,e){let n=yH[e];n===void 0&&(n=new Int32Array(e),yH[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function BRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function $Re(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(Ai(n,e))return;t.uniform2fv(this.addr,e),Ti(n,e)}}function HRe(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(Ai(n,e))return;t.uniform3fv(this.addr,e),Ti(n,e)}}function VRe(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(Ai(n,e))return;t.uniform4fv(this.addr,e),Ti(n,e)}}function GRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;wH.set(r),t.uniformMatrix2fv(this.addr,!1,wH),Ti(n,r)}}function WRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;_H.set(r),t.uniformMatrix3fv(this.addr,!1,_H),Ti(n,r)}}function qRe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ai(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),Ti(n,e)}else{if(Ai(n,r))return;vH.set(r),t.uniformMatrix4fv(this.addr,!1,vH),Ti(n,r)}}function KRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function XRe(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(Ai(n,e))return;t.uniform2iv(this.addr,e),Ti(n,e)}}function YRe(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(Ai(n,e))return;t.uniform3iv(this.addr,e),Ti(n,e)}}function QRe(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(Ai(n,e))return;t.uniform4iv(this.addr,e),Ti(n,e)}}function ZRe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function JRe(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(Ai(n,e))return;t.uniform2uiv(this.addr,e),Ti(n,e)}}function eDe(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(Ai(n,e))return;t.uniform3uiv(this.addr,e),Ti(n,e)}}function tDe(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(Ai(n,e))return;t.uniform4uiv(this.addr,e),Ti(n,e)}}function nDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(xH.compareFunction=KQ,a=xH):a=bZ,n.setTexture2D(e||a,i)}function rDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||vZ,i)}function iDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||_Z,i)}function aDe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||yZ,i)}function sDe(t){switch(t){case 5126:return BRe;case 35664:return $Re;case 35665:return HRe;case 35666:return VRe;case 35674:return GRe;case 35675:return WRe;case 35676:return qRe;case 5124:case 35670:return KRe;case 35667:case 35671:return XRe;case 35668:case 35672:return YRe;case 35669:case 35673:return QRe;case 5125:return ZRe;case 36294:return JRe;case 36295:return eDe;case 36296:return tDe;case 35678:case 36198:case 36298:case 36306:case 35682:return nDe;case 35679:case 36299:case 36307:return rDe;case 35680:case 36300:case 36308:case 36293:return iDe;case 36289:case 36303:case 36311:case 36292:return aDe}}function oDe(t,e){t.uniform1fv(this.addr,e)}function lDe(t,e){const n=Lg(e,this.size,2);t.uniform2fv(this.addr,n)}function cDe(t,e){const n=Lg(e,this.size,3);t.uniform3fv(this.addr,n)}function uDe(t,e){const n=Lg(e,this.size,4);t.uniform4fv(this.addr,n)}function dDe(t,e){const n=Lg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function hDe(t,e){const n=Lg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function fDe(t,e){const n=Lg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function mDe(t,e){t.uniform1iv(this.addr,e)}function pDe(t,e){t.uniform2iv(this.addr,e)}function gDe(t,e){t.uniform3iv(this.addr,e)}function xDe(t,e){t.uniform4iv(this.addr,e)}function bDe(t,e){t.uniform1uiv(this.addr,e)}function yDe(t,e){t.uniform2uiv(this.addr,e)}function vDe(t,e){t.uniform3uiv(this.addr,e)}function _De(t,e){t.uniform4uiv(this.addr,e)}function wDe(t,e,n){const r=this.cache,i=e.length,a=MM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||bZ,a[o])}function SDe(t,e,n){const r=this.cache,i=e.length,a=MM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||vZ,a[o])}function MDe(t,e,n){const r=this.cache,i=e.length,a=MM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||_Z,a[o])}function EDe(t,e,n){const r=this.cache,i=e.length,a=MM(n,i);Ai(r,a)||(t.uniform1iv(this.addr,a),Ti(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||yZ,a[o])}function NDe(t){switch(t){case 5126:return oDe;case 35664:return lDe;case 35665:return cDe;case 35666:return uDe;case 35674:return dDe;case 35675:return hDe;case 35676:return fDe;case 5124:case 35670:return mDe;case 35667:case 35671:return pDe;case 35668:case 35672:return gDe;case 35669:case 35673:return xDe;case 5125:return bDe;case 36294:return yDe;case 36295:return vDe;case 36296:return _De;case 35678:case 36198:case 36298:case 36306:case 35682:return wDe;case 35679:case 36299:case 36307:return SDe;case 35680:case 36300:case 36308:case 36293:return MDe;case 36289:case 36303:case 36311:case 36292:return EDe}}let ADe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=sDe(n.type)}},TDe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=NDe(n.type)}},CDe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}};const RC=/(\w+)(\])?(\[|\.)?/g;function SH(t,e){t.seq.push(e),t.map[e.id]=e}function kDe(t,e,n){const r=t.name,i=r.length;for(RC.lastIndex=0;;){const a=RC.exec(r),o=RC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){SH(n,u===void 0?new ADe(l,t,e):new TDe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new CDe(l),SH(n,f)),n=f}}}let $1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);kDe(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function MH(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const jDe=37297;let PDe=0;function RDe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}const EH=new vn;function DDe(t){Fn._getMatrix(EH,Fn.workingColorSpace,t);const e=`mat3( ${EH.elements.map(n=>n.toFixed(4))} )`;switch(Fn.getTransfer(t)){case aS:return[e,"LinearTransferOETF"];case or:return[e,"sRGBTransferOETF"];default:return nn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function NH(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+a+`
- `+RDe(t.getShaderSource(e),l)}else return a}function ODe(t,e){const n=DDe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function LDe(t,e){let n;switch(e){case Rke:n="Linear";break;case Dke:n="Reinhard";break;case Oke:n="Cineon";break;case Lke:n="ACESFilmic";break;case Fke:n="AgX";break;case Uke:n="Neutral";break;case Ike:n="Custom";break;default:nn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const T_=new at;function IDe(){Fn.getLuminanceCoefficients(T_);const t=T_.x.toFixed(4),e=T_.y.toFixed(4),n=T_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function FDe(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ub).join(`
- `)}function UDe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function zDe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function ub(t){return t!==""}function AH(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 TH(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const BDe=/^[ \t]*#include +<([\w\d./]+)>/gm;function yP(t){return t.replace(BDe,HDe)}const $De=new Map;function HDe(t,e){let n=pn[e];if(n===void 0){const r=$De.get(e);if(r!==void 0)n=pn[r],nn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return yP(n)}const VDe=/#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 CH(t){return t.replace(VDe,GDe)}function GDe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function kH(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 WDe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===FQ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===hke?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Sc&&(e="SHADOWMAP_TYPE_VSM"),e}function qDe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case eg:case tg:e="ENVMAP_TYPE_CUBE";break;case _M:e="ENVMAP_TYPE_CUBE_UV";break}return e}function KDe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case tg:e="ENVMAP_MODE_REFRACTION";break}return e}function XDe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case B4:e="ENVMAP_BLENDING_MULTIPLY";break;case jke:e="ENVMAP_BLENDING_MIX";break;case Pke:e="ENVMAP_BLENDING_ADD";break}return e}function YDe(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}function QDe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=WDe(n),u=qDe(n),d=KDe(n),f=XDe(n),p=YDe(n),g=FDe(n),b=UDe(a),v=i.createProgram();let x,y,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ub).join(`
- `),x.length>0&&(x+=`
- `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(ub).join(`
- `),y.length>0&&(y+=`
- `)):(x=[kH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",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(ub).join(`
- `),y=[kH(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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 "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",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!==Sd?"#define TONE_MAPPING":"",n.toneMapping!==Sd?pn.tonemapping_pars_fragment:"",n.toneMapping!==Sd?LDe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",pn.colorspace_pars_fragment,ODe("linearToOutputTexel",n.outputColorSpace),IDe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(ub).join(`
- `)),o=yP(o),o=AH(o,n),o=TH(o,n),l=yP(l),l=AH(l,n),l=TH(l,n),o=CH(o),l=CH(l),n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,x=[g,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,y=["#define varying in",n.glslVersion===I$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===I$?"":"#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(`
- `)+`
- `+y);const w=E+x+o,A=E+y+l,N=MH(i,i.VERTEX_SHADER,w),C=MH(i,i.FRAGMENT_SHADER,A);i.attachShader(v,N),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function T(z){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v)||"",X=i.getShaderInfoLog(N)||"",R=i.getShaderInfoLog(C)||"",Y=L.trim(),J=X.trim(),G=R.trim();let W=!0,ee=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(W=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,N,C);else{const K=NH(i,N,"vertex"),F=NH(i,C,"fragment");ii("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Material Name: `+z.name+`
- Material Type: `+z.type+`
- Program Info Log: `+Y+`
- `+K+`
- `+F)}else Y!==""?nn("WebGLProgram: Program Info Log:",Y):(J===""||G==="")&&(ee=!1);ee&&(z.diagnostics={runnable:W,programLog:Y,vertexShader:{log:J,prefix:x},fragmentShader:{log:G,prefix:y}})}i.deleteShader(N),i.deleteShader(C),D=new $1(i,v),k=zDe(i,v)}let D;this.getUniforms=function(){return D===void 0&&T(this),D};let k;this.getAttributes=function(){return k===void 0&&T(this),k};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(v,jDe)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=PDe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=N,this.fragmentShader=C,this}let ZDe=0,JDe=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.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 r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new e4e(e),n.set(e,r)),r}},e4e=class{constructor(e){this.id=ZDe++,this.code=e,this.usedTimes=0}};function t4e(t,e,n,r,i,a,o){const l=new nZ,c=new JDe,u=new Set,d=[],f=i.logarithmicDepthBuffer,p=i.vertexTextures;let g=i.precision;const b={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 v(k){return u.add(k),k===0?"uv":`uv${k}`}function x(k,P,z,L,X){const R=L.fog,Y=X.geometry,J=k.isMeshStandardMaterial?L.environment:null,G=(k.isMeshStandardMaterial?n:e).get(k.envMap||J),W=G&&G.mapping===_M?G.image.height:null,ee=b[k.type];k.precision!==null&&(g=i.getMaxPrecision(k.precision),g!==k.precision&&nn("WebGLProgram.getParameters:",k.precision,"not supported, using",g,"instead."));const K=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,F=K!==void 0?K.length:0;let q=0;Y.morphAttributes.position!==void 0&&(q=1),Y.morphAttributes.normal!==void 0&&(q=2),Y.morphAttributes.color!==void 0&&(q=3);let ne,re,se,de;if(ee){const Rt=bl[ee];ne=Rt.vertexShader,re=Rt.fragmentShader}else ne=k.vertexShader,re=k.fragmentShader,c.update(k),se=c.getVertexShaderID(k),de=c.getFragmentShaderID(k);const pe=t.getRenderTarget(),Ce=t.state.buffers.depth.getReversed(),oe=X.isInstancedMesh===!0,ae=X.isBatchedMesh===!0,ge=!!k.map,ue=!!k.matcap,Le=!!G,V=!!k.aoMap,$=!!k.lightMap,Z=!!k.bumpMap,B=!!k.normalMap,U=!!k.displacementMap,Q=!!k.emissiveMap,Me=!!k.metalnessMap,Te=!!k.roughnessMap,fe=k.anisotropy>0,H=k.clearcoat>0,I=k.dispersion>0,ce=k.iridescence>0,we=k.sheen>0,Se=k.transmission>0,_e=fe&&!!k.anisotropyMap,st=H&&!!k.clearcoatMap,Ve=H&&!!k.clearcoatNormalMap,it=H&&!!k.clearcoatRoughnessMap,ct=ce&&!!k.iridescenceMap,Fe=ce&&!!k.iridescenceThicknessMap,me=we&&!!k.sheenColorMap,Ke=we&&!!k.sheenRoughnessMap,qe=!!k.specularMap,Qe=!!k.specularColorMap,ut=!!k.specularIntensityMap,ie=Se&&!!k.transmissionMap,He=Se&&!!k.thicknessMap,ve=!!k.gradientMap,Be=!!k.alphaMap,je=k.alphaTest>0,Ne=!!k.alphaHash,Xe=!!k.extensions;let mt=Sd;k.toneMapped&&(pe===null||pe.isXRRenderTarget===!0)&&(mt=t.toneMapping);const At={shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:ne,fragmentShader:re,defines:k.defines,customVertexShaderID:se,customFragmentShaderID:de,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:g,batching:ae,batchingColor:ae&&X._colorsTexture!==null,instancing:oe,instancingColor:oe&&X.instanceColor!==null,instancingMorph:oe&&X.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:pe===null?t.outputColorSpace:pe.isXRRenderTarget===!0?pe.texture.colorSpace:ng,alphaToCoverage:!!k.alphaToCoverage,map:ge,matcap:ue,envMap:Le,envMapMode:Le&&G.mapping,envMapCubeUVHeight:W,aoMap:V,lightMap:$,bumpMap:Z,normalMap:B,displacementMap:p&&U,emissiveMap:Q,normalMapObjectSpace:B&&k.normalMapType===Hke,normalMapTangentSpace:B&&k.normalMapType===qQ,metalnessMap:Me,roughnessMap:Te,anisotropy:fe,anisotropyMap:_e,clearcoat:H,clearcoatMap:st,clearcoatNormalMap:Ve,clearcoatRoughnessMap:it,dispersion:I,iridescence:ce,iridescenceMap:ct,iridescenceThicknessMap:Fe,sheen:we,sheenColorMap:me,sheenRoughnessMap:Ke,specularMap:qe,specularColorMap:Qe,specularIntensityMap:ut,transmission:Se,transmissionMap:ie,thicknessMap:He,gradientMap:ve,opaque:k.transparent===!1&&k.blending===jp&&k.alphaToCoverage===!1,alphaMap:Be,alphaTest:je,alphaHash:Ne,combine:k.combine,mapUv:ge&&v(k.map.channel),aoMapUv:V&&v(k.aoMap.channel),lightMapUv:$&&v(k.lightMap.channel),bumpMapUv:Z&&v(k.bumpMap.channel),normalMapUv:B&&v(k.normalMap.channel),displacementMapUv:U&&v(k.displacementMap.channel),emissiveMapUv:Q&&v(k.emissiveMap.channel),metalnessMapUv:Me&&v(k.metalnessMap.channel),roughnessMapUv:Te&&v(k.roughnessMap.channel),anisotropyMapUv:_e&&v(k.anisotropyMap.channel),clearcoatMapUv:st&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:Ve&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:ct&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:Fe&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:me&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:Ke&&v(k.sheenRoughnessMap.channel),specularMapUv:qe&&v(k.specularMap.channel),specularColorMapUv:Qe&&v(k.specularColorMap.channel),specularIntensityMapUv:ut&&v(k.specularIntensityMap.channel),transmissionMapUv:ie&&v(k.transmissionMap.channel),thicknessMapUv:He&&v(k.thicknessMap.channel),alphaMapUv:Be&&v(k.alphaMap.channel),vertexTangents:!!Y.attributes.tangent&&(B||fe),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,pointsUvs:X.isPoints===!0&&!!Y.attributes.uv&&(ge||Be),fog:!!R,useFog:k.fog===!0,fogExp2:!!R&&R.isFogExp2,flatShading:k.flatShading===!0&&k.wireframe===!1,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ce,skinning:X.isSkinnedMesh===!0,morphTargets:Y.morphAttributes.position!==void 0,morphNormals:Y.morphAttributes.normal!==void 0,morphColors:Y.morphAttributes.color!==void 0,morphTargetsCount:F,morphTextureStride:q,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:mt,decodeVideoTexture:ge&&k.map.isVideoTexture===!0&&Fn.getTransfer(k.map.colorSpace)===or,decodeVideoTextureEmissive:Q&&k.emissiveMap.isVideoTexture===!0&&Fn.getTransfer(k.emissiveMap.colorSpace)===or,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===yl,flipSided:k.side===ls,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Xe&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Xe&&k.extensions.multiDraw===!0||ae)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return At.vertexUv1s=u.has(1),At.vertexUv2s=u.has(2),At.vertexUv3s=u.has(3),u.clear(),At}function y(k){const P=[];if(k.shaderID?P.push(k.shaderID):(P.push(k.customVertexShaderID),P.push(k.customFragmentShaderID)),k.defines!==void 0)for(const z in k.defines)P.push(z),P.push(k.defines[z]);return k.isRawShaderMaterial===!1&&(E(P,k),w(P,k),P.push(t.outputColorSpace)),P.push(k.customProgramCacheKey),P.join()}function E(k,P){k.push(P.precision),k.push(P.outputColorSpace),k.push(P.envMapMode),k.push(P.envMapCubeUVHeight),k.push(P.mapUv),k.push(P.alphaMapUv),k.push(P.lightMapUv),k.push(P.aoMapUv),k.push(P.bumpMapUv),k.push(P.normalMapUv),k.push(P.displacementMapUv),k.push(P.emissiveMapUv),k.push(P.metalnessMapUv),k.push(P.roughnessMapUv),k.push(P.anisotropyMapUv),k.push(P.clearcoatMapUv),k.push(P.clearcoatNormalMapUv),k.push(P.clearcoatRoughnessMapUv),k.push(P.iridescenceMapUv),k.push(P.iridescenceThicknessMapUv),k.push(P.sheenColorMapUv),k.push(P.sheenRoughnessMapUv),k.push(P.specularMapUv),k.push(P.specularColorMapUv),k.push(P.specularIntensityMapUv),k.push(P.transmissionMapUv),k.push(P.thicknessMapUv),k.push(P.combine),k.push(P.fogExp2),k.push(P.sizeAttenuation),k.push(P.morphTargetsCount),k.push(P.morphAttributeCount),k.push(P.numDirLights),k.push(P.numPointLights),k.push(P.numSpotLights),k.push(P.numSpotLightMaps),k.push(P.numHemiLights),k.push(P.numRectAreaLights),k.push(P.numDirLightShadows),k.push(P.numPointLightShadows),k.push(P.numSpotLightShadows),k.push(P.numSpotLightShadowsWithMaps),k.push(P.numLightProbes),k.push(P.shadowMapType),k.push(P.toneMapping),k.push(P.numClippingPlanes),k.push(P.numClipIntersection),k.push(P.depthPacking)}function w(k,P){l.disableAll(),P.supportsVertexTextures&&l.enable(0),P.instancing&&l.enable(1),P.instancingColor&&l.enable(2),P.instancingMorph&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),P.dispersion&&l.enable(20),P.batchingColor&&l.enable(21),P.gradientMap&&l.enable(22),k.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.reversedDepthBuffer&&l.enable(4),P.skinning&&l.enable(5),P.morphTargets&&l.enable(6),P.morphNormals&&l.enable(7),P.morphColors&&l.enable(8),P.premultipliedAlpha&&l.enable(9),P.shadowMapEnabled&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),P.decodeVideoTextureEmissive&&l.enable(20),P.alphaToCoverage&&l.enable(21),k.push(l.mask)}function A(k){const P=b[k.type];let z;if(P){const L=bl[P];z=yje.clone(L.uniforms)}else z=k.uniforms;return z}function N(k,P){let z;for(let L=0,X=d.length;L<X;L++){const R=d[L];if(R.cacheKey===P){z=R,++z.usedTimes;break}}return z===void 0&&(z=new QDe(t,P,k,a),d.push(z)),z}function C(k){if(--k.usedTimes===0){const P=d.indexOf(k);d[P]=d[d.length-1],d.pop(),k.destroy()}}function T(k){c.remove(k)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:y,getUniforms:A,acquireProgram:N,releaseProgram:C,releaseShaderCache:T,programs:d,dispose:D}}function n4e(){let t=new WeakMap;function e(o){return t.has(o)}function n(o){let l=t.get(o);return l===void 0&&(l={},t.set(o,l)),l}function r(o){t.delete(o)}function i(o,l,c){t.get(o)[l]=c}function a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function r4e(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 jH(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 PH(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,g,b,v,x){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:p,material:g,groupOrder:b,renderOrder:f.renderOrder,z:v,group:x},t[e]=y):(y.id=f.id,y.object=f,y.geometry=p,y.material=g,y.groupOrder=b,y.renderOrder=f.renderOrder,y.z=v,y.group=x),e++,y}function l(f,p,g,b,v,x){const y=o(f,p,g,b,v,x);g.transmission>0?r.push(y):g.transparent===!0?i.push(y):n.push(y)}function c(f,p,g,b,v,x){const y=o(f,p,g,b,v,x);g.transmission>0?r.unshift(y):g.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,p){n.length>1&&n.sort(f||r4e),r.length>1&&r.sort(p||jH),i.length>1&&i.sort(p||jH)}function d(){for(let f=e,p=t.length;f<p;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:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function i4e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new PH,t.set(r,[o])):i>=a.length?(o=new PH,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function a4e(){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 at,color:new An};break;case"SpotLight":n={position:new at,direction:new at,color:new An,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new at,color:new An,distance:0,decay:0};break;case"HemisphereLight":n={direction:new at,skyColor:new An,groundColor:new An};break;case"RectAreaLight":n={color:new An,position:new at,halfWidth:new at,halfHeight:new at};break}return t[e.id]=n,n}}}function s4e(){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 xn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let o4e=0;function l4e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function c4e(t){const e=new a4e,n=s4e(),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 at);const i=new at,a=new yi,o=new yi;function l(u){let d=0,f=0,p=0;for(let k=0;k<9;k++)r.probe[k].set(0,0,0);let g=0,b=0,v=0,x=0,y=0,E=0,w=0,A=0,N=0,C=0,T=0;u.sort(l4e);for(let k=0,P=u.length;k<P;k++){const z=u[k],L=z.color,X=z.intensity,R=z.distance,Y=z.shadow&&z.shadow.map?z.shadow.map.texture:null;if(z.isAmbientLight)d+=L.r*X,f+=L.g*X,p+=L.b*X;else if(z.isLightProbe){for(let J=0;J<9;J++)r.probe[J].addScaledVector(z.sh.coefficients[J],X);T++}else if(z.isDirectionalLight){const J=e.get(z);if(J.color.copy(z.color).multiplyScalar(z.intensity),z.castShadow){const G=z.shadow,W=n.get(z);W.shadowIntensity=G.intensity,W.shadowBias=G.bias,W.shadowNormalBias=G.normalBias,W.shadowRadius=G.radius,W.shadowMapSize=G.mapSize,r.directionalShadow[g]=W,r.directionalShadowMap[g]=Y,r.directionalShadowMatrix[g]=z.shadow.matrix,E++}r.directional[g]=J,g++}else if(z.isSpotLight){const J=e.get(z);J.position.setFromMatrixPosition(z.matrixWorld),J.color.copy(L).multiplyScalar(X),J.distance=R,J.coneCos=Math.cos(z.angle),J.penumbraCos=Math.cos(z.angle*(1-z.penumbra)),J.decay=z.decay,r.spot[v]=J;const G=z.shadow;if(z.map&&(r.spotLightMap[N]=z.map,N++,G.updateMatrices(z),z.castShadow&&C++),r.spotLightMatrix[v]=G.matrix,z.castShadow){const W=n.get(z);W.shadowIntensity=G.intensity,W.shadowBias=G.bias,W.shadowNormalBias=G.normalBias,W.shadowRadius=G.radius,W.shadowMapSize=G.mapSize,r.spotShadow[v]=W,r.spotShadowMap[v]=Y,A++}v++}else if(z.isRectAreaLight){const J=e.get(z);J.color.copy(L).multiplyScalar(X),J.halfWidth.set(z.width*.5,0,0),J.halfHeight.set(0,z.height*.5,0),r.rectArea[x]=J,x++}else if(z.isPointLight){const J=e.get(z);if(J.color.copy(z.color).multiplyScalar(z.intensity),J.distance=z.distance,J.decay=z.decay,z.castShadow){const G=z.shadow,W=n.get(z);W.shadowIntensity=G.intensity,W.shadowBias=G.bias,W.shadowNormalBias=G.normalBias,W.shadowRadius=G.radius,W.shadowMapSize=G.mapSize,W.shadowCameraNear=G.camera.near,W.shadowCameraFar=G.camera.far,r.pointShadow[b]=W,r.pointShadowMap[b]=Y,r.pointShadowMatrix[b]=z.shadow.matrix,w++}r.point[b]=J,b++}else if(z.isHemisphereLight){const J=e.get(z);J.skyColor.copy(z.color).multiplyScalar(X),J.groundColor.copy(z.groundColor).multiplyScalar(X),r.hemi[y]=J,y++}}x>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=kt.LTC_FLOAT_1,r.rectAreaLTC2=kt.LTC_FLOAT_2):(r.rectAreaLTC1=kt.LTC_HALF_1,r.rectAreaLTC2=kt.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=p;const D=r.hash;(D.directionalLength!==g||D.pointLength!==b||D.spotLength!==v||D.rectAreaLength!==x||D.hemiLength!==y||D.numDirectionalShadows!==E||D.numPointShadows!==w||D.numSpotShadows!==A||D.numSpotMaps!==N||D.numLightProbes!==T)&&(r.directional.length=g,r.spot.length=v,r.rectArea.length=x,r.point.length=b,r.hemi.length=y,r.directionalShadow.length=E,r.directionalShadowMap.length=E,r.pointShadow.length=w,r.pointShadowMap.length=w,r.spotShadow.length=A,r.spotShadowMap.length=A,r.directionalShadowMatrix.length=E,r.pointShadowMatrix.length=w,r.spotLightMatrix.length=A+N-C,r.spotLightMap.length=N,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=T,D.directionalLength=g,D.pointLength=b,D.spotLength=v,D.rectAreaLength=x,D.hemiLength=y,D.numDirectionalShadows=E,D.numPointShadows=w,D.numSpotShadows=A,D.numSpotMaps=N,D.numLightProbes=T,r.version=o4e++)}function c(u,d){let f=0,p=0,g=0,b=0,v=0;const x=d.matrixWorldInverse;for(let y=0,E=u.length;y<E;y++){const w=u[y];if(w.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(x),f++}else if(w.isSpotLight){const A=r.spot[g];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(x),A.direction.setFromMatrixPosition(w.matrixWorld),i.setFromMatrixPosition(w.target.matrixWorld),A.direction.sub(i),A.direction.transformDirection(x),g++}else if(w.isRectAreaLight){const A=r.rectArea[b];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(x),o.identity(),a.copy(w.matrixWorld),a.premultiply(x),o.extractRotation(a),A.halfWidth.set(w.width*.5,0,0),A.halfHeight.set(0,w.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),b++}else if(w.isPointLight){const A=r.point[p];A.position.setFromMatrixPosition(w.matrixWorld),A.position.applyMatrix4(x),p++}else if(w.isHemisphereLight){const A=r.hemi[v];A.direction.setFromMatrixPosition(w.matrixWorld),A.direction.transformDirection(x),v++}}}return{setup:l,setupView:c,state:r}}function RH(t){const e=new c4e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(d){n.push(d)}function o(d){r.push(d)}function l(){e.setup(n)}function c(d){e.setupView(n,d)}const u={lightsArray:n,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:u,setupLights:l,setupLightsView:c,pushLight:a,pushShadow:o}}function u4e(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new RH(t),e.set(i,[l])):a>=o.length?(l=new RH(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const d4e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,h4e=`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 f4e(t,e,n){let r=new J4;const i=new xn,a=new xn,o=new mi,l=new Rje({depthPacking:$ke}),c=new Dje,u={},d=n.maxTextureSize,f={[Ud]:ls,[ls]:Ud,[yl]:yl},p=new su({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xn},radius:{value:4}},vertexShader:d4e,fragmentShader:h4e}),g=p.clone();g.defines.HORIZONTAL_PASS=1;const b=new Vl;b.setAttribute("position",new vo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ol(b,p),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=FQ;let y=this.type;this.render=function(C,T,D){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||C.length===0)return;const k=t.getRenderTarget(),P=t.getActiveCubeFace(),z=t.getActiveMipmapLevel(),L=t.state;L.setBlending($c),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const X=y!==Sc&&this.type===Sc,R=y===Sc&&this.type!==Sc;for(let Y=0,J=C.length;Y<J;Y++){const G=C[Y],W=G.shadow;if(W===void 0){nn("WebGLShadowMap:",G,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);const ee=W.getFrameExtents();if(i.multiply(ee),a.copy(W.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/ee.x),i.x=a.x*ee.x,W.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/ee.y),i.y=a.y*ee.y,W.mapSize.y=a.y)),W.map===null||X===!0||R===!0){const F=this.type!==Sc?{minFilter:Fs,magFilter:Fs}:{};W.map!==null&&W.map.dispose(),W.map=new Tf(i.x,i.y,F),W.map.texture.name=G.name+".shadowMap",W.camera.updateProjectionMatrix()}t.setRenderTarget(W.map),t.clear();const K=W.getViewportCount();for(let F=0;F<K;F++){const q=W.getViewport(F);o.set(a.x*q.x,a.y*q.y,a.x*q.z,a.y*q.w),L.viewport(o),W.updateMatrices(G,F),r=W.getFrustum(),A(T,D,W.camera,G,this.type)}W.isPointLightShadow!==!0&&this.type===Sc&&E(W,D),W.needsUpdate=!1}y=this.type,x.needsUpdate=!1,t.setRenderTarget(k,P,z)};function E(C,T){const D=e.update(v);p.defines.VSM_SAMPLES!==C.blurSamples&&(p.defines.VSM_SAMPLES=C.blurSamples,g.defines.VSM_SAMPLES=C.blurSamples,p.needsUpdate=!0,g.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new Tf(i.x,i.y)),p.uniforms.shadow_pass.value=C.map.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(T,null,D,p,v,null),g.uniforms.shadow_pass.value=C.mapPass.texture,g.uniforms.resolution.value=C.mapSize,g.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(T,null,D,g,v,null)}function w(C,T,D,k){let P=null;const z=D.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(z!==void 0)P=z;else if(P=D.isPointLight===!0?c:l,t.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const L=P.uuid,X=T.uuid;let R=u[L];R===void 0&&(R={},u[L]=R);let Y=R[X];Y===void 0&&(Y=P.clone(),R[X]=Y,T.addEventListener("dispose",N)),P=Y}if(P.visible=T.visible,P.wireframe=T.wireframe,k===Sc?P.side=T.shadowSide!==null?T.shadowSide:T.side:P.side=T.shadowSide!==null?T.shadowSide:f[T.side],P.alphaMap=T.alphaMap,P.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,P.map=T.map,P.clipShadows=T.clipShadows,P.clippingPlanes=T.clippingPlanes,P.clipIntersection=T.clipIntersection,P.displacementMap=T.displacementMap,P.displacementScale=T.displacementScale,P.displacementBias=T.displacementBias,P.wireframeLinewidth=T.wireframeLinewidth,P.linewidth=T.linewidth,D.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=t.properties.get(P);L.light=D}return P}function A(C,T,D,k,P){if(C.visible===!1)return;if(C.layers.test(T.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&P===Sc)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,C.matrixWorld);const X=e.update(C),R=C.material;if(Array.isArray(R)){const Y=X.groups;for(let J=0,G=Y.length;J<G;J++){const W=Y[J],ee=R[W.materialIndex];if(ee&&ee.visible){const K=w(C,ee,k,P);C.onBeforeShadow(t,C,T,D,X,K,W),t.renderBufferDirect(D,null,X,K,C,W),C.onAfterShadow(t,C,T,D,X,K,W)}}}else if(R.visible){const Y=w(C,R,k,P);C.onBeforeShadow(t,C,T,D,X,Y,null),t.renderBufferDirect(D,null,X,Y,C,null),C.onAfterShadow(t,C,T,D,X,Y,null)}}const L=C.children;for(let X=0,R=L.length;X<R;X++)A(L[X],T,D,k,P)}function N(C){C.target.removeEventListener("dispose",N);for(const D in u){const k=u[D],P=C.target.uuid;P in k&&(k[P].dispose(),delete k[P])}}}const m4e={[P3]:R3,[D3]:I3,[O3]:F3,[Jp]:L3,[R3]:P3,[I3]:D3,[F3]:O3,[L3]:Jp};function p4e(t,e){function n(){let ie=!1;const He=new mi;let ve=null;const Be=new mi(0,0,0,0);return{setMask:function(je){ve!==je&&!ie&&(t.colorMask(je,je,je,je),ve=je)},setLocked:function(je){ie=je},setClear:function(je,Ne,Xe,mt,At){At===!0&&(je*=mt,Ne*=mt,Xe*=mt),He.set(je,Ne,Xe,mt),Be.equals(He)===!1&&(t.clearColor(je,Ne,Xe,mt),Be.copy(He))},reset:function(){ie=!1,ve=null,Be.set(-1,0,0,0)}}}function r(){let ie=!1,He=!1,ve=null,Be=null,je=null;return{setReversed:function(Ne){if(He!==Ne){const Xe=e.get("EXT_clip_control");Ne?Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.ZERO_TO_ONE_EXT):Xe.clipControlEXT(Xe.LOWER_LEFT_EXT,Xe.NEGATIVE_ONE_TO_ONE_EXT),He=Ne;const mt=je;je=null,this.setClear(mt)}},getReversed:function(){return He},setTest:function(Ne){Ne?pe(t.DEPTH_TEST):Ce(t.DEPTH_TEST)},setMask:function(Ne){ve!==Ne&&!ie&&(t.depthMask(Ne),ve=Ne)},setFunc:function(Ne){if(He&&(Ne=m4e[Ne]),Be!==Ne){switch(Ne){case P3:t.depthFunc(t.NEVER);break;case R3:t.depthFunc(t.ALWAYS);break;case D3:t.depthFunc(t.LESS);break;case Jp:t.depthFunc(t.LEQUAL);break;case O3:t.depthFunc(t.EQUAL);break;case L3:t.depthFunc(t.GEQUAL);break;case I3:t.depthFunc(t.GREATER);break;case F3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Be=Ne}},setLocked:function(Ne){ie=Ne},setClear:function(Ne){je!==Ne&&(He&&(Ne=1-Ne),t.clearDepth(Ne),je=Ne)},reset:function(){ie=!1,ve=null,Be=null,je=null,He=!1}}}function i(){let ie=!1,He=null,ve=null,Be=null,je=null,Ne=null,Xe=null,mt=null,At=null;return{setTest:function(Rt){ie||(Rt?pe(t.STENCIL_TEST):Ce(t.STENCIL_TEST))},setMask:function(Rt){He!==Rt&&!ie&&(t.stencilMask(Rt),He=Rt)},setFunc:function(Rt,Xt,Lt){(ve!==Rt||Be!==Xt||je!==Lt)&&(t.stencilFunc(Rt,Xt,Lt),ve=Rt,Be=Xt,je=Lt)},setOp:function(Rt,Xt,Lt){(Ne!==Rt||Xe!==Xt||mt!==Lt)&&(t.stencilOp(Rt,Xt,Lt),Ne=Rt,Xe=Xt,mt=Lt)},setLocked:function(Rt){ie=Rt},setClear:function(Rt){At!==Rt&&(t.clearStencil(Rt),At=Rt)},reset:function(){ie=!1,He=null,ve=null,Be=null,je=null,Ne=null,Xe=null,mt=null,At=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},p=new WeakMap,g=[],b=null,v=!1,x=null,y=null,E=null,w=null,A=null,N=null,C=null,T=new An(0,0,0),D=0,k=!1,P=null,z=null,L=null,X=null,R=null;const Y=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,G=0;const W=t.getParameter(t.VERSION);W.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(W)[1]),J=G>=1):W.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),J=G>=2);let ee=null,K={};const F=t.getParameter(t.SCISSOR_BOX),q=t.getParameter(t.VIEWPORT),ne=new mi().fromArray(F),re=new mi().fromArray(q);function se(ie,He,ve,Be){const je=new Uint8Array(4),Ne=t.createTexture();t.bindTexture(ie,Ne),t.texParameteri(ie,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ie,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Xe=0;Xe<ve;Xe++)ie===t.TEXTURE_3D||ie===t.TEXTURE_2D_ARRAY?t.texImage3D(He,0,t.RGBA,1,1,Be,0,t.RGBA,t.UNSIGNED_BYTE,je):t.texImage2D(He+Xe,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,je);return Ne}const de={};de[t.TEXTURE_2D]=se(t.TEXTURE_2D,t.TEXTURE_2D,1),de[t.TEXTURE_CUBE_MAP]=se(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),de[t.TEXTURE_2D_ARRAY]=se(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),de[t.TEXTURE_3D]=se(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),pe(t.DEPTH_TEST),o.setFunc(Jp),Z(!1),B(j$),pe(t.CULL_FACE),V($c);function pe(ie){d[ie]!==!0&&(t.enable(ie),d[ie]=!0)}function Ce(ie){d[ie]!==!1&&(t.disable(ie),d[ie]=!1)}function oe(ie,He){return f[ie]!==He?(t.bindFramebuffer(ie,He),f[ie]=He,ie===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=He),ie===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=He),!0):!1}function ae(ie,He){let ve=g,Be=!1;if(ie){ve=p.get(He),ve===void 0&&(ve=[],p.set(He,ve));const je=ie.textures;if(ve.length!==je.length||ve[0]!==t.COLOR_ATTACHMENT0){for(let Ne=0,Xe=je.length;Ne<Xe;Ne++)ve[Ne]=t.COLOR_ATTACHMENT0+Ne;ve.length=je.length,Be=!0}}else ve[0]!==t.BACK&&(ve[0]=t.BACK,Be=!0);Be&&t.drawBuffers(ve)}function ge(ie){return b!==ie?(t.useProgram(ie),b=ie,!0):!1}const ue={[jh]:t.FUNC_ADD,[mke]:t.FUNC_SUBTRACT,[pke]:t.FUNC_REVERSE_SUBTRACT};ue[gke]=t.MIN,ue[xke]=t.MAX;const Le={[bke]:t.ZERO,[yke]:t.ONE,[vke]:t.SRC_COLOR,[k3]:t.SRC_ALPHA,[Nke]:t.SRC_ALPHA_SATURATE,[Mke]:t.DST_COLOR,[wke]:t.DST_ALPHA,[_ke]:t.ONE_MINUS_SRC_COLOR,[j3]:t.ONE_MINUS_SRC_ALPHA,[Eke]:t.ONE_MINUS_DST_COLOR,[Ske]:t.ONE_MINUS_DST_ALPHA,[Ake]:t.CONSTANT_COLOR,[Tke]:t.ONE_MINUS_CONSTANT_COLOR,[Cke]:t.CONSTANT_ALPHA,[kke]:t.ONE_MINUS_CONSTANT_ALPHA};function V(ie,He,ve,Be,je,Ne,Xe,mt,At,Rt){if(ie===$c){v===!0&&(Ce(t.BLEND),v=!1);return}if(v===!1&&(pe(t.BLEND),v=!0),ie!==fke){if(ie!==x||Rt!==k){if((y!==jh||A!==jh)&&(t.blendEquation(t.FUNC_ADD),y=jh,A=jh),Rt)switch(ie){case jp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P$:t.blendFunc(t.ONE,t.ONE);break;case R$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case D$:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:ii("WebGLState: Invalid blending: ",ie);break}else switch(ie){case jp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P$:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case R$:ii("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case D$:ii("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ii("WebGLState: Invalid blending: ",ie);break}E=null,w=null,N=null,C=null,T.set(0,0,0),D=0,x=ie,k=Rt}return}je=je||He,Ne=Ne||ve,Xe=Xe||Be,(He!==y||je!==A)&&(t.blendEquationSeparate(ue[He],ue[je]),y=He,A=je),(ve!==E||Be!==w||Ne!==N||Xe!==C)&&(t.blendFuncSeparate(Le[ve],Le[Be],Le[Ne],Le[Xe]),E=ve,w=Be,N=Ne,C=Xe),(mt.equals(T)===!1||At!==D)&&(t.blendColor(mt.r,mt.g,mt.b,At),T.copy(mt),D=At),x=ie,k=!1}function $(ie,He){ie.side===yl?Ce(t.CULL_FACE):pe(t.CULL_FACE);let ve=ie.side===ls;He&&(ve=!ve),Z(ve),ie.blending===jp&&ie.transparent===!1?V($c):V(ie.blending,ie.blendEquation,ie.blendSrc,ie.blendDst,ie.blendEquationAlpha,ie.blendSrcAlpha,ie.blendDstAlpha,ie.blendColor,ie.blendAlpha,ie.premultipliedAlpha),o.setFunc(ie.depthFunc),o.setTest(ie.depthTest),o.setMask(ie.depthWrite),a.setMask(ie.colorWrite);const Be=ie.stencilWrite;l.setTest(Be),Be&&(l.setMask(ie.stencilWriteMask),l.setFunc(ie.stencilFunc,ie.stencilRef,ie.stencilFuncMask),l.setOp(ie.stencilFail,ie.stencilZFail,ie.stencilZPass)),Q(ie.polygonOffset,ie.polygonOffsetFactor,ie.polygonOffsetUnits),ie.alphaToCoverage===!0?pe(t.SAMPLE_ALPHA_TO_COVERAGE):Ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function Z(ie){P!==ie&&(ie?t.frontFace(t.CW):t.frontFace(t.CCW),P=ie)}function B(ie){ie!==uke?(pe(t.CULL_FACE),ie!==z&&(ie===j$?t.cullFace(t.BACK):ie===dke?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ce(t.CULL_FACE),z=ie}function U(ie){ie!==L&&(J&&t.lineWidth(ie),L=ie)}function Q(ie,He,ve){ie?(pe(t.POLYGON_OFFSET_FILL),(X!==He||R!==ve)&&(t.polygonOffset(He,ve),X=He,R=ve)):Ce(t.POLYGON_OFFSET_FILL)}function Me(ie){ie?pe(t.SCISSOR_TEST):Ce(t.SCISSOR_TEST)}function Te(ie){ie===void 0&&(ie=t.TEXTURE0+Y-1),ee!==ie&&(t.activeTexture(ie),ee=ie)}function fe(ie,He,ve){ve===void 0&&(ee===null?ve=t.TEXTURE0+Y-1:ve=ee);let Be=K[ve];Be===void 0&&(Be={type:void 0,texture:void 0},K[ve]=Be),(Be.type!==ie||Be.texture!==He)&&(ee!==ve&&(t.activeTexture(ve),ee=ve),t.bindTexture(ie,He||de[ie]),Be.type=ie,Be.texture=He)}function H(){const ie=K[ee];ie!==void 0&&ie.type!==void 0&&(t.bindTexture(ie.type,null),ie.type=void 0,ie.texture=void 0)}function I(){try{t.compressedTexImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function ce(){try{t.compressedTexImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function we(){try{t.texSubImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function Se(){try{t.texSubImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function _e(){try{t.compressedTexSubImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function st(){try{t.compressedTexSubImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function Ve(){try{t.texStorage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function it(){try{t.texStorage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function ct(){try{t.texImage2D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function Fe(){try{t.texImage3D(...arguments)}catch(ie){ie("WebGLState:",ie)}}function me(ie){ne.equals(ie)===!1&&(t.scissor(ie.x,ie.y,ie.z,ie.w),ne.copy(ie))}function Ke(ie){re.equals(ie)===!1&&(t.viewport(ie.x,ie.y,ie.z,ie.w),re.copy(ie))}function qe(ie,He){let ve=u.get(He);ve===void 0&&(ve=new WeakMap,u.set(He,ve));let Be=ve.get(ie);Be===void 0&&(Be=t.getUniformBlockIndex(He,ie.name),ve.set(ie,Be))}function Qe(ie,He){const Be=u.get(He).get(ie);c.get(He)!==Be&&(t.uniformBlockBinding(He,Be,ie.__bindingPointIndex),c.set(He,Be))}function ut(){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),o.setReversed(!1),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(t.ALWAYS,0,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.clearStencil(0),t.cullFace(t.BACK),t.frontFace(t.CCW),t.polygonOffset(0,0),t.activeTexture(t.TEXTURE0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),d={},ee=null,K={},f={},p=new WeakMap,g=[],b=null,v=!1,x=null,y=null,E=null,w=null,A=null,N=null,C=null,T=new An(0,0,0),D=0,k=!1,P=null,z=null,L=null,X=null,R=null,ne.set(0,0,t.canvas.width,t.canvas.height),re.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:pe,disable:Ce,bindFramebuffer:oe,drawBuffers:ae,useProgram:ge,setBlending:V,setMaterial:$,setFlipSided:Z,setCullFace:B,setLineWidth:U,setPolygonOffset:Q,setScissorTest:Me,activeTexture:Te,bindTexture:fe,unbindTexture:H,compressedTexImage2D:I,compressedTexImage3D:ce,texImage2D:ct,texImage3D:Fe,updateUBOMapping:qe,uniformBlockBinding:Qe,texStorage2D:Ve,texStorage3D:it,texSubImage2D:we,texSubImage3D:Se,compressedTexSubImage2D:_e,compressedTexSubImage3D:st,scissor:me,viewport:Ke,reset:ut}}function g4e(t,e,n,r,i,a,o){const l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),u=new xn,d=new WeakMap;let f;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function b(H,I){return g?new OffscreenCanvas(H,I):oS("canvas")}function v(H,I,ce){let we=1;const Se=fe(H);if((Se.width>ce||Se.height>ce)&&(we=ce/Math.max(Se.width,Se.height)),we<1)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap||typeof VideoFrame<"u"&&H instanceof VideoFrame){const _e=Math.floor(we*Se.width),st=Math.floor(we*Se.height);f===void 0&&(f=b(_e,st));const Ve=I?b(_e,st):f;return Ve.width=_e,Ve.height=st,Ve.getContext("2d").drawImage(H,0,0,_e,st),nn("WebGLRenderer: Texture has been resized from ("+Se.width+"x"+Se.height+") to ("+_e+"x"+st+")."),Ve}else return"data"in H&&nn("WebGLRenderer: Image in DataTexture is too big ("+Se.width+"x"+Se.height+")."),H;return H}function x(H){return H.generateMipmaps}function y(H){t.generateMipmap(H)}function E(H){return H.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:H.isWebGL3DRenderTarget?t.TEXTURE_3D:H.isWebGLArrayRenderTarget||H.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function w(H,I,ce,we,Se=!1){if(H!==null){if(t[H]!==void 0)return t[H];nn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let _e=I;if(I===t.RED&&(ce===t.FLOAT&&(_e=t.R32F),ce===t.HALF_FLOAT&&(_e=t.R16F),ce===t.UNSIGNED_BYTE&&(_e=t.R8)),I===t.RED_INTEGER&&(ce===t.UNSIGNED_BYTE&&(_e=t.R8UI),ce===t.UNSIGNED_SHORT&&(_e=t.R16UI),ce===t.UNSIGNED_INT&&(_e=t.R32UI),ce===t.BYTE&&(_e=t.R8I),ce===t.SHORT&&(_e=t.R16I),ce===t.INT&&(_e=t.R32I)),I===t.RG&&(ce===t.FLOAT&&(_e=t.RG32F),ce===t.HALF_FLOAT&&(_e=t.RG16F),ce===t.UNSIGNED_BYTE&&(_e=t.RG8)),I===t.RG_INTEGER&&(ce===t.UNSIGNED_BYTE&&(_e=t.RG8UI),ce===t.UNSIGNED_SHORT&&(_e=t.RG16UI),ce===t.UNSIGNED_INT&&(_e=t.RG32UI),ce===t.BYTE&&(_e=t.RG8I),ce===t.SHORT&&(_e=t.RG16I),ce===t.INT&&(_e=t.RG32I)),I===t.RGB_INTEGER&&(ce===t.UNSIGNED_BYTE&&(_e=t.RGB8UI),ce===t.UNSIGNED_SHORT&&(_e=t.RGB16UI),ce===t.UNSIGNED_INT&&(_e=t.RGB32UI),ce===t.BYTE&&(_e=t.RGB8I),ce===t.SHORT&&(_e=t.RGB16I),ce===t.INT&&(_e=t.RGB32I)),I===t.RGBA_INTEGER&&(ce===t.UNSIGNED_BYTE&&(_e=t.RGBA8UI),ce===t.UNSIGNED_SHORT&&(_e=t.RGBA16UI),ce===t.UNSIGNED_INT&&(_e=t.RGBA32UI),ce===t.BYTE&&(_e=t.RGBA8I),ce===t.SHORT&&(_e=t.RGBA16I),ce===t.INT&&(_e=t.RGBA32I)),I===t.RGB&&(ce===t.UNSIGNED_INT_5_9_9_9_REV&&(_e=t.RGB9_E5),ce===t.UNSIGNED_INT_10F_11F_11F_REV&&(_e=t.R11F_G11F_B10F)),I===t.RGBA){const st=Se?aS:Fn.getTransfer(we);ce===t.FLOAT&&(_e=t.RGBA32F),ce===t.HALF_FLOAT&&(_e=t.RGBA16F),ce===t.UNSIGNED_BYTE&&(_e=st===or?t.SRGB8_ALPHA8:t.RGBA8),ce===t.UNSIGNED_SHORT_4_4_4_4&&(_e=t.RGBA4),ce===t.UNSIGNED_SHORT_5_5_5_1&&(_e=t.RGB5_A1)}return(_e===t.R16F||_e===t.R32F||_e===t.RG16F||_e===t.RG32F||_e===t.RGBA16F||_e===t.RGBA32F)&&e.get("EXT_color_buffer_float"),_e}function A(H,I){let ce;return H?I===null||I===Nf||I===m0?ce=t.DEPTH24_STENCIL8:I===Lc?ce=t.DEPTH32F_STENCIL8:I===f0&&(ce=t.DEPTH24_STENCIL8,nn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):I===null||I===Nf||I===m0?ce=t.DEPTH_COMPONENT24:I===Lc?ce=t.DEPTH_COMPONENT32F:I===f0&&(ce=t.DEPTH_COMPONENT16),ce}function N(H,I){return x(H)===!0||H.isFramebufferTexture&&H.minFilter!==Fs&&H.minFilter!==yo?Math.log2(Math.max(I.width,I.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?I.mipmaps.length:1}function C(H){const I=H.target;I.removeEventListener("dispose",C),D(I),I.isVideoTexture&&d.delete(I)}function T(H){const I=H.target;I.removeEventListener("dispose",T),P(I)}function D(H){const I=r.get(H);if(I.__webglInit===void 0)return;const ce=H.source,we=p.get(ce);if(we){const Se=we[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&k(H),Object.keys(we).length===0&&p.delete(ce)}r.remove(H)}function k(H){const I=r.get(H);t.deleteTexture(I.__webglTexture);const ce=H.source,we=p.get(ce);delete we[I.__cacheKey],o.memory.textures--}function P(H){const I=r.get(H);if(H.depthTexture&&(H.depthTexture.dispose(),r.remove(H.depthTexture)),H.isWebGLCubeRenderTarget)for(let we=0;we<6;we++){if(Array.isArray(I.__webglFramebuffer[we]))for(let Se=0;Se<I.__webglFramebuffer[we].length;Se++)t.deleteFramebuffer(I.__webglFramebuffer[we][Se]);else t.deleteFramebuffer(I.__webglFramebuffer[we]);I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer[we])}else{if(Array.isArray(I.__webglFramebuffer))for(let we=0;we<I.__webglFramebuffer.length;we++)t.deleteFramebuffer(I.__webglFramebuffer[we]);else t.deleteFramebuffer(I.__webglFramebuffer);if(I.__webglDepthbuffer&&t.deleteRenderbuffer(I.__webglDepthbuffer),I.__webglMultisampledFramebuffer&&t.deleteFramebuffer(I.__webglMultisampledFramebuffer),I.__webglColorRenderbuffer)for(let we=0;we<I.__webglColorRenderbuffer.length;we++)I.__webglColorRenderbuffer[we]&&t.deleteRenderbuffer(I.__webglColorRenderbuffer[we]);I.__webglDepthRenderbuffer&&t.deleteRenderbuffer(I.__webglDepthRenderbuffer)}const ce=H.textures;for(let we=0,Se=ce.length;we<Se;we++){const _e=r.get(ce[we]);_e.__webglTexture&&(t.deleteTexture(_e.__webglTexture),o.memory.textures--),r.remove(ce[we])}r.remove(H)}let z=0;function L(){z=0}function X(){const H=z;return H>=i.maxTextures&&nn("WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+i.maxTextures),z+=1,H}function R(H){const I=[];return I.push(H.wrapS),I.push(H.wrapT),I.push(H.wrapR||0),I.push(H.magFilter),I.push(H.minFilter),I.push(H.anisotropy),I.push(H.internalFormat),I.push(H.format),I.push(H.type),I.push(H.generateMipmaps),I.push(H.premultiplyAlpha),I.push(H.flipY),I.push(H.unpackAlignment),I.push(H.colorSpace),I.join()}function Y(H,I){const ce=r.get(H);if(H.isVideoTexture&&Me(H),H.isRenderTargetTexture===!1&&H.isExternalTexture!==!0&&H.version>0&&ce.__version!==H.version){const we=H.image;if(we===null)nn("WebGLRenderer: Texture marked for update but no image data found.");else if(we.complete===!1)nn("WebGLRenderer: Texture marked for update but image is incomplete");else{de(ce,H,I);return}}else H.isExternalTexture&&(ce.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ce.__webglTexture,t.TEXTURE0+I)}function J(H,I){const ce=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&ce.__version!==H.version){de(ce,H,I);return}else H.isExternalTexture&&(ce.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ce.__webglTexture,t.TEXTURE0+I)}function G(H,I){const ce=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&ce.__version!==H.version){de(ce,H,I);return}n.bindTexture(t.TEXTURE_3D,ce.__webglTexture,t.TEXTURE0+I)}function W(H,I){const ce=r.get(H);if(H.version>0&&ce.__version!==H.version){pe(ce,H,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ce.__webglTexture,t.TEXTURE0+I)}const ee={[B3]:t.REPEAT,[Oc]:t.CLAMP_TO_EDGE,[$3]:t.MIRRORED_REPEAT},K={[Fs]:t.NEAREST,[zke]:t.NEAREST_MIPMAP_NEAREST,[o_]:t.NEAREST_MIPMAP_LINEAR,[yo]:t.LINEAR,[rC]:t.LINEAR_MIPMAP_NEAREST,[Hh]:t.LINEAR_MIPMAP_LINEAR},F={[Vke]:t.NEVER,[Yke]:t.ALWAYS,[Gke]:t.LESS,[KQ]:t.LEQUAL,[Wke]:t.EQUAL,[Xke]:t.GEQUAL,[qke]:t.GREATER,[Kke]:t.NOTEQUAL};function q(H,I){if(I.type===Lc&&e.has("OES_texture_float_linear")===!1&&(I.magFilter===yo||I.magFilter===rC||I.magFilter===o_||I.magFilter===Hh||I.minFilter===yo||I.minFilter===rC||I.minFilter===o_||I.minFilter===Hh)&&nn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(H,t.TEXTURE_WRAP_S,ee[I.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,ee[I.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,ee[I.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,K[I.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,K[I.minFilter]),I.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,F[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(I.magFilter===Fs||I.minFilter!==o_&&I.minFilter!==Hh||I.type===Lc&&e.has("OES_texture_float_linear")===!1)return;if(I.anisotropy>1||r.get(I).__currentAnisotropy){const ce=e.get("EXT_texture_filter_anisotropic");t.texParameterf(H,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy}}}function ne(H,I){let ce=!1;H.__webglInit===void 0&&(H.__webglInit=!0,I.addEventListener("dispose",C));const we=I.source;let Se=p.get(we);Se===void 0&&(Se={},p.set(we,Se));const _e=R(I);if(_e!==H.__cacheKey){Se[_e]===void 0&&(Se[_e]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ce=!0),Se[_e].usedTimes++;const st=Se[H.__cacheKey];st!==void 0&&(Se[H.__cacheKey].usedTimes--,st.usedTimes===0&&k(I)),H.__cacheKey=_e,H.__webglTexture=Se[_e].texture}return ce}function re(H,I,ce){return Math.floor(Math.floor(H/ce)/I)}function se(H,I,ce,we){const _e=H.updateRanges;if(_e.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,I.width,I.height,ce,we,I.data);else{_e.sort((Fe,me)=>Fe.start-me.start);let st=0;for(let Fe=1;Fe<_e.length;Fe++){const me=_e[st],Ke=_e[Fe],qe=me.start+me.count,Qe=re(Ke.start,I.width,4),ut=re(me.start,I.width,4);Ke.start<=qe+1&&Qe===ut&&re(Ke.start+Ke.count-1,I.width,4)===Qe?me.count=Math.max(me.count,Ke.start+Ke.count-me.start):(++st,_e[st]=Ke)}_e.length=st+1;const Ve=t.getParameter(t.UNPACK_ROW_LENGTH),it=t.getParameter(t.UNPACK_SKIP_PIXELS),ct=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,I.width);for(let Fe=0,me=_e.length;Fe<me;Fe++){const Ke=_e[Fe],qe=Math.floor(Ke.start/4),Qe=Math.ceil(Ke.count/4),ut=qe%I.width,ie=Math.floor(qe/I.width),He=Qe,ve=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,ut),t.pixelStorei(t.UNPACK_SKIP_ROWS,ie),n.texSubImage2D(t.TEXTURE_2D,0,ut,ie,He,ve,ce,we,I.data)}H.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Ve),t.pixelStorei(t.UNPACK_SKIP_PIXELS,it),t.pixelStorei(t.UNPACK_SKIP_ROWS,ct)}}function de(H,I,ce){let we=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(we=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(we=t.TEXTURE_3D);const Se=ne(H,I),_e=I.source;n.bindTexture(we,H.__webglTexture,t.TEXTURE0+ce);const st=r.get(_e);if(_e.version!==st.__version||Se===!0){n.activeTexture(t.TEXTURE0+ce);const Ve=Fn.getPrimaries(Fn.workingColorSpace),it=I.colorSpace===cd?null:Fn.getPrimaries(I.colorSpace),ct=I.colorSpace===cd||Ve===it?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ct);let Fe=v(I.image,!1,i.maxTextureSize);Fe=Te(I,Fe);const me=a.convert(I.format,I.colorSpace),Ke=a.convert(I.type);let qe=w(I.internalFormat,me,Ke,I.colorSpace,I.isVideoTexture);q(we,I);let Qe;const ut=I.mipmaps,ie=I.isVideoTexture!==!0,He=st.__version===void 0||Se===!0,ve=_e.dataReady,Be=N(I,Fe);if(I.isDepthTexture)qe=A(I.format===g0,I.type),He&&(ie?n.texStorage2D(t.TEXTURE_2D,1,qe,Fe.width,Fe.height):n.texImage2D(t.TEXTURE_2D,0,qe,Fe.width,Fe.height,0,me,Ke,null));else if(I.isDataTexture)if(ut.length>0){ie&&He&&n.texStorage2D(t.TEXTURE_2D,Be,qe,ut[0].width,ut[0].height);for(let je=0,Ne=ut.length;je<Ne;je++)Qe=ut[je],ie?ve&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,Qe.width,Qe.height,me,Ke,Qe.data):n.texImage2D(t.TEXTURE_2D,je,qe,Qe.width,Qe.height,0,me,Ke,Qe.data);I.generateMipmaps=!1}else ie?(He&&n.texStorage2D(t.TEXTURE_2D,Be,qe,Fe.width,Fe.height),ve&&se(I,Fe,me,Ke)):n.texImage2D(t.TEXTURE_2D,0,qe,Fe.width,Fe.height,0,me,Ke,Fe.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){ie&&He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Be,qe,ut[0].width,ut[0].height,Fe.depth);for(let je=0,Ne=ut.length;je<Ne;je++)if(Qe=ut[je],I.format!==qo)if(me!==null)if(ie){if(ve)if(I.layerUpdates.size>0){const Xe=uH(Qe.width,Qe.height,I.format,I.type);for(const mt of I.layerUpdates){const At=Qe.data.subarray(mt*Xe/Qe.data.BYTES_PER_ELEMENT,(mt+1)*Xe/Qe.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,mt,Qe.width,Qe.height,1,me,At)}I.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,Qe.width,Qe.height,Fe.depth,me,Qe.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,je,qe,Qe.width,Qe.height,Fe.depth,0,Qe.data,0,0);else nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ie?ve&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,je,0,0,0,Qe.width,Qe.height,Fe.depth,me,Ke,Qe.data):n.texImage3D(t.TEXTURE_2D_ARRAY,je,qe,Qe.width,Qe.height,Fe.depth,0,me,Ke,Qe.data)}else{ie&&He&&n.texStorage2D(t.TEXTURE_2D,Be,qe,ut[0].width,ut[0].height);for(let je=0,Ne=ut.length;je<Ne;je++)Qe=ut[je],I.format!==qo?me!==null?ie?ve&&n.compressedTexSubImage2D(t.TEXTURE_2D,je,0,0,Qe.width,Qe.height,me,Qe.data):n.compressedTexImage2D(t.TEXTURE_2D,je,qe,Qe.width,Qe.height,0,Qe.data):nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ie?ve&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,Qe.width,Qe.height,me,Ke,Qe.data):n.texImage2D(t.TEXTURE_2D,je,qe,Qe.width,Qe.height,0,me,Ke,Qe.data)}else if(I.isDataArrayTexture)if(ie){if(He&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Be,qe,Fe.width,Fe.height,Fe.depth),ve)if(I.layerUpdates.size>0){const je=uH(Fe.width,Fe.height,I.format,I.type);for(const Ne of I.layerUpdates){const Xe=Fe.data.subarray(Ne*je/Fe.data.BYTES_PER_ELEMENT,(Ne+1)*je/Fe.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,Ne,Fe.width,Fe.height,1,me,Ke,Xe)}I.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,Fe.width,Fe.height,Fe.depth,me,Ke,Fe.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,qe,Fe.width,Fe.height,Fe.depth,0,me,Ke,Fe.data);else if(I.isData3DTexture)ie?(He&&n.texStorage3D(t.TEXTURE_3D,Be,qe,Fe.width,Fe.height,Fe.depth),ve&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,Fe.width,Fe.height,Fe.depth,me,Ke,Fe.data)):n.texImage3D(t.TEXTURE_3D,0,qe,Fe.width,Fe.height,Fe.depth,0,me,Ke,Fe.data);else if(I.isFramebufferTexture){if(He)if(ie)n.texStorage2D(t.TEXTURE_2D,Be,qe,Fe.width,Fe.height);else{let je=Fe.width,Ne=Fe.height;for(let Xe=0;Xe<Be;Xe++)n.texImage2D(t.TEXTURE_2D,Xe,qe,je,Ne,0,me,Ke,null),je>>=1,Ne>>=1}}else if(ut.length>0){if(ie&&He){const je=fe(ut[0]);n.texStorage2D(t.TEXTURE_2D,Be,qe,je.width,je.height)}for(let je=0,Ne=ut.length;je<Ne;je++)Qe=ut[je],ie?ve&&n.texSubImage2D(t.TEXTURE_2D,je,0,0,me,Ke,Qe):n.texImage2D(t.TEXTURE_2D,je,qe,me,Ke,Qe);I.generateMipmaps=!1}else if(ie){if(He){const je=fe(Fe);n.texStorage2D(t.TEXTURE_2D,Be,qe,je.width,je.height)}ve&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,me,Ke,Fe)}else n.texImage2D(t.TEXTURE_2D,0,qe,me,Ke,Fe);x(I)&&y(we),st.__version=_e.version,I.onUpdate&&I.onUpdate(I)}H.__version=I.version}function pe(H,I,ce){if(I.image.length!==6)return;const we=ne(H,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+ce);const _e=r.get(Se);if(Se.version!==_e.__version||we===!0){n.activeTexture(t.TEXTURE0+ce);const st=Fn.getPrimaries(Fn.workingColorSpace),Ve=I.colorSpace===cd?null:Fn.getPrimaries(I.colorSpace),it=I.colorSpace===cd||st===Ve?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,it);const ct=I.isCompressedTexture||I.image[0].isCompressedTexture,Fe=I.image[0]&&I.image[0].isDataTexture,me=[];for(let Ne=0;Ne<6;Ne++)!ct&&!Fe?me[Ne]=v(I.image[Ne],!0,i.maxCubemapSize):me[Ne]=Fe?I.image[Ne].image:I.image[Ne],me[Ne]=Te(I,me[Ne]);const Ke=me[0],qe=a.convert(I.format,I.colorSpace),Qe=a.convert(I.type),ut=w(I.internalFormat,qe,Qe,I.colorSpace),ie=I.isVideoTexture!==!0,He=_e.__version===void 0||we===!0,ve=Se.dataReady;let Be=N(I,Ke);q(t.TEXTURE_CUBE_MAP,I);let je;if(ct){ie&&He&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ut,Ke.width,Ke.height);for(let Ne=0;Ne<6;Ne++){je=me[Ne].mipmaps;for(let Xe=0;Xe<je.length;Xe++){const mt=je[Xe];I.format!==qo?qe!==null?ie?ve&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,0,0,mt.width,mt.height,qe,mt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,ut,mt.width,mt.height,0,mt.data):nn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ie?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,0,0,mt.width,mt.height,qe,Qe,mt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,ut,mt.width,mt.height,0,qe,Qe,mt.data)}}}else{if(je=I.mipmaps,ie&&He){je.length>0&&Be++;const Ne=fe(me[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ut,Ne.width,Ne.height)}for(let Ne=0;Ne<6;Ne++)if(Fe){ie?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,me[Ne].width,me[Ne].height,qe,Qe,me[Ne].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,ut,me[Ne].width,me[Ne].height,0,qe,Qe,me[Ne].data);for(let Xe=0;Xe<je.length;Xe++){const At=je[Xe].image[Ne].image;ie?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,0,0,At.width,At.height,qe,Qe,At.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,ut,At.width,At.height,0,qe,Qe,At.data)}}else{ie?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,qe,Qe,me[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,ut,qe,Qe,me[Ne]);for(let Xe=0;Xe<je.length;Xe++){const mt=je[Xe];ie?ve&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,0,0,qe,Qe,mt.image[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,ut,qe,Qe,mt.image[Ne])}}}x(I)&&y(t.TEXTURE_CUBE_MAP),_e.__version=Se.version,I.onUpdate&&I.onUpdate(I)}H.__version=I.version}function Ce(H,I,ce,we,Se,_e){const st=a.convert(ce.format,ce.colorSpace),Ve=a.convert(ce.type),it=w(ce.internalFormat,st,Ve,ce.colorSpace),ct=r.get(I),Fe=r.get(ce);if(Fe.__renderTarget=I,!ct.__hasExternalTextures){const me=Math.max(1,I.width>>_e),Ke=Math.max(1,I.height>>_e);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,_e,it,me,Ke,I.depth,0,st,Ve,null):n.texImage2D(Se,_e,it,me,Ke,0,st,Ve,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),Q(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,we,Se,Fe.__webglTexture,0,U(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,we,Se,Fe.__webglTexture,_e),n.bindFramebuffer(t.FRAMEBUFFER,null)}function oe(H,I,ce){if(t.bindRenderbuffer(t.RENDERBUFFER,H),I.depthBuffer){const we=I.depthTexture,Se=we&&we.isDepthTexture?we.type:null,_e=A(I.stencilBuffer,Se),st=I.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ve=U(I);Q(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,_e,I.width,I.height):ce?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,_e,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,_e,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,st,t.RENDERBUFFER,H)}else{const we=I.textures;for(let Se=0;Se<we.length;Se++){const _e=we[Se],st=a.convert(_e.format,_e.colorSpace),Ve=a.convert(_e.type),it=w(_e.internalFormat,st,Ve,_e.colorSpace),ct=U(I);ce&&Q(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ct,it,I.width,I.height):Q(I)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ct,it,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,it,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ae(H,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const we=r.get(I.depthTexture);we.__renderTarget=I,(!we.__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),Y(I.depthTexture,0);const Se=we.__webglTexture,_e=U(I);if(I.depthTexture.format===p0)Q(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0);else if(I.depthTexture.format===g0)Q(I)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0);else throw new Error("Unknown depthTexture format")}function ge(H){const I=r.get(H),ce=H.isWebGLCubeRenderTarget===!0;if(I.__boundDepthTexture!==H.depthTexture){const we=H.depthTexture;if(I.__depthDisposeCallback&&I.__depthDisposeCallback(),we){const Se=()=>{delete I.__boundDepthTexture,delete I.__depthDisposeCallback,we.removeEventListener("dispose",Se)};we.addEventListener("dispose",Se),I.__depthDisposeCallback=Se}I.__boundDepthTexture=we}if(H.depthTexture&&!I.__autoAllocateDepthBuffer){if(ce)throw new Error("target.depthTexture not supported in Cube render targets");const we=H.texture.mipmaps;we&&we.length>0?ae(I.__webglFramebuffer[0],H):ae(I.__webglFramebuffer,H)}else if(ce){I.__webglDepthbuffer=[];for(let we=0;we<6;we++)if(n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[we]),I.__webglDepthbuffer[we]===void 0)I.__webglDepthbuffer[we]=t.createRenderbuffer(),oe(I.__webglDepthbuffer[we],H,!1);else{const Se=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,_e=I.__webglDepthbuffer[we];t.bindRenderbuffer(t.RENDERBUFFER,_e),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,_e)}}else{const we=H.texture.mipmaps;if(we&&we.length>0?n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer===void 0)I.__webglDepthbuffer=t.createRenderbuffer(),oe(I.__webglDepthbuffer,H,!1);else{const Se=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,_e=I.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,_e),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,_e)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(H,I,ce){const we=r.get(H);I!==void 0&&Ce(we.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ce!==void 0&&ge(H)}function Le(H){const I=H.texture,ce=r.get(H),we=r.get(I);H.addEventListener("dispose",T);const Se=H.textures,_e=H.isWebGLCubeRenderTarget===!0,st=Se.length>1;if(st||(we.__webglTexture===void 0&&(we.__webglTexture=t.createTexture()),we.__version=I.version,o.memory.textures++),_e){ce.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)if(I.mipmaps&&I.mipmaps.length>0){ce.__webglFramebuffer[Ve]=[];for(let it=0;it<I.mipmaps.length;it++)ce.__webglFramebuffer[Ve][it]=t.createFramebuffer()}else ce.__webglFramebuffer[Ve]=t.createFramebuffer()}else{if(I.mipmaps&&I.mipmaps.length>0){ce.__webglFramebuffer=[];for(let Ve=0;Ve<I.mipmaps.length;Ve++)ce.__webglFramebuffer[Ve]=t.createFramebuffer()}else ce.__webglFramebuffer=t.createFramebuffer();if(st)for(let Ve=0,it=Se.length;Ve<it;Ve++){const ct=r.get(Se[Ve]);ct.__webglTexture===void 0&&(ct.__webglTexture=t.createTexture(),o.memory.textures++)}if(H.samples>0&&Q(H)===!1){ce.__webglMultisampledFramebuffer=t.createFramebuffer(),ce.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ce.__webglMultisampledFramebuffer);for(let Ve=0;Ve<Se.length;Ve++){const it=Se[Ve];ce.__webglColorRenderbuffer[Ve]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ce.__webglColorRenderbuffer[Ve]);const ct=a.convert(it.format,it.colorSpace),Fe=a.convert(it.type),me=w(it.internalFormat,ct,Fe,it.colorSpace,H.isXRRenderTarget===!0),Ke=U(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ke,me,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,ce.__webglColorRenderbuffer[Ve])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(ce.__webglDepthRenderbuffer=t.createRenderbuffer(),oe(ce.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,we.__webglTexture),q(t.TEXTURE_CUBE_MAP,I);for(let Ve=0;Ve<6;Ve++)if(I.mipmaps&&I.mipmaps.length>0)for(let it=0;it<I.mipmaps.length;it++)Ce(ce.__webglFramebuffer[Ve][it],H,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,it);else Ce(ce.__webglFramebuffer[Ve],H,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0);x(I)&&y(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(st){for(let Ve=0,it=Se.length;Ve<it;Ve++){const ct=Se[Ve],Fe=r.get(ct);let me=t.TEXTURE_2D;(H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(me=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(me,Fe.__webglTexture),q(me,ct),Ce(ce.__webglFramebuffer,H,ct,t.COLOR_ATTACHMENT0+Ve,me,0),x(ct)&&y(me)}n.unbindTexture()}else{let Ve=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(Ve=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Ve,we.__webglTexture),q(Ve,I),I.mipmaps&&I.mipmaps.length>0)for(let it=0;it<I.mipmaps.length;it++)Ce(ce.__webglFramebuffer[it],H,I,t.COLOR_ATTACHMENT0,Ve,it);else Ce(ce.__webglFramebuffer,H,I,t.COLOR_ATTACHMENT0,Ve,0);x(I)&&y(Ve),n.unbindTexture()}H.depthBuffer&&ge(H)}function V(H){const I=H.textures;for(let ce=0,we=I.length;ce<we;ce++){const Se=I[ce];if(x(Se)){const _e=E(H),st=r.get(Se).__webglTexture;n.bindTexture(_e,st),y(_e),n.unbindTexture()}}}const $=[],Z=[];function B(H){if(H.samples>0){if(Q(H)===!1){const I=H.textures,ce=H.width,we=H.height;let Se=t.COLOR_BUFFER_BIT;const _e=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,st=r.get(H),Ve=I.length>1;if(Ve)for(let ct=0;ct<I.length;ct++)n.bindFramebuffer(t.FRAMEBUFFER,st.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,st.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,st.__webglMultisampledFramebuffer);const it=H.texture.mipmaps;it&&it.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,st.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,st.__webglFramebuffer);for(let ct=0;ct<I.length;ct++){if(H.resolveDepthBuffer&&(H.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&H.resolveStencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Ve){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,st.__webglColorRenderbuffer[ct]);const Fe=r.get(I[ct]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,Fe,0)}t.blitFramebuffer(0,0,ce,we,0,0,ce,we,Se,t.NEAREST),c===!0&&($.length=0,Z.length=0,$.push(t.COLOR_ATTACHMENT0+ct),H.depthBuffer&&H.resolveDepthBuffer===!1&&($.push(_e),Z.push(_e),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,Z)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,$))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Ve)for(let ct=0;ct<I.length;ct++){n.bindFramebuffer(t.FRAMEBUFFER,st.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,st.__webglColorRenderbuffer[ct]);const Fe=r.get(I[ct]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,st.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,st.__webglMultisampledFramebuffer)}else if(H.depthBuffer&&H.resolveDepthBuffer===!1&&c){const I=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[I])}}}function U(H){return Math.min(i.maxSamples,H.samples)}function Q(H){const I=r.get(H);return H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Me(H){const I=o.render.frame;d.get(H)!==I&&(d.set(H,I),H.update())}function Te(H,I){const ce=H.colorSpace,we=H.format,Se=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||ce!==ng&&ce!==cd&&(Fn.getTransfer(ce)===or?(we!==qo||Se!==Dl)&&nn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ii("WebGLTextures: Unsupported texture color space:",ce)),I}function fe(H){return typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement?(u.width=H.naturalWidth||H.width,u.height=H.naturalHeight||H.height):typeof VideoFrame<"u"&&H instanceof VideoFrame?(u.width=H.displayWidth,u.height=H.displayHeight):(u.width=H.width,u.height=H.height),u}this.allocateTextureUnit=X,this.resetTextureUnits=L,this.setTexture2D=Y,this.setTexture2DArray=J,this.setTexture3D=G,this.setTextureCube=W,this.rebindTextures=ue,this.setupRenderTarget=Le,this.updateRenderTargetMipmap=V,this.updateMultisampleRenderTarget=B,this.setupDepthRenderbuffer=ge,this.setupFrameBufferTexture=Ce,this.useMultisampledRTT=Q}function x4e(t,e){function n(r,i=cd){let a;const o=Fn.getTransfer(i);if(r===Dl)return t.UNSIGNED_BYTE;if(r===H4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===V4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===$Q)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===HQ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===zQ)return t.BYTE;if(r===BQ)return t.SHORT;if(r===f0)return t.UNSIGNED_SHORT;if(r===$4)return t.INT;if(r===Nf)return t.UNSIGNED_INT;if(r===Lc)return t.FLOAT;if(r===Dg)return t.HALF_FLOAT;if(r===VQ)return t.ALPHA;if(r===GQ)return t.RGB;if(r===qo)return t.RGBA;if(r===p0)return t.DEPTH_COMPONENT;if(r===g0)return t.DEPTH_STENCIL;if(r===WQ)return t.RED;if(r===G4)return t.RED_INTEGER;if(r===W4)return t.RG;if(r===q4)return t.RG_INTEGER;if(r===K4)return t.RGBA_INTEGER;if(r===O1||r===L1||r===I1||r===F1)if(o===or)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===O1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===L1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===I1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===F1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===O1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===L1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===I1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===F1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===H3||r===V3||r===G3||r===W3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===H3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===V3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===G3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===W3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===q3||r===K3||r===X3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===q3||r===K3)return o===or?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===X3)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Y3||r===Q3||r===Z3||r===J3||r===eP||r===tP||r===nP||r===rP||r===iP||r===aP||r===sP||r===oP||r===lP||r===cP)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===Y3)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Q3)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Z3)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===J3)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===eP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===tP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===nP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===rP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===iP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===aP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===sP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===oP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===lP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===cP)return o===or?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===uP||r===dP||r===hP)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===uP)return o===or?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===dP)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===hP)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===fP||r===mP||r===pP||r===gP)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===fP)return a.COMPRESSED_RED_RGTC1_EXT;if(r===mP)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===pP)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===gP)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===m0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const b4e=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,y4e=`
- 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 v4e{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new fZ(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const n=e.cameras[0].viewport,r=new su({vertexShader:b4e,fragmentShader:y4e,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new Ol(new eO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let _4e=class extends Bf{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,g=null,b=null;const v=typeof XRWebGLBinding<"u",x=new v4e,y={},E=n.getContextAttributes();let w=null,A=null;const N=[],C=[],T=new xn;let D=null;const k=new fo;k.viewport=new mi;const P=new fo;P.viewport=new mi;const z=[k,P],L=new Fje;let X=null,R=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(de){let pe=N[de];return pe===void 0&&(pe=new EC,N[de]=pe),pe.getTargetRaySpace()},this.getControllerGrip=function(de){let pe=N[de];return pe===void 0&&(pe=new EC,N[de]=pe),pe.getGripSpace()},this.getHand=function(de){let pe=N[de];return pe===void 0&&(pe=new EC,N[de]=pe),pe.getHandSpace()};function Y(de){const pe=C.indexOf(de.inputSource);if(pe===-1)return;const Ce=N[pe];Ce!==void 0&&(Ce.update(de.inputSource,de.frame,u||o),Ce.dispatchEvent({type:de.type,data:de.inputSource}))}function J(){i.removeEventListener("select",Y),i.removeEventListener("selectstart",Y),i.removeEventListener("selectend",Y),i.removeEventListener("squeeze",Y),i.removeEventListener("squeezestart",Y),i.removeEventListener("squeezeend",Y),i.removeEventListener("end",J),i.removeEventListener("inputsourceschange",G);for(let de=0;de<N.length;de++){const pe=C[de];pe!==null&&(C[de]=null,N[de].disconnect(pe))}X=null,R=null,x.reset();for(const de in y)delete y[de];e.setRenderTarget(w),g=null,p=null,f=null,i=null,A=null,se.stop(),r.isPresenting=!1,e.setPixelRatio(D),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(de){a=de,r.isPresenting===!0&&nn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(de){l=de,r.isPresenting===!0&&nn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(de){u=de},this.getBaseLayer=function(){return p!==null?p:g},this.getBinding=function(){return f===null&&v&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(de){if(i=de,i!==null){if(w=e.getRenderTarget(),i.addEventListener("select",Y),i.addEventListener("selectstart",Y),i.addEventListener("selectend",Y),i.addEventListener("squeeze",Y),i.addEventListener("squeezestart",Y),i.addEventListener("squeezeend",Y),i.addEventListener("end",J),i.addEventListener("inputsourceschange",G),E.xrCompatible!==!0&&await n.makeXRCompatible(),D=e.getPixelRatio(),e.getSize(T),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ce=null,oe=null,ae=null;E.depth&&(ae=E.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ce=E.stencil?g0:p0,oe=E.stencil?m0:Nf);const ge={colorFormat:n.RGBA8,depthFormat:ae,scaleFactor:a};f=this.getBinding(),p=f.createProjectionLayer(ge),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),A=new Tf(p.textureWidth,p.textureHeight,{format:qo,type:Dl,depthTexture:new hZ(p.textureWidth,p.textureHeight,oe,void 0,void 0,void 0,void 0,void 0,void 0,Ce),stencilBuffer:E.stencil,colorSpace:e.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Ce={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(i,n,Ce),i.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),A=new Tf(g.framebufferWidth,g.framebufferHeight,{format:qo,type:Dl,colorSpace:e.outputColorSpace,stencilBuffer:E.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}A.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),se.setContext(i),se.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function G(de){for(let pe=0;pe<de.removed.length;pe++){const Ce=de.removed[pe],oe=C.indexOf(Ce);oe>=0&&(C[oe]=null,N[oe].disconnect(Ce))}for(let pe=0;pe<de.added.length;pe++){const Ce=de.added[pe];let oe=C.indexOf(Ce);if(oe===-1){for(let ge=0;ge<N.length;ge++)if(ge>=C.length){C.push(Ce),oe=ge;break}else if(C[ge]===null){C[ge]=Ce,oe=ge;break}if(oe===-1)break}const ae=N[oe];ae&&ae.connect(Ce)}}const W=new at,ee=new at;function K(de,pe,Ce){W.setFromMatrixPosition(pe.matrixWorld),ee.setFromMatrixPosition(Ce.matrixWorld);const oe=W.distanceTo(ee),ae=pe.projectionMatrix.elements,ge=Ce.projectionMatrix.elements,ue=ae[14]/(ae[10]-1),Le=ae[14]/(ae[10]+1),V=(ae[9]+1)/ae[5],$=(ae[9]-1)/ae[5],Z=(ae[8]-1)/ae[0],B=(ge[8]+1)/ge[0],U=ue*Z,Q=ue*B,Me=oe/(-Z+B),Te=Me*-Z;if(pe.matrixWorld.decompose(de.position,de.quaternion,de.scale),de.translateX(Te),de.translateZ(Me),de.matrixWorld.compose(de.position,de.quaternion,de.scale),de.matrixWorldInverse.copy(de.matrixWorld).invert(),ae[10]===-1)de.projectionMatrix.copy(pe.projectionMatrix),de.projectionMatrixInverse.copy(pe.projectionMatrixInverse);else{const fe=ue+Me,H=Le+Me,I=U-Te,ce=Q+(oe-Te),we=V*Le/H*fe,Se=$*Le/H*fe;de.projectionMatrix.makePerspective(I,ce,we,Se,fe,H),de.projectionMatrixInverse.copy(de.projectionMatrix).invert()}}function F(de,pe){pe===null?de.matrixWorld.copy(de.matrix):de.matrixWorld.multiplyMatrices(pe.matrixWorld,de.matrix),de.matrixWorldInverse.copy(de.matrixWorld).invert()}this.updateCamera=function(de){if(i===null)return;let pe=de.near,Ce=de.far;x.texture!==null&&(x.depthNear>0&&(pe=x.depthNear),x.depthFar>0&&(Ce=x.depthFar)),L.near=P.near=k.near=pe,L.far=P.far=k.far=Ce,(X!==L.near||R!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),X=L.near,R=L.far),L.layers.mask=de.layers.mask|6,k.layers.mask=L.layers.mask&3,P.layers.mask=L.layers.mask&5;const oe=de.parent,ae=L.cameras;F(L,oe);for(let ge=0;ge<ae.length;ge++)F(ae[ge],oe);ae.length===2?K(L,k,P):L.projectionMatrix.copy(k.projectionMatrix),q(de,L,oe)};function q(de,pe,Ce){Ce===null?de.matrix.copy(pe.matrixWorld):(de.matrix.copy(Ce.matrixWorld),de.matrix.invert(),de.matrix.multiply(pe.matrixWorld)),de.matrix.decompose(de.position,de.quaternion,de.scale),de.updateMatrixWorld(!0),de.projectionMatrix.copy(pe.projectionMatrix),de.projectionMatrixInverse.copy(pe.projectionMatrixInverse),de.isPerspectiveCamera&&(de.fov=xP*2*Math.atan(1/de.projectionMatrix.elements[5]),de.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(p===null&&g===null))return c},this.setFoveation=function(de){c=de,p!==null&&(p.fixedFoveation=de),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=de)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(L)},this.getCameraTexture=function(de){return y[de]};let ne=null;function re(de,pe){if(d=pe.getViewerPose(u||o),b=pe,d!==null){const Ce=d.views;g!==null&&(e.setRenderTargetFramebuffer(A,g.framebuffer),e.setRenderTarget(A));let oe=!1;Ce.length!==L.cameras.length&&(L.cameras.length=0,oe=!0);for(let Le=0;Le<Ce.length;Le++){const V=Ce[Le];let $=null;if(g!==null)$=g.getViewport(V);else{const B=f.getViewSubImage(p,V);$=B.viewport,Le===0&&(e.setRenderTargetTextures(A,B.colorTexture,B.depthStencilTexture),e.setRenderTarget(A))}let Z=z[Le];Z===void 0&&(Z=new fo,Z.layers.enable(Le),Z.viewport=new mi,z[Le]=Z),Z.matrix.fromArray(V.transform.matrix),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.projectionMatrix.fromArray(V.projectionMatrix),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert(),Z.viewport.set($.x,$.y,$.width,$.height),Le===0&&(L.matrix.copy(Z.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),oe===!0&&L.cameras.push(Z)}const ae=i.enabledFeatures;if(ae&&ae.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){f=r.getBinding();const Le=f.getDepthInformation(Ce[0]);Le&&Le.isValid&&Le.texture&&x.init(Le,i.renderState)}if(ae&&ae.includes("camera-access")&&v){e.state.unbindTexture(),f=r.getBinding();for(let Le=0;Le<Ce.length;Le++){const V=Ce[Le].camera;if(V){let $=y[V];$||($=new fZ,y[V]=$);const Z=f.getCameraImage(V);$.sourceTexture=Z}}}}for(let Ce=0;Ce<N.length;Ce++){const oe=C[Ce],ae=N[Ce];oe!==null&&ae!==void 0&&ae.update(oe,pe,u||o)}ne&&ne(de,pe),pe.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:pe}),b=null}const se=new xZ;se.setAnimationLoop(re),this.setAnimationLoop=function(de){ne=de},this.dispose=function(){}}};const yh=new zd,w4e=new yi;function S4e(t,e){function n(x,y){x.matrixAutoUpdate===!0&&x.updateMatrix(),y.value.copy(x.matrix)}function r(x,y){y.color.getRGB(x.fogColor.value,lZ(t)),y.isFog?(x.fogNear.value=y.near,x.fogFar.value=y.far):y.isFogExp2&&(x.fogDensity.value=y.density)}function i(x,y,E,w,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(x,y):y.isMeshToonMaterial?(a(x,y),f(x,y)):y.isMeshPhongMaterial?(a(x,y),d(x,y)):y.isMeshStandardMaterial?(a(x,y),p(x,y),y.isMeshPhysicalMaterial&&g(x,y,A)):y.isMeshMatcapMaterial?(a(x,y),b(x,y)):y.isMeshDepthMaterial?a(x,y):y.isMeshDistanceMaterial?(a(x,y),v(x,y)):y.isMeshNormalMaterial?a(x,y):y.isLineBasicMaterial?(o(x,y),y.isLineDashedMaterial&&l(x,y)):y.isPointsMaterial?c(x,y,E,w):y.isSpriteMaterial?u(x,y):y.isShadowMaterial?(x.color.value.copy(y.color),x.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(x,y){x.opacity.value=y.opacity,y.color&&x.diffuse.value.copy(y.color),y.emissive&&x.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.bumpMap&&(x.bumpMap.value=y.bumpMap,n(y.bumpMap,x.bumpMapTransform),x.bumpScale.value=y.bumpScale,y.side===ls&&(x.bumpScale.value*=-1)),y.normalMap&&(x.normalMap.value=y.normalMap,n(y.normalMap,x.normalMapTransform),x.normalScale.value.copy(y.normalScale),y.side===ls&&x.normalScale.value.negate()),y.displacementMap&&(x.displacementMap.value=y.displacementMap,n(y.displacementMap,x.displacementMapTransform),x.displacementScale.value=y.displacementScale,x.displacementBias.value=y.displacementBias),y.emissiveMap&&(x.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,x.emissiveMapTransform)),y.specularMap&&(x.specularMap.value=y.specularMap,n(y.specularMap,x.specularMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest);const E=e.get(y),w=E.envMap,A=E.envMapRotation;w&&(x.envMap.value=w,yh.copy(A),yh.x*=-1,yh.y*=-1,yh.z*=-1,w.isCubeTexture&&w.isRenderTargetTexture===!1&&(yh.y*=-1,yh.z*=-1),x.envMapRotation.value.setFromMatrix4(w4e.makeRotationFromEuler(yh)),x.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=y.reflectivity,x.ior.value=y.ior,x.refractionRatio.value=y.refractionRatio),y.lightMap&&(x.lightMap.value=y.lightMap,x.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,x.lightMapTransform)),y.aoMap&&(x.aoMap.value=y.aoMap,x.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,x.aoMapTransform))}function o(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform))}function l(x,y){x.dashSize.value=y.dashSize,x.totalSize.value=y.dashSize+y.gapSize,x.scale.value=y.scale}function c(x,y,E,w){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.size.value=y.size*E,x.scale.value=w*.5,y.map&&(x.map.value=y.map,n(y.map,x.uvTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function u(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.rotation.value=y.rotation,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function d(x,y){x.specular.value.copy(y.specular),x.shininess.value=Math.max(y.shininess,1e-4)}function f(x,y){y.gradientMap&&(x.gradientMap.value=y.gradientMap)}function p(x,y){x.metalness.value=y.metalness,y.metalnessMap&&(x.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,x.metalnessMapTransform)),x.roughness.value=y.roughness,y.roughnessMap&&(x.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,x.roughnessMapTransform)),y.envMap&&(x.envMapIntensity.value=y.envMapIntensity)}function g(x,y,E){x.ior.value=y.ior,y.sheen>0&&(x.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),x.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(x.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,x.sheenColorMapTransform)),y.sheenRoughnessMap&&(x.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,x.sheenRoughnessMapTransform))),y.clearcoat>0&&(x.clearcoat.value=y.clearcoat,x.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(x.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,x.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(x.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===ls&&x.clearcoatNormalScale.value.negate())),y.dispersion>0&&(x.dispersion.value=y.dispersion),y.iridescence>0&&(x.iridescence.value=y.iridescence,x.iridescenceIOR.value=y.iridescenceIOR,x.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(x.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,x.iridescenceMapTransform)),y.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),y.transmission>0&&(x.transmission.value=y.transmission,x.transmissionSamplerMap.value=E.texture,x.transmissionSamplerSize.value.set(E.width,E.height),y.transmissionMap&&(x.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,x.transmissionMapTransform)),x.thickness.value=y.thickness,y.thicknessMap&&(x.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=y.attenuationDistance,x.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(x.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(x.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=y.specularIntensity,x.specularColor.value.copy(y.specularColor),y.specularColorMap&&(x.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,x.specularColorMapTransform)),y.specularIntensityMap&&(x.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,y){y.matcap&&(x.matcap.value=y.matcap)}function v(x,y){const E=e.get(y).light;x.referencePosition.value.setFromMatrixPosition(E.matrixWorld),x.nearDistance.value=E.shadow.camera.near,x.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function M4e(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(b(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",x));const N=w.program;r.updateUBOMapping(E,N);const C=e.render.frame;a[E.id]!==C&&(p(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),N=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,N,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<l;E++)if(o.indexOf(E)===-1)return o.push(E),E;return ii("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(E){const w=i[E.id],A=E.uniforms,N=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,T=A.length;C<T;C++){const D=Array.isArray(A[C])?A[C]:[A[C]];for(let k=0,P=D.length;k<P;k++){const z=D[k];if(g(z,C,k,N)===!0){const L=z.__offset,X=Array.isArray(z.value)?z.value:[z.value];let R=0;for(let Y=0;Y<X.length;Y++){const J=X[Y],G=v(J);typeof J=="number"||typeof J=="boolean"?(z.__data[0]=J,t.bufferSubData(t.UNIFORM_BUFFER,L+R,z.__data)):J.isMatrix3?(z.__data[0]=J.elements[0],z.__data[1]=J.elements[1],z.__data[2]=J.elements[2],z.__data[3]=0,z.__data[4]=J.elements[3],z.__data[5]=J.elements[4],z.__data[6]=J.elements[5],z.__data[7]=0,z.__data[8]=J.elements[6],z.__data[9]=J.elements[7],z.__data[10]=J.elements[8],z.__data[11]=0):(J.toArray(z.__data,R),R+=G.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,z.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(E,w,A,N){const C=E.value,T=w+"_"+A;if(N[T]===void 0)return typeof C=="number"||typeof C=="boolean"?N[T]=C:N[T]=C.clone(),!0;{const D=N[T];if(typeof C=="number"||typeof C=="boolean"){if(D!==C)return N[T]=C,!0}else if(D.equals(C)===!1)return D.copy(C),!0}return!1}function b(E){const w=E.uniforms;let A=0;const N=16;for(let T=0,D=w.length;T<D;T++){const k=Array.isArray(w[T])?w[T]:[w[T]];for(let P=0,z=k.length;P<z;P++){const L=k[P],X=Array.isArray(L.value)?L.value:[L.value];for(let R=0,Y=X.length;R<Y;R++){const J=X[R],G=v(J),W=A%N,ee=W%G.boundary,K=W+ee;A+=ee,K!==0&&N-K<G.storage&&(A+=N-K),L.__data=new Float32Array(G.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=A,A+=G.storage}}}const C=A%N;return C>0&&(A+=N-C),E.__size=A,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?nn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):nn("WebGLRenderer: Unsupported uniform value type.",E),w}function x(E){const w=E.target;w.removeEventListener("dispose",x);const A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function y(){for(const E in i)t.deleteBuffer(i[E]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}const E4e=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 mc=null;function N4e(){return mc===null&&(mc=new Nje(E4e,32,32,W4,Dg),mc.minFilter=yo,mc.magFilter=yo,mc.wrapS=Oc,mc.wrapT=Oc,mc.generateMipmaps=!1,mc.needsUpdate=!0),mc}let A4e=class{constructor(e={}){const{canvas:n=Qke(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let g;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=r.getContextAttributes().alpha}else g=o;const b=new Set([K4,q4,G4]),v=new Set([Dl,Nf,f0,m0,H4,V4]),x=new Uint32Array(4),y=new Int32Array(4);let E=null,w=null;const A=[],N=[];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=Sd,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let T=!1;this._outputColorSpace=co;let D=0,k=0,P=null,z=-1,L=null;const X=new mi,R=new mi;let Y=null;const J=new An(0);let G=0,W=n.width,ee=n.height,K=1,F=null,q=null;const ne=new mi(0,0,W,ee),re=new mi(0,0,W,ee);let se=!1;const de=new J4;let pe=!1,Ce=!1;const oe=new yi,ae=new at,ge=new mi,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Le=!1;function V(){return P===null?K:1}let $=r;function Z(le,Ae){return n.getContext(le,Ae)}try{const le={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${z4}`),n.addEventListener("webglcontextlost",je,!1),n.addEventListener("webglcontextrestored",Ne,!1),n.addEventListener("webglcontextcreationerror",Xe,!1),$===null){const Ae="webgl2";if($=Z(Ae,le),$===null)throw Z(Ae)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(le){throw le("WebGLRenderer: "+le.message),le}let B,U,Q,Me,Te,fe,H,I,ce,we,Se,_e,st,Ve,it,ct,Fe,me,Ke,qe,Qe,ut,ie,He;function ve(){B=new ORe($),B.init(),ut=new x4e($,B),U=new NRe($,B,e,ut),Q=new p4e($,B),U.reversedDepthBuffer&&p&&Q.buffers.depth.setReversed(!0),Me=new FRe($),Te=new n4e,fe=new g4e($,B,Q,Te,U,ut,Me),H=new TRe(C),I=new DRe(C),ce=new $je($),ie=new MRe($,ce),we=new LRe($,ce,Me,ie),Se=new zRe($,we,ce,Me),Ke=new URe($,U,fe),ct=new ARe(Te),_e=new t4e(C,H,I,B,U,ie,ct),st=new S4e(C,Te),Ve=new i4e,it=new u4e(B),me=new SRe(C,H,I,Q,Se,g,c),Fe=new f4e(C,Se,U),He=new M4e($,Me,U,Q),qe=new ERe($,B,Me),Qe=new IRe($,B,Me),Me.programs=_e.programs,C.capabilities=U,C.extensions=B,C.properties=Te,C.renderLists=Ve,C.shadowMap=Fe,C.state=Q,C.info=Me}ve();const Be=new _4e(C,$);this.xr=Be,this.getContext=function(){return $},this.getContextAttributes=function(){return $.getContextAttributes()},this.forceContextLoss=function(){const le=B.get("WEBGL_lose_context");le&&le.loseContext()},this.forceContextRestore=function(){const le=B.get("WEBGL_lose_context");le&&le.restoreContext()},this.getPixelRatio=function(){return K},this.setPixelRatio=function(le){le!==void 0&&(K=le,this.setSize(W,ee,!1))},this.getSize=function(le){return le.set(W,ee)},this.setSize=function(le,Ae,Oe=!0){if(Be.isPresenting){nn("WebGLRenderer: Can't change size while VR device is presenting.");return}W=le,ee=Ae,n.width=Math.floor(le*K),n.height=Math.floor(Ae*K),Oe===!0&&(n.style.width=le+"px",n.style.height=Ae+"px"),this.setViewport(0,0,le,Ae)},this.getDrawingBufferSize=function(le){return le.set(W*K,ee*K).floor()},this.setDrawingBufferSize=function(le,Ae,Oe){W=le,ee=Ae,K=Oe,n.width=Math.floor(le*Oe),n.height=Math.floor(Ae*Oe),this.setViewport(0,0,le,Ae)},this.getCurrentViewport=function(le){return le.copy(X)},this.getViewport=function(le){return le.copy(ne)},this.setViewport=function(le,Ae,Oe,Ie){le.isVector4?ne.set(le.x,le.y,le.z,le.w):ne.set(le,Ae,Oe,Ie),Q.viewport(X.copy(ne).multiplyScalar(K).round())},this.getScissor=function(le){return le.copy(re)},this.setScissor=function(le,Ae,Oe,Ie){le.isVector4?re.set(le.x,le.y,le.z,le.w):re.set(le,Ae,Oe,Ie),Q.scissor(R.copy(re).multiplyScalar(K).round())},this.getScissorTest=function(){return se},this.setScissorTest=function(le){Q.setScissorTest(se=le)},this.setOpaqueSort=function(le){F=le},this.setTransparentSort=function(le){q=le},this.getClearColor=function(le){return le.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor(...arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha(...arguments)},this.clear=function(le=!0,Ae=!0,Oe=!0){let Ie=0;if(le){let Re=!1;if(P!==null){const Je=P.texture.format;Re=b.has(Je)}if(Re){const Je=P.texture.type,xt=v.has(Je),Nt=me.getClearColor(),Et=me.getClearAlpha(),Ct=Nt.r,jt=Nt.g,wt=Nt.b;xt?(x[0]=Ct,x[1]=jt,x[2]=wt,x[3]=Et,$.clearBufferuiv($.COLOR,0,x)):(y[0]=Ct,y[1]=jt,y[2]=wt,y[3]=Et,$.clearBufferiv($.COLOR,0,y))}else Ie|=$.COLOR_BUFFER_BIT}Ae&&(Ie|=$.DEPTH_BUFFER_BIT),Oe&&(Ie|=$.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),$.clear(Ie)},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",je,!1),n.removeEventListener("webglcontextrestored",Ne,!1),n.removeEventListener("webglcontextcreationerror",Xe,!1),me.dispose(),Ve.dispose(),it.dispose(),Te.dispose(),H.dispose(),I.dispose(),Se.dispose(),ie.dispose(),He.dispose(),_e.dispose(),Be.dispose(),Be.removeEventListener("sessionstart",$t),Be.removeEventListener("sessionend",Cn),nr.stop()};function je(le){le.preventDefault(),U$("WebGLRenderer: Context Lost."),T=!0}function Ne(){U$("WebGLRenderer: Context Restored."),T=!1;const le=Me.autoReset,Ae=Fe.enabled,Oe=Fe.autoUpdate,Ie=Fe.needsUpdate,Re=Fe.type;ve(),Me.autoReset=le,Fe.enabled=Ae,Fe.autoUpdate=Oe,Fe.needsUpdate=Ie,Fe.type=Re}function Xe(le){ii("WebGLRenderer: A WebGL context could not be created. Reason: ",le.statusMessage)}function mt(le){const Ae=le.target;Ae.removeEventListener("dispose",mt),At(Ae)}function At(le){Rt(le),Te.remove(le)}function Rt(le){const Ae=Te.get(le).programs;Ae!==void 0&&(Ae.forEach(function(Oe){_e.releaseProgram(Oe)}),le.isShaderMaterial&&_e.releaseShaderCache(le))}this.renderBufferDirect=function(le,Ae,Oe,Ie,Re,Je){Ae===null&&(Ae=ue);const xt=Re.isMesh&&Re.matrixWorld.determinant()<0,Nt=ye(le,Ae,Oe,Ie,Re);Q.setMaterial(Ie,xt);let Et=Oe.index,Ct=1;if(Ie.wireframe===!0){if(Et=we.getWireframeAttribute(Oe),Et===void 0)return;Ct=2}const jt=Oe.drawRange,wt=Oe.attributes.position;let tn=jt.start*Ct,Vt=(jt.start+jt.count)*Ct;Je!==null&&(tn=Math.max(tn,Je.start*Ct),Vt=Math.min(Vt,(Je.start+Je.count)*Ct)),Et!==null?(tn=Math.max(tn,0),Vt=Math.min(Vt,Et.count)):wt!=null&&(tn=Math.max(tn,0),Vt=Math.min(Vt,wt.count));const hn=Vt-tn;if(hn<0||hn===1/0)return;ie.setup(Re,Ie,Nt,Oe,Et);let _n,kn=qe;if(Et!==null&&(_n=ce.get(Et),kn=Qe,kn.setIndex(_n)),Re.isMesh)Ie.wireframe===!0?(Q.setLineWidth(Ie.wireframeLinewidth*V()),kn.setMode($.LINES)):kn.setMode($.TRIANGLES);else if(Re.isLine){let Ht=Ie.linewidth;Ht===void 0&&(Ht=1),Q.setLineWidth(Ht*V()),Re.isLineSegments?kn.setMode($.LINES):Re.isLineLoop?kn.setMode($.LINE_LOOP):kn.setMode($.LINE_STRIP)}else Re.isPoints?kn.setMode($.POINTS):Re.isSprite&&kn.setMode($.TRIANGLES);if(Re.isBatchedMesh)if(Re._multiDrawInstances!==null)x0("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),kn.renderMultiDrawInstances(Re._multiDrawStarts,Re._multiDrawCounts,Re._multiDrawCount,Re._multiDrawInstances);else if(B.get("WEBGL_multi_draw"))kn.renderMultiDraw(Re._multiDrawStarts,Re._multiDrawCounts,Re._multiDrawCount);else{const Ht=Re._multiDrawStarts,sn=Re._multiDrawCounts,cn=Re._multiDrawCount,Ur=Et?ce.get(Et).bytesPerElement:1,ei=Te.get(Ie).currentProgram.getUniforms();for(let Vn=0;Vn<cn;Vn++)ei.setValue($,"_gl_DrawID",Vn),kn.render(Ht[Vn]/Ur,sn[Vn])}else if(Re.isInstancedMesh)kn.renderInstances(tn,hn,Re.count);else if(Oe.isInstancedBufferGeometry){const Ht=Oe._maxInstanceCount!==void 0?Oe._maxInstanceCount:1/0,sn=Math.min(Oe.instanceCount,Ht);kn.renderInstances(tn,hn,sn)}else kn.render(tn,hn)};function Xt(le,Ae,Oe){le.transparent===!0&&le.side===yl&&le.forceSinglePass===!1?(le.side=ls,le.needsUpdate=!0,qt(le,Ae,Oe),le.side=Ud,le.needsUpdate=!0,qt(le,Ae,Oe),le.side=yl):qt(le,Ae,Oe)}this.compile=function(le,Ae,Oe=null){Oe===null&&(Oe=le),w=it.get(Oe),w.init(Ae),N.push(w),Oe.traverseVisible(function(Re){Re.isLight&&Re.layers.test(Ae.layers)&&(w.pushLight(Re),Re.castShadow&&w.pushShadow(Re))}),le!==Oe&&le.traverseVisible(function(Re){Re.isLight&&Re.layers.test(Ae.layers)&&(w.pushLight(Re),Re.castShadow&&w.pushShadow(Re))}),w.setupLights();const Ie=new Set;return le.traverse(function(Re){if(!(Re.isMesh||Re.isPoints||Re.isLine||Re.isSprite))return;const Je=Re.material;if(Je)if(Array.isArray(Je))for(let xt=0;xt<Je.length;xt++){const Nt=Je[xt];Xt(Nt,Oe,Re),Ie.add(Nt)}else Xt(Je,Oe,Re),Ie.add(Je)}),w=N.pop(),Ie},this.compileAsync=function(le,Ae,Oe=null){const Ie=this.compile(le,Ae,Oe);return new Promise(Re=>{function Je(){if(Ie.forEach(function(xt){Te.get(xt).currentProgram.isReady()&&Ie.delete(xt)}),Ie.size===0){Re(le);return}setTimeout(Je,10)}B.get("KHR_parallel_shader_compile")!==null?Je():setTimeout(Je,10)})};let Lt=null;function Sn(le){Lt&&Lt(le)}function $t(){nr.stop()}function Cn(){nr.start()}const nr=new xZ;nr.setAnimationLoop(Sn),typeof self<"u"&&nr.setContext(self),this.setAnimationLoop=function(le){Lt=le,Be.setAnimationLoop(le),le===null?nr.stop():nr.start()},Be.addEventListener("sessionstart",$t),Be.addEventListener("sessionend",Cn),this.render=function(le,Ae){if(Ae!==void 0&&Ae.isCamera!==!0){ii("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;if(le.matrixWorldAutoUpdate===!0&&le.updateMatrixWorld(),Ae.parent===null&&Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),Be.enabled===!0&&Be.isPresenting===!0&&(Be.cameraAutoUpdate===!0&&Be.updateCamera(Ae),Ae=Be.getCamera()),le.isScene===!0&&le.onBeforeRender(C,le,Ae,P),w=it.get(le,N.length),w.init(Ae),N.push(w),oe.multiplyMatrices(Ae.projectionMatrix,Ae.matrixWorldInverse),de.setFromProjectionMatrix(oe,Sl,Ae.reversedDepth),Ce=this.localClippingEnabled,pe=ct.init(this.clippingPlanes,Ce),E=Ve.get(le,A.length),E.init(),A.push(E),Be.enabled===!0&&Be.isPresenting===!0){const Je=C.xr.getDepthSensingMesh();Je!==null&&Hn(Je,Ae,-1/0,C.sortObjects)}Hn(le,Ae,0,C.sortObjects),E.finish(),C.sortObjects===!0&&E.sort(F,q),Le=Be.enabled===!1||Be.isPresenting===!1||Be.hasDepthSensing()===!1,Le&&me.addToRenderList(E,le),this.info.render.frame++,pe===!0&&ct.beginShadows();const Oe=w.state.shadowsArray;Fe.render(Oe,le,Ae),pe===!0&&ct.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ie=E.opaque,Re=E.transmissive;if(w.setupLights(),Ae.isArrayCamera){const Je=Ae.cameras;if(Re.length>0)for(let xt=0,Nt=Je.length;xt<Nt;xt++){const Et=Je[xt];qn(Ie,Re,le,Et)}Le&&me.render(le);for(let xt=0,Nt=Je.length;xt<Nt;xt++){const Et=Je[xt];Jr(E,le,Et,Et.viewport)}}else Re.length>0&&qn(Ie,Re,le,Ae),Le&&me.render(le),Jr(E,le,Ae);P!==null&&k===0&&(fe.updateMultisampleRenderTarget(P),fe.updateRenderTargetMipmap(P)),le.isScene===!0&&le.onAfterRender(C,le,Ae),ie.resetDefaultState(),z=-1,L=null,N.pop(),N.length>0?(w=N[N.length-1],pe===!0&&ct.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,A.pop(),A.length>0?E=A[A.length-1]:E=null};function Hn(le,Ae,Oe,Ie){if(le.visible===!1)return;if(le.layers.test(Ae.layers)){if(le.isGroup)Oe=le.renderOrder;else if(le.isLOD)le.autoUpdate===!0&&le.update(Ae);else if(le.isLight)w.pushLight(le),le.castShadow&&w.pushShadow(le);else if(le.isSprite){if(!le.frustumCulled||de.intersectsSprite(le)){Ie&&ge.setFromMatrixPosition(le.matrixWorld).applyMatrix4(oe);const xt=Se.update(le),Nt=le.material;Nt.visible&&E.push(le,xt,Nt,Oe,ge.z,null)}}else if((le.isMesh||le.isLine||le.isPoints)&&(!le.frustumCulled||de.intersectsObject(le))){const xt=Se.update(le),Nt=le.material;if(Ie&&(le.boundingSphere!==void 0?(le.boundingSphere===null&&le.computeBoundingSphere(),ge.copy(le.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),ge.copy(xt.boundingSphere.center)),ge.applyMatrix4(le.matrixWorld).applyMatrix4(oe)),Array.isArray(Nt)){const Et=xt.groups;for(let Ct=0,jt=Et.length;Ct<jt;Ct++){const wt=Et[Ct],tn=Nt[wt.materialIndex];tn&&tn.visible&&E.push(le,xt,tn,Oe,ge.z,wt)}}else Nt.visible&&E.push(le,xt,Nt,Oe,ge.z,null)}}const Je=le.children;for(let xt=0,Nt=Je.length;xt<Nt;xt++)Hn(Je[xt],Ae,Oe,Ie)}function Jr(le,Ae,Oe,Ie){const{opaque:Re,transmissive:Je,transparent:xt}=le;w.setupLightsView(Oe),pe===!0&&ct.setGlobalState(C.clippingPlanes,Oe),Ie&&Q.viewport(X.copy(Ie)),Re.length>0&&yt(Re,Ae,Oe),Je.length>0&&yt(Je,Ae,Oe),xt.length>0&&yt(xt,Ae,Oe),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function qn(le,Ae,Oe,Ie){if((Oe.isScene===!0?Oe.overrideMaterial:null)!==null)return;w.state.transmissionRenderTarget[Ie.id]===void 0&&(w.state.transmissionRenderTarget[Ie.id]=new Tf(1,1,{generateMipmaps:!0,type:B.has("EXT_color_buffer_half_float")||B.has("EXT_color_buffer_float")?Dg:Dl,minFilter:Hh,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Fn.workingColorSpace}));const Je=w.state.transmissionRenderTarget[Ie.id],xt=Ie.viewport||X;Je.setSize(xt.z*C.transmissionResolutionScale,xt.w*C.transmissionResolutionScale);const Nt=C.getRenderTarget(),Et=C.getActiveCubeFace(),Ct=C.getActiveMipmapLevel();C.setRenderTarget(Je),C.getClearColor(J),G=C.getClearAlpha(),G<1&&C.setClearColor(16777215,.5),C.clear(),Le&&me.render(Oe);const jt=C.toneMapping;C.toneMapping=Sd;const wt=Ie.viewport;if(Ie.viewport!==void 0&&(Ie.viewport=void 0),w.setupLightsView(Ie),pe===!0&&ct.setGlobalState(C.clippingPlanes,Ie),yt(le,Oe,Ie),fe.updateMultisampleRenderTarget(Je),fe.updateRenderTargetMipmap(Je),B.has("WEBGL_multisampled_render_to_texture")===!1){let tn=!1;for(let Vt=0,hn=Ae.length;Vt<hn;Vt++){const _n=Ae[Vt],{object:kn,geometry:Ht,material:sn,group:cn}=_n;if(sn.side===yl&&kn.layers.test(Ie.layers)){const Ur=sn.side;sn.side=ls,sn.needsUpdate=!0,Ft(kn,Oe,Ie,Ht,sn,cn),sn.side=Ur,sn.needsUpdate=!0,tn=!0}}tn===!0&&(fe.updateMultisampleRenderTarget(Je),fe.updateRenderTargetMipmap(Je))}C.setRenderTarget(Nt,Et,Ct),C.setClearColor(J,G),wt!==void 0&&(Ie.viewport=wt),C.toneMapping=jt}function yt(le,Ae,Oe){const Ie=Ae.isScene===!0?Ae.overrideMaterial:null;for(let Re=0,Je=le.length;Re<Je;Re++){const xt=le[Re],{object:Nt,geometry:Et,group:Ct}=xt;let jt=xt.material;jt.allowOverride===!0&&Ie!==null&&(jt=Ie),Nt.layers.test(Oe.layers)&&Ft(Nt,Ae,Oe,Et,jt,Ct)}}function Ft(le,Ae,Oe,Ie,Re,Je){le.onBeforeRender(C,Ae,Oe,Ie,Re,Je),le.modelViewMatrix.multiplyMatrices(Oe.matrixWorldInverse,le.matrixWorld),le.normalMatrix.getNormalMatrix(le.modelViewMatrix),Re.onBeforeRender(C,Ae,Oe,Ie,le,Je),Re.transparent===!0&&Re.side===yl&&Re.forceSinglePass===!1?(Re.side=ls,Re.needsUpdate=!0,C.renderBufferDirect(Oe,Ae,Ie,Re,le,Je),Re.side=Ud,Re.needsUpdate=!0,C.renderBufferDirect(Oe,Ae,Ie,Re,le,Je),Re.side=yl):C.renderBufferDirect(Oe,Ae,Ie,Re,le,Je),le.onAfterRender(C,Ae,Oe,Ie,Re,Je)}function qt(le,Ae,Oe){Ae.isScene!==!0&&(Ae=ue);const Ie=Te.get(le),Re=w.state.lights,Je=w.state.shadowsArray,xt=Re.state.version,Nt=_e.getParameters(le,Re.state,Je,Ae,Oe),Et=_e.getProgramCacheKey(Nt);let Ct=Ie.programs;Ie.environment=le.isMeshStandardMaterial?Ae.environment:null,Ie.fog=Ae.fog,Ie.envMap=(le.isMeshStandardMaterial?I:H).get(le.envMap||Ie.environment),Ie.envMapRotation=Ie.environment!==null&&le.envMap===null?Ae.environmentRotation:le.envMapRotation,Ct===void 0&&(le.addEventListener("dispose",mt),Ct=new Map,Ie.programs=Ct);let jt=Ct.get(Et);if(jt!==void 0){if(Ie.currentProgram===jt&&Ie.lightsStateVersion===xt)return en(le,Nt),jt}else Nt.uniforms=_e.getUniforms(le),le.onBeforeCompile(Nt,C),jt=_e.acquireProgram(Nt,Et),Ct.set(Et,jt),Ie.uniforms=Nt.uniforms;const wt=Ie.uniforms;return(!le.isShaderMaterial&&!le.isRawShaderMaterial||le.clipping===!0)&&(wt.clippingPlanes=ct.uniform),en(le,Nt),Ie.needsLights=Ye(le),Ie.lightsStateVersion=xt,Ie.needsLights&&(wt.ambientLightColor.value=Re.state.ambient,wt.lightProbe.value=Re.state.probe,wt.directionalLights.value=Re.state.directional,wt.directionalLightShadows.value=Re.state.directionalShadow,wt.spotLights.value=Re.state.spot,wt.spotLightShadows.value=Re.state.spotShadow,wt.rectAreaLights.value=Re.state.rectArea,wt.ltc_1.value=Re.state.rectAreaLTC1,wt.ltc_2.value=Re.state.rectAreaLTC2,wt.pointLights.value=Re.state.point,wt.pointLightShadows.value=Re.state.pointShadow,wt.hemisphereLights.value=Re.state.hemi,wt.directionalShadowMap.value=Re.state.directionalShadowMap,wt.directionalShadowMatrix.value=Re.state.directionalShadowMatrix,wt.spotShadowMap.value=Re.state.spotShadowMap,wt.spotLightMatrix.value=Re.state.spotLightMatrix,wt.spotLightMap.value=Re.state.spotLightMap,wt.pointShadowMap.value=Re.state.pointShadowMap,wt.pointShadowMatrix.value=Re.state.pointShadowMatrix),Ie.currentProgram=jt,Ie.uniformsList=null,jt}function gt(le){if(le.uniformsList===null){const Ae=le.currentProgram.getUniforms();le.uniformsList=$1.seqWithValue(Ae.seq,le.uniforms)}return le.uniformsList}function en(le,Ae){const Oe=Te.get(le);Oe.outputColorSpace=Ae.outputColorSpace,Oe.batching=Ae.batching,Oe.batchingColor=Ae.batchingColor,Oe.instancing=Ae.instancing,Oe.instancingColor=Ae.instancingColor,Oe.instancingMorph=Ae.instancingMorph,Oe.skinning=Ae.skinning,Oe.morphTargets=Ae.morphTargets,Oe.morphNormals=Ae.morphNormals,Oe.morphColors=Ae.morphColors,Oe.morphTargetsCount=Ae.morphTargetsCount,Oe.numClippingPlanes=Ae.numClippingPlanes,Oe.numIntersection=Ae.numClipIntersection,Oe.vertexAlphas=Ae.vertexAlphas,Oe.vertexTangents=Ae.vertexTangents,Oe.toneMapping=Ae.toneMapping}function ye(le,Ae,Oe,Ie,Re){Ae.isScene!==!0&&(Ae=ue),fe.resetTextureUnits();const Je=Ae.fog,xt=Ie.isMeshStandardMaterial?Ae.environment:null,Nt=P===null?C.outputColorSpace:P.isXRRenderTarget===!0?P.texture.colorSpace:ng,Et=(Ie.isMeshStandardMaterial?I:H).get(Ie.envMap||xt),Ct=Ie.vertexColors===!0&&!!Oe.attributes.color&&Oe.attributes.color.itemSize===4,jt=!!Oe.attributes.tangent&&(!!Ie.normalMap||Ie.anisotropy>0),wt=!!Oe.morphAttributes.position,tn=!!Oe.morphAttributes.normal,Vt=!!Oe.morphAttributes.color;let hn=Sd;Ie.toneMapped&&(P===null||P.isXRRenderTarget===!0)&&(hn=C.toneMapping);const _n=Oe.morphAttributes.position||Oe.morphAttributes.normal||Oe.morphAttributes.color,kn=_n!==void 0?_n.length:0,Ht=Te.get(Ie),sn=w.state.lights;if(pe===!0&&(Ce===!0||le!==L)){const Fi=le===L&&Ie.id===z;ct.setState(Ie,le,Fi)}let cn=!1;Ie.version===Ht.__version?(Ht.needsLights&&Ht.lightsStateVersion!==sn.state.version||Ht.outputColorSpace!==Nt||Re.isBatchedMesh&&Ht.batching===!1||!Re.isBatchedMesh&&Ht.batching===!0||Re.isBatchedMesh&&Ht.batchingColor===!0&&Re.colorTexture===null||Re.isBatchedMesh&&Ht.batchingColor===!1&&Re.colorTexture!==null||Re.isInstancedMesh&&Ht.instancing===!1||!Re.isInstancedMesh&&Ht.instancing===!0||Re.isSkinnedMesh&&Ht.skinning===!1||!Re.isSkinnedMesh&&Ht.skinning===!0||Re.isInstancedMesh&&Ht.instancingColor===!0&&Re.instanceColor===null||Re.isInstancedMesh&&Ht.instancingColor===!1&&Re.instanceColor!==null||Re.isInstancedMesh&&Ht.instancingMorph===!0&&Re.morphTexture===null||Re.isInstancedMesh&&Ht.instancingMorph===!1&&Re.morphTexture!==null||Ht.envMap!==Et||Ie.fog===!0&&Ht.fog!==Je||Ht.numClippingPlanes!==void 0&&(Ht.numClippingPlanes!==ct.numPlanes||Ht.numIntersection!==ct.numIntersection)||Ht.vertexAlphas!==Ct||Ht.vertexTangents!==jt||Ht.morphTargets!==wt||Ht.morphNormals!==tn||Ht.morphColors!==Vt||Ht.toneMapping!==hn||Ht.morphTargetsCount!==kn)&&(cn=!0):(cn=!0,Ht.__version=Ie.version);let Ur=Ht.currentProgram;cn===!0&&(Ur=qt(Ie,Ae,Re));let ei=!1,Vn=!1,jo=!1;const Kn=Ur.getUniforms(),Ii=Ht.uniforms;if(Q.useProgram(Ur.program)&&(ei=!0,Vn=!0,jo=!0),Ie.id!==z&&(z=Ie.id,Vn=!0),ei||L!==le){Q.buffers.depth.getReversed()&&le.reversedDepth!==!0&&(le._reversedDepth=!0,le.updateProjectionMatrix()),Kn.setValue($,"projectionMatrix",le.projectionMatrix),Kn.setValue($,"viewMatrix",le.matrixWorldInverse);const Ji=Kn.map.cameraPosition;Ji!==void 0&&Ji.setValue($,ae.setFromMatrixPosition(le.matrixWorld)),U.logarithmicDepthBuffer&&Kn.setValue($,"logDepthBufFC",2/(Math.log(le.far+1)/Math.LN2)),(Ie.isMeshPhongMaterial||Ie.isMeshToonMaterial||Ie.isMeshLambertMaterial||Ie.isMeshBasicMaterial||Ie.isMeshStandardMaterial||Ie.isShaderMaterial)&&Kn.setValue($,"isOrthographic",le.isOrthographicCamera===!0),L!==le&&(L=le,Vn=!0,jo=!0)}if(Re.isSkinnedMesh){Kn.setOptional($,Re,"bindMatrix"),Kn.setOptional($,Re,"bindMatrixInverse");const Fi=Re.skeleton;Fi&&(Fi.boneTexture===null&&Fi.computeBoneTexture(),Kn.setValue($,"boneTexture",Fi.boneTexture,fe))}Re.isBatchedMesh&&(Kn.setOptional($,Re,"batchingTexture"),Kn.setValue($,"batchingTexture",Re._matricesTexture,fe),Kn.setOptional($,Re,"batchingIdTexture"),Kn.setValue($,"batchingIdTexture",Re._indirectTexture,fe),Kn.setOptional($,Re,"batchingColorTexture"),Re._colorsTexture!==null&&Kn.setValue($,"batchingColorTexture",Re._colorsTexture,fe));const _i=Oe.morphAttributes;if((_i.position!==void 0||_i.normal!==void 0||_i.color!==void 0)&&Ke.update(Re,Oe,Ur),(Vn||Ht.receiveShadow!==Re.receiveShadow)&&(Ht.receiveShadow=Re.receiveShadow,Kn.setValue($,"receiveShadow",Re.receiveShadow)),Ie.isMeshGouraudMaterial&&Ie.envMap!==null&&(Ii.envMap.value=Et,Ii.flipEnvMap.value=Et.isCubeTexture&&Et.isRenderTargetTexture===!1?-1:1),Ie.isMeshStandardMaterial&&Ie.envMap===null&&Ae.environment!==null&&(Ii.envMapIntensity.value=Ae.environmentIntensity),Ii.dfgLUT!==void 0&&(Ii.dfgLUT.value=N4e()),Vn&&(Kn.setValue($,"toneMappingExposure",C.toneMappingExposure),Ht.needsLights&&$e(Ii,jo),Je&&Ie.fog===!0&&st.refreshFogUniforms(Ii,Je),st.refreshMaterialUniforms(Ii,Ie,K,ee,w.state.transmissionRenderTarget[le.id]),$1.upload($,gt(Ht),Ii,fe)),Ie.isShaderMaterial&&Ie.uniformsNeedUpdate===!0&&($1.upload($,gt(Ht),Ii,fe),Ie.uniformsNeedUpdate=!1),Ie.isSpriteMaterial&&Kn.setValue($,"center",Re.center),Kn.setValue($,"modelViewMatrix",Re.modelViewMatrix),Kn.setValue($,"normalMatrix",Re.normalMatrix),Kn.setValue($,"modelMatrix",Re.matrixWorld),Ie.isShaderMaterial||Ie.isRawShaderMaterial){const Fi=Ie.uniformsGroups;for(let Ji=0,al=Fi.length;Ji<al;Ji++){const Gl=Fi[Ji];He.update(Gl,Ur),He.bind(Gl,Ur)}}return Ur}function $e(le,Ae){le.ambientLightColor.needsUpdate=Ae,le.lightProbe.needsUpdate=Ae,le.directionalLights.needsUpdate=Ae,le.directionalLightShadows.needsUpdate=Ae,le.pointLights.needsUpdate=Ae,le.pointLightShadows.needsUpdate=Ae,le.spotLights.needsUpdate=Ae,le.spotLightShadows.needsUpdate=Ae,le.rectAreaLights.needsUpdate=Ae,le.hemisphereLights.needsUpdate=Ae}function Ye(le){return le.isMeshLambertMaterial||le.isMeshToonMaterial||le.isMeshPhongMaterial||le.isMeshStandardMaterial||le.isShadowMaterial||le.isShaderMaterial&&le.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return P},this.setRenderTargetTextures=function(le,Ae,Oe){const Ie=Te.get(le);Ie.__autoAllocateDepthBuffer=le.resolveDepthBuffer===!1,Ie.__autoAllocateDepthBuffer===!1&&(Ie.__useRenderToTexture=!1),Te.get(le.texture).__webglTexture=Ae,Te.get(le.depthTexture).__webglTexture=Ie.__autoAllocateDepthBuffer?void 0:Oe,Ie.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(le,Ae){const Oe=Te.get(le);Oe.__webglFramebuffer=Ae,Oe.__useDefaultFramebuffer=Ae===void 0};const nt=$.createFramebuffer();this.setRenderTarget=function(le,Ae=0,Oe=0){P=le,D=Ae,k=Oe;let Ie=!0,Re=null,Je=!1,xt=!1;if(le){const Et=Te.get(le);if(Et.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer($.FRAMEBUFFER,null),Ie=!1;else if(Et.__webglFramebuffer===void 0)fe.setupRenderTarget(le);else if(Et.__hasExternalTextures)fe.rebindTextures(le,Te.get(le.texture).__webglTexture,Te.get(le.depthTexture).__webglTexture);else if(le.depthBuffer){const wt=le.depthTexture;if(Et.__boundDepthTexture!==wt){if(wt!==null&&Te.has(wt)&&(le.width!==wt.image.width||le.height!==wt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");fe.setupDepthRenderbuffer(le)}}const Ct=le.texture;(Ct.isData3DTexture||Ct.isDataArrayTexture||Ct.isCompressedArrayTexture)&&(xt=!0);const jt=Te.get(le).__webglFramebuffer;le.isWebGLCubeRenderTarget?(Array.isArray(jt[Ae])?Re=jt[Ae][Oe]:Re=jt[Ae],Je=!0):le.samples>0&&fe.useMultisampledRTT(le)===!1?Re=Te.get(le).__webglMultisampledFramebuffer:Array.isArray(jt)?Re=jt[Oe]:Re=jt,X.copy(le.viewport),R.copy(le.scissor),Y=le.scissorTest}else X.copy(ne).multiplyScalar(K).floor(),R.copy(re).multiplyScalar(K).floor(),Y=se;if(Oe!==0&&(Re=nt),Q.bindFramebuffer($.FRAMEBUFFER,Re)&&Ie&&Q.drawBuffers(le,Re),Q.viewport(X),Q.scissor(R),Q.setScissorTest(Y),Je){const Et=Te.get(le.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,Et.__webglTexture,Oe)}else if(xt){const Et=Ae;for(let Ct=0;Ct<le.textures.length;Ct++){const jt=Te.get(le.textures[Ct]);$.framebufferTextureLayer($.FRAMEBUFFER,$.COLOR_ATTACHMENT0+Ct,jt.__webglTexture,Oe,Et)}}else if(le!==null&&Oe!==0){const Et=Te.get(le.texture);$.framebufferTexture2D($.FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,Et.__webglTexture,Oe)}z=-1},this.readRenderTargetPixels=function(le,Ae,Oe,Ie,Re,Je,xt,Nt=0){if(!(le&&le.isWebGLRenderTarget)){ii("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Et=Te.get(le).__webglFramebuffer;if(le.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et){Q.bindFramebuffer($.FRAMEBUFFER,Et);try{const Ct=le.textures[Nt],jt=Ct.format,wt=Ct.type;if(!U.textureFormatReadable(jt)){ii("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!U.textureTypeReadable(wt)){ii("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ae>=0&&Ae<=le.width-Ie&&Oe>=0&&Oe<=le.height-Re&&(le.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+Nt),$.readPixels(Ae,Oe,Ie,Re,ut.convert(jt),ut.convert(wt),Je))}finally{const Ct=P!==null?Te.get(P).__webglFramebuffer:null;Q.bindFramebuffer($.FRAMEBUFFER,Ct)}}},this.readRenderTargetPixelsAsync=async function(le,Ae,Oe,Ie,Re,Je,xt,Nt=0){if(!(le&&le.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Et=Te.get(le).__webglFramebuffer;if(le.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et)if(Ae>=0&&Ae<=le.width-Ie&&Oe>=0&&Oe<=le.height-Re){Q.bindFramebuffer($.FRAMEBUFFER,Et);const Ct=le.textures[Nt],jt=Ct.format,wt=Ct.type;if(!U.textureFormatReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!U.textureTypeReadable(wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const tn=$.createBuffer();$.bindBuffer($.PIXEL_PACK_BUFFER,tn),$.bufferData($.PIXEL_PACK_BUFFER,Je.byteLength,$.STREAM_READ),le.textures.length>1&&$.readBuffer($.COLOR_ATTACHMENT0+Nt),$.readPixels(Ae,Oe,Ie,Re,ut.convert(jt),ut.convert(wt),0);const Vt=P!==null?Te.get(P).__webglFramebuffer:null;Q.bindFramebuffer($.FRAMEBUFFER,Vt);const hn=$.fenceSync($.SYNC_GPU_COMMANDS_COMPLETE,0);return $.flush(),await Zke($,hn,4),$.bindBuffer($.PIXEL_PACK_BUFFER,tn),$.getBufferSubData($.PIXEL_PACK_BUFFER,0,Je),$.deleteBuffer(tn),$.deleteSync(hn),Je}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(le,Ae=null,Oe=0){const Ie=Math.pow(2,-Oe),Re=Math.floor(le.image.width*Ie),Je=Math.floor(le.image.height*Ie),xt=Ae!==null?Ae.x:0,Nt=Ae!==null?Ae.y:0;fe.setTexture2D(le,0),$.copyTexSubImage2D($.TEXTURE_2D,Oe,0,0,xt,Nt,Re,Je),Q.unbindTexture()};const ke=$.createFramebuffer(),xe=$.createFramebuffer();this.copyTextureToTexture=function(le,Ae,Oe=null,Ie=null,Re=0,Je=null){Je===null&&(Re!==0?(x0("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Je=Re,Re=0):Je=0);let xt,Nt,Et,Ct,jt,wt,tn,Vt,hn;const _n=le.isCompressedTexture?le.mipmaps[Je]:le.image;if(Oe!==null)xt=Oe.max.x-Oe.min.x,Nt=Oe.max.y-Oe.min.y,Et=Oe.isBox3?Oe.max.z-Oe.min.z:1,Ct=Oe.min.x,jt=Oe.min.y,wt=Oe.isBox3?Oe.min.z:0;else{const _i=Math.pow(2,-Re);xt=Math.floor(_n.width*_i),Nt=Math.floor(_n.height*_i),le.isDataArrayTexture?Et=_n.depth:le.isData3DTexture?Et=Math.floor(_n.depth*_i):Et=1,Ct=0,jt=0,wt=0}Ie!==null?(tn=Ie.x,Vt=Ie.y,hn=Ie.z):(tn=0,Vt=0,hn=0);const kn=ut.convert(Ae.format),Ht=ut.convert(Ae.type);let sn;Ae.isData3DTexture?(fe.setTexture3D(Ae,0),sn=$.TEXTURE_3D):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?(fe.setTexture2DArray(Ae,0),sn=$.TEXTURE_2D_ARRAY):(fe.setTexture2D(Ae,0),sn=$.TEXTURE_2D),$.pixelStorei($.UNPACK_FLIP_Y_WEBGL,Ae.flipY),$.pixelStorei($.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ae.premultiplyAlpha),$.pixelStorei($.UNPACK_ALIGNMENT,Ae.unpackAlignment);const cn=$.getParameter($.UNPACK_ROW_LENGTH),Ur=$.getParameter($.UNPACK_IMAGE_HEIGHT),ei=$.getParameter($.UNPACK_SKIP_PIXELS),Vn=$.getParameter($.UNPACK_SKIP_ROWS),jo=$.getParameter($.UNPACK_SKIP_IMAGES);$.pixelStorei($.UNPACK_ROW_LENGTH,_n.width),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,_n.height),$.pixelStorei($.UNPACK_SKIP_PIXELS,Ct),$.pixelStorei($.UNPACK_SKIP_ROWS,jt),$.pixelStorei($.UNPACK_SKIP_IMAGES,wt);const Kn=le.isDataArrayTexture||le.isData3DTexture,Ii=Ae.isDataArrayTexture||Ae.isData3DTexture;if(le.isDepthTexture){const _i=Te.get(le),Fi=Te.get(Ae),Ji=Te.get(_i.__renderTarget),al=Te.get(Fi.__renderTarget);Q.bindFramebuffer($.READ_FRAMEBUFFER,Ji.__webglFramebuffer),Q.bindFramebuffer($.DRAW_FRAMEBUFFER,al.__webglFramebuffer);for(let Gl=0;Gl<Et;Gl++)Kn&&($.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Te.get(le).__webglTexture,Re,wt+Gl),$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Te.get(Ae).__webglTexture,Je,hn+Gl)),$.blitFramebuffer(Ct,jt,xt,Nt,tn,Vt,xt,Nt,$.DEPTH_BUFFER_BIT,$.NEAREST);Q.bindFramebuffer($.READ_FRAMEBUFFER,null),Q.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else if(Re!==0||le.isRenderTargetTexture||Te.has(le)){const _i=Te.get(le),Fi=Te.get(Ae);Q.bindFramebuffer($.READ_FRAMEBUFFER,ke),Q.bindFramebuffer($.DRAW_FRAMEBUFFER,xe);for(let Ji=0;Ji<Et;Ji++)Kn?$.framebufferTextureLayer($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,_i.__webglTexture,Re,wt+Ji):$.framebufferTexture2D($.READ_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,_i.__webglTexture,Re),Ii?$.framebufferTextureLayer($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,Fi.__webglTexture,Je,hn+Ji):$.framebufferTexture2D($.DRAW_FRAMEBUFFER,$.COLOR_ATTACHMENT0,$.TEXTURE_2D,Fi.__webglTexture,Je),Re!==0?$.blitFramebuffer(Ct,jt,xt,Nt,tn,Vt,xt,Nt,$.COLOR_BUFFER_BIT,$.NEAREST):Ii?$.copyTexSubImage3D(sn,Je,tn,Vt,hn+Ji,Ct,jt,xt,Nt):$.copyTexSubImage2D(sn,Je,tn,Vt,Ct,jt,xt,Nt);Q.bindFramebuffer($.READ_FRAMEBUFFER,null),Q.bindFramebuffer($.DRAW_FRAMEBUFFER,null)}else Ii?le.isDataTexture||le.isData3DTexture?$.texSubImage3D(sn,Je,tn,Vt,hn,xt,Nt,Et,kn,Ht,_n.data):Ae.isCompressedArrayTexture?$.compressedTexSubImage3D(sn,Je,tn,Vt,hn,xt,Nt,Et,kn,_n.data):$.texSubImage3D(sn,Je,tn,Vt,hn,xt,Nt,Et,kn,Ht,_n):le.isDataTexture?$.texSubImage2D($.TEXTURE_2D,Je,tn,Vt,xt,Nt,kn,Ht,_n.data):le.isCompressedTexture?$.compressedTexSubImage2D($.TEXTURE_2D,Je,tn,Vt,_n.width,_n.height,kn,_n.data):$.texSubImage2D($.TEXTURE_2D,Je,tn,Vt,xt,Nt,kn,Ht,_n);$.pixelStorei($.UNPACK_ROW_LENGTH,cn),$.pixelStorei($.UNPACK_IMAGE_HEIGHT,Ur),$.pixelStorei($.UNPACK_SKIP_PIXELS,ei),$.pixelStorei($.UNPACK_SKIP_ROWS,Vn),$.pixelStorei($.UNPACK_SKIP_IMAGES,jo),Je===0&&Ae.generateMipmaps&&$.generateMipmap(sn),Q.unbindTexture()},this.initRenderTarget=function(le){Te.get(le).__webglFramebuffer===void 0&&fe.setupRenderTarget(le)},this.initTexture=function(le){le.isCubeTexture?fe.setTextureCube(le,0):le.isData3DTexture?fe.setTexture3D(le,0):le.isDataArrayTexture||le.isCompressedArrayTexture?fe.setTexture2DArray(le,0):fe.setTexture2D(le,0),Q.unbindTexture()},this.resetState=function(){D=0,k=0,P=null,Q.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Sl}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=Fn._getDrawingBufferColorSpace(e),n.unpackColorSpace=Fn._getUnpackColorSpace()}};const DH={type:"change"},tO={type:"start"},wZ={type:"end"},C_=new Y4,OH=new nd,T4e=Math.cos(70*eje.DEG2RAD),Si=new at,ns=2*Math.PI,ur={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},DC=1e-6;class C4e extends zje{constructor(e,n=null){super(e,n),this.state=ur.NONE,this.target=new at,this.cursor=new at,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:kp.ROTATE,MIDDLE:kp.DOLLY,RIGHT:kp.PAN},this.touches={ONE:wp.ROTATE,TWO:wp.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new at,this._lastQuaternion=new Af,this._lastTargetPosition=new at,this._quat=new Af().setFromUnitVectors(e.up,new at(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new cH,this._sphericalDelta=new cH,this._scale=1,this._panOffset=new at,this._rotateStart=new xn,this._rotateEnd=new xn,this._rotateDelta=new xn,this._panStart=new xn,this._panEnd=new xn,this._panDelta=new xn,this._dollyStart=new xn,this._dollyEnd=new xn,this._dollyDelta=new xn,this._dollyDirection=new at,this._mouse=new xn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=j4e.bind(this),this._onPointerDown=k4e.bind(this),this._onPointerUp=P4e.bind(this),this._onContextMenu=U4e.bind(this),this._onMouseWheel=O4e.bind(this),this._onKeyDown=L4e.bind(this),this._onTouchStart=I4e.bind(this),this._onTouchMove=F4e.bind(this),this._onMouseDown=R4e.bind(this),this._onMouseMove=D4e.bind(this),this._interceptControlDown=z4e.bind(this),this._interceptControlUp=B4e.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(DH),this.update(),this.state=ur.NONE}update(e=null){const n=this.object.position;Si.copy(n).sub(this.target),Si.applyQuaternion(this._quat),this._spherical.setFromVector3(Si),this.autoRotate&&this.state===ur.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 r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=ns:r>Math.PI&&(r-=ns),i<-Math.PI?i+=ns:i>Math.PI&&(i-=ns),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,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 o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(Si.setFromSpherical(this._spherical),Si.applyQuaternion(this._quatInverse),n.copy(this.target).add(Si),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 o=null;if(this.object.isPerspectiveCamera){const l=Si.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new at(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new at(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Si.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(C_.origin.copy(this.object.position),C_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(C_.direction))<T4e?this.object.lookAt(this.target):(OH.setFromNormalAndCoplanarPoint(this.object.up,this.target),C_.intersectPlane(OH,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>DC||8*(1-this._lastQuaternion.dot(this.object.quaternion))>DC||this._lastTargetPosition.distanceToSquared(this.target)>DC?(this.dispatchEvent(DH),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ns/60*this.autoRotateSpeed*e:ns/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){Si.setFromMatrixColumn(n,0),Si.multiplyScalar(-e),this._panOffset.add(Si)}_panUp(e,n){this.screenSpacePanning===!0?Si.setFromMatrixColumn(n,1):(Si.setFromMatrixColumn(n,0),Si.crossVectors(this.object.up,Si)),Si.multiplyScalar(e),this._panOffset.add(Si)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Si.copy(i).sub(this.target);let a=Si.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.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 r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/l)*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(ns*this._rotateDelta.x/n.clientHeight),this._rotateUp(ns*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(ns*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(-ns*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(ns*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(-ns*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),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);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 r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(ns*this._rotateDelta.x/n.clientHeight),this._rotateUp(ns*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),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}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),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);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 o=(e.pageX+n.x)*.5,l=(e.pageY+n.y)*.5;this._updateZoomParameters(o,l)}_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 xn,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,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function k4e(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 j4e(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function P4e(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(wZ),this.state=ur.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 R4e(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 kp.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=ur.DOLLY;break;case kp.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=ur.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=ur.ROTATE}break;case kp.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=ur.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=ur.PAN}break;default:this.state=ur.NONE}this.state!==ur.NONE&&this.dispatchEvent(tO)}function D4e(t){switch(this.state){case ur.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case ur.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case ur.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function O4e(t){this.enabled===!1||this.enableZoom===!1||this.state!==ur.NONE||(t.preventDefault(),this.dispatchEvent(tO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(wZ))}function L4e(t){this.enabled!==!1&&this._handleKeyDown(t)}function I4e(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case wp.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=ur.TOUCH_ROTATE;break;case wp.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=ur.TOUCH_PAN;break;default:this.state=ur.NONE}break;case 2:switch(this.touches.TWO){case wp.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=ur.TOUCH_DOLLY_PAN;break;case wp.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=ur.TOUCH_DOLLY_ROTATE;break;default:this.state=ur.NONE}break;default:this.state=ur.NONE}this.state!==ur.NONE&&this.dispatchEvent(tO)}function F4e(t){switch(this._trackPointer(t),this.state){case ur.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case ur.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case ur.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case ur.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=ur.NONE}}function U4e(t){this.enabled!==!1&&t.preventDefault()}function z4e(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function B4e(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function $4e(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},o={},l=t[0].morphTargetsRelative,c=new Vl;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let p=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const g in f.attributes){if(!r.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. 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]),p++}if(p!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const g in f.morphAttributes){if(!i.has(g))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[g]===void 0&&(o[g]=[]),o[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 "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,g,d),u+=g}}if(n){let d=0;const f=[];for(let p=0;p<t.length;++p){const g=t[p].index;for(let b=0;b<g.count;++b)f.push(g.getX(b)+d);d+=t[p].attributes.position.count}c.setIndex(f)}for(const d in a){const f=LH(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let p=0;p<f;++p){const g=[];for(let v=0;v<o[d].length;++v)g.push(o[d][v][p]);const b=LH(g);if(!b)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;c.morphAttributes[d].push(b)}}return c}function LH(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const o=new e(a),l=new vo(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let p=0,g=d.count;p<g;p++)for(let b=0;b<n;b++){const v=d.getComponent(p,b);l.setComponent(p+f,b,v)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function k_(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 OC={exports:{}};var IH;function H4e(){return IH||(IH=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof k_=="function"&&k_;if(!d&&f)return f(u,!0);if(l)return l(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var g=i[u]={exports:{}};r[u][0].call(g.exports,function(b){var v=r[u][1][b];return o(v||b)},g,g.exports,n,r,i,a)}return i[u].exports}for(var l=typeof k_=="function"&&k_,c=0;c<a.length;c++)o(a[c]);return o})({1:[function(n,r,i){var a=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,p,g,b,v,x=[],y=0,E=c.length,w=E,A=a.getTypeOf(c)!=="string";y<c.length;)w=E-y,f=A?(u=c[y++],d=y<E?c[y++]:0,y<E?c[y++]:0):(u=c.charCodeAt(y++),d=y<E?c.charCodeAt(y++):0,y<E?c.charCodeAt(y++):0),p=u>>2,g=(3&u)<<4|d>>4,b=1<w?(15&d)<<2|f>>6:64,v=2<w?63&f:64,x.push(l.charAt(p)+l.charAt(g)+l.charAt(b)+l.charAt(v));return x.join("")},i.decode=function(c){var u,d,f,p,g,b,v=0,x=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var E,w=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&w--,c.charAt(c.length-2)===l.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(E=o.uint8array?new Uint8Array(0|w):new Array(0|w);v<c.length;)u=l.indexOf(c.charAt(v++))<<2|(p=l.indexOf(c.charAt(v++)))>>4,d=(15&p)<<4|(g=l.indexOf(c.charAt(v++)))>>2,f=(3&g)<<6|(b=l.indexOf(c.charAt(v++))),E[x++]=u,g!==64&&(E[x++]=d),b!==64&&(E[x++]=f);return E}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,p,g,b){this.compressedSize=d,this.uncompressedSize=f,this.crc32=p,this.compression=g,this.compressedContent=b}u.prototype={getContentWorker:function(){var d=new o(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,p){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),o=(function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c})();r.exports=function(l,c){return l!==void 0&&l.length?a.getTypeOf(l)!=="string"?(function(u,d,f,p){var g=o,b=p+f;u^=-1;for(var v=p;v<b;v++)u=u>>>8^g[255&(u^d[v])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,p){var g=o,b=p+f;u^=-1;for(var v=p;v<b;v++)u=u>>>8^g[255&(u^d.charCodeAt(v))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,p){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(g,b){var v,x="";for(v=0;v<b;v++)x+=String.fromCharCode(255&g),g>>>=8;return x}function o(g,b,v,x,y,E){var w,A,N=g.file,C=g.compression,T=E!==u.utf8encode,D=l.transformTo("string",E(N.name)),k=l.transformTo("string",u.utf8encode(N.name)),P=N.comment,z=l.transformTo("string",E(P)),L=l.transformTo("string",u.utf8encode(P)),X=k.length!==N.name.length,R=L.length!==P.length,Y="",J="",G="",W=N.dir,ee=N.date,K={crc32:0,compressedSize:0,uncompressedSize:0};b&&!v||(K.crc32=g.crc32,K.compressedSize=g.compressedSize,K.uncompressedSize=g.uncompressedSize);var F=0;b&&(F|=8),T||!X&&!R||(F|=2048);var q=0,ne=0;W&&(q|=16),y==="UNIX"?(ne=798,q|=(function(se,de){var pe=se;return se||(pe=de?16893:33204),(65535&pe)<<16})(N.unixPermissions,W)):(ne=20,q|=(function(se){return 63&(se||0)})(N.dosPermissions)),w=ee.getUTCHours(),w<<=6,w|=ee.getUTCMinutes(),w<<=5,w|=ee.getUTCSeconds()/2,A=ee.getUTCFullYear()-1980,A<<=4,A|=ee.getUTCMonth()+1,A<<=5,A|=ee.getUTCDate(),X&&(J=a(1,1)+a(d(D),4)+k,Y+="up"+a(J.length,2)+J),R&&(G=a(1,1)+a(d(z),4)+L,Y+="uc"+a(G.length,2)+G);var re="";return re+=`
- \0`,re+=a(F,2),re+=C.magic,re+=a(w,2),re+=a(A,2),re+=a(K.crc32,4),re+=a(K.compressedSize,4),re+=a(K.uncompressedSize,4),re+=a(D.length,2),re+=a(Y.length,2),{fileRecord:f.LOCAL_FILE_HEADER+re+D+Y,dirRecord:f.CENTRAL_FILE_HEADER+a(ne,2)+re+a(z.length,2)+"\0\0\0\0"+a(q,4)+a(x,4)+D+Y+z}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function p(g,b,v,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=v,this.encodeFileName=x,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(p,c),p.prototype.push=function(g){var b=g.meta.percent||0,v=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,c.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:v?(b+100*(v-x-1))/v:100}}))},p.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var b=this.streamFiles&&!g.file.dir;if(b){var v=o(g,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(g){this.accumulate=!1;var b=this.streamFiles&&!g.file.dir,v=o(g,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),b)this.push({data:(function(x){return f.DATA_DESCRIPTOR+a(x.crc32,4)+a(x.compressedSize,4)+a(x.uncompressedSize,4)})(g),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var g=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var v=this.bytesWritten-g,x=(function(y,E,w,A,N){var C=l.transformTo("string",N(A));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(y,2)+a(y,2)+a(E,4)+a(w,4)+a(C.length,2)+C})(this.dirRecords.length,v,g,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(g){this._sources.push(g);var b=this;return g.on("data",function(v){b.processChunk(v)}),g.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),g.on("error",function(v){b.error(v)}),this},p.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(g){var b=this._sources;if(!c.prototype.error.call(this,g))return!1;for(var v=0;v<b.length;v++)try{b[v].error(g)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var g=this._sources,b=0;b<g.length;b++)g[b].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,i){var a=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(p,g){f++;var b=(function(E,w){var A=E||w,N=a[A];if(!N)throw new Error(A+" is not a valid compression method !");return N})(g.options.compression,c.compression),v=g.options.compressionOptions||c.compressionOptions||{},x=g.dir,y=g.date;g._compressWorker(b,v).withStreamInfo("file",{name:p,dir:x,date:y,comment:g.comment||"",unixPermissions:g.unixPermissions,dosPermissions:g.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){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 o=new a;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(o,l){return new a().loadAsync(o,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(p){return new o.Promise(function(g,b){var v=p.decompressed.getContentWorker().pipe(new u);v.on("error",function(x){b(x)}).on("end",function(){v.streamInfo.crc32!==p.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):g()}).resume()})}r.exports=function(p,g){var b=this;return g=a.extend(g||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(p)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):a.prepareContent("the loaded zip file",p,!0,g.optimizedBinaryString,g.base64).then(function(v){var x=new c(g);return x.load(v),x}).then(function(v){var x=[o.Promise.resolve(v)],y=v.files;if(g.checkCRC32)for(var E=0;E<y.length;E++)x.push(f(y[E]));return o.Promise.all(x)}).then(function(v){for(var x=v.shift(),y=x.files,E=0;E<y.length;E++){var w=y[E],A=w.fileNameStr,N=a.resolve(w.fileNameStr);b.file(N,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||(b.file(N).unsafeOriginalName=A)}return x.zipComment.length&&(b.comment=x.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,i){var a=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}a.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,i){var a=n("readable-stream").Readable;function o(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,p){d.push(f)||d._helper.pause(),u&&u(p)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,a),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,i){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},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,r,i){function a(N,C,T){var D,k=l.getTypeOf(C),P=l.extend(T||{},d);P.date=P.date||new Date,P.compression!==null&&(P.compression=P.compression.toUpperCase()),typeof P.unixPermissions=="string"&&(P.unixPermissions=parseInt(P.unixPermissions,8)),P.unixPermissions&&16384&P.unixPermissions&&(P.dir=!0),P.dosPermissions&&16&P.dosPermissions&&(P.dir=!0),P.dir&&(N=y(N)),P.createFolders&&(D=x(N))&&E.call(this,D,!0);var z=k==="string"&&P.binary===!1&&P.base64===!1;T&&T.binary!==void 0||(P.binary=!z),(C instanceof f&&C.uncompressedSize===0||P.dir||!C||C.length===0)&&(P.base64=!1,P.binary=!0,C="",P.compression="STORE",k="string");var L=null;L=C instanceof f||C instanceof c?C:b.isNode&&b.isStream(C)?new v(N,C):l.prepareContent(N,C,P.binary,P.optimizedBinaryString,P.base64);var X=new p(N,L,P);this.files[N]=X}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),g=n("./generate"),b=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),x=function(N){N.slice(-1)==="/"&&(N=N.substring(0,N.length-1));var C=N.lastIndexOf("/");return 0<C?N.substring(0,C):""},y=function(N){return N.slice(-1)!=="/"&&(N+="/"),N},E=function(N,C){return C=C!==void 0?C:d.createFolders,N=y(N),this.files[N]||a.call(this,N,null,{dir:!0,createFolders:C}),this.files[N]};function w(N){return Object.prototype.toString.call(N)==="[object RegExp]"}var A={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(N){var C,T,D;for(C in this.files)D=this.files[C],(T=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&N(T,D)},filter:function(N){var C=[];return this.forEach(function(T,D){N(T,D)&&C.push(D)}),C},file:function(N,C,T){if(arguments.length!==1)return N=this.root+N,a.call(this,N,C,T),this;if(w(N)){var D=N;return this.filter(function(P,z){return!z.dir&&D.test(P)})}var k=this.files[this.root+N];return k&&!k.dir?k:null},folder:function(N){if(!N)return this;if(w(N))return this.filter(function(k,P){return P.dir&&N.test(k)});var C=this.root+N,T=E.call(this,C),D=this.clone();return D.root=T.name,D},remove:function(N){N=this.root+N;var C=this.files[N];if(C||(N.slice(-1)!=="/"&&(N+="/"),C=this.files[N]),C&&!C.dir)delete this.files[N];else for(var T=this.filter(function(k,P){return P.name.slice(0,N.length)===N}),D=0;D<T.length;D++)delete this.files[T[D].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(N){var C,T={};try{if((T=l.extend(N||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=T.type.toLowerCase(),T.compression=T.compression.toUpperCase(),T.type==="binarystring"&&(T.type="string"),!T.type)throw new Error("No output type specified.");l.checkSupport(T.type),T.platform!=="darwin"&&T.platform!=="freebsd"&&T.platform!=="linux"&&T.platform!=="sunos"||(T.platform="UNIX"),T.platform==="win32"&&(T.platform="DOS");var D=T.comment||this.comment||"";C=g.generateWorker(this,T,D)}catch(k){(C=new c("error")).error(k)}return new u(C,T.type||"string",T.mimeType)},generateAsync:function(N,C){return this.generateInternalStream(N).accumulate(C)},generateNodeStream:function(N,C){return(N=N||{}).type||(N.type="nodebuffer"),this.generateInternalStream(N).toNodejsStream(C)}};r.exports=A},{"./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,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===f)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&f===p[3]},o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,i){var a=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,i){var a=n("./ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,i){var a=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var p=a.getTypeOf(f);return a.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new u(f):o.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),o=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,a),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,i){var a=n("./GenericWorker"),o=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,i){var a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(o){this.name=o||"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(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),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 o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},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 o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=a},{}],29:[function(n,r,i){var a=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,v){return new d.Promise(function(x,y){var E=[],w=b._internalType,A=b._outputType,N=b._mimeType;b.on("data",function(C,T){E.push(C),v&&v(T)}).on("error",function(C){E=[],y(C)}).on("end",function(){try{var C=(function(T,D,k){switch(T){case"blob":return a.newBlob(a.transformTo("arraybuffer",D),k);case"base64":return c.encode(D);default:return a.transformTo(T,D)}})(A,(function(T,D){var k,P=0,z=null,L=0;for(k=0;k<D.length;k++)L+=D[k].length;switch(T){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(z=new Uint8Array(L),k=0;k<D.length;k++)z.set(D[k],P),P+=D[k].length;return z;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+T+"'")}})(w,E),N);x(C)}catch(T){y(T)}E=[]}).resume()})}function g(b,v,x){var y=v;switch(v){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=v,this._mimeType=x,a.checkSupport(y),this._worker=b.pipe(new o(y)),b.lock()}catch(E){this._worker=new l("error"),this._worker.error(E)}}g.prototype={accumulate:function(b){return p(this,b)},on:function(b,v){var x=this;return b==="data"?this._worker.on(b,function(y){v.call(x,y.data,y.meta)}):this._worker.on(b,function(){a.delay(v,arguments,x)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){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"},b)}},r.exports=g},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(a),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!n("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,i){for(var a=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}i.utf8encode=function(g){return o.nodebuffer?l.newBufferFrom(g,"utf-8"):(function(b){var v,x,y,E,w,A=b.length,N=0;for(E=0;E<A;E++)(64512&(x=b.charCodeAt(E)))==55296&&E+1<A&&(64512&(y=b.charCodeAt(E+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),E++),N+=x<128?1:x<2048?2:x<65536?3:4;for(v=o.uint8array?new Uint8Array(N):new Array(N),E=w=0;w<N;E++)(64512&(x=b.charCodeAt(E)))==55296&&E+1<A&&(64512&(y=b.charCodeAt(E+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),E++),x<128?v[w++]=x:(x<2048?v[w++]=192|x>>>6:(x<65536?v[w++]=224|x>>>12:(v[w++]=240|x>>>18,v[w++]=128|x>>>12&63),v[w++]=128|x>>>6&63),v[w++]=128|63&x);return v})(g)},i.utf8decode=function(g){return o.nodebuffer?a.transformTo("nodebuffer",g).toString("utf-8"):(function(b){var v,x,y,E,w=b.length,A=new Array(2*w);for(v=x=0;v<w;)if((y=b[v++])<128)A[x++]=y;else if(4<(E=u[y]))A[x++]=65533,v+=E-1;else{for(y&=E===2?31:E===3?15:7;1<E&&v<w;)y=y<<6|63&b[v++],E--;1<E?A[x++]=65533:y<65536?A[x++]=y:(y-=65536,A[x++]=55296|y>>10&1023,A[x++]=56320|1023&y)}return A.length!==x&&(A.subarray?A=A.subarray(0,x):A.length=x),a.applyFromCharCode(A)})(g=a.transformTo(o.uint8array?"uint8array":"array",g))},a.inherits(f,c),f.prototype.processChunk=function(g){var b=a.transformTo(o.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var v=b;(b=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),b.set(v,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var x=(function(E,w){var A;for((w=w||E.length)>E.length&&(w=E.length),A=w-1;0<=A&&(192&E[A])==128;)A--;return A<0||A===0?w:A+u[E[A]]>w?A:w})(b),y=b;x!==b.length&&(o.uint8array?(y=b.subarray(0,x),this.leftOver=b.subarray(x,b.length)):(y=b.slice(0,x),this.leftOver=b.slice(x,b.length))),this.push({data:i.utf8decode(y),meta:g.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(p,c),p.prototype.processChunk=function(g){this.push({data:i.utf8encode(g.data),meta:g.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,i){var a=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(v){return v}function d(v,x){for(var y=0;y<v.length;++y)x[y]=255&v.charCodeAt(y);return x}n("setimmediate"),i.newBlob=function(v,x){i.checkSupport("blob");try{return new Blob([v],{type:x})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(v),y.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,x,y){var E=[],w=0,A=v.length;if(A<=y)return String.fromCharCode.apply(null,v);for(;w<A;)x==="array"||x==="nodebuffer"?E.push(String.fromCharCode.apply(null,v.slice(w,Math.min(w+y,A)))):E.push(String.fromCharCode.apply(null,v.subarray(w,Math.min(w+y,A)))),w+=y;return E.join("")},stringifyByChar:function(v){for(var x="",y=0;y<v.length;y++)x+=String.fromCharCode(v[y]);return x},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,l.allocBuffer(1)).length===1}catch{return!1}})()}};function p(v){var x=65536,y=i.getTypeOf(v),E=!0;if(y==="uint8array"?E=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(E=f.applyCanBeUsed.nodebuffer),E)for(;1<x;)try{return f.stringifyByChunk(v,y,x)}catch{x=Math.floor(x/2)}return f.stringifyByChar(v)}function g(v,x){for(var y=0;y<v.length;y++)x[y]=v[y];return x}i.applyFromCharCode=p;var b={};b.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return b.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,l.allocBuffer(v.length))}},b.array={string:p,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(v)}},b.arraybuffer={string:function(v){return p(new Uint8Array(v))},array:function(v){return g(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return l.newBufferFrom(new Uint8Array(v))}},b.uint8array={string:p,array:function(v){return g(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return l.newBufferFrom(v)}},b.nodebuffer={string:p,array:function(v){return g(v,new Array(v.length))},arraybuffer:function(v){return b.nodebuffer.uint8array(v).buffer},uint8array:function(v){return g(v,new Uint8Array(v.length))},nodebuffer:u},i.transformTo=function(v,x){if(x=x||"",!v)return x;i.checkSupport(v);var y=i.getTypeOf(x);return b[y][v](x)},i.resolve=function(v){for(var x=v.split("/"),y=[],E=0;E<x.length;E++){var w=x[E];w==="."||w===""&&E!==0&&E!==x.length-1||(w===".."?y.pop():y.push(w))}return y.join("/")},i.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(v)?"nodebuffer":a.uint8array&&v instanceof Uint8Array?"uint8array":a.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(v){if(!a[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(v){var x,y,E="";for(y=0;y<(v||"").length;y++)E+="\\x"+((x=v.charCodeAt(y))<16?"0":"")+x.toString(16).toUpperCase();return E},i.delay=function(v,x,y){setImmediate(function(){v.apply(y||null,x||[])})},i.inherits=function(v,x){function y(){}y.prototype=x.prototype,v.prototype=new y},i.extend=function(){var v,x,y={};for(v=0;v<arguments.length;v++)for(x in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],x)&&y[x]===void 0&&(y[x]=arguments[v][x]);return y},i.prepareContent=function(v,x,y,E,w){return c.Promise.resolve(x).then(function(A){return a.blob&&(A instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(A))!==-1)&&typeof FileReader<"u"?new c.Promise(function(N,C){var T=new FileReader;T.onload=function(D){N(D.target.result)},T.onerror=function(D){C(D.target.error)},T.readAsArrayBuffer(A)}):A}).then(function(A){var N=i.getTypeOf(A);return N?(N==="arraybuffer"?A=i.transformTo("uint8array",A):N==="string"&&(w?A=o.decode(A):y&&E!==!0&&(A=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(A))),A):c.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(f)+")")}},isSignature:function(f,p){var g=this.reader.index;this.reader.setIndex(f);var b=this.reader.readString(4)===p;return this.reader.setIndex(g),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",g=o.transformTo(p,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,p,g,b=this.zip64EndOfCentralSize-44;0<b;)f=this.reader.readInt(2),p=this.reader.readInt(4),g=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,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,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({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(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.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(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.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(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var g=this.centralDirOffset+this.centralDirSize;this.zip64&&(g+=20,g+=12+this.zip64EndOfCentralSize);var b=p-g;if(0<b)this.isSignature(p,l.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function p(g,b){this.options=g,this.loadOptions=b}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(g){var b,v;if(g.skip(22),this.fileNameLength=g.readInt(2),v=g.readInt(2),this.fileName=g.readData(this.fileNameLength),g.skip(v),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((b=(function(x){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===x)return d[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,b,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 b=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(b),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===o.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var b,v,x,y=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4<y;)b=g.readInt(2),v=g.readInt(2),x=g.readData(v),this.extraFields[b]={id:b,length:v,value:x};g.setIndex(y)},handleUTF8:function(){var g=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var v=o.transformTo(g,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var y=o.transformTo(g,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var g=this.extraFields[28789];if(g){var b=a(g.value);return b.readInt(1)!==1||c(this.fileName)!==b.readInt(4)?null:u.utf8decode(b.readData(g.length-5))}return null},findExtraFieldUnicodeComment:function(){var g=this.extraFields[25461];if(g){var b=a(g.value);return b.readInt(1)!==1||c(this.fileComment)!==b.readInt(4)?null:u.utf8decode(b.readData(g.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function a(b,v,x){this.name=b,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=v,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");a.prototype={internalStream:function(b){var v=null,x="string";try{if(!b)throw new Error("No output type specified.");var y=(x=b.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),v=this._decompressWorker();var E=!this._dataBinary;E&&!y&&(v=v.pipe(new c.Utf8EncodeWorker)),!E&&y&&(v=v.pipe(new c.Utf8DecodeWorker))}catch(w){(v=new d("error")).error(w)}return new o(v,x,"")},async:function(b,v){return this.internalStream(b).accumulate(v)},nodeStream:function(b,v){return this.internalStream(b||"nodebuffer").toNodejsStream(v)},_compressWorker:function(b,v){if(this._data instanceof u&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,b,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},g=0;g<f.length;g++)a.prototype[f[g]]=p;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var o,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(b),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)o="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var v=a.document.createElement("script");v.onreadystatechange=function(){b(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},a.document.documentElement.appendChild(v)}:function(){setTimeout(b,0)};else{var p=new a.MessageChannel;p.port1.onmessage=b,o=function(){p.port2.postMessage(0)}}var g=[];function b(){var v,x;l=!0;for(var y=g.length;y;){for(x=g,g=[],v=-1;++v<y;)x[v]();y=g.length}l=!1}r.exports=function(v){g.push(v)!==1||l||o()}}).call(this,typeof Fv<"u"?Fv:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==o&&v(this,y)}function p(y,E,w){this.promise=y,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function g(y,E,w){a(function(){var A;try{A=E(w)}catch(N){return l.reject(y,N)}A===y?l.reject(y,new TypeError("Cannot resolve promise with itself")):l.resolve(y,A)})}function b(y){var E=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof E=="function")return function(){E.apply(y,arguments)}}function v(y,E){var w=!1;function A(T){w||(w=!0,l.reject(y,T))}function N(T){w||(w=!0,l.resolve(y,T))}var C=x(function(){E(N,A)});C.status==="error"&&A(C.value)}function x(y,E){var w={};try{w.value=y(E),w.status="success"}catch(A){w.status="error",w.value=A}return w}(r.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var E=this.constructor;return this.then(function(w){return E.resolve(y()).then(function(){return w})},function(w){return E.resolve(y()).then(function(){throw w})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,E){if(typeof y!="function"&&this.state===u||typeof E!="function"&&this.state===c)return this;var w=new this.constructor(o);return this.state!==d?g(w,this.state===u?y:E,this.outcome):this.queue.push(new p(w,y,E)),w},p.prototype.callFulfilled=function(y){l.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){g(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){l.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){g(this.promise,this.onRejected,y)},l.resolve=function(y,E){var w=x(b,E);if(w.status==="error")return l.reject(y,w.value);var A=w.value;if(A)v(y,A);else{y.state=u,y.outcome=E;for(var N=-1,C=y.queue.length;++N<C;)y.queue[N].callFulfilled(E)}return y},l.reject=function(y,E){y.state=c,y.outcome=E;for(var w=-1,A=y.queue.length;++w<A;)y.queue[w].callRejected(E);return y},f.resolve=function(y){return y instanceof this?y:l.resolve(new this(o),y)},f.reject=function(y){var E=new this(o);return l.reject(E,y)},f.all=function(y){var E=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,A=!1;if(!w)return this.resolve([]);for(var N=new Array(w),C=0,T=-1,D=new this(o);++T<w;)k(y[T],T);return D;function k(P,z){E.resolve(P).then(function(L){N[z]=L,++C!==w||A||(A=!0,l.resolve(D,N))},function(L){A||(A=!0,l.reject(D,L))})}},f.race=function(y){var E=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,A=!1;if(!w)return this.resolve([]);for(var N=-1,C=new this(o);++N<w;)T=y[N],E.resolve(T).then(function(D){A||(A=!0,l.resolve(C,D))},function(D){A||(A=!0,l.reject(C,D))});var T;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,p=-1,g=0,b=8;function v(y){if(!(this instanceof v))return new v(y);this.options=o.assign({level:p,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:g,to:""},y||{});var E=this.options;E.raw&&0<E.windowBits?E.windowBits=-E.windowBits:E.gzip&&0<E.windowBits&&E.windowBits<16&&(E.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var w=a.deflateInit2(this.strm,E.level,E.method,E.windowBits,E.memLevel,E.strategy);if(w!==f)throw new Error(c[w]);if(E.header&&a.deflateSetHeader(this.strm,E.header),E.dictionary){var A;if(A=typeof E.dictionary=="string"?l.string2buf(E.dictionary):d.call(E.dictionary)==="[object ArrayBuffer]"?new Uint8Array(E.dictionary):E.dictionary,(w=a.deflateSetDictionary(this.strm,A))!==f)throw new Error(c[w]);this._dict_set=!0}}function x(y,E){var w=new v(E);if(w.push(y,!0),w.err)throw w.msg||c[w.err];return w.result}v.prototype.push=function(y,E){var w,A,N=this.strm,C=this.options.chunkSize;if(this.ended)return!1;A=E===~~E?E:E===!0?4:0,typeof y=="string"?N.input=l.string2buf(y):d.call(y)==="[object ArrayBuffer]"?N.input=new Uint8Array(y):N.input=y,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new o.Buf8(C),N.next_out=0,N.avail_out=C),(w=a.deflate(N,A))!==1&&w!==f)return this.onEnd(w),!(this.ended=!0);N.avail_out!==0&&(N.avail_in!==0||A!==4&&A!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(N.output,N.next_out))):this.onData(o.shrinkBuf(N.output,N.next_out)))}while((0<N.avail_in||N.avail_out===0)&&w!==1);return A===4?(w=a.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===f):A!==2||(this.onEnd(f),!(N.avail_out=0))},v.prototype.onData=function(y){this.chunks.push(y)},v.prototype.onEnd=function(y){y===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=v,i.deflate=x,i.deflateRaw=function(y,E){return(E=E||{}).raw=!0,x(y,E)},i.gzip=function(y,E){return(E=E||{}).gzip=!0,x(y,E)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),p=Object.prototype.toString;function g(v){if(!(this instanceof g))return new g(v);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},v||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||v&&v.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&(15&x.windowBits)==0&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var y=a.inflateInit2(this.strm,x.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function b(v,x){var y=new g(x);if(y.push(v,!0),y.err)throw y.msg||u[y.err];return y.result}g.prototype.push=function(v,x){var y,E,w,A,N,C,T=this.strm,D=this.options.chunkSize,k=this.options.dictionary,P=!1;if(this.ended)return!1;E=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof v=="string"?T.input=l.binstring2buf(v):p.call(v)==="[object ArrayBuffer]"?T.input=new Uint8Array(v):T.input=v,T.next_in=0,T.avail_in=T.input.length;do{if(T.avail_out===0&&(T.output=new o.Buf8(D),T.next_out=0,T.avail_out=D),(y=a.inflate(T,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&k&&(C=typeof k=="string"?l.string2buf(k):p.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,y=a.inflateSetDictionary(this.strm,C)),y===c.Z_BUF_ERROR&&P===!0&&(y=c.Z_OK,P=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);T.next_out&&(T.avail_out!==0&&y!==c.Z_STREAM_END&&(T.avail_in!==0||E!==c.Z_FINISH&&E!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=l.utf8border(T.output,T.next_out),A=T.next_out-w,N=l.buf2string(T.output,w),T.next_out=A,T.avail_out=D-A,A&&o.arraySet(T.output,T.output,w,A,0),this.onData(N)):this.onData(o.shrinkBuf(T.output,T.next_out)))),T.avail_in===0&&T.avail_out===0&&(P=!0)}while((0<T.avail_in||T.avail_out===0)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(E=c.Z_FINISH),E===c.Z_FINISH?(y=a.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):E!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(T.avail_out=0))},g.prototype.onData=function(v){this.chunks.push(v)},g.prototype.onEnd=function(v){v===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},i.Inflate=g,i.inflate=b,i.inflateRaw=function(v,x){return(x=x||{}).raw=!0,b(v,x)},i.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),p);else for(var g=0;g<f;g++)c[p+g]=u[d+g]},flattenChunks:function(c){var u,d,f,p,g,b;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(b=new Uint8Array(f),u=p=0,d=c.length;u<d;u++)g=c[u],b.set(g,p),p+=g.length;return b}},l={arraySet:function(c,u,d,f,p){for(var g=0;g<f;g++)c[p+g]=u[d+g]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,l))},i.setTyped(a)},{}],42:[function(n,r,i){var a=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,p){if(p<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,p));for(var g="",b=0;b<p;b++)g+=String.fromCharCode(f[b]);return g}c[254]=c[254]=1,i.string2buf=function(f){var p,g,b,v,x,y=f.length,E=0;for(v=0;v<y;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(b=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(b-56320),v++),E+=g<128?1:g<2048?2:g<65536?3:4;for(p=new a.Buf8(E),v=x=0;x<E;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<y&&(64512&(b=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(b-56320),v++),g<128?p[x++]=g:(g<2048?p[x++]=192|g>>>6:(g<65536?p[x++]=224|g>>>12:(p[x++]=240|g>>>18,p[x++]=128|g>>>12&63),p[x++]=128|g>>>6&63),p[x++]=128|63&g);return p},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var p=new a.Buf8(f.length),g=0,b=p.length;g<b;g++)p[g]=f.charCodeAt(g);return p},i.buf2string=function(f,p){var g,b,v,x,y=p||f.length,E=new Array(2*y);for(g=b=0;g<y;)if((v=f[g++])<128)E[b++]=v;else if(4<(x=c[v]))E[b++]=65533,g+=x-1;else{for(v&=x===2?31:x===3?15:7;1<x&&g<y;)v=v<<6|63&f[g++],x--;1<x?E[b++]=65533:v<65536?E[b++]=v:(v-=65536,E[b++]=55296|v>>10&1023,E[b++]=56320|1023&v)}return d(E,b)},i.utf8border=function(f,p){var g;for((p=p||f.length)>f.length&&(p=f.length),g=p-1;0<=g&&(192&f[g])==128;)g--;return g<0||g===0?p:g+c[f[g]]>p?g:p}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,o,l,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.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,r,i){var a=(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})();r.exports=function(o,l,c,u){var d=a,f=u+c;o^=-1;for(var p=u;p<f;p++)o=o>>>8^d[255&(o^l[p])];return-1^o}},{}],46:[function(n,r,i){var a,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,p=4,g=0,b=-2,v=-1,x=4,y=2,E=8,w=9,A=286,N=30,C=19,T=2*A+1,D=15,k=3,P=258,z=P+k+1,L=42,X=113,R=1,Y=2,J=3,G=4;function W(V,$){return V.msg=d[$],$}function ee(V){return(V<<1)-(4<V?9:0)}function K(V){for(var $=V.length;0<=--$;)V[$]=0}function F(V){var $=V.state,Z=$.pending;Z>V.avail_out&&(Z=V.avail_out),Z!==0&&(o.arraySet(V.output,$.pending_buf,$.pending_out,Z,V.next_out),V.next_out+=Z,$.pending_out+=Z,V.total_out+=Z,V.avail_out-=Z,$.pending-=Z,$.pending===0&&($.pending_out=0))}function q(V,$){l._tr_flush_block(V,0<=V.block_start?V.block_start:-1,V.strstart-V.block_start,$),V.block_start=V.strstart,F(V.strm)}function ne(V,$){V.pending_buf[V.pending++]=$}function re(V,$){V.pending_buf[V.pending++]=$>>>8&255,V.pending_buf[V.pending++]=255&$}function se(V,$){var Z,B,U=V.max_chain_length,Q=V.strstart,Me=V.prev_length,Te=V.nice_match,fe=V.strstart>V.w_size-z?V.strstart-(V.w_size-z):0,H=V.window,I=V.w_mask,ce=V.prev,we=V.strstart+P,Se=H[Q+Me-1],_e=H[Q+Me];V.prev_length>=V.good_match&&(U>>=2),Te>V.lookahead&&(Te=V.lookahead);do if(H[(Z=$)+Me]===_e&&H[Z+Me-1]===Se&&H[Z]===H[Q]&&H[++Z]===H[Q+1]){Q+=2,Z++;do;while(H[++Q]===H[++Z]&&H[++Q]===H[++Z]&&H[++Q]===H[++Z]&&H[++Q]===H[++Z]&&H[++Q]===H[++Z]&&H[++Q]===H[++Z]&&H[++Q]===H[++Z]&&H[++Q]===H[++Z]&&Q<we);if(B=P-(we-Q),Q=we-P,Me<B){if(V.match_start=$,Te<=(Me=B))break;Se=H[Q+Me-1],_e=H[Q+Me]}}while(($=ce[$&I])>fe&&--U!=0);return Me<=V.lookahead?Me:V.lookahead}function de(V){var $,Z,B,U,Q,Me,Te,fe,H,I,ce=V.w_size;do{if(U=V.window_size-V.lookahead-V.strstart,V.strstart>=ce+(ce-z)){for(o.arraySet(V.window,V.window,ce,ce,0),V.match_start-=ce,V.strstart-=ce,V.block_start-=ce,$=Z=V.hash_size;B=V.head[--$],V.head[$]=ce<=B?B-ce:0,--Z;);for($=Z=ce;B=V.prev[--$],V.prev[$]=ce<=B?B-ce:0,--Z;);U+=ce}if(V.strm.avail_in===0)break;if(Me=V.strm,Te=V.window,fe=V.strstart+V.lookahead,H=U,I=void 0,I=Me.avail_in,H<I&&(I=H),Z=I===0?0:(Me.avail_in-=I,o.arraySet(Te,Me.input,Me.next_in,I,fe),Me.state.wrap===1?Me.adler=c(Me.adler,Te,I,fe):Me.state.wrap===2&&(Me.adler=u(Me.adler,Te,I,fe)),Me.next_in+=I,Me.total_in+=I,I),V.lookahead+=Z,V.lookahead+V.insert>=k)for(Q=V.strstart-V.insert,V.ins_h=V.window[Q],V.ins_h=(V.ins_h<<V.hash_shift^V.window[Q+1])&V.hash_mask;V.insert&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[Q+k-1])&V.hash_mask,V.prev[Q&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=Q,Q++,V.insert--,!(V.lookahead+V.insert<k)););}while(V.lookahead<z&&V.strm.avail_in!==0)}function pe(V,$){for(var Z,B;;){if(V.lookahead<z){if(de(V),V.lookahead<z&&$===f)return R;if(V.lookahead===0)break}if(Z=0,V.lookahead>=k&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,Z=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),Z!==0&&V.strstart-Z<=V.w_size-z&&(V.match_length=se(V,Z)),V.match_length>=k)if(B=l._tr_tally(V,V.strstart-V.match_start,V.match_length-k),V.lookahead-=V.match_length,V.match_length<=V.max_lazy_match&&V.lookahead>=k){for(V.match_length--;V.strstart++,V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,Z=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart,--V.match_length!=0;);V.strstart++}else V.strstart+=V.match_length,V.match_length=0,V.ins_h=V.window[V.strstart],V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+1])&V.hash_mask;else B=l._tr_tally(V,0,V.window[V.strstart]),V.lookahead--,V.strstart++;if(B&&(q(V,!1),V.strm.avail_out===0))return R}return V.insert=V.strstart<k-1?V.strstart:k-1,$===p?(q(V,!0),V.strm.avail_out===0?J:G):V.last_lit&&(q(V,!1),V.strm.avail_out===0)?R:Y}function Ce(V,$){for(var Z,B,U;;){if(V.lookahead<z){if(de(V),V.lookahead<z&&$===f)return R;if(V.lookahead===0)break}if(Z=0,V.lookahead>=k&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,Z=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),V.prev_length=V.match_length,V.prev_match=V.match_start,V.match_length=k-1,Z!==0&&V.prev_length<V.max_lazy_match&&V.strstart-Z<=V.w_size-z&&(V.match_length=se(V,Z),V.match_length<=5&&(V.strategy===1||V.match_length===k&&4096<V.strstart-V.match_start)&&(V.match_length=k-1)),V.prev_length>=k&&V.match_length<=V.prev_length){for(U=V.strstart+V.lookahead-k,B=l._tr_tally(V,V.strstart-1-V.prev_match,V.prev_length-k),V.lookahead-=V.prev_length-1,V.prev_length-=2;++V.strstart<=U&&(V.ins_h=(V.ins_h<<V.hash_shift^V.window[V.strstart+k-1])&V.hash_mask,Z=V.prev[V.strstart&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=V.strstart),--V.prev_length!=0;);if(V.match_available=0,V.match_length=k-1,V.strstart++,B&&(q(V,!1),V.strm.avail_out===0))return R}else if(V.match_available){if((B=l._tr_tally(V,0,V.window[V.strstart-1]))&&q(V,!1),V.strstart++,V.lookahead--,V.strm.avail_out===0)return R}else V.match_available=1,V.strstart++,V.lookahead--}return V.match_available&&(B=l._tr_tally(V,0,V.window[V.strstart-1]),V.match_available=0),V.insert=V.strstart<k-1?V.strstart:k-1,$===p?(q(V,!0),V.strm.avail_out===0?J:G):V.last_lit&&(q(V,!1),V.strm.avail_out===0)?R:Y}function oe(V,$,Z,B,U){this.good_length=V,this.max_lazy=$,this.nice_length=Z,this.max_chain=B,this.func=U}function ae(){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=E,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 o.Buf16(2*T),this.dyn_dtree=new o.Buf16(2*(2*N+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),K(this.dyn_ltree),K(this.dyn_dtree),K(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(D+1),this.heap=new o.Buf16(2*A+1),K(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*A+1),K(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 ge(V){var $;return V&&V.state?(V.total_in=V.total_out=0,V.data_type=y,($=V.state).pending=0,$.pending_out=0,$.wrap<0&&($.wrap=-$.wrap),$.status=$.wrap?L:X,V.adler=$.wrap===2?0:1,$.last_flush=f,l._tr_init($),g):W(V,b)}function ue(V){var $=ge(V);return $===g&&(function(Z){Z.window_size=2*Z.w_size,K(Z.head),Z.max_lazy_match=a[Z.level].max_lazy,Z.good_match=a[Z.level].good_length,Z.nice_match=a[Z.level].nice_length,Z.max_chain_length=a[Z.level].max_chain,Z.strstart=0,Z.block_start=0,Z.lookahead=0,Z.insert=0,Z.match_length=Z.prev_length=k-1,Z.match_available=0,Z.ins_h=0})(V.state),$}function Le(V,$,Z,B,U,Q){if(!V)return b;var Me=1;if($===v&&($=6),B<0?(Me=0,B=-B):15<B&&(Me=2,B-=16),U<1||w<U||Z!==E||B<8||15<B||$<0||9<$||Q<0||x<Q)return W(V,b);B===8&&(B=9);var Te=new ae;return(V.state=Te).strm=V,Te.wrap=Me,Te.gzhead=null,Te.w_bits=B,Te.w_size=1<<Te.w_bits,Te.w_mask=Te.w_size-1,Te.hash_bits=U+7,Te.hash_size=1<<Te.hash_bits,Te.hash_mask=Te.hash_size-1,Te.hash_shift=~~((Te.hash_bits+k-1)/k),Te.window=new o.Buf8(2*Te.w_size),Te.head=new o.Buf16(Te.hash_size),Te.prev=new o.Buf16(Te.w_size),Te.lit_bufsize=1<<U+6,Te.pending_buf_size=4*Te.lit_bufsize,Te.pending_buf=new o.Buf8(Te.pending_buf_size),Te.d_buf=1*Te.lit_bufsize,Te.l_buf=3*Te.lit_bufsize,Te.level=$,Te.strategy=Q,Te.method=Z,ue(V)}a=[new oe(0,0,0,0,function(V,$){var Z=65535;for(Z>V.pending_buf_size-5&&(Z=V.pending_buf_size-5);;){if(V.lookahead<=1){if(de(V),V.lookahead===0&&$===f)return R;if(V.lookahead===0)break}V.strstart+=V.lookahead,V.lookahead=0;var B=V.block_start+Z;if((V.strstart===0||V.strstart>=B)&&(V.lookahead=V.strstart-B,V.strstart=B,q(V,!1),V.strm.avail_out===0)||V.strstart-V.block_start>=V.w_size-z&&(q(V,!1),V.strm.avail_out===0))return R}return V.insert=0,$===p?(q(V,!0),V.strm.avail_out===0?J:G):(V.strstart>V.block_start&&(q(V,!1),V.strm.avail_out),R)}),new oe(4,4,8,4,pe),new oe(4,5,16,8,pe),new oe(4,6,32,32,pe),new oe(4,4,16,16,Ce),new oe(8,16,32,32,Ce),new oe(8,16,128,128,Ce),new oe(8,32,128,256,Ce),new oe(32,128,258,1024,Ce),new oe(32,258,258,4096,Ce)],i.deflateInit=function(V,$){return Le(V,$,E,15,8,0)},i.deflateInit2=Le,i.deflateReset=ue,i.deflateResetKeep=ge,i.deflateSetHeader=function(V,$){return V&&V.state?V.state.wrap!==2?b:(V.state.gzhead=$,g):b},i.deflate=function(V,$){var Z,B,U,Q;if(!V||!V.state||5<$||$<0)return V?W(V,b):b;if(B=V.state,!V.output||!V.input&&V.avail_in!==0||B.status===666&&$!==p)return W(V,V.avail_out===0?-5:b);if(B.strm=V,Z=B.last_flush,B.last_flush=$,B.status===L)if(B.wrap===2)V.adler=0,ne(B,31),ne(B,139),ne(B,8),B.gzhead?(ne(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),ne(B,255&B.gzhead.time),ne(B,B.gzhead.time>>8&255),ne(B,B.gzhead.time>>16&255),ne(B,B.gzhead.time>>24&255),ne(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ne(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ne(B,255&B.gzhead.extra.length),ne(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(V.adler=u(V.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ne(B,0),ne(B,0),ne(B,0),ne(B,0),ne(B,0),ne(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ne(B,3),B.status=X);else{var Me=E+(B.w_bits-8<<4)<<8;Me|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Me|=32),Me+=31-Me%31,B.status=X,re(B,Me),B.strstart!==0&&(re(B,V.adler>>>16),re(B,65535&V.adler)),V.adler=1}if(B.status===69)if(B.gzhead.extra){for(U=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>U&&(V.adler=u(V.adler,B.pending_buf,B.pending-U,U)),F(V),U=B.pending,B.pending!==B.pending_buf_size));)ne(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>U&&(V.adler=u(V.adler,B.pending_buf,B.pending-U,U)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){U=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>U&&(V.adler=u(V.adler,B.pending_buf,B.pending-U,U)),F(V),U=B.pending,B.pending===B.pending_buf_size)){Q=1;break}Q=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,ne(B,Q)}while(Q!==0);B.gzhead.hcrc&&B.pending>U&&(V.adler=u(V.adler,B.pending_buf,B.pending-U,U)),Q===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){U=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>U&&(V.adler=u(V.adler,B.pending_buf,B.pending-U,U)),F(V),U=B.pending,B.pending===B.pending_buf_size)){Q=1;break}Q=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,ne(B,Q)}while(Q!==0);B.gzhead.hcrc&&B.pending>U&&(V.adler=u(V.adler,B.pending_buf,B.pending-U,U)),Q===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&F(V),B.pending+2<=B.pending_buf_size&&(ne(B,255&V.adler),ne(B,V.adler>>8&255),V.adler=0,B.status=X)):B.status=X),B.pending!==0){if(F(V),V.avail_out===0)return B.last_flush=-1,g}else if(V.avail_in===0&&ee($)<=ee(Z)&&$!==p)return W(V,-5);if(B.status===666&&V.avail_in!==0)return W(V,-5);if(V.avail_in!==0||B.lookahead!==0||$!==f&&B.status!==666){var Te=B.strategy===2?(function(fe,H){for(var I;;){if(fe.lookahead===0&&(de(fe),fe.lookahead===0)){if(H===f)return R;break}if(fe.match_length=0,I=l._tr_tally(fe,0,fe.window[fe.strstart]),fe.lookahead--,fe.strstart++,I&&(q(fe,!1),fe.strm.avail_out===0))return R}return fe.insert=0,H===p?(q(fe,!0),fe.strm.avail_out===0?J:G):fe.last_lit&&(q(fe,!1),fe.strm.avail_out===0)?R:Y})(B,$):B.strategy===3?(function(fe,H){for(var I,ce,we,Se,_e=fe.window;;){if(fe.lookahead<=P){if(de(fe),fe.lookahead<=P&&H===f)return R;if(fe.lookahead===0)break}if(fe.match_length=0,fe.lookahead>=k&&0<fe.strstart&&(ce=_e[we=fe.strstart-1])===_e[++we]&&ce===_e[++we]&&ce===_e[++we]){Se=fe.strstart+P;do;while(ce===_e[++we]&&ce===_e[++we]&&ce===_e[++we]&&ce===_e[++we]&&ce===_e[++we]&&ce===_e[++we]&&ce===_e[++we]&&ce===_e[++we]&&we<Se);fe.match_length=P-(Se-we),fe.match_length>fe.lookahead&&(fe.match_length=fe.lookahead)}if(fe.match_length>=k?(I=l._tr_tally(fe,1,fe.match_length-k),fe.lookahead-=fe.match_length,fe.strstart+=fe.match_length,fe.match_length=0):(I=l._tr_tally(fe,0,fe.window[fe.strstart]),fe.lookahead--,fe.strstart++),I&&(q(fe,!1),fe.strm.avail_out===0))return R}return fe.insert=0,H===p?(q(fe,!0),fe.strm.avail_out===0?J:G):fe.last_lit&&(q(fe,!1),fe.strm.avail_out===0)?R:Y})(B,$):a[B.level].func(B,$);if(Te!==J&&Te!==G||(B.status=666),Te===R||Te===J)return V.avail_out===0&&(B.last_flush=-1),g;if(Te===Y&&($===1?l._tr_align(B):$!==5&&(l._tr_stored_block(B,0,0,!1),$===3&&(K(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),F(V),V.avail_out===0))return B.last_flush=-1,g}return $!==p?g:B.wrap<=0?1:(B.wrap===2?(ne(B,255&V.adler),ne(B,V.adler>>8&255),ne(B,V.adler>>16&255),ne(B,V.adler>>24&255),ne(B,255&V.total_in),ne(B,V.total_in>>8&255),ne(B,V.total_in>>16&255),ne(B,V.total_in>>24&255)):(re(B,V.adler>>>16),re(B,65535&V.adler)),F(V),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?g:1)},i.deflateEnd=function(V){var $;return V&&V.state?($=V.state.status)!==L&&$!==69&&$!==73&&$!==91&&$!==103&&$!==X&&$!==666?W(V,b):(V.state=null,$===X?W(V,-3):g):b},i.deflateSetDictionary=function(V,$){var Z,B,U,Q,Me,Te,fe,H,I=$.length;if(!V||!V.state||(Q=(Z=V.state).wrap)===2||Q===1&&Z.status!==L||Z.lookahead)return b;for(Q===1&&(V.adler=c(V.adler,$,I,0)),Z.wrap=0,I>=Z.w_size&&(Q===0&&(K(Z.head),Z.strstart=0,Z.block_start=0,Z.insert=0),H=new o.Buf8(Z.w_size),o.arraySet(H,$,I-Z.w_size,Z.w_size,0),$=H,I=Z.w_size),Me=V.avail_in,Te=V.next_in,fe=V.input,V.avail_in=I,V.next_in=0,V.input=$,de(Z);Z.lookahead>=k;){for(B=Z.strstart,U=Z.lookahead-(k-1);Z.ins_h=(Z.ins_h<<Z.hash_shift^Z.window[B+k-1])&Z.hash_mask,Z.prev[B&Z.w_mask]=Z.head[Z.ins_h],Z.head[Z.ins_h]=B,B++,--U;);Z.strstart=B,Z.lookahead=k-1,de(Z)}return Z.strstart+=Z.lookahead,Z.block_start=Z.strstart,Z.insert=Z.lookahead,Z.lookahead=0,Z.match_length=Z.prev_length=k-1,Z.match_available=0,V.next_in=Te,V.input=fe,V.avail_in=Me,Z.wrap=Q,g},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.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,r,i){r.exports=function(a,o){var l,c,u,d,f,p,g,b,v,x,y,E,w,A,N,C,T,D,k,P,z,L,X,R,Y;l=a.state,c=a.next_in,R=a.input,u=c+(a.avail_in-5),d=a.next_out,Y=a.output,f=d-(o-a.avail_out),p=d+(a.avail_out-257),g=l.dmax,b=l.wsize,v=l.whave,x=l.wnext,y=l.window,E=l.hold,w=l.bits,A=l.lencode,N=l.distcode,C=(1<<l.lenbits)-1,T=(1<<l.distbits)-1;e:do{w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),D=A[E&C];t:for(;;){if(E>>>=k=D>>>24,w-=k,(k=D>>>16&255)===0)Y[d++]=65535&D;else{if(!(16&k)){if((64&k)==0){D=A[(65535&D)+(E&(1<<k)-1)];continue t}if(32&k){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}P=65535&D,(k&=15)&&(w<k&&(E+=R[c++]<<w,w+=8),P+=E&(1<<k)-1,E>>>=k,w-=k),w<15&&(E+=R[c++]<<w,w+=8,E+=R[c++]<<w,w+=8),D=N[E&T];n:for(;;){if(E>>>=k=D>>>24,w-=k,!(16&(k=D>>>16&255))){if((64&k)==0){D=N[(65535&D)+(E&(1<<k)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(z=65535&D,w<(k&=15)&&(E+=R[c++]<<w,(w+=8)<k&&(E+=R[c++]<<w,w+=8)),g<(z+=E&(1<<k)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(E>>>=k,w-=k,(k=d-f)<z){if(v<(k=z-k)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(X=y,(L=0)===x){if(L+=b-k,k<P){for(P-=k;Y[d++]=y[L++],--k;);L=d-z,X=Y}}else if(x<k){if(L+=b+x-k,(k-=x)<P){for(P-=k;Y[d++]=y[L++],--k;);if(L=0,x<P){for(P-=k=x;Y[d++]=y[L++],--k;);L=d-z,X=Y}}}else if(L+=x-k,k<P){for(P-=k;Y[d++]=y[L++],--k;);L=d-z,X=Y}for(;2<P;)Y[d++]=X[L++],Y[d++]=X[L++],Y[d++]=X[L++],P-=3;P&&(Y[d++]=X[L++],1<P&&(Y[d++]=X[L++]))}else{for(L=d-z;Y[d++]=Y[L++],Y[d++]=Y[L++],Y[d++]=Y[L++],2<(P-=3););P&&(Y[d++]=Y[L++],1<P&&(Y[d++]=Y[L++]))}break}}break}}while(c<u&&d<p);c-=P=w>>3,E&=(1<<(w-=P<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<p?p-d+257:257-(d-p),l.hold=E,l.bits=w}},{}],49:[function(n,r,i){var a=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,p=0,g=-2,b=1,v=852,x=592;function y(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function E(){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(L){var X;return L&&L.state?(X=L.state,L.total_in=L.total_out=X.total=0,L.msg="",X.wrap&&(L.adler=1&X.wrap),X.mode=b,X.last=0,X.havedict=0,X.dmax=32768,X.head=null,X.hold=0,X.bits=0,X.lencode=X.lendyn=new a.Buf32(v),X.distcode=X.distdyn=new a.Buf32(x),X.sane=1,X.back=-1,p):g}function A(L){var X;return L&&L.state?((X=L.state).wsize=0,X.whave=0,X.wnext=0,w(L)):g}function N(L,X){var R,Y;return L&&L.state?(Y=L.state,X<0?(R=0,X=-X):(R=1+(X>>4),X<48&&(X&=15)),X&&(X<8||15<X)?g:(Y.window!==null&&Y.wbits!==X&&(Y.window=null),Y.wrap=R,Y.wbits=X,A(L))):g}function C(L,X){var R,Y;return L?(Y=new E,(L.state=Y).window=null,(R=N(L,X))!==p&&(L.state=null),R):g}var T,D,k=!0;function P(L){if(k){var X;for(T=new a.Buf32(512),D=new a.Buf32(32),X=0;X<144;)L.lens[X++]=8;for(;X<256;)L.lens[X++]=9;for(;X<280;)L.lens[X++]=7;for(;X<288;)L.lens[X++]=8;for(u(d,L.lens,0,288,T,0,L.work,{bits:9}),X=0;X<32;)L.lens[X++]=5;u(f,L.lens,0,32,D,0,L.work,{bits:5}),k=!1}L.lencode=T,L.lenbits=9,L.distcode=D,L.distbits=5}function z(L,X,R,Y){var J,G=L.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new a.Buf8(G.wsize)),Y>=G.wsize?(a.arraySet(G.window,X,R-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(Y<(J=G.wsize-G.wnext)&&(J=Y),a.arraySet(G.window,X,R-Y,J,G.wnext),(Y-=J)?(a.arraySet(G.window,X,R-Y,Y,0),G.wnext=Y,G.whave=G.wsize):(G.wnext+=J,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=J))),0}i.inflateReset=A,i.inflateReset2=N,i.inflateResetKeep=w,i.inflateInit=function(L){return C(L,15)},i.inflateInit2=C,i.inflate=function(L,X){var R,Y,J,G,W,ee,K,F,q,ne,re,se,de,pe,Ce,oe,ae,ge,ue,Le,V,$,Z,B,U=0,Q=new a.Buf8(4),Me=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return g;(R=L.state).mode===12&&(R.mode=13),W=L.next_out,J=L.output,K=L.avail_out,G=L.next_in,Y=L.input,ee=L.avail_in,F=R.hold,q=R.bits,ne=ee,re=K,$=p;e:for(;;)switch(R.mode){case b:if(R.wrap===0){R.mode=13;break}for(;q<16;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(2&R.wrap&&F===35615){Q[R.check=0]=255&F,Q[1]=F>>>8&255,R.check=l(R.check,Q,2,0),q=F=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&F)<<8)+(F>>8))%31){L.msg="incorrect header check",R.mode=30;break}if((15&F)!=8){L.msg="unknown compression method",R.mode=30;break}if(q-=4,V=8+(15&(F>>>=4)),R.wbits===0)R.wbits=V;else if(V>R.wbits){L.msg="invalid window size",R.mode=30;break}R.dmax=1<<V,L.adler=R.check=1,R.mode=512&F?10:12,q=F=0;break;case 2:for(;q<16;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(R.flags=F,(255&R.flags)!=8){L.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){L.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=F>>8&1),512&R.flags&&(Q[0]=255&F,Q[1]=F>>>8&255,R.check=l(R.check,Q,2,0)),q=F=0,R.mode=3;case 3:for(;q<32;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}R.head&&(R.head.time=F),512&R.flags&&(Q[0]=255&F,Q[1]=F>>>8&255,Q[2]=F>>>16&255,Q[3]=F>>>24&255,R.check=l(R.check,Q,4,0)),q=F=0,R.mode=4;case 4:for(;q<16;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}R.head&&(R.head.xflags=255&F,R.head.os=F>>8),512&R.flags&&(Q[0]=255&F,Q[1]=F>>>8&255,R.check=l(R.check,Q,2,0)),q=F=0,R.mode=5;case 5:if(1024&R.flags){for(;q<16;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}R.length=F,R.head&&(R.head.extra_len=F),512&R.flags&&(Q[0]=255&F,Q[1]=F>>>8&255,R.check=l(R.check,Q,2,0)),q=F=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(ee<(se=R.length)&&(se=ee),se&&(R.head&&(V=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),a.arraySet(R.head.extra,Y,G,se,V)),512&R.flags&&(R.check=l(R.check,Y,se,G)),ee-=se,G+=se,R.length-=se),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(ee===0)break e;for(se=0;V=Y[G+se++],R.head&&V&&R.length<65536&&(R.head.name+=String.fromCharCode(V)),V&&se<ee;);if(512&R.flags&&(R.check=l(R.check,Y,se,G)),ee-=se,G+=se,V)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(ee===0)break e;for(se=0;V=Y[G+se++],R.head&&V&&R.length<65536&&(R.head.comment+=String.fromCharCode(V)),V&&se<ee;);if(512&R.flags&&(R.check=l(R.check,Y,se,G)),ee-=se,G+=se,V)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;q<16;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(F!==(65535&R.check)){L.msg="header crc mismatch",R.mode=30;break}q=F=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),L.adler=R.check=0,R.mode=12;break;case 10:for(;q<32;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}L.adler=R.check=y(F),q=F=0,R.mode=11;case 11:if(R.havedict===0)return L.next_out=W,L.avail_out=K,L.next_in=G,L.avail_in=ee,R.hold=F,R.bits=q,2;L.adler=R.check=1,R.mode=12;case 12:if(X===5||X===6)break e;case 13:if(R.last){F>>>=7&q,q-=7&q,R.mode=27;break}for(;q<3;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}switch(R.last=1&F,q-=1,3&(F>>>=1)){case 0:R.mode=14;break;case 1:if(P(R),R.mode=20,X!==6)break;F>>>=2,q-=2;break e;case 2:R.mode=17;break;case 3:L.msg="invalid block type",R.mode=30}F>>>=2,q-=2;break;case 14:for(F>>>=7&q,q-=7&q;q<32;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if((65535&F)!=(F>>>16^65535)){L.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&F,q=F=0,R.mode=15,X===6)break e;case 15:R.mode=16;case 16:if(se=R.length){if(ee<se&&(se=ee),K<se&&(se=K),se===0)break e;a.arraySet(J,Y,G,se,W),ee-=se,G+=se,K-=se,W+=se,R.length-=se;break}R.mode=12;break;case 17:for(;q<14;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(R.nlen=257+(31&F),F>>>=5,q-=5,R.ndist=1+(31&F),F>>>=5,q-=5,R.ncode=4+(15&F),F>>>=4,q-=4,286<R.nlen||30<R.ndist){L.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;q<3;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}R.lens[Me[R.have++]]=7&F,F>>>=3,q-=3}for(;R.have<19;)R.lens[Me[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,Z={bits:R.lenbits},$=u(0,R.lens,0,19,R.lencode,0,R.work,Z),R.lenbits=Z.bits,$){L.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;oe=(U=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,ae=65535&U,!((Ce=U>>>24)<=q);){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(ae<16)F>>>=Ce,q-=Ce,R.lens[R.have++]=ae;else{if(ae===16){for(B=Ce+2;q<B;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(F>>>=Ce,q-=Ce,R.have===0){L.msg="invalid bit length repeat",R.mode=30;break}V=R.lens[R.have-1],se=3+(3&F),F>>>=2,q-=2}else if(ae===17){for(B=Ce+3;q<B;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}q-=Ce,V=0,se=3+(7&(F>>>=Ce)),F>>>=3,q-=3}else{for(B=Ce+7;q<B;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}q-=Ce,V=0,se=11+(127&(F>>>=Ce)),F>>>=7,q-=7}if(R.have+se>R.nlen+R.ndist){L.msg="invalid bit length repeat",R.mode=30;break}for(;se--;)R.lens[R.have++]=V}}if(R.mode===30)break;if(R.lens[256]===0){L.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,Z={bits:R.lenbits},$=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,Z),R.lenbits=Z.bits,$){L.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,Z={bits:R.distbits},$=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,Z),R.distbits=Z.bits,$){L.msg="invalid distances set",R.mode=30;break}if(R.mode=20,X===6)break e;case 20:R.mode=21;case 21:if(6<=ee&&258<=K){L.next_out=W,L.avail_out=K,L.next_in=G,L.avail_in=ee,R.hold=F,R.bits=q,c(L,re),W=L.next_out,J=L.output,K=L.avail_out,G=L.next_in,Y=L.input,ee=L.avail_in,F=R.hold,q=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;oe=(U=R.lencode[F&(1<<R.lenbits)-1])>>>16&255,ae=65535&U,!((Ce=U>>>24)<=q);){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(oe&&(240&oe)==0){for(ge=Ce,ue=oe,Le=ae;oe=(U=R.lencode[Le+((F&(1<<ge+ue)-1)>>ge)])>>>16&255,ae=65535&U,!(ge+(Ce=U>>>24)<=q);){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}F>>>=ge,q-=ge,R.back+=ge}if(F>>>=Ce,q-=Ce,R.back+=Ce,R.length=ae,oe===0){R.mode=26;break}if(32&oe){R.back=-1,R.mode=12;break}if(64&oe){L.msg="invalid literal/length code",R.mode=30;break}R.extra=15&oe,R.mode=22;case 22:if(R.extra){for(B=R.extra;q<B;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}R.length+=F&(1<<R.extra)-1,F>>>=R.extra,q-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;oe=(U=R.distcode[F&(1<<R.distbits)-1])>>>16&255,ae=65535&U,!((Ce=U>>>24)<=q);){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if((240&oe)==0){for(ge=Ce,ue=oe,Le=ae;oe=(U=R.distcode[Le+((F&(1<<ge+ue)-1)>>ge)])>>>16&255,ae=65535&U,!(ge+(Ce=U>>>24)<=q);){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}F>>>=ge,q-=ge,R.back+=ge}if(F>>>=Ce,q-=Ce,R.back+=Ce,64&oe){L.msg="invalid distance code",R.mode=30;break}R.offset=ae,R.extra=15&oe,R.mode=24;case 24:if(R.extra){for(B=R.extra;q<B;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}R.offset+=F&(1<<R.extra)-1,F>>>=R.extra,q-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){L.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(K===0)break e;if(se=re-K,R.offset>se){if((se=R.offset-se)>R.whave&&R.sane){L.msg="invalid distance too far back",R.mode=30;break}de=se>R.wnext?(se-=R.wnext,R.wsize-se):R.wnext-se,se>R.length&&(se=R.length),pe=R.window}else pe=J,de=W-R.offset,se=R.length;for(K<se&&(se=K),K-=se,R.length-=se;J[W++]=pe[de++],--se;);R.length===0&&(R.mode=21);break;case 26:if(K===0)break e;J[W++]=R.length,K--,R.mode=21;break;case 27:if(R.wrap){for(;q<32;){if(ee===0)break e;ee--,F|=Y[G++]<<q,q+=8}if(re-=K,L.total_out+=re,R.total+=re,re&&(L.adler=R.check=R.flags?l(R.check,J,re,W-re):o(R.check,J,re,W-re)),re=K,(R.flags?F:y(F))!==R.check){L.msg="incorrect data check",R.mode=30;break}q=F=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;q<32;){if(ee===0)break e;ee--,F+=Y[G++]<<q,q+=8}if(F!==(4294967295&R.total)){L.msg="incorrect length check",R.mode=30;break}q=F=0}R.mode=29;case 29:$=1;break e;case 30:$=-3;break e;case 31:return-4;case 32:default:return g}return L.next_out=W,L.avail_out=K,L.next_in=G,L.avail_in=ee,R.hold=F,R.bits=q,(R.wsize||re!==L.avail_out&&R.mode<30&&(R.mode<27||X!==4))&&z(L,L.output,L.next_out,re-L.avail_out)?(R.mode=31,-4):(ne-=L.avail_in,re-=L.avail_out,L.total_in+=ne,L.total_out+=re,R.total+=re,R.wrap&&re&&(L.adler=R.check=R.flags?l(R.check,J,re,L.next_out-re):o(R.check,J,re,L.next_out-re)),L.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ne==0&&re===0||X===4)&&$===p&&($=-5),$)},i.inflateEnd=function(L){if(!L||!L.state)return g;var X=L.state;return X.window&&(X.window=null),L.state=null,p},i.inflateGetHeader=function(L,X){var R;return L&&L.state?(2&(R=L.state).wrap)==0?g:((R.head=X).done=!1,p):g},i.inflateSetDictionary=function(L,X){var R,Y=X.length;return L&&L.state?(R=L.state).wrap!==0&&R.mode!==11?g:R.mode===11&&o(1,X,Y,0)!==R.check?-3:z(L,X,Y,Y)?(R.mode=31,-4):(R.havedict=1,p):g},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var a=n("../utils/common"),o=[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],l=[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],c=[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],u=[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];r.exports=function(d,f,p,g,b,v,x,y){var E,w,A,N,C,T,D,k,P,z=y.bits,L=0,X=0,R=0,Y=0,J=0,G=0,W=0,ee=0,K=0,F=0,q=null,ne=0,re=new a.Buf16(16),se=new a.Buf16(16),de=null,pe=0;for(L=0;L<=15;L++)re[L]=0;for(X=0;X<g;X++)re[f[p+X]]++;for(J=z,Y=15;1<=Y&&re[Y]===0;Y--);if(Y<J&&(J=Y),Y===0)return b[v++]=20971520,b[v++]=20971520,y.bits=1,0;for(R=1;R<Y&&re[R]===0;R++);for(J<R&&(J=R),L=ee=1;L<=15;L++)if(ee<<=1,(ee-=re[L])<0)return-1;if(0<ee&&(d===0||Y!==1))return-1;for(se[1]=0,L=1;L<15;L++)se[L+1]=se[L]+re[L];for(X=0;X<g;X++)f[p+X]!==0&&(x[se[f[p+X]]++]=X);if(T=d===0?(q=de=x,19):d===1?(q=o,ne-=257,de=l,pe-=257,256):(q=c,de=u,-1),L=R,C=v,W=X=F=0,A=-1,N=(K=1<<(G=J))-1,d===1&&852<K||d===2&&592<K)return 1;for(;;){for(D=L-W,P=x[X]<T?(k=0,x[X]):x[X]>T?(k=de[pe+x[X]],q[ne+x[X]]):(k=96,0),E=1<<L-W,R=w=1<<G;b[C+(F>>W)+(w-=E)]=D<<24|k<<16|P|0,w!==0;);for(E=1<<L-1;F&E;)E>>=1;if(E!==0?(F&=E-1,F+=E):F=0,X++,--re[L]==0){if(L===Y)break;L=f[p+x[X]]}if(J<L&&(F&N)!==A){for(W===0&&(W=J),C+=R,ee=1<<(G=L-W);G+W<Y&&!((ee-=re[G+W])<=0);)G++,ee<<=1;if(K+=1<<G,d===1&&852<K||d===2&&592<K)return 1;b[A=F&N]=J<<24|G<<16|C-v|0}}return F!==0&&(b[C+F]=L-W<<24|64<<16|0),y.bits=J,0}},{"../utils/common":41}],51:[function(n,r,i){r.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,r,i){var a=n("../utils/common"),o=0,l=1;function c(U){for(var Q=U.length;0<=--Q;)U[Q]=0}var u=0,d=29,f=256,p=f+1+d,g=30,b=19,v=2*p+1,x=15,y=16,E=7,w=256,A=16,N=17,C=18,T=[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],D=[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],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(p+2));c(z);var L=new Array(2*g);c(L);var X=new Array(512);c(X);var R=new Array(256);c(R);var Y=new Array(d);c(Y);var J,G,W,ee=new Array(g);function K(U,Q,Me,Te,fe){this.static_tree=U,this.extra_bits=Q,this.extra_base=Me,this.elems=Te,this.max_length=fe,this.has_stree=U&&U.length}function F(U,Q){this.dyn_tree=U,this.max_code=0,this.stat_desc=Q}function q(U){return U<256?X[U]:X[256+(U>>>7)]}function ne(U,Q){U.pending_buf[U.pending++]=255&Q,U.pending_buf[U.pending++]=Q>>>8&255}function re(U,Q,Me){U.bi_valid>y-Me?(U.bi_buf|=Q<<U.bi_valid&65535,ne(U,U.bi_buf),U.bi_buf=Q>>y-U.bi_valid,U.bi_valid+=Me-y):(U.bi_buf|=Q<<U.bi_valid&65535,U.bi_valid+=Me)}function se(U,Q,Me){re(U,Me[2*Q],Me[2*Q+1])}function de(U,Q){for(var Me=0;Me|=1&U,U>>>=1,Me<<=1,0<--Q;);return Me>>>1}function pe(U,Q,Me){var Te,fe,H=new Array(x+1),I=0;for(Te=1;Te<=x;Te++)H[Te]=I=I+Me[Te-1]<<1;for(fe=0;fe<=Q;fe++){var ce=U[2*fe+1];ce!==0&&(U[2*fe]=de(H[ce]++,ce))}}function Ce(U){var Q;for(Q=0;Q<p;Q++)U.dyn_ltree[2*Q]=0;for(Q=0;Q<g;Q++)U.dyn_dtree[2*Q]=0;for(Q=0;Q<b;Q++)U.bl_tree[2*Q]=0;U.dyn_ltree[2*w]=1,U.opt_len=U.static_len=0,U.last_lit=U.matches=0}function oe(U){8<U.bi_valid?ne(U,U.bi_buf):0<U.bi_valid&&(U.pending_buf[U.pending++]=U.bi_buf),U.bi_buf=0,U.bi_valid=0}function ae(U,Q,Me,Te){var fe=2*Q,H=2*Me;return U[fe]<U[H]||U[fe]===U[H]&&Te[Q]<=Te[Me]}function ge(U,Q,Me){for(var Te=U.heap[Me],fe=Me<<1;fe<=U.heap_len&&(fe<U.heap_len&&ae(Q,U.heap[fe+1],U.heap[fe],U.depth)&&fe++,!ae(Q,Te,U.heap[fe],U.depth));)U.heap[Me]=U.heap[fe],Me=fe,fe<<=1;U.heap[Me]=Te}function ue(U,Q,Me){var Te,fe,H,I,ce=0;if(U.last_lit!==0)for(;Te=U.pending_buf[U.d_buf+2*ce]<<8|U.pending_buf[U.d_buf+2*ce+1],fe=U.pending_buf[U.l_buf+ce],ce++,Te===0?se(U,fe,Q):(se(U,(H=R[fe])+f+1,Q),(I=T[H])!==0&&re(U,fe-=Y[H],I),se(U,H=q(--Te),Me),(I=D[H])!==0&&re(U,Te-=ee[H],I)),ce<U.last_lit;);se(U,w,Q)}function Le(U,Q){var Me,Te,fe,H=Q.dyn_tree,I=Q.stat_desc.static_tree,ce=Q.stat_desc.has_stree,we=Q.stat_desc.elems,Se=-1;for(U.heap_len=0,U.heap_max=v,Me=0;Me<we;Me++)H[2*Me]!==0?(U.heap[++U.heap_len]=Se=Me,U.depth[Me]=0):H[2*Me+1]=0;for(;U.heap_len<2;)H[2*(fe=U.heap[++U.heap_len]=Se<2?++Se:0)]=1,U.depth[fe]=0,U.opt_len--,ce&&(U.static_len-=I[2*fe+1]);for(Q.max_code=Se,Me=U.heap_len>>1;1<=Me;Me--)ge(U,H,Me);for(fe=we;Me=U.heap[1],U.heap[1]=U.heap[U.heap_len--],ge(U,H,1),Te=U.heap[1],U.heap[--U.heap_max]=Me,U.heap[--U.heap_max]=Te,H[2*fe]=H[2*Me]+H[2*Te],U.depth[fe]=(U.depth[Me]>=U.depth[Te]?U.depth[Me]:U.depth[Te])+1,H[2*Me+1]=H[2*Te+1]=fe,U.heap[1]=fe++,ge(U,H,1),2<=U.heap_len;);U.heap[--U.heap_max]=U.heap[1],(function(_e,st){var Ve,it,ct,Fe,me,Ke,qe=st.dyn_tree,Qe=st.max_code,ut=st.stat_desc.static_tree,ie=st.stat_desc.has_stree,He=st.stat_desc.extra_bits,ve=st.stat_desc.extra_base,Be=st.stat_desc.max_length,je=0;for(Fe=0;Fe<=x;Fe++)_e.bl_count[Fe]=0;for(qe[2*_e.heap[_e.heap_max]+1]=0,Ve=_e.heap_max+1;Ve<v;Ve++)Be<(Fe=qe[2*qe[2*(it=_e.heap[Ve])+1]+1]+1)&&(Fe=Be,je++),qe[2*it+1]=Fe,Qe<it||(_e.bl_count[Fe]++,me=0,ve<=it&&(me=He[it-ve]),Ke=qe[2*it],_e.opt_len+=Ke*(Fe+me),ie&&(_e.static_len+=Ke*(ut[2*it+1]+me)));if(je!==0){do{for(Fe=Be-1;_e.bl_count[Fe]===0;)Fe--;_e.bl_count[Fe]--,_e.bl_count[Fe+1]+=2,_e.bl_count[Be]--,je-=2}while(0<je);for(Fe=Be;Fe!==0;Fe--)for(it=_e.bl_count[Fe];it!==0;)Qe<(ct=_e.heap[--Ve])||(qe[2*ct+1]!==Fe&&(_e.opt_len+=(Fe-qe[2*ct+1])*qe[2*ct],qe[2*ct+1]=Fe),it--)}})(U,Q),pe(H,Se,U.bl_count)}function V(U,Q,Me){var Te,fe,H=-1,I=Q[1],ce=0,we=7,Se=4;for(I===0&&(we=138,Se=3),Q[2*(Me+1)+1]=65535,Te=0;Te<=Me;Te++)fe=I,I=Q[2*(Te+1)+1],++ce<we&&fe===I||(ce<Se?U.bl_tree[2*fe]+=ce:fe!==0?(fe!==H&&U.bl_tree[2*fe]++,U.bl_tree[2*A]++):ce<=10?U.bl_tree[2*N]++:U.bl_tree[2*C]++,H=fe,Se=(ce=0)===I?(we=138,3):fe===I?(we=6,3):(we=7,4))}function $(U,Q,Me){var Te,fe,H=-1,I=Q[1],ce=0,we=7,Se=4;for(I===0&&(we=138,Se=3),Te=0;Te<=Me;Te++)if(fe=I,I=Q[2*(Te+1)+1],!(++ce<we&&fe===I)){if(ce<Se)for(;se(U,fe,U.bl_tree),--ce!=0;);else fe!==0?(fe!==H&&(se(U,fe,U.bl_tree),ce--),se(U,A,U.bl_tree),re(U,ce-3,2)):ce<=10?(se(U,N,U.bl_tree),re(U,ce-3,3)):(se(U,C,U.bl_tree),re(U,ce-11,7));H=fe,Se=(ce=0)===I?(we=138,3):fe===I?(we=6,3):(we=7,4)}}c(ee);var Z=!1;function B(U,Q,Me,Te){re(U,(u<<1)+(Te?1:0),3),(function(fe,H,I,ce){oe(fe),ne(fe,I),ne(fe,~I),a.arraySet(fe.pending_buf,fe.window,H,I,fe.pending),fe.pending+=I})(U,Q,Me)}i._tr_init=function(U){Z||((function(){var Q,Me,Te,fe,H,I=new Array(x+1);for(fe=Te=0;fe<d-1;fe++)for(Y[fe]=Te,Q=0;Q<1<<T[fe];Q++)R[Te++]=fe;for(R[Te-1]=fe,fe=H=0;fe<16;fe++)for(ee[fe]=H,Q=0;Q<1<<D[fe];Q++)X[H++]=fe;for(H>>=7;fe<g;fe++)for(ee[fe]=H<<7,Q=0;Q<1<<D[fe]-7;Q++)X[256+H++]=fe;for(Me=0;Me<=x;Me++)I[Me]=0;for(Q=0;Q<=143;)z[2*Q+1]=8,Q++,I[8]++;for(;Q<=255;)z[2*Q+1]=9,Q++,I[9]++;for(;Q<=279;)z[2*Q+1]=7,Q++,I[7]++;for(;Q<=287;)z[2*Q+1]=8,Q++,I[8]++;for(pe(z,p+1,I),Q=0;Q<g;Q++)L[2*Q+1]=5,L[2*Q]=de(Q,5);J=new K(z,T,f+1,p,x),G=new K(L,D,0,g,x),W=new K(new Array(0),k,0,b,E)})(),Z=!0),U.l_desc=new F(U.dyn_ltree,J),U.d_desc=new F(U.dyn_dtree,G),U.bl_desc=new F(U.bl_tree,W),U.bi_buf=0,U.bi_valid=0,Ce(U)},i._tr_stored_block=B,i._tr_flush_block=function(U,Q,Me,Te){var fe,H,I=0;0<U.level?(U.strm.data_type===2&&(U.strm.data_type=(function(ce){var we,Se=4093624447;for(we=0;we<=31;we++,Se>>>=1)if(1&Se&&ce.dyn_ltree[2*we]!==0)return o;if(ce.dyn_ltree[18]!==0||ce.dyn_ltree[20]!==0||ce.dyn_ltree[26]!==0)return l;for(we=32;we<f;we++)if(ce.dyn_ltree[2*we]!==0)return l;return o})(U)),Le(U,U.l_desc),Le(U,U.d_desc),I=(function(ce){var we;for(V(ce,ce.dyn_ltree,ce.l_desc.max_code),V(ce,ce.dyn_dtree,ce.d_desc.max_code),Le(ce,ce.bl_desc),we=b-1;3<=we&&ce.bl_tree[2*P[we]+1]===0;we--);return ce.opt_len+=3*(we+1)+5+5+4,we})(U),fe=U.opt_len+3+7>>>3,(H=U.static_len+3+7>>>3)<=fe&&(fe=H)):fe=H=Me+5,Me+4<=fe&&Q!==-1?B(U,Q,Me,Te):U.strategy===4||H===fe?(re(U,2+(Te?1:0),3),ue(U,z,L)):(re(U,4+(Te?1:0),3),(function(ce,we,Se,_e){var st;for(re(ce,we-257,5),re(ce,Se-1,5),re(ce,_e-4,4),st=0;st<_e;st++)re(ce,ce.bl_tree[2*P[st]+1],3);$(ce,ce.dyn_ltree,we-1),$(ce,ce.dyn_dtree,Se-1)})(U,U.l_desc.max_code+1,U.d_desc.max_code+1,I+1),ue(U,U.dyn_ltree,U.dyn_dtree)),Ce(U),Te&&oe(U)},i._tr_tally=function(U,Q,Me){return U.pending_buf[U.d_buf+2*U.last_lit]=Q>>>8&255,U.pending_buf[U.d_buf+2*U.last_lit+1]=255&Q,U.pending_buf[U.l_buf+U.last_lit]=255&Me,U.last_lit++,Q===0?U.dyn_ltree[2*Me]++:(U.matches++,Q--,U.dyn_ltree[2*(R[Me]+f+1)]++,U.dyn_dtree[2*q(Q)]++),U.last_lit===U.lit_bufsize-1},i._tr_align=function(U){re(U,2,3),se(U,w,z),(function(Q){Q.bi_valid===16?(ne(Q,Q.bi_buf),Q.bi_buf=0,Q.bi_valid=0):8<=Q.bi_valid&&(Q.pending_buf[Q.pending++]=255&Q.bi_buf,Q.bi_buf>>=8,Q.bi_valid-=8)})(U)}},{"../utils/common":41}],53:[function(n,r,i){r.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,r,i){(function(a){(function(o,l){if(!o.setImmediate){var c,u,d,f,p=1,g={},b=!1,v=o.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(o);x=x&&x.setTimeout?x:o,c={}.toString.call(o.process)==="[object process]"?function(A){process.nextTick(function(){E(A)})}:(function(){if(o.postMessage&&!o.importScripts){var A=!0,N=o.onmessage;return o.onmessage=function(){A=!1},o.postMessage("","*"),o.onmessage=N,A}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",w,!1):o.attachEvent("onmessage",w),function(A){o.postMessage(f+A,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){E(A.data)},function(A){d.port2.postMessage(A)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(A){var N=v.createElement("script");N.onreadystatechange=function(){E(A),N.onreadystatechange=null,u.removeChild(N),N=null},u.appendChild(N)}):function(A){setTimeout(E,0,A)},x.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var N=new Array(arguments.length-1),C=0;C<N.length;C++)N[C]=arguments[C+1];var T={callback:A,args:N};return g[p]=T,c(p),p++},x.clearImmediate=y}function y(A){delete g[A]}function E(A){if(b)setTimeout(E,0,A);else{var N=g[A];if(N){b=!0;try{(function(C){var T=C.callback,D=C.args;switch(D.length){case 0:T();break;case 1:T(D[0]);break;case 2:T(D[0],D[1]);break;case 3:T(D[0],D[1],D[2]);break;default:T.apply(l,D)}})(N)}finally{y(A),b=!1}}}}function w(A){A.source===o&&typeof A.data=="string"&&A.data.indexOf(f)===0&&E(+A.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Fv<"u"?Fv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(OC)),OC.exports}var V4e=H4e();const G4e=Co(V4e);function W4e(t){const e=new yi;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 FH=W4e;async function UH(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=a.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function q4e(t){const e=await G4e.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(g){const b=g.startsWith("/")?g.slice(1):g,v=e.files[b];if(!v)return null;const x=await v.async("string");return i.parseFromString(x,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const g=await c.async("string"),v=i.parseFromString(g,"application/xml").getElementsByTagName("object");for(let x=0;x<v.length;x++){const y=v[x],E=y.getAttribute("id");if(!E)continue;const w=Array.from(y.children).filter(N=>N.tagName==="metadata"&&N.getAttribute("key")==="extruder");if(w.length>0){const N=w[0].getAttribute("value");N&&o.set(E,Math.max(0,parseInt(N,10)-1))}const A=y.getElementsByTagName("part");for(let N=0;N<A.length;N++){const C=A[N],T=C.getAttribute("id");if(!T)continue;const D=Array.from(C.children).filter(k=>k.tagName==="metadata"&&k.getAttribute("key")==="extruder");if(D.length>0){const k=D[0].getAttribute("value");k&&l.set(`${E}:${T}`,Math.max(0,parseInt(k,10)-1))}}}}catch{}const u=Object.keys(e.files).find(g=>g==="3D/3dmodel.model"||g.endsWith("/3dmodel.model"));if(!u){const g=Object.keys(e.files).find(b=>b.endsWith(".model"));if(g){const b=await a(g);if(b){const v=await UH(b,0);v.length>0&&n.set("1",{id:"1",meshes:v,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let g=0;g<f.length;g++){const b=f[g],v=b.getAttribute("id");if(!v)continue;let x=o.get(v)??-1;if(x<0){const A=b.getAttribute("p:extruder")||b.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";x=Math.max(0,parseInt(A,10)-1)}const y=[],E=b.getElementsByTagName("mesh");for(let A=0;A<E.length;A++){const N=E[A],C=[],T=[],D=N.getElementsByTagName("vertex");for(let P=0;P<D.length;P++){const z=D[P];C.push(parseFloat(z.getAttribute("x")||"0"),parseFloat(z.getAttribute("y")||"0"),parseFloat(z.getAttribute("z")||"0"))}const k=N.getElementsByTagName("triangle");for(let P=0;P<k.length;P++){const z=k[P];T.push(parseInt(z.getAttribute("v1")||"0"),parseInt(z.getAttribute("v2")||"0"),parseInt(z.getAttribute("v3")||"0"))}C.length>0&&T.length>0&&y.push({vertices:C,triangles:T,extruder:x})}const w=b.getElementsByTagName("component");for(let A=0;A<w.length;A++){const N=w[A],C=N.getAttribute("p:path")||N.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),T=N.getAttribute("objectid");if(C){const D=await a(C);if(D){const k=T?`${v}:${T}`:null,P=k?l.get(k)??x:x,z=await UH(D,P),L=N.getAttribute("transform"),X=FH(L);for(const R of z)if(L){const Y=[];for(let J=0;J<R.vertices.length;J+=3){const G=new at(R.vertices[J],R.vertices[J+1],R.vertices[J+2]);G.applyMatrix4(X),Y.push(G.x,G.y,G.z)}y.push({vertices:Y,triangles:R.triangles,extruder:R.extruder})}else y.push(R)}}}y.length>0&&n.set(v,{id:v,meshes:y,defaultExtruder:x})}const p=d.getElementsByTagName("build");if(p.length>0){const g=p[0].getElementsByTagName("item");for(let b=0;b<g.length;b++){const v=g[b],x=v.getAttribute("objectid");if(!x)continue;const y=FH(v.getAttribute("transform"));r.push({objectId:x,transform:y})}}return{objects:n,buildItems:r}}function zH(t){const e=new Vl,n=new Float32Array(t.vertices.length);for(let r=0;r<t.vertices.length;r+=3)n[r]=t.vertices[r],n[r+1]=t.vertices[r+2],n[r+2]=t.vertices[r+1];return e.setAttribute("position",new vo(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function K4e({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=S.useRef(null),a=S.useRef(null),o=S.useRef(null),l=S.useRef(null),c=S.useRef(null),[u,d]=S.useState(!0),[f,p]=S.useState(null);S.useEffect(()=>{if(!i.current)return;const v=i.current,x=v.clientWidth,y=v.clientHeight,E=new Eje;E.background=new An(1710618),o.current=E;const w=new fo(45,x/y,.1,1e4);w.position.set(150,150,150),l.current=w;const A=new A4e({antialias:!0});A.setSize(x,y),A.setPixelRatio(window.devicePixelRatio),v.appendChild(A.domElement),a.current=A;const N=new C4e(w,A.domElement);N.enableDamping=!0,N.dampingFactor=.05,c.current=N;const C=new Ije(16777215,.6);E.add(C);const T=new lH(16777215,.8);T.position.set(100,100,100),E.add(T);const D=new lH(16777215,.4);D.position.set(-100,50,-100),E.add(D);const k=Math.max(e.x,e.y),P=Math.ceil(k/16),z=new Uje(k,P,4473924,3355443);E.add(z);const L=new eO(e.x,e.y),X=new Q4({color:44610,transparent:!0,opacity:.15,side:yl}),R=new Ol(L,X);R.rotation.x=-Math.PI/2,R.position.y=-.5,E.add(R);let Y;const J=()=>{Y=requestAnimationFrame(J),N.update(),A.render(E,w)};J(),fetch(t).then(W=>{if(!W.ok)throw new Error("Failed to load file");return W.arrayBuffer()}).then(q4e).then(({objects:W,buildItems:ee})=>{if(W.size===0)throw new Error("No meshes found in 3MF file");const K=ae=>{const ue=n?.[ae]||"#00ae42",Le=new An(ue);return new Pje({color:Le,shininess:30,flatShading:!1})},F=new cb,q=new Map;if(ee.length>0)for(const ae of ee){const ge=W.get(ae.objectId);if(ge)for(const ue of ge.meshes){const Le=ae.extruder??ue.extruder,V=[];for(let Z=0;Z<ue.vertices.length;Z+=3){const B=new at(ue.vertices[Z],ue.vertices[Z+1],ue.vertices[Z+2]);B.applyMatrix4(ae.transform),V.push(B.x,B.y,B.z)}const $=zH({vertices:V,triangles:ue.triangles});q.has(Le)||q.set(Le,[]),q.get(Le).push($)}}else for(const ae of W.values())for(const ge of ae.meshes){const ue=ge.extruder,Le=zH(ge);q.has(ue)||q.set(ue,[]),q.get(ue).push(Le)}for(const[ae,ge]of q){if(ge.length===0)continue;const ue=ge.length===1?ge[0]:$4e(ge,!1);if(ue){const Le=K(ae),V=new Ol(ue,Le);F.add(V)}if(ge.length>1)for(const Le of ge)Le.dispose()}const ne=new Cf().setFromObject(F),re=ne.getCenter(new at);F.position.y=-ne.min.y,ee.length===0&&(F.position.x=-re.x,F.position.z=-re.z),E.add(F);const se=new Cf().setFromObject(F),de=se.getCenter(new at),pe=se.getSize(new at),oe=Math.max(pe.x,pe.y,pe.z)*1.8;w.position.set(de.x+oe*.7,de.y+oe*.5,de.z+oe*.7),N.target.copy(de),N.update(),d(!1)}).catch(W=>{p(W.message),d(!1)});const G=()=>{if(!v)return;const W=v.clientWidth,ee=v.clientHeight;w.aspect=W/ee,w.updateProjectionMatrix(),A.setSize(W,ee)};return window.addEventListener("resize",G),()=>{window.removeEventListener("resize",G),cancelAnimationFrame(Y),N.dispose(),A.dispose(),v.removeChild(A.domElement)}},[t,e,n]);const g=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},b=v=>{l.current&&l.current.position.multiplyScalar(v)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("p",{className:"text-red-400",children:f})}),!u&&!f&&s.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>b(.8),children:s.jsx(ghe,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>b(1.25),children:s.jsx(yhe,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:g,children:s.jsx(If,{className:"w-4 h-4"})})]})]})}const EM="159",Bm={ROTATE:0,DOLLY:1,PAN:2},$m={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},X4e=0,BH=1,Y4e=2,SZ=1,Q4e=2,Mc=3,Bd=0,cs=1,jc=2,Md=0,Rp=1,$H=2,HH=3,VH=4,Z4e=5,Rh=100,J4e=101,eOe=102,GH=103,WH=104,tOe=200,nOe=201,rOe=202,iOe=203,vP=204,_P=205,aOe=206,sOe=207,oOe=208,lOe=209,cOe=210,uOe=211,dOe=212,hOe=213,fOe=214,mOe=0,pOe=1,gOe=2,uS=3,xOe=4,bOe=5,yOe=6,vOe=7,nO=0,_Oe=1,wOe=2,Ed=0,SOe=1,MOe=2,EOe=3,NOe=4,AOe=5,MZ=300,ig=301,ag=302,wP=303,SP=304,NM=306,MP=1e3,Go=1001,EP=1002,ca=1003,qH=1004,LC=1005,mo=1006,TOe=1007,b0=1008,Nd=1009,COe=1010,kOe=1011,rO=1012,EZ=1013,md=1014,Ic=1015,y0=1016,NZ=1017,AZ=1018,tf=1020,jOe=1021,po=1023,POe=1024,ROe=1025,nf=1026,sg=1027,DOe=1028,TZ=1029,OOe=1030,CZ=1031,kZ=1033,IC=33776,FC=33777,UC=33778,zC=33779,KH=35840,XH=35841,YH=35842,QH=35843,jZ=36196,ZH=37492,JH=37496,eV=37808,tV=37809,nV=37810,rV=37811,iV=37812,aV=37813,sV=37814,oV=37815,lV=37816,cV=37817,uV=37818,dV=37819,hV=37820,fV=37821,BC=36492,mV=36494,pV=36495,LOe=36283,gV=36284,xV=36285,bV=36286,PZ=3e3,rf=3001,IOe=3200,FOe=3201,RZ=0,UOe=1,go="",ua="srgb",ou="srgb-linear",iO="display-p3",AM="display-p3-linear",dS="linear",Sr="srgb",hS="rec709",fS="p3",Hm=7680,yV=519,zOe=512,BOe=513,$Oe=514,DZ=515,HOe=516,VOe=517,GOe=518,WOe=519,NP=35044,vV="300 es",AP=1035,Ml=2e3,v0=2001;class $f{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}}const va=["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 _V=1234567;const Sb=Math.PI/180,_0=180/Math.PI;function Vc(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(va[t&255]+va[t>>8&255]+va[t>>16&255]+va[t>>24&255]+"-"+va[e&255]+va[e>>8&255]+"-"+va[e>>16&15|64]+va[e>>24&255]+"-"+va[n&63|128]+va[n>>8&255]+"-"+va[n>>16&255]+va[n>>24&255]+va[r&255]+va[r>>8&255]+va[r>>16&255]+va[r>>24&255]).toLowerCase()}function da(t,e,n){return Math.max(e,Math.min(n,t))}function aO(t,e){return(t%e+e)%e}function qOe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function KOe(t,e,n){return t!==e?(n-t)/(e-t):0}function Mb(t,e,n){return(1-n)*t+n*e}function XOe(t,e,n,r){return Mb(t,e,1-Math.exp(-n*r))}function YOe(t,e=1){return e-Math.abs(aO(t,e*2)-e)}function QOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function ZOe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function JOe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function eLe(t,e){return t+Math.random()*(e-t)}function tLe(t){return t*(.5-Math.random())}function nLe(t){t!==void 0&&(_V=t);let e=_V+=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 rLe(t){return t*Sb}function iLe(t){return t*_0}function TP(t){return(t&t-1)===0&&t!==0}function aLe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function mS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function sLe(t,e,n,r,i){const a=Math.cos,o=Math.sin,l=a(n/2),c=o(n/2),u=a((e+r)/2),d=o((e+r)/2),f=a((e-r)/2),p=o((e-r)/2),g=a((r-e)/2),b=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*p,l*u);break;case"YZY":t.set(c*p,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,c*p,l*d,l*u);break;case"XZX":t.set(l*d,c*b,c*g,l*u);break;case"YXY":t.set(c*g,l*d,c*b,l*u);break;case"ZYZ":t.set(c*b,c*g,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function vl(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 lr(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 OZ={DEG2RAD:Sb,RAD2DEG:_0,generateUUID:Vc,clamp:da,euclideanModulo:aO,mapLinear:qOe,inverseLerp:KOe,lerp:Mb,damp:XOe,pingpong:YOe,smoothstep:QOe,smootherstep:ZOe,randInt:JOe,randFloat:eLe,randFloatSpread:tLe,seededRandom:nLe,degToRad:rLe,radToDeg:iLe,isPowerOfTwo:TP,ceilPowerOfTwo:aLe,floorPowerOfTwo:mS,setQuaternionFromProperEuler:sLe,normalize:lr,denormalize:vl};class rn{constructor(e=0,n=0){rn.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,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[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 r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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 r=this.dot(e)/n;return Math.acos(da(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,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 r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*i+o*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class wn{constructor(e,n,r,i,a,o,l,c,u){wn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=o,d[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],this}extractBasis(e,n,r){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),r.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 r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],g=r[5],b=r[8],v=i[0],x=i[3],y=i[6],E=i[1],w=i[4],A=i[7],N=i[2],C=i[5],T=i[8];return a[0]=o*v+l*E+c*N,a[3]=o*x+l*w+c*C,a[6]=o*y+l*A+c*T,a[1]=u*v+d*E+f*N,a[4]=u*x+d*w+f*C,a[7]=u*y+d*A+f*T,a[2]=p*v+g*E+b*N,a[5]=p*x+g*w+b*C,a[8]=p*y+g*A+b*T,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],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8];return n*o*d-n*l*u-r*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,g=u*a-o*c,b=n*f+r*p+i*g;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/b;return e[0]=f*v,e[1]=(i*u-d*r)*v,e[2]=(l*r-i*o)*v,e[3]=p*v,e[4]=(d*n-i*c)*v,e[5]=(i*a-l*n)*v,e[6]=g*v,e[7]=(r*c-u*n)*v,e[8]=(o*n-r*a)*v,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,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);return this.set(r*c,r*u,-r*(c*o+u*l)+o+e,-i*u,i*c,-i*(-u*o+c*l)+l+n,0,0,1),this}scale(e,n){return this.premultiply($C.makeScale(e,n)),this}rotate(e){return this.premultiply($C.makeRotation(-e)),this}translate(e,n){return this.premultiply($C.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),r=Math.sin(e);return this.set(n,-r,0,r,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,r=e.elements;for(let i=0;i<9;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<9;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const $C=new wn;function LZ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function pS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function oLe(){const t=pS("canvas");return t.style.display="block",t}const wV={};function Eb(t){t in wV||(wV[t]=!0,console.warn(t))}const SV=new wn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),MV=new wn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),j_={[ou]:{transfer:dS,primaries:hS,toReference:t=>t,fromReference:t=>t},[ua]:{transfer:Sr,primaries:hS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[AM]:{transfer:dS,primaries:fS,toReference:t=>t.applyMatrix3(MV),fromReference:t=>t.applyMatrix3(SV)},[iO]:{transfer:Sr,primaries:fS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(MV),fromReference:t=>t.applyMatrix3(SV).convertLinearToSRGB()}},lLe=new Set([ou,AM]),cr={enabled:!0,_workingColorSpace:ou,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(!lLe.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 r=j_[e].toReference,i=j_[n].fromReference;return i(r(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 j_[t].primaries},getTransfer:function(t){return t===go?dS:j_[t].transfer}};function Dp(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function HC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Vm;class IZ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Vm===void 0&&(Vm=pS("canvas")),Vm.width=e.width,Vm.height=e.height;const r=Vm.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Vm}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=pS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Dp(a[o]/255)*255;return r.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let r=0;r<n.length;r++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[r]=Math.floor(Dp(n[r]/255)*255):n[r]=Dp(n[r]);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 cLe=0;class FZ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cLe++}),this.uuid=Vc(),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 r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(VC(i[o].image)):a.push(VC(i[o]))}else a=VC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function VC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?IZ.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 uLe=0;class us extends $f{constructor(e=us.DEFAULT_IMAGE,n=us.DEFAULT_MAPPING,r=Go,i=Go,a=mo,o=b0,l=po,c=Nd,u=us.DEFAULT_ANISOTROPY,d=go){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:uLe++}),this.uuid=Vc(),this.name="",this.source=new FZ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=u,this.format=l,this.internalFormat=null,this.type=c,this.offset=new rn(0,0),this.repeat=new rn(1,1),this.center=new rn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new wn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(Eb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===rf?ua:go),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 r={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&&(r.userData=this.userData),n||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==MZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case MP:e.x=e.x-Math.floor(e.x);break;case Go:e.x=e.x<0?0:1;break;case EP: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 MP:e.y=e.y-Math.floor(e.y);break;case Go:e.y=e.y<0?0:1;break;case EP: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 Eb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ua?rf:PZ}set encoding(e){Eb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===rf?ua:go}}us.DEFAULT_IMAGE=null;us.DEFAULT_MAPPING=MZ;us.DEFAULT_ANISOTROPY=1;class hr{constructor(e=0,n=0,r=0,i=1){hr.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,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,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[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,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],g=c[5],b=c[9],v=c[2],x=c[6],y=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-v)<.01&&Math.abs(b-x)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+v)<.1&&Math.abs(b+x)<.1&&Math.abs(u+g+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const w=(u+1)/2,A=(g+1)/2,N=(y+1)/2,C=(d+p)/4,T=(f+v)/4,D=(b+x)/4;return w>A&&w>N?w<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(w),i=C/r,a=T/r):A>N?A<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(A),r=C/i,a=D/i):N<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(N),r=T/a,i=D/a),this.set(r,i,a,n),this}let E=Math.sqrt((x-b)*(x-b)+(f-v)*(f-v)+(p-d)*(p-d));return Math.abs(E)<.001&&(E=1),this.x=(x-b)/E,this.y=(f-v)/E,this.z=(p-d)/E,this.w=Math.acos((u+g+y-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 r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,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 dLe extends $f{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new hr(0,0,e,n),this.scissorTest=!1,this.viewport=new hr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(Eb("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===rf?ua:go),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:mo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new us(i,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps,this.texture.internalFormat=r.internalFormat,this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture,this.samples=r.samples}setSize(e,n,r=1){(this.width!==e||this.height!==n||this.depth!==r)&&(this.width=e,this.height=n,this.depth=r,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=r,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 FZ(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 kf extends dLe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class UZ extends us{constructor(e=null,n=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ca,this.minFilter=ca,this.wrapR=Go,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class hLe extends us{constructor(e=null,n=1,r=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:r,depth:i},this.magFilter=ca,this.minFilter=ca,this.wrapR=Go,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class jf{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const p=a[o+0],g=a[o+1],b=a[o+2],v=a[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=p,e[n+1]=g,e[n+2]=b,e[n+3]=v;return}if(f!==v||c!==p||u!==g||d!==b){let x=1-l;const y=c*p+u*g+d*b+f*v,E=y>=0?1:-1,w=1-y*y;if(w>Number.EPSILON){const N=Math.sqrt(w),C=Math.atan2(N,y*E);x=Math.sin(x*C)/N,l=Math.sin(l*C)/N}const A=l*E;if(c=c*x+p*A,u=u*x+g*A,d=d*x+b*A,f=f*x+v*A,x===1-l){const N=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=N,u*=N,d*=N,f*=N}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],g=a[o+2],b=a[o+3];return e[n]=l*b+d*f+c*g-u*p,e[n+1]=c*b+d*p+u*f-l*g,e[n+2]=u*b+d*g+l*p-c*f,e[n+3]=d*b-l*f-c*p-u*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,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,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 r=e._x,i=e._y,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),g=c(i/2),b=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*g*b,this._y=u*g*f-p*d*b,this._z=u*d*b+p*g*f,this._w=u*d*f-p*g*b;break;case"YXZ":this._x=p*d*f+u*g*b,this._y=u*g*f-p*d*b,this._z=u*d*b-p*g*f,this._w=u*d*f+p*g*b;break;case"ZXY":this._x=p*d*f-u*g*b,this._y=u*g*f+p*d*b,this._z=u*d*b+p*g*f,this._w=u*d*f-p*g*b;break;case"ZYX":this._x=p*d*f-u*g*b,this._y=u*g*f+p*d*b,this._z=u*d*b-p*g*f,this._w=u*d*f+p*g*b;break;case"YZX":this._x=p*d*f+u*g*b,this._y=u*g*f+p*d*b,this._z=u*d*b-p*g*f,this._w=u*d*f-p*g*b;break;case"XZY":this._x=p*d*f-u*g*b,this._y=u*g*f-p*d*b,this._z=u*d*b+p*g*f,this._w=u*d*f+p*g*b;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const r=n/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const g=.5/Math.sqrt(p+1);this._w=.25/g,this._x=(d-c)*g,this._y=(a-u)*g,this._z=(o-i)*g}else if(r>l&&r>f){const g=2*Math.sqrt(1+r-l-f);this._w=(d-c)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(a+u)/g}else if(l>f){const g=2*Math.sqrt(1+l-r-f);this._w=(a-u)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(c+d)/g}else{const g=2*Math.sqrt(1+f-r-l);this._w=(o-i)/g,this._x=(a+u)/g,this._y=(c+d)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(da(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),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 r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=a,this;const c=1-l*l;if(c<=Number.EPSILON){const g=1-n;return this._w=g*o+n*this._w,this._x=g*r+n*this._x,this._y=g*i+n*this._y,this._z=g*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,p=Math.sin(n*d)/u;return this._w=o*f+this._w*p,this._x=r*f+this._x*p,this._y=i*f+this._y*p,this._z=a*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,n,r){return this.copy(e).slerp(n,r)}random(){const e=Math.random(),n=Math.sqrt(1-e),r=Math.sqrt(e),i=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}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 ze{constructor(e=0,n=0,r=0){ze.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,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(EV.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(EV.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*d-o*u,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,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,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 r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}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,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*o-r*c,this.z=r*l-i*o,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const r=e.dot(this)/n;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return GC.copy(this).projectOnVector(e),this.sub(GC)}reflect(e){return this.sub(GC.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 r=this.dot(e)/n;return Math.acos(da(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}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,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,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(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,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,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const GC=new ze,EV=new jf;class _o{constructor(e=new ze(1/0,1/0,1/0),n=new ze(-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,r=e.length;n<r;n+=3)this.expandByPoint(Fo.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Fo.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const r=Fo.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),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 r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Fo):Fo.fromBufferAttribute(a,o),Fo.applyMatrix4(e.matrixWorld),this.expandByPoint(Fo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),P_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),P_.copy(r.boundingBox)),P_.applyMatrix4(e.matrixWorld),this.union(P_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[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,Fo),Fo.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,r;return e.normal.x>0?(n=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),n<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Yx),R_.subVectors(this.max,Yx),Gm.subVectors(e.a,Yx),Wm.subVectors(e.b,Yx),qm.subVectors(e.c,Yx),Vu.subVectors(Wm,Gm),Gu.subVectors(qm,Wm),vh.subVectors(Gm,qm);let n=[0,-Vu.z,Vu.y,0,-Gu.z,Gu.y,0,-vh.z,vh.y,Vu.z,0,-Vu.x,Gu.z,0,-Gu.x,vh.z,0,-vh.x,-Vu.y,Vu.x,0,-Gu.y,Gu.x,0,-vh.y,vh.x,0];return!WC(n,Gm,Wm,qm,R_)||(n=[1,0,0,0,1,0,0,0,1],!WC(n,Gm,Wm,qm,R_))?!1:(D_.crossVectors(Vu,Gu),n=[D_.x,D_.y,D_.z],WC(n,Gm,Wm,qm,R_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Fo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Fo).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:(pc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pc),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 pc=[new ze,new ze,new ze,new ze,new ze,new ze,new ze,new ze],Fo=new ze,P_=new _o,Gm=new ze,Wm=new ze,qm=new ze,Vu=new ze,Gu=new ze,vh=new ze,Yx=new ze,R_=new ze,D_=new ze,_h=new ze;function WC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){_h.fromArray(t,a);const l=i.x*Math.abs(_h.x)+i.y*Math.abs(_h.y)+i.z*Math.abs(_h.z),c=e.dot(_h),u=n.dot(_h),d=r.dot(_h);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const fLe=new _o,Qx=new ze,qC=new ze;class Al{constructor(e=new ze,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):fLe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),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 r=this.center.distanceToSquared(e);return n.copy(e),r>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;Qx.subVectors(e,this.center);const n=Qx.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Qx,i/r),this.radius+=i}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):(qC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Qx.copy(e.center).add(qC)),this.expandByPoint(Qx.copy(e.center).sub(qC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const gc=new ze,KC=new ze,O_=new ze,Wu=new ze,XC=new ze,L_=new ze,YC=new ze;class sO{constructor(e=new ze,n=new ze(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,gc)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const r=n.dot(this.direction);return r<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=gc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(gc.copy(this.origin).addScaledVector(this.direction,n),gc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){KC.copy(e).add(n).multiplyScalar(.5),O_.copy(n).sub(e).normalize(),Wu.copy(this.origin).sub(KC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(O_),l=Wu.dot(this.direction),c=-Wu.dot(O_),u=Wu.lengthSq(),d=Math.abs(1-o*o);let f,p,g,b;if(d>0)if(f=o*c-l,p=o*l-c,b=a*d,f>=0)if(p>=-b)if(p<=b){const v=1/d;f*=v,p*=v,g=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),g=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),g=-f*f+p*(p+2*c)+u;else p<=-b?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),g=-f*f+p*(p+2*c)+u):p<=b?(f=0,p=Math.min(Math.max(-a,-c),a),g=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),g=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),g=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(KC).addScaledVector(O_,p),g}intersectSphere(e,n){gc.subVectors(e.center,this.origin);const r=gc.dot(this.direction),i=gc.dot(gc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-i),l=r-o,c=r+o;return c<0?null:l<0?this.at(c,n):this.at(l,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 r=-(this.origin.dot(e.normal)+e.constant)/n;return r>=0?r:null}intersectPlane(e,n){const r=this.distanceToPlane(e);return r===null?null:this.at(r,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let r,i,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,gc)!==null}intersectTriangle(e,n,r,i,a){XC.subVectors(n,e),L_.subVectors(r,e),YC.crossVectors(XC,L_);let o=this.direction.dot(YC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Wu.subVectors(this.origin,e);const c=l*this.direction.dot(L_.crossVectors(Wu,L_));if(c<0)return null;const u=l*this.direction.dot(XC.cross(Wu));if(u<0||c+u>o)return null;const d=-l*Wu.dot(YC);return d<0?null:this.at(d/o,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 vr{constructor(e,n,r,i,a,o,l,c,u,d,f,p,g,b,v,x){vr.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,r,i,a,o,l,c,u,d,f,p,g,b,v,x)}set(e,n,r,i,a,o,l,c,u,d,f,p,g,b,v,x){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=p,y[3]=g,y[7]=b,y[11]=v,y[15]=x,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 vr().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[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,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Km.setFromMatrixColumn(e,0).length(),a=1/Km.setFromMatrixColumn(e,1).length(),o=1/Km.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*o,n[9]=r[9]*o,n[10]=r[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,r=e.x,i=e.y,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,g=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=g+b*u,n[5]=p-v*u,n[9]=-l*c,n[2]=v-p*u,n[6]=b+g*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,g=c*f,b=u*d,v=u*f;n[0]=p+v*l,n[4]=b*l-g,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=g*l-b,n[6]=v+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,g=c*f,b=u*d,v=u*f;n[0]=p-v*l,n[4]=-o*f,n[8]=b+g*l,n[1]=g+b*l,n[5]=o*d,n[9]=v-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,g=o*f,b=l*d,v=l*f;n[0]=c*d,n[4]=b*u-g,n[8]=p*u+v,n[1]=c*f,n[5]=v*u+p,n[9]=g*u-b,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,g=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=v-p*f,n[8]=b*f+g,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=g*f+b,n[10]=p-v*f}else if(e.order==="XZY"){const p=o*c,g=o*u,b=l*c,v=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+v,n[5]=o*d,n[9]=g*f-b,n[2]=b*f-g,n[6]=l*d,n[10]=v*f+p}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(mLe,e,pLe)}lookAt(e,n,r){const i=this.elements;return Es.subVectors(e,n),Es.lengthSq()===0&&(Es.z=1),Es.normalize(),qu.crossVectors(r,Es),qu.lengthSq()===0&&(Math.abs(r.z)===1?Es.x+=1e-4:Es.z+=1e-4,Es.normalize(),qu.crossVectors(r,Es)),qu.normalize(),I_.crossVectors(Es,qu),i[0]=qu.x,i[4]=I_.x,i[8]=Es.x,i[1]=qu.y,i[5]=I_.y,i[9]=Es.y,i[2]=qu.z,i[6]=I_.z,i[10]=Es.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],g=r[13],b=r[2],v=r[6],x=r[10],y=r[14],E=r[3],w=r[7],A=r[11],N=r[15],C=i[0],T=i[4],D=i[8],k=i[12],P=i[1],z=i[5],L=i[9],X=i[13],R=i[2],Y=i[6],J=i[10],G=i[14],W=i[3],ee=i[7],K=i[11],F=i[15];return a[0]=o*C+l*P+c*R+u*W,a[4]=o*T+l*z+c*Y+u*ee,a[8]=o*D+l*L+c*J+u*K,a[12]=o*k+l*X+c*G+u*F,a[1]=d*C+f*P+p*R+g*W,a[5]=d*T+f*z+p*Y+g*ee,a[9]=d*D+f*L+p*J+g*K,a[13]=d*k+f*X+p*G+g*F,a[2]=b*C+v*P+x*R+y*W,a[6]=b*T+v*z+x*Y+y*ee,a[10]=b*D+v*L+x*J+y*K,a[14]=b*k+v*X+x*G+y*F,a[3]=E*C+w*P+A*R+N*W,a[7]=E*T+w*z+A*Y+N*ee,a[11]=E*D+w*L+A*J+N*K,a[15]=E*k+w*X+A*G+N*F,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],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],g=e[14],b=e[3],v=e[7],x=e[11],y=e[15];return b*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*g-r*c*g)+v*(+n*c*g-n*u*p+a*o*p-i*o*g+i*u*d-a*c*d)+x*(+n*u*f-n*l*g-a*o*f+r*o*g+a*l*d-r*u*d)+y*(-i*l*d-n*c*f+n*l*p+i*o*f-r*o*p+r*c*d)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,r){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=r),this}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],g=e[11],b=e[12],v=e[13],x=e[14],y=e[15],E=f*x*u-v*p*u+v*c*g-l*x*g-f*c*y+l*p*y,w=b*p*u-d*x*u-b*c*g+o*x*g+d*c*y-o*p*y,A=d*v*u-b*f*u+b*l*g-o*v*g-d*l*y+o*f*y,N=b*f*c-d*v*c-b*l*p+o*v*p+d*l*x-o*f*x,C=n*E+r*w+i*A+a*N;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/C;return e[0]=E*T,e[1]=(v*p*a-f*x*a-v*i*g+r*x*g+f*i*y-r*p*y)*T,e[2]=(l*x*a-v*c*a+v*i*u-r*x*u-l*i*y+r*c*y)*T,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*g-r*c*g)*T,e[4]=w*T,e[5]=(d*x*a-b*p*a+b*i*g-n*x*g-d*i*y+n*p*y)*T,e[6]=(b*c*a-o*x*a-b*i*u+n*x*u+o*i*y-n*c*y)*T,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*g+n*c*g)*T,e[8]=A*T,e[9]=(b*f*a-d*v*a-b*r*g+n*v*g+d*r*y-n*f*y)*T,e[10]=(o*v*a-b*l*a+b*r*u-n*v*u-o*r*y+n*l*y)*T,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*g-n*l*g)*T,e[12]=N*T,e[13]=(d*v*i-b*f*i+b*r*p-n*v*p-d*r*x+n*f*x)*T,e[14]=(b*l*i-o*v*i-b*r*c+n*v*c+o*r*x-n*l*x)*T,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*T,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){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,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*l;return this.set(u*o+r,u*l-i*c,u*c+i*l,0,u*l+i*c,d*l+r,d*c-i*o,0,u*c-i*l,d*c+i*o,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,g=a*d,b=a*f,v=o*d,x=o*f,y=l*f,E=c*u,w=c*d,A=c*f,N=r.x,C=r.y,T=r.z;return i[0]=(1-(v+y))*N,i[1]=(g+A)*N,i[2]=(b-w)*N,i[3]=0,i[4]=(g-A)*C,i[5]=(1-(p+y))*C,i[6]=(x+E)*C,i[7]=0,i[8]=(b+w)*T,i[9]=(x-E)*T,i[10]=(1-(p+v))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,r){const i=this.elements;let a=Km.set(i[0],i[1],i[2]).length();const o=Km.set(i[4],i[5],i[6]).length(),l=Km.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Uo.copy(this);const u=1/a,d=1/o,f=1/l;return Uo.elements[0]*=u,Uo.elements[1]*=u,Uo.elements[2]*=u,Uo.elements[4]*=d,Uo.elements[5]*=d,Uo.elements[6]*=d,Uo.elements[8]*=f,Uo.elements[9]*=f,Uo.elements[10]*=f,n.setFromRotationMatrix(Uo),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=Ml){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),p=(r+i)/(r-i);let g,b;if(l===Ml)g=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===v0)g=-o/(o-a),b=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=Ml){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),p=(n+e)*u,g=(r+i)*d;let b,v;if(l===Ml)b=(o+a)*f,v=-2*f;else if(l===v0)b=a*f,v=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-g,c[2]=0,c[6]=0,c[10]=v,c[14]=-b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const n=this.elements,r=e.elements;for(let i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0}fromArray(e,n=0){for(let r=0;r<16;r++)this.elements[r]=e[r+n];return this}toArray(e=[],n=0){const r=this.elements;return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],e[n+4]=r[4],e[n+5]=r[5],e[n+6]=r[6],e[n+7]=r[7],e[n+8]=r[8],e[n+9]=r[9],e[n+10]=r[10],e[n+11]=r[11],e[n+12]=r[12],e[n+13]=r[13],e[n+14]=r[14],e[n+15]=r[15],e}}const Km=new ze,Uo=new vr,mLe=new ze(0,0,0),pLe=new ze(1,1,1),qu=new ze,I_=new ze,Es=new ze,NV=new vr,AV=new jf;class yy{constructor(e=0,n=0,r=0,i=yy.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}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,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,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,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(da(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-da(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,g),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(da(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-da(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,g),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(da(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,g));break;case"XZY":this._z=Math.asin(-da(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,g),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return NV.makeRotationFromQuaternion(e),this.setFromRotationMatrix(NV,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return AV.setFromEuler(this),this.setFromQuaternion(AV,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}}yy.DEFAULT_ORDER="XYZ";class zZ{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 gLe=0;const TV=new ze,Xm=new jf,xc=new vr,F_=new ze,Zx=new ze,xLe=new ze,bLe=new jf,CV=new ze(1,0,0),kV=new ze(0,1,0),jV=new ze(0,0,1),yLe={type:"added"},vLe={type:"removed"};class $a extends $f{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gLe++}),this.uuid=Vc(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=$a.DEFAULT_UP.clone();const e=new ze,n=new yy,r=new jf,i=new ze(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new vr},normalMatrix:{value:new wn}}),this.matrix=new vr,this.matrixWorld=new vr,this.matrixAutoUpdate=$a.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=$a.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zZ,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 Xm.setFromAxisAngle(e,n),this.quaternion.multiply(Xm),this}rotateOnWorldAxis(e,n){return Xm.setFromAxisAngle(e,n),this.quaternion.premultiply(Xm),this}rotateX(e){return this.rotateOnAxis(CV,e)}rotateY(e){return this.rotateOnAxis(kV,e)}rotateZ(e){return this.rotateOnAxis(jV,e)}translateOnAxis(e,n){return TV.copy(e).applyQuaternion(this.quaternion),this.position.add(TV.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(CV,e)}translateY(e){return this.translateOnAxis(kV,e)}translateZ(e){return this.translateOnAxis(jV,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(xc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?F_.copy(e):F_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Zx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xc.lookAt(Zx,F_,this.up):xc.lookAt(F_,Zx,this.up),this.quaternion.setFromRotationMatrix(xc),i&&(xc.extractRotation(i.matrixWorld),Xm.setFromRotationMatrix(xc),this.quaternion.premultiply(Xm.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(yLe)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(vLe)),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),xc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),xc.multiply(e.parent.matrixWorld)),e.applyMatrix4(xc),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 r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zx,e,xLe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zx,bLe,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 r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].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 r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.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 i=this.children;for(let a=0,o=i.length;a<o;a++){const l=i[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=o(e.shapes),p=o(e.skeletons),g=o(e.animations),b=o(e.nodes);l.length>0&&(r.geometries=l),c.length>0&&(r.materials=c),u.length>0&&(r.textures=u),d.length>0&&(r.images=d),f.length>0&&(r.shapes=f),p.length>0&&(r.skeletons=p),g.length>0&&(r.animations=g),b.length>0&&(r.nodes=b)}return r.object=i,r;function o(l){const c=[];for(const u in l){const d=l[u];delete d.metadata,c.push(d)}return c}}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 r=0;r<e.children.length;r++){const i=e.children[r];this.add(i.clone())}return this}}$a.DEFAULT_UP=new ze(0,1,0);$a.DEFAULT_MATRIX_AUTO_UPDATE=!0;$a.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const zo=new ze,bc=new ze,QC=new ze,yc=new ze,Ym=new ze,Qm=new ze,PV=new ze,ZC=new ze,JC=new ze,ek=new ze;let U_=!1;class Bo{constructor(e=new ze,n=new ze,r=new ze){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),zo.subVectors(e,n),i.cross(zo);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){zo.subVectors(i,n),bc.subVectors(r,n),QC.subVectors(e,n);const o=zo.dot(zo),l=zo.dot(bc),c=zo.dot(QC),u=bc.dot(bc),d=bc.dot(QC),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const p=1/f,g=(u*c-l*d)*p,b=(o*d-l*c)*p;return a.set(1-g-b,b,g)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,yc),yc.x>=0&&yc.y>=0&&yc.x+yc.y<=1}static getUV(e,n,r,i,a,o,l,c){return U_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),U_=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,yc),c.setScalar(0),c.addScaledVector(a,yc.x),c.addScaledVector(o,yc.y),c.addScaledVector(l,yc.z),c}static isFrontFacing(e,n,r,i){return zo.subVectors(r,n),bc.subVectors(e,n),zo.cross(bc).dot(i)<0}set(e,n,r){return this.a.copy(e),this.b.copy(n),this.c.copy(r),this}setFromPointsAndIndices(e,n,r,i){return this.a.copy(e[n]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,r,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 zo.subVectors(this.c,this.b),bc.subVectors(this.a,this.b),zo.cross(bc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Bo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Bo.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return U_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),U_=!0),Bo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return Bo.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return Bo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Bo.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;Ym.subVectors(i,r),Qm.subVectors(a,r),ZC.subVectors(e,r);const c=Ym.dot(ZC),u=Qm.dot(ZC);if(c<=0&&u<=0)return n.copy(r);JC.subVectors(e,i);const d=Ym.dot(JC),f=Qm.dot(JC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Ym,o);ek.subVectors(e,a);const g=Ym.dot(ek),b=Qm.dot(ek);if(b>=0&&g<=b)return n.copy(a);const v=g*u-c*b;if(v<=0&&u>=0&&b<=0)return l=u/(u-b),n.copy(r).addScaledVector(Qm,l);const x=d*b-g*f;if(x<=0&&f-d>=0&&g-b>=0)return PV.subVectors(a,i),l=(f-d)/(f-d+(g-b)),n.copy(i).addScaledVector(PV,l);const y=1/(x+v+p);return o=v*y,l=p*y,n.copy(r).addScaledVector(Ym,o).addScaledVector(Qm,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const BZ={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},Ku={h:0,s:0,l:0},z_={h:0,s:0,l:0};function tk(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 Yt=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=ua){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,cr.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=cr.workingColorSpace){return this.r=e,this.g=n,this.b=r,cr.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=cr.workingColorSpace){if(e=aO(e,1),n=da(n,0,1),r=da(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=tk(o,a,e+1/3),this.g=tk(o,a,e),this.b=tk(o,a,e-1/3)}return cr.toWorkingColorSpace(this,i),this}setStyle(e,n=ua){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(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(l))return r(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(l))return r(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(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===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=ua){const r=BZ[e.toLowerCase()];return r!==void 0?this.setHex(r,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=Dp(e.r),this.g=Dp(e.g),this.b=Dp(e.b),this}copyLinearToSRGB(e){return this.r=HC(e.r),this.g=HC(e.g),this.b=HC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ua){return cr.fromWorkingColorSpace(_a.copy(this),e),Math.round(da(_a.r*255,0,255))*65536+Math.round(da(_a.g*255,0,255))*256+Math.round(da(_a.b*255,0,255))}getHexString(e=ua){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=cr.workingColorSpace){cr.fromWorkingColorSpace(_a.copy(this),n);const r=_a.r,i=_a.g,a=_a.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=cr.workingColorSpace){return cr.fromWorkingColorSpace(_a.copy(this),n),e.r=_a.r,e.g=_a.g,e.b=_a.b,e}getStyle(e=ua){cr.fromWorkingColorSpace(_a.copy(this),e);const n=_a.r,r=_a.g,i=_a.b;return e!==ua?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(Ku),this.setHSL(Ku.h+e,Ku.s+n,Ku.l+r)}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,r){return this.r=e.r+(n.r-e.r)*r,this.g=e.g+(n.g-e.g)*r,this.b=e.b+(n.b-e.b)*r,this}lerpHSL(e,n){this.getHSL(Ku),e.getHSL(z_);const r=Mb(Ku.h,z_.h,n),i=Mb(Ku.s,z_.s,n),a=Mb(Ku.l,z_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,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 _a=new Yt;Yt.NAMES=BZ;let _Le=0;class Ig extends $f{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:_Le++}),this.uuid=Vc(),this.name="",this.type="Material",this.blending=Rp,this.side=Bd,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=vP,this.blendDst=_P,this.blendEquation=Rh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Yt(0,0,0),this.blendAlpha=0,this.depthFunc=uS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yV,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Hm,this.stencilZFail=Hm,this.stencilZPass=Hm,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 r=e[n];if(r===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[n]=r}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const r={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Rp&&(r.blending=this.blending),this.side!==Bd&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==vP&&(r.blendSrc=this.blendSrc),this.blendDst!==_P&&(r.blendDst=this.blendDst),this.blendEquation!==Rh&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==uS&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yV&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Hm&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Hm&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Hm&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),o.length>0&&(r.images=o)}return r}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 r=null;if(n!==null){const i=n.length;r=new Array(i);for(let a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,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 $Z extends Ig{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Yt(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=nO,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 di=new ze,B_=new rn;class Us{constructor(e,n,r=!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=r,this.usage=NP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ic,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,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)B_.fromBufferAttribute(this,n),B_.applyMatrix3(e),this.setXY(n,B_.x,B_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyMatrix3(e),this.setXYZ(n,di.x,di.y,di.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyMatrix4(e),this.setXYZ(n,di.x,di.y,di.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.applyNormalMatrix(e),this.setXYZ(n,di.x,di.y,di.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)di.fromBufferAttribute(this,n),di.transformDirection(e),this.setXYZ(n,di.x,di.y,di.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let r=this.array[e*this.itemSize+n];return this.normalized&&(r=vl(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=lr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=vl(n,this.array)),n}setX(e,n){return this.normalized&&(n=lr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=vl(n,this.array)),n}setY(e,n){return this.normalized&&(n=lr(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=vl(n,this.array)),n}setZ(e,n){return this.normalized&&(n=lr(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=vl(n,this.array)),n}setW(e,n){return this.normalized&&(n=lr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=lr(n,this.array),r=lr(r,this.array)),this.array[e+0]=n,this.array[e+1]=r,this}setXYZ(e,n,r,i){return e*=this.itemSize,this.normalized&&(n=lr(n,this.array),r=lr(r,this.array),i=lr(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=lr(n,this.array),r=lr(r,this.array),i=lr(i,this.array),a=lr(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,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!==NP&&(e.usage=this.usage),e}}class HZ extends Us{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class VZ extends Us{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class ai extends Us{constructor(e,n,r){super(new Float32Array(e),n,r)}}let wLe=0;const ro=new vr,nk=new $a,Zm=new ze,Ns=new _o,Jx=new _o,Bi=new ze;class ka extends $f{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:wLe++}),this.uuid=Vc(),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(LZ(e)?VZ:HZ)(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,r=0){this.groups.push({start:e,count:n,materialIndex:r})}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 r=this.attributes.normal;if(r!==void 0){const a=new wn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return ro.makeRotationFromQuaternion(e),this.applyMatrix4(ro),this}rotateX(e){return ro.makeRotationX(e),this.applyMatrix4(ro),this}rotateY(e){return ro.makeRotationY(e),this.applyMatrix4(ro),this}rotateZ(e){return ro.makeRotationZ(e),this.applyMatrix4(ro),this}translate(e,n,r){return ro.makeTranslation(e,n,r),this.applyMatrix4(ro),this}scale(e,n,r){return ro.makeScale(e,n,r),this.applyMatrix4(ro),this}lookAt(e){return nk.lookAt(e),nk.updateMatrix(),this.applyMatrix4(nk.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Zm).negate(),this.translate(Zm.x,Zm.y,Zm.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new ai(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _o);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 ze(-1/0,-1/0,-1/0),new ze(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];Ns.setFromBufferAttribute(a),this.morphTargetsRelative?(Bi.addVectors(this.boundingBox.min,Ns.min),this.boundingBox.expandByPoint(Bi),Bi.addVectors(this.boundingBox.max,Ns.max),this.boundingBox.expandByPoint(Bi)):(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 Al);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 ze,1/0);return}if(e){const r=this.boundingSphere.center;if(Ns.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Jx.setFromBufferAttribute(l),this.morphTargetsRelative?(Bi.addVectors(Ns.min,Jx.min),Ns.expandByPoint(Bi),Bi.addVectors(Ns.max,Jx.max),Ns.expandByPoint(Bi)):(Ns.expandByPoint(Jx.min),Ns.expandByPoint(Jx.max))}Ns.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Bi.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Bi));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)Bi.fromBufferAttribute(l,u),c&&(Zm.fromBufferAttribute(e,u),Bi.add(Zm)),i=Math.max(i,r.distanceToSquared(Bi))}this.boundingSphere.radius=Math.sqrt(i),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 r=e.array,i=n.position.array,a=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Us(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let P=0;P<l;P++)u[P]=new ze,d[P]=new ze;const f=new ze,p=new ze,g=new ze,b=new rn,v=new rn,x=new rn,y=new ze,E=new ze;function w(P,z,L){f.fromArray(i,P*3),p.fromArray(i,z*3),g.fromArray(i,L*3),b.fromArray(o,P*2),v.fromArray(o,z*2),x.fromArray(o,L*2),p.sub(f),g.sub(f),v.sub(b),x.sub(b);const X=1/(v.x*x.y-x.x*v.y);isFinite(X)&&(y.copy(p).multiplyScalar(x.y).addScaledVector(g,-v.y).multiplyScalar(X),E.copy(g).multiplyScalar(v.x).addScaledVector(p,-x.x).multiplyScalar(X),u[P].add(y),u[z].add(y),u[L].add(y),d[P].add(E),d[z].add(E),d[L].add(E))}let A=this.groups;A.length===0&&(A=[{start:0,count:r.length}]);for(let P=0,z=A.length;P<z;++P){const L=A[P],X=L.start,R=L.count;for(let Y=X,J=X+R;Y<J;Y+=3)w(r[Y+0],r[Y+1],r[Y+2])}const N=new ze,C=new ze,T=new ze,D=new ze;function k(P){T.fromArray(a,P*3),D.copy(T);const z=u[P];N.copy(z),N.sub(T.multiplyScalar(T.dot(z))).normalize(),C.crossVectors(D,z);const X=C.dot(d[P])<0?-1:1;c[P*4]=N.x,c[P*4+1]=N.y,c[P*4+2]=N.z,c[P*4+3]=X}for(let P=0,z=A.length;P<z;++P){const L=A[P],X=L.start,R=L.count;for(let Y=X,J=X+R;Y<J;Y+=3)k(r[Y+0]),k(r[Y+1]),k(r[Y+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new Us(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,g=r.count;p<g;p++)r.setXYZ(p,0,0,0);const i=new ze,a=new ze,o=new ze,l=new ze,c=new ze,u=new ze,d=new ze,f=new ze;if(e)for(let p=0,g=e.count;p<g;p+=3){const b=e.getX(p+0),v=e.getX(p+1),x=e.getX(p+2);i.fromBufferAttribute(n,b),a.fromBufferAttribute(n,v),o.fromBufferAttribute(n,x),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,b),c.fromBufferAttribute(r,v),u.fromBufferAttribute(r,x),l.add(d),c.add(d),u.add(d),r.setXYZ(b,l.x,l.y,l.z),r.setXYZ(v,c.x,c.y,c.z),r.setXYZ(x,u.x,u.y,u.z)}else for(let p=0,g=n.count;p<g;p+=3)i.fromBufferAttribute(n,p+0),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,r=e.count;n<r;n++)Bi.fromBufferAttribute(e,n),Bi.normalize(),e.setXYZ(n,Bi.x,Bi.y,Bi.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let g=0,b=0;for(let v=0,x=c.length;v<x;v++){l.isInterleavedBufferAttribute?g=c[v]*l.data.stride+l.offset:g=c[v]*d;for(let y=0;y<d;y++)p[b++]=u[g++]}return new Us(p,d,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ka,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const p=u[d],g=e(p,r);c.push(g)}n.morphAttributes[l]=c}n.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let l=0,c=o.length;l<c;l++){const u=o[l];n.addGroup(u.start,u.count,u.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 c=this.parameters;for(const u in c)c[u]!==void 0&&(e[u]=c[u]);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 r=this.attributes;for(const c in r){const u=r[c];e.data.attributes[c]=u.toJSON(e.data)}const i={};let a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const g=u[f];d.push(g.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.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 r=e.index;r!==null&&this.setIndex(r.clone(n));const i=e.attributes;for(const u in i){const d=i[u];this.setAttribute(u,d.clone(n))}const a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,g=f.length;p<g;p++)d.push(f[p].clone(n));this.morphAttributes[u]=d}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let u=0,d=o.length;u<d;u++){const f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const RV=new vr,wh=new sO,$_=new Al,DV=new ze,Jm=new ze,ep=new ze,tp=new ze,rk=new ze,H_=new ze,V_=new rn,G_=new rn,W_=new rn,OV=new ze,LV=new ze,IV=new ze,q_=new ze,K_=new ze;class Ko extends $a{constructor(e=new ka,n=new $Z){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,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){H_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(rk.fromBufferAttribute(f,e),o?H_.addScaledVector(rk,d):H_.addScaledVector(rk.sub(n),d))}n.add(H_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),$_.copy(r.boundingSphere),$_.applyMatrix4(a),wh.copy(e.ray).recast(e.near),!($_.containsPoint(wh.origin)===!1&&(wh.intersectSphere($_,DV)===null||wh.origin.distanceToSquared(DV)>(e.far-e.near)**2))&&(RV.copy(a).invert(),wh.copy(e.ray).applyMatrix4(RV),!(r.boundingBox!==null&&wh.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,wh)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,g=a.drawRange;if(l!==null)if(Array.isArray(o))for(let b=0,v=p.length;b<v;b++){const x=p[b],y=o[x.materialIndex],E=Math.max(x.start,g.start),w=Math.min(l.count,Math.min(x.start+x.count,g.start+g.count));for(let A=E,N=w;A<N;A+=3){const C=l.getX(A),T=l.getX(A+1),D=l.getX(A+2);i=X_(this,y,e,r,u,d,f,C,T,D),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,g.start),v=Math.min(l.count,g.start+g.count);for(let x=b,y=v;x<y;x+=3){const E=l.getX(x),w=l.getX(x+1),A=l.getX(x+2);i=X_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let b=0,v=p.length;b<v;b++){const x=p[b],y=o[x.materialIndex],E=Math.max(x.start,g.start),w=Math.min(c.count,Math.min(x.start+x.count,g.start+g.count));for(let A=E,N=w;A<N;A+=3){const C=A,T=A+1,D=A+2;i=X_(this,y,e,r,u,d,f,C,T,D),i&&(i.faceIndex=Math.floor(A/3),i.face.materialIndex=x.materialIndex,n.push(i))}}else{const b=Math.max(0,g.start),v=Math.min(c.count,g.start+g.count);for(let x=b,y=v;x<y;x+=3){const E=x,w=x+1,A=x+2;i=X_(this,o,e,r,u,d,f,E,w,A),i&&(i.faceIndex=Math.floor(x/3),n.push(i))}}}}function SLe(t,e,n,r,i,a,o,l){let c;if(e.side===cs?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Bd,l),c===null)return null;K_.copy(l),K_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(K_);return u<n.near||u>n.far?null:{distance:u,point:K_.clone(),object:t}}function X_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,Jm),t.getVertexPosition(c,ep),t.getVertexPosition(u,tp);const d=SLe(t,e,n,r,Jm,ep,tp,q_);if(d){i&&(V_.fromBufferAttribute(i,l),G_.fromBufferAttribute(i,c),W_.fromBufferAttribute(i,u),d.uv=Bo.getInterpolation(q_,Jm,ep,tp,V_,G_,W_,new rn)),a&&(V_.fromBufferAttribute(a,l),G_.fromBufferAttribute(a,c),W_.fromBufferAttribute(a,u),d.uv1=Bo.getInterpolation(q_,Jm,ep,tp,V_,G_,W_,new rn),d.uv2=d.uv1),o&&(OV.fromBufferAttribute(o,l),LV.fromBufferAttribute(o,c),IV.fromBufferAttribute(o,u),d.normal=Bo.getInterpolation(q_,Jm,ep,tp,OV,LV,IV,new ze),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new ze,materialIndex:0};Bo.getNormal(Jm,ep,tp,f.normal),d.face=f}return d}class vy extends ka{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,g=0;b("z","y","x",-1,-1,r,n,e,o,a,0),b("z","y","x",1,-1,r,n,-e,o,a,1),b("x","z","y",1,1,e,r,n,i,o,2),b("x","z","y",1,-1,e,r,-n,i,o,3),b("x","y","z",1,-1,e,n,r,i,a,4),b("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new ai(u,3)),this.setAttribute("normal",new ai(d,3)),this.setAttribute("uv",new ai(f,2));function b(v,x,y,E,w,A,N,C,T,D,k){const P=A/T,z=N/D,L=A/2,X=N/2,R=C/2,Y=T+1,J=D+1;let G=0,W=0;const ee=new ze;for(let K=0;K<J;K++){const F=K*z-X;for(let q=0;q<Y;q++){const ne=q*P-L;ee[v]=ne*E,ee[x]=F*w,ee[y]=R,u.push(ee.x,ee.y,ee.z),ee[v]=0,ee[x]=0,ee[y]=C>0?1:-1,d.push(ee.x,ee.y,ee.z),f.push(q/T),f.push(1-K/D),G+=1}}for(let K=0;K<D;K++)for(let F=0;F<T;F++){const q=p+F+Y*K,ne=p+F+Y*(K+1),re=p+(F+1)+Y*(K+1),se=p+(F+1)+Y*K;c.push(q,ne,se),c.push(ne,re,se),W+=6}l.addGroup(g,W,k),g+=W,p+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function og(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][r]=null):e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function La(t){const e={};for(let n=0;n<t.length;n++){const r=og(t[n]);for(const i in r)e[i]=r[i]}return e}function MLe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function GZ(t){return t.getRenderTarget()===null?t.outputColorSpace:cr.workingColorSpace}const oO={clone:og,merge:La};var ELe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,NLe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class $d extends Ig{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ELe,this.fragmentShader=NLe,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=og(e.uniforms),this.uniformsGroups=MLe(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 i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?n.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?n.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?n.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?n.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?n.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?n.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?n.uniforms[i]={type:"m4",value:o.toArray()}:n.uniforms[i]={value:o}}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 r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(n.extensions=r),n}}class WZ extends $a{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new vr,this.projectionMatrix=new vr,this.projectionMatrixInverse=new vr,this.coordinateSystem=Ml}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 Cs extends WZ{constructor(e=50,n=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,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=_0*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Sb*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return _0*2*Math.atan(Math.tan(Sb*.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,r,i,a,o){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=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(Sb*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,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,rp=1;class ALe extends $a{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Cs(np,rp,e,n);i.layers=this.layers,this.add(i);const a=new Cs(np,rp,e,n);a.layers=this.layers,this.add(a);const o=new Cs(np,rp,e,n);o.layers=this.layers,this.add(o);const l=new Cs(np,rp,e,n);l.layers=this.layers,this.add(l);const c=new Cs(np,rp,e,n);c.layers=this.layers,this.add(c);const u=new Cs(np,rp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===Ml)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===v0)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const u of n)this.add(u),u.updateMatrixWorld()}update(e,n){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),b=e.xr.enabled;e.xr.enabled=!1;const v=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),e.setRenderTarget(r,1,i),e.render(n,o),e.setRenderTarget(r,2,i),e.render(n,l),e.setRenderTarget(r,3,i),e.render(n,c),e.setRenderTarget(r,4,i),e.render(n,u),r.texture.generateMipmaps=v,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,p,g),e.xr.enabled=b,r.texture.needsPMREMUpdate=!0}}class qZ extends us{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:ig,super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class TLe extends kf{constructor(e=1,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];n.encoding!==void 0&&(Eb("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===rf?ua:go),this.texture=new qZ(i,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:mo}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 r={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 );
- }
- `},i=new vy(5,5,5),a=new $d({name:"CubemapFromEquirect",uniforms:og(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:cs,blending:Md});a.uniforms.tEquirect.value=n;const o=new Ko(i,a),l=n.minFilter;return n.minFilter===b0&&(n.minFilter=mo),new ALe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}}const ik=new ze,CLe=new ze,kLe=new wn;class rd{constructor(e=new ze(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,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=ik.subVectors(r,n).cross(CLe.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,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 r=e.delta(ik),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<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 r=n||kLe.getNormalMatrix(e),i=this.coplanarPoint(ik).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.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 Sh=new Al,Y_=new ze;class TM{constructor(e=new rd,n=new rd,r=new rd,i=new rd,a=new rd,o=new rd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,o){const l=this.planes;return l[0].copy(e),l[1].copy(n),l[2].copy(r),l[3].copy(i),l[4].copy(a),l[5].copy(o),this}copy(e){const n=this.planes;for(let r=0;r<6;r++)n[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,n=Ml){const r=this.planes,i=e.elements,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],p=i[7],g=i[8],b=i[9],v=i[10],x=i[11],y=i[12],E=i[13],w=i[14],A=i[15];if(r[0].setComponents(c-a,p-u,x-g,A-y).normalize(),r[1].setComponents(c+a,p+u,x+g,A+y).normalize(),r[2].setComponents(c+o,p+d,x+b,A+E).normalize(),r[3].setComponents(c-o,p-d,x-b,A-E).normalize(),r[4].setComponents(c-l,p-f,x-v,A-w).normalize(),n===Ml)r[5].setComponents(c+l,p+f,x+v,A+w).normalize();else if(n===v0)r[5].setComponents(l,f,v,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(),Sh.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),Sh.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Sh)}intersectsSprite(e){return Sh.center.set(0,0,0),Sh.radius=.7071067811865476,Sh.applyMatrix4(e.matrixWorld),this.intersectsSphere(Sh)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(Y_.x=i.normal.x>0?e.max.x:e.min.x,Y_.y=i.normal.y>0?e.max.y:e.min.y,Y_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Y_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function KZ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,o),r=t.requestAnimationFrame(i)}return{start:function(){e!==!0&&n!==null&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){n=a},setContext:function(a){t=a}}}function jLe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,p=u.usage,g=f.byteLength,b=t.createBuffer();t.bindBuffer(d,b),t.bufferData(d,f,p),u.onUploadCallback();let v;if(f instanceof Float32Array)v=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)v=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)v=t.SHORT;else if(f instanceof Uint32Array)v=t.UNSIGNED_INT;else if(f instanceof Int32Array)v=t.INT;else if(f instanceof Int8Array)v=t.BYTE;else if(f instanceof Uint8Array)v=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)v=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:b,type:v,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:g}}function a(u,d,f){const p=d.array,g=d._updateRange,b=d.updateRanges;if(t.bindBuffer(f,u),g.count===-1&&b.length===0&&t.bufferSubData(f,0,p),b.length!==0){for(let v=0,x=b.length;v<x;v++){const y=b[v];n?t.bufferSubData(f,y.start*p.BYTES_PER_ELEMENT,p,y.start,y.count):t.bufferSubData(f,y.start*p.BYTES_PER_ELEMENT,p.subarray(y.start,y.start+y.count))}d.clearUpdateRanges()}g.count!==-1&&(n?t.bufferSubData(f,g.offset*p.BYTES_PER_ELEMENT,p,g.offset,g.count):t.bufferSubData(f,g.offset*p.BYTES_PER_ELEMENT,p.subarray(g.offset,g.offset+g.count)),g.count=-1),d.onUploadCallback()}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),r.get(u)}function l(u){u.isInterleavedBufferAttribute&&(u=u.data);const d=r.get(u);d&&(t.deleteBuffer(d.buffer),r.delete(u))}function c(u,d){if(u.isGLBufferAttribute){const p=r.get(u);(!p||p.version<u.version)&&r.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);const f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.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,u,d),f.version=u.version}}return{get:o,remove:l,update:c}}class lO extends ka{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,g=[],b=[],v=[],x=[];for(let y=0;y<d;y++){const E=y*p-o;for(let w=0;w<u;w++){const A=w*f-a;b.push(A,-E,0),v.push(0,0,1),x.push(w/l),x.push(1-y/c)}}for(let y=0;y<c;y++)for(let E=0;E<l;E++){const w=E+u*y,A=E+u*(y+1),N=E+1+u*(y+1),C=E+1+u*y;g.push(w,A,C),g.push(A,N,C)}this.setIndex(g),this.setAttribute("position",new ai(b,3)),this.setAttribute("normal",new ai(v,3)),this.setAttribute("uv",new ai(x,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new lO(e.width,e.height,e.widthSegments,e.heightSegments)}}var PLe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,RLe=`#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`,DLe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,OLe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,LLe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,ILe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,FLe=`#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`,ULe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,zLe=`#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`,BLe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,$Le=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,HLe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,VLe=`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`,GLe=`#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`,WLe=`#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`,qLe=`#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`,KLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,XLe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,YLe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,QLe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,ZLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,JLe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,eIe=`#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`,tIe=`#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`,nIe=`#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`,rIe=`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`,iIe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,aIe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,sIe=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,oIe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,lIe="gl_FragColor = linearToOutputTexel( gl_FragColor );",cIe=`
- 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 );
- }`,uIe=`#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`,dIe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,hIe=`#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`,fIe=`#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`,mIe=`#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`,pIe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,gIe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,xIe=`#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`,bIe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,yIe=`#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
- }`,vIe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,_Ie=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,wIe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,SIe=`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`,MIe=`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`,EIe=`#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`,NIe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,AIe=`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`,TIe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,CIe=`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`,kIe=`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`,jIe=`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 );
- }`,PIe=`
- 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`,RIe=`#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`,DIe=`#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`,OIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,LIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,IIe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,FIe=`#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`,UIe=`#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`,zIe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,BIe=`#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`,$Ie=`#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`,HIe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,VIe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,GIe=`#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`,WIe=`#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`,qIe=`#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`,KIe=`#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`,XIe=`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;`,YIe=`#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`,QIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,ZIe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,JIe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,e5e=`#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`,t5e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,n5e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,r5e=`#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`,i5e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,a5e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,s5e=`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 );
- }`,o5e=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,l5e=`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;`,c5e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,u5e=`#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`,d5e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,h5e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,f5e=`#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`,m5e=`#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`,p5e=`#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`,g5e=`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;
- }`,x5e=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,b5e=`#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`,y5e=`#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`,v5e=`#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`,_5e=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,w5e=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,S5e=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,M5e=`#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; }`,E5e=`#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`,N5e=`#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`,A5e=`#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`,T5e=`#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`,C5e=`#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`,k5e=`#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 j5e=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,P5e=`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>
- }`,R5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,D5e=`#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>
- }`,O5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,L5e=`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>
- }`,I5e=`#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;
- }`,F5e=`#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
- }`,U5e=`#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;
- }`,z5e=`#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 );
- }`,B5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,$5e=`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>
- }`,H5e=`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>
- }`,V5e=`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>
- }`,G5e=`#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>
- }`,W5e=`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>
- }`,q5e=`#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>
- }`,K5e=`#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>
- }`,X5e=`#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;
- }`,Y5e=`#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>
- }`,Q5e=`#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
- }`,Z5e=`#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
- }`,J5e=`#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>
- }`,eFe=`#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>
- }`,tFe=`#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
- }`,nFe=`#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>
- }`,rFe=`#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>
- }`,iFe=`#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>
- }`,aFe=`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>
- }`,sFe=`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>
- }`,oFe=`#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>
- }`,lFe=`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>
- }`,cFe=`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>
- }`,uFe=`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>
- }`,gn={alphahash_fragment:PLe,alphahash_pars_fragment:RLe,alphamap_fragment:DLe,alphamap_pars_fragment:OLe,alphatest_fragment:LLe,alphatest_pars_fragment:ILe,aomap_fragment:FLe,aomap_pars_fragment:ULe,batching_pars_vertex:zLe,batching_vertex:BLe,begin_vertex:$Le,beginnormal_vertex:HLe,bsdfs:VLe,iridescence_fragment:GLe,bumpmap_pars_fragment:WLe,clipping_planes_fragment:qLe,clipping_planes_pars_fragment:KLe,clipping_planes_pars_vertex:XLe,clipping_planes_vertex:YLe,color_fragment:QLe,color_pars_fragment:ZLe,color_pars_vertex:JLe,color_vertex:eIe,common:tIe,cube_uv_reflection_fragment:nIe,defaultnormal_vertex:rIe,displacementmap_pars_vertex:iIe,displacementmap_vertex:aIe,emissivemap_fragment:sIe,emissivemap_pars_fragment:oIe,colorspace_fragment:lIe,colorspace_pars_fragment:cIe,envmap_fragment:uIe,envmap_common_pars_fragment:dIe,envmap_pars_fragment:hIe,envmap_pars_vertex:fIe,envmap_physical_pars_fragment:EIe,envmap_vertex:mIe,fog_vertex:pIe,fog_pars_vertex:gIe,fog_fragment:xIe,fog_pars_fragment:bIe,gradientmap_pars_fragment:yIe,lightmap_fragment:vIe,lightmap_pars_fragment:_Ie,lights_lambert_fragment:wIe,lights_lambert_pars_fragment:SIe,lights_pars_begin:MIe,lights_toon_fragment:NIe,lights_toon_pars_fragment:AIe,lights_phong_fragment:TIe,lights_phong_pars_fragment:CIe,lights_physical_fragment:kIe,lights_physical_pars_fragment:jIe,lights_fragment_begin:PIe,lights_fragment_maps:RIe,lights_fragment_end:DIe,logdepthbuf_fragment:OIe,logdepthbuf_pars_fragment:LIe,logdepthbuf_pars_vertex:IIe,logdepthbuf_vertex:FIe,map_fragment:UIe,map_pars_fragment:zIe,map_particle_fragment:BIe,map_particle_pars_fragment:$Ie,metalnessmap_fragment:HIe,metalnessmap_pars_fragment:VIe,morphcolor_vertex:GIe,morphnormal_vertex:WIe,morphtarget_pars_vertex:qIe,morphtarget_vertex:KIe,normal_fragment_begin:XIe,normal_fragment_maps:YIe,normal_pars_fragment:QIe,normal_pars_vertex:ZIe,normal_vertex:JIe,normalmap_pars_fragment:e5e,clearcoat_normal_fragment_begin:t5e,clearcoat_normal_fragment_maps:n5e,clearcoat_pars_fragment:r5e,iridescence_pars_fragment:i5e,opaque_fragment:a5e,packing:s5e,premultiplied_alpha_fragment:o5e,project_vertex:l5e,dithering_fragment:c5e,dithering_pars_fragment:u5e,roughnessmap_fragment:d5e,roughnessmap_pars_fragment:h5e,shadowmap_pars_fragment:f5e,shadowmap_pars_vertex:m5e,shadowmap_vertex:p5e,shadowmask_pars_fragment:g5e,skinbase_vertex:x5e,skinning_pars_vertex:b5e,skinning_vertex:y5e,skinnormal_vertex:v5e,specularmap_fragment:_5e,specularmap_pars_fragment:w5e,tonemapping_fragment:S5e,tonemapping_pars_fragment:M5e,transmission_fragment:E5e,transmission_pars_fragment:N5e,uv_pars_fragment:A5e,uv_pars_vertex:T5e,uv_vertex:C5e,worldpos_vertex:k5e,background_vert:j5e,background_frag:P5e,backgroundCube_vert:R5e,backgroundCube_frag:D5e,cube_vert:O5e,cube_frag:L5e,depth_vert:I5e,depth_frag:F5e,distanceRGBA_vert:U5e,distanceRGBA_frag:z5e,equirect_vert:B5e,equirect_frag:$5e,linedashed_vert:H5e,linedashed_frag:V5e,meshbasic_vert:G5e,meshbasic_frag:W5e,meshlambert_vert:q5e,meshlambert_frag:K5e,meshmatcap_vert:X5e,meshmatcap_frag:Y5e,meshnormal_vert:Q5e,meshnormal_frag:Z5e,meshphong_vert:J5e,meshphong_frag:eFe,meshphysical_vert:tFe,meshphysical_frag:nFe,meshtoon_vert:rFe,meshtoon_frag:iFe,points_vert:aFe,points_frag:sFe,shadow_vert:oFe,shadow_frag:lFe,sprite_vert:cFe,sprite_frag:uFe},Tt={common:{diffuse:{value:new Yt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new wn},alphaMap:{value:null},alphaMapTransform:{value:new wn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new wn}},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 wn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new wn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new wn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new wn},normalScale:{value:new rn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new wn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new wn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new wn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new wn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Yt(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 Yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new wn},alphaTest:{value:0},uvTransform:{value:new wn}},sprite:{diffuse:{value:new Yt(16777215)},opacity:{value:1},center:{value:new rn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new wn},alphaMap:{value:null},alphaMapTransform:{value:new wn},alphaTest:{value:0}}},is={basic:{uniforms:La([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.fog]),vertexShader:gn.meshbasic_vert,fragmentShader:gn.meshbasic_frag},lambert:{uniforms:La([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new Yt(0)}}]),vertexShader:gn.meshlambert_vert,fragmentShader:gn.meshlambert_frag},phong:{uniforms:La([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new Yt(0)},specular:{value:new Yt(1118481)},shininess:{value:30}}]),vertexShader:gn.meshphong_vert,fragmentShader:gn.meshphong_frag},standard:{uniforms:La([Tt.common,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.roughnessmap,Tt.metalnessmap,Tt.fog,Tt.lights,{emissive:{value:new Yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag},toon:{uniforms:La([Tt.common,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.gradientmap,Tt.fog,Tt.lights,{emissive:{value:new Yt(0)}}]),vertexShader:gn.meshtoon_vert,fragmentShader:gn.meshtoon_frag},matcap:{uniforms:La([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,{matcap:{value:null}}]),vertexShader:gn.meshmatcap_vert,fragmentShader:gn.meshmatcap_frag},points:{uniforms:La([Tt.points,Tt.fog]),vertexShader:gn.points_vert,fragmentShader:gn.points_frag},dashed:{uniforms:La([Tt.common,Tt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:gn.linedashed_vert,fragmentShader:gn.linedashed_frag},depth:{uniforms:La([Tt.common,Tt.displacementmap]),vertexShader:gn.depth_vert,fragmentShader:gn.depth_frag},normal:{uniforms:La([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,{opacity:{value:1}}]),vertexShader:gn.meshnormal_vert,fragmentShader:gn.meshnormal_frag},sprite:{uniforms:La([Tt.sprite,Tt.fog]),vertexShader:gn.sprite_vert,fragmentShader:gn.sprite_frag},background:{uniforms:{uvTransform:{value:new wn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:gn.background_vert,fragmentShader:gn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:gn.backgroundCube_vert,fragmentShader:gn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:gn.cube_vert,fragmentShader:gn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:gn.equirect_vert,fragmentShader:gn.equirect_frag},distanceRGBA:{uniforms:La([Tt.common,Tt.displacementmap,{referencePosition:{value:new ze},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:gn.distanceRGBA_vert,fragmentShader:gn.distanceRGBA_frag},shadow:{uniforms:La([Tt.lights,Tt.fog,{color:{value:new Yt(0)},opacity:{value:1}}]),vertexShader:gn.shadow_vert,fragmentShader:gn.shadow_frag}};is.physical={uniforms:La([is.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new wn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new wn},clearcoatNormalScale:{value:new rn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new wn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new wn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new wn},sheen:{value:0},sheenColor:{value:new Yt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new wn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new wn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new wn},transmissionSamplerSize:{value:new rn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new wn},attenuationDistance:{value:0},attenuationColor:{value:new Yt(0)},specularColor:{value:new Yt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new wn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new wn},anisotropyVector:{value:new rn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new wn}}]),vertexShader:gn.meshphysical_vert,fragmentShader:gn.meshphysical_frag};const Q_={r:0,b:0,g:0};function dFe(t,e,n,r,i,a,o){const l=new Yt(0);let c=a===!0?0:1,u,d,f=null,p=0,g=null;function b(x,y){let E=!1,w=y.isScene===!0?y.background:null;w&&w.isTexture&&(w=(y.backgroundBlurriness>0?n:e).get(w)),w===null?v(l,c):w&&w.isColor&&(v(w,1),E=!0);const A=t.xr.getEnvironmentBlendMode();A==="additive"?r.buffers.color.setClear(0,0,0,1,o):A==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,o),(t.autoClear||E)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),w&&(w.isCubeTexture||w.mapping===NM)?(d===void 0&&(d=new Ko(new vy(1,1,1),new $d({name:"BackgroundCubeMaterial",uniforms:og(is.backgroundCube.uniforms),vertexShader:is.backgroundCube.vertexShader,fragmentShader:is.backgroundCube.fragmentShader,side:cs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(N,C,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=w,d.material.uniforms.flipEnvMap.value=w.isCubeTexture&&w.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,d.material.toneMapped=cr.getTransfer(w.colorSpace)!==Sr,(f!==w||p!==w.version||g!==t.toneMapping)&&(d.material.needsUpdate=!0,f=w,p=w.version,g=t.toneMapping),d.layers.enableAll(),x.unshift(d,d.geometry,d.material,0,0,null)):w&&w.isTexture&&(u===void 0&&(u=new Ko(new lO(2,2),new $d({name:"BackgroundMaterial",uniforms:og(is.background.uniforms),vertexShader:is.background.vertexShader,fragmentShader:is.background.fragmentShader,side:Bd,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),Object.defineProperty(u.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(u)),u.material.uniforms.t2D.value=w,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=cr.getTransfer(w.colorSpace)!==Sr,w.matrixAutoUpdate===!0&&w.updateMatrix(),u.material.uniforms.uvTransform.value.copy(w.matrix),(f!==w||p!==w.version||g!==t.toneMapping)&&(u.material.needsUpdate=!0,f=w,p=w.version,g=t.toneMapping),u.layers.enableAll(),x.unshift(u,u.geometry,u.material,0,0,null))}function v(x,y){x.getRGB(Q_,GZ(t)),r.buffers.color.setClear(Q_.r,Q_.g,Q_.b,y,o)}return{getClearColor:function(){return l},setClearColor:function(x,y=1){l.set(x),c=y,v(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(x){c=x,v(l,c)},render:b}}function hFe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||a!==null,l={},c=x(null);let u=c,d=!1;function f(R,Y,J,G,W){let ee=!1;if(o){const K=v(G,J,Y);u!==K&&(u=K,g(u.object)),ee=y(R,G,J,W),ee&&E(R,G,J,W)}else{const K=Y.wireframe===!0;(u.geometry!==G.id||u.program!==J.id||u.wireframe!==K)&&(u.geometry=G.id,u.program=J.id,u.wireframe=K,ee=!0)}W!==null&&n.update(W,t.ELEMENT_ARRAY_BUFFER),(ee||d)&&(d=!1,D(R,Y,J,G),W!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(W).buffer))}function p(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function g(R){return r.isWebGL2?t.bindVertexArray(R):a.bindVertexArrayOES(R)}function b(R){return r.isWebGL2?t.deleteVertexArray(R):a.deleteVertexArrayOES(R)}function v(R,Y,J){const G=J.wireframe===!0;let W=l[R.id];W===void 0&&(W={},l[R.id]=W);let ee=W[Y.id];ee===void 0&&(ee={},W[Y.id]=ee);let K=ee[G];return K===void 0&&(K=x(p()),ee[G]=K),K}function x(R){const Y=[],J=[],G=[];for(let W=0;W<i;W++)Y[W]=0,J[W]=0,G[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:Y,enabledAttributes:J,attributeDivisors:G,object:R,attributes:{},index:null}}function y(R,Y,J,G){const W=u.attributes,ee=Y.attributes;let K=0;const F=J.getAttributes();for(const q in F)if(F[q].location>=0){const re=W[q];let se=ee[q];if(se===void 0&&(q==="instanceMatrix"&&R.instanceMatrix&&(se=R.instanceMatrix),q==="instanceColor"&&R.instanceColor&&(se=R.instanceColor)),re===void 0||re.attribute!==se||se&&re.data!==se.data)return!0;K++}return u.attributesNum!==K||u.index!==G}function E(R,Y,J,G){const W={},ee=Y.attributes;let K=0;const F=J.getAttributes();for(const q in F)if(F[q].location>=0){let re=ee[q];re===void 0&&(q==="instanceMatrix"&&R.instanceMatrix&&(re=R.instanceMatrix),q==="instanceColor"&&R.instanceColor&&(re=R.instanceColor));const se={};se.attribute=re,re&&re.data&&(se.data=re.data),W[q]=se,K++}u.attributes=W,u.attributesNum=K,u.index=G}function w(){const R=u.newAttributes;for(let Y=0,J=R.length;Y<J;Y++)R[Y]=0}function A(R){N(R,0)}function N(R,Y){const J=u.newAttributes,G=u.enabledAttributes,W=u.attributeDivisors;J[R]=1,G[R]===0&&(t.enableVertexAttribArray(R),G[R]=1),W[R]!==Y&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](R,Y),W[R]=Y)}function C(){const R=u.newAttributes,Y=u.enabledAttributes;for(let J=0,G=Y.length;J<G;J++)Y[J]!==R[J]&&(t.disableVertexAttribArray(J),Y[J]=0)}function T(R,Y,J,G,W,ee,K){K===!0?t.vertexAttribIPointer(R,Y,J,W,ee):t.vertexAttribPointer(R,Y,J,G,W,ee)}function D(R,Y,J,G){if(r.isWebGL2===!1&&(R.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();const W=G.attributes,ee=J.getAttributes(),K=Y.defaultAttributeValues;for(const F in ee){const q=ee[F];if(q.location>=0){let ne=W[F];if(ne===void 0&&(F==="instanceMatrix"&&R.instanceMatrix&&(ne=R.instanceMatrix),F==="instanceColor"&&R.instanceColor&&(ne=R.instanceColor)),ne!==void 0){const re=ne.normalized,se=ne.itemSize,de=n.get(ne);if(de===void 0)continue;const pe=de.buffer,Ce=de.type,oe=de.bytesPerElement,ae=r.isWebGL2===!0&&(Ce===t.INT||Ce===t.UNSIGNED_INT||ne.gpuType===EZ);if(ne.isInterleavedBufferAttribute){const ge=ne.data,ue=ge.stride,Le=ne.offset;if(ge.isInstancedInterleavedBuffer){for(let V=0;V<q.locationSize;V++)N(q.location+V,ge.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let V=0;V<q.locationSize;V++)A(q.location+V);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let V=0;V<q.locationSize;V++)T(q.location+V,se/q.locationSize,Ce,re,ue*oe,(Le+se/q.locationSize*V)*oe,ae)}else{if(ne.isInstancedBufferAttribute){for(let ge=0;ge<q.locationSize;ge++)N(q.location+ge,ne.meshPerAttribute);R.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let ge=0;ge<q.locationSize;ge++)A(q.location+ge);t.bindBuffer(t.ARRAY_BUFFER,pe);for(let ge=0;ge<q.locationSize;ge++)T(q.location+ge,se/q.locationSize,Ce,re,se*oe,se/q.locationSize*ge*oe,ae)}}else if(K!==void 0){const re=K[F];if(re!==void 0)switch(re.length){case 2:t.vertexAttrib2fv(q.location,re);break;case 3:t.vertexAttrib3fv(q.location,re);break;case 4:t.vertexAttrib4fv(q.location,re);break;default:t.vertexAttrib1fv(q.location,re)}}}}C()}function k(){L();for(const R in l){const Y=l[R];for(const J in Y){const G=Y[J];for(const W in G)b(G[W].object),delete G[W];delete Y[J]}delete l[R]}}function P(R){if(l[R.id]===void 0)return;const Y=l[R.id];for(const J in Y){const G=Y[J];for(const W in G)b(G[W].object),delete G[W];delete Y[J]}delete l[R.id]}function z(R){for(const Y in l){const J=l[Y];if(J[R.id]===void 0)continue;const G=J[R.id];for(const W in G)b(G[W].object),delete G[W];delete J[R.id]}}function L(){X(),d=!0,u!==c&&(u=c,g(u.object))}function X(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:L,resetDefaultState:X,dispose:k,releaseStatesOfGeometry:P,releaseStatesOfProgram:z,initAttributes:w,enableAttribute:A,disableUnusedAttributes:C}}function fFe(t,e,n,r){const i=r.isWebGL2;let a;function o(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,p){if(p===0)return;let g,b;if(i)g=t,b="drawArraysInstanced";else if(g=e.get("ANGLE_instanced_arrays"),b="drawArraysInstancedANGLE",g===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[b](a,d,f,p),n.update(f,a,p)}function u(d,f,p){if(p===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let b=0;b<p;b++)this.render(d[b],f[b]);else{g.multiDrawArraysWEBGL(a,d,0,f,0,p);let b=0;for(let v=0;v<p;v++)b+=f[v];n.update(b,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function mFe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const T=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(T){if(T==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&t.constructor.name==="WebGL2RenderingContext";let l=n.precision!==void 0?n.precision:"highp";const c=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=t.getParameter(t.MAX_TEXTURE_SIZE),b=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),v=t.getParameter(t.MAX_VERTEX_ATTRIBS),x=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),y=t.getParameter(t.MAX_VARYING_VECTORS),E=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),w=p>0,A=o||e.has("OES_texture_float"),N=w&&A,C=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:g,maxCubemapSize:b,maxAttributes:v,maxVertexUniforms:x,maxVaryings:y,maxFragmentUniforms:E,vertexTextures:w,floatFragmentTextures:A,floatVertexTextures:N,maxSamples:C}}function pFe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new rd,l=new wn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const g=f.length!==0||p||r!==0||i;return i=p,r=f.length,g},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,g){const b=f.clippingPlanes,v=f.clipIntersection,x=f.clipShadows,y=t.get(f);if(!i||b===null||b.length===0||a&&!x)a?d(null):u();else{const E=a?0:r,w=E*4;let A=y.clippingState||null;c.value=A,A=d(b,p,w,g);for(let N=0;N!==w;++N)A[N]=n[N];y.clippingState=A,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=E}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(f,p,g,b){const v=f!==null?f.length:0;let x=null;if(v!==0){if(x=c.value,b!==!0||x===null){const y=g+v*4,E=p.matrixWorldInverse;l.getNormalMatrix(E),(x===null||x.length<y)&&(x=new Float32Array(y));for(let w=0,A=g;w!==v;++w,A+=4)o.copy(f[w]).applyMatrix4(E,l),o.normal.toArray(x,A),x[A+3]=o.constant}c.value=x,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,x}}function gFe(t){let e=new WeakMap;function n(o,l){return l===wP?o.mapping=ig:l===SP&&(o.mapping=ag),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===wP||l===SP)if(e.has(o)){const c=e.get(o).texture;return n(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const u=new TLe(c.height/2);return u.fromEquirectangularTexture(t,o),e.set(o,u),o.addEventListener("dispose",i),n(u.texture,o.mapping)}else return null}}return o}function i(o){const l=o.target;l.removeEventListener("dispose",i);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}class xFe extends WZ{constructor(e=-1,n=1,r=1,i=-1,a=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=r,this.bottom=i,this.near=a,this.far=o,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,r,i,a,o){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=r,this.view.offsetY=i,this.view.width=a,this.view.height=o,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),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let a=r-e,o=r+e,l=i+n,c=i-n;if(this.view!==null&&this.view.enabled){const u=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,o,l,c,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 Sp=4,FV=[.125,.215,.35,.446,.526,.582],Dh=20,ak=new xFe,UV=new Yt;let sk=null,ok=0,lk=0;const kh=(1+Math.sqrt(5))/2,ip=1/kh,zV=[new ze(1,1,1),new ze(-1,1,1),new ze(1,1,-1),new ze(-1,1,-1),new ze(0,kh,ip),new ze(0,kh,-ip),new ze(ip,0,kh),new ze(-ip,0,kh),new ze(kh,ip,0),new ze(-kh,ip,0)];class BV{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,r=.1,i=100){sk=this._renderer.getRenderTarget(),ok=this._renderer.getActiveCubeFace(),lk=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,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=VV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=HV(),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(sk,ok,lk),e.scissorTest=!1,Z_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===ig||e.mapping===ag?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),sk=this._renderer.getRenderTarget(),ok=this._renderer.getActiveCubeFace(),lk=this._renderer.getActiveMipmapLevel();const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:mo,minFilter:mo,generateMipmaps:!1,type:y0,format:po,colorSpace:ou,depthBuffer:!1},i=$V(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=$V(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=bFe(a)),this._blurMaterial=yFe(a,e,n)}return i}_compileMaterial(e){const n=new Ko(this._lodPlanes[0],e);this._renderer.compile(n,ak)}_sceneToCubeUV(e,n,r,i){const l=new Cs(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,p=d.toneMapping;d.getClearColor(UV),d.toneMapping=Ed,d.autoClear=!1;const g=new $Z({name:"PMREM.Background",side:cs,depthWrite:!1,depthTest:!1}),b=new Ko(new vy,g);let v=!1;const x=e.background;x?x.isColor&&(g.color.copy(x),e.background=null,v=!0):(g.color.copy(UV),v=!0);for(let y=0;y<6;y++){const E=y%3;E===0?(l.up.set(0,c[y],0),l.lookAt(u[y],0,0)):E===1?(l.up.set(0,0,c[y]),l.lookAt(0,u[y],0)):(l.up.set(0,c[y],0),l.lookAt(0,0,u[y]));const w=this._cubeSize;Z_(i,E*w,y>2?w:0,w,w),d.setRenderTarget(i),v&&d.render(b,l),d.render(e,l)}b.geometry.dispose(),b.material.dispose(),d.toneMapping=p,d.autoClear=f,e.background=x}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===ig||e.mapping===ag;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=VV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=HV());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new Ko(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Z_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,ak)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=zV[(i-1)%zV.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Ko(this._lodPlanes[i],u),p=u.uniforms,g=this._sizeLods[r]-1,b=isFinite(a)?Math.PI/(2*g):2*Math.PI/(2*Dh-1),v=a/b,x=isFinite(a)?1+Math.floor(d*v):Dh;x>Dh&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${x} samples when the maximum is set to ${Dh}`);const y=[];let E=0;for(let T=0;T<Dh;++T){const D=T/v,k=Math.exp(-D*D/2);y.push(k),T===0?E+=k:T<x&&(E+=2*k)}for(let T=0;T<y.length;T++)y[T]=y[T]/E;p.envMap.value=e.texture,p.samples.value=x,p.weights.value=y,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:w}=this;p.dTheta.value=b,p.mipInt.value=w-r;const A=this._sizeLods[i],N=3*A*(i>w-Sp?i-w+Sp:0),C=4*(this._cubeSize-A);Z_(n,N,C,3*A,2*A),c.setRenderTarget(n),c.render(f,ak)}}function bFe(t){const e=[],n=[],r=[];let i=t;const a=t-Sp+1+FV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-Sp?c=FV[o-t+Sp-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],g=6,b=6,v=3,x=2,y=1,E=new Float32Array(v*b*g),w=new Float32Array(x*b*g),A=new Float32Array(y*b*g);for(let C=0;C<g;C++){const T=C%3*2/3-1,D=C>2?0:-1,k=[T,D,0,T+2/3,D,0,T+2/3,D+1,0,T,D,0,T+2/3,D+1,0,T,D+1,0];E.set(k,v*b*C),w.set(p,x*b*C);const P=[C,C,C,C,C,C];A.set(P,y*b*C)}const N=new ka;N.setAttribute("position",new Us(E,v)),N.setAttribute("uv",new Us(w,x)),N.setAttribute("faceIndex",new Us(A,y)),e.push(N),i>Sp&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function $V(t,e,n){const r=new kf(t,e,n);return r.texture.mapping=NM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Z_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function yFe(t,e,n){const r=new Float32Array(Dh),i=new ze(0,1,0);return new $d({name:"SphericalGaussianBlur",defines:{n:Dh,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:cO(),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:Md,depthTest:!1,depthWrite:!1})}function HV(){return new $d({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:cO(),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:Md,depthTest:!1,depthWrite:!1})}function VV(){return new $d({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cO(),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:Md,depthTest:!1,depthWrite:!1})}function cO(){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 vFe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===wP||c===SP,d=c===ig||c===ag;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new BV(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new BV(t));const p=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,p),l.addEventListener("dispose",a),p.texture}else return null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function _Fe(t){const e={};function n(r){if(e[r]!==void 0)return e[r];let i;switch(r){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=t.getExtension(r)}return e[r]=i,i}return{has:function(r){return n(r)!==null},init:function(r){r.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(r){const i=n(r);return i===null&&console.warn("THREE.WebGLRenderer: "+r+" extension not supported."),i}}}function wFe(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.target;p.index!==null&&e.remove(p.index);for(const b in p.attributes)e.remove(p.attributes[b]);for(const b in p.morphAttributes){const v=p.morphAttributes[b];for(let x=0,y=v.length;x<y;x++)e.remove(v[x])}p.removeEventListener("dispose",o),delete i[p.id];const g=a.get(p);g&&(e.remove(g),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const b in p)e.update(p[b],t.ARRAY_BUFFER);const g=f.morphAttributes;for(const b in g){const v=g[b];for(let x=0,y=v.length;x<y;x++)e.update(v[x],t.ARRAY_BUFFER)}}function u(f){const p=[],g=f.index,b=f.attributes.position;let v=0;if(g!==null){const E=g.array;v=g.version;for(let w=0,A=E.length;w<A;w+=3){const N=E[w+0],C=E[w+1],T=E[w+2];p.push(N,C,C,T,T,N)}}else if(b!==void 0){const E=b.array;v=b.version;for(let w=0,A=E.length/3-1;w<A;w+=3){const N=w+0,C=w+1,T=w+2;p.push(N,C,C,T,T,N)}}else return;const x=new(LZ(p)?VZ:HZ)(p,1);x.version=v;const y=a.get(f);y&&e.remove(y),a.set(f,x)}function d(f){const p=a.get(f);if(p){const g=f.index;g!==null&&p.version<g.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function SFe(t,e,n,r){const i=r.isWebGL2;let a;function o(g){a=g}let l,c;function u(g){l=g.type,c=g.bytesPerElement}function d(g,b){t.drawElements(a,b,l,g*c),n.update(b,a,1)}function f(g,b,v){if(v===0)return;let x,y;if(i)x=t,y="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),y="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[y](a,b,l,g*c,v),n.update(b,a,v)}function p(g,b,v){if(v===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let y=0;y<v;y++)this.render(g[y]/c,b[y]);else{x.multiDrawElementsWEBGL(a,b,0,l,g,0,v);let y=0;for(let E=0;E<v;E++)y+=b[E];n.update(y,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=p}function MFe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:i,update:r}}function EFe(t,e){return t[0]-e[0]}function NFe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function AFe(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new hr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const p=u.morphTargetInfluences;if(e.isWebGL2===!0){const b=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,v=b!==void 0?b.length:0;let x=a.get(d);if(x===void 0||x.count!==v){let Y=function(){X.dispose(),a.delete(d),d.removeEventListener("dispose",Y)};var g=Y;x!==void 0&&x.texture.dispose();const w=d.morphAttributes.position!==void 0,A=d.morphAttributes.normal!==void 0,N=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],T=d.morphAttributes.normal||[],D=d.morphAttributes.color||[];let k=0;w===!0&&(k=1),A===!0&&(k=2),N===!0&&(k=3);let P=d.attributes.position.count*k,z=1;P>e.maxTextureSize&&(z=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);const L=new Float32Array(P*z*4*v),X=new UZ(L,P,z,v);X.type=Ic,X.needsUpdate=!0;const R=k*4;for(let J=0;J<v;J++){const G=C[J],W=T[J],ee=D[J],K=P*z*4*J;for(let F=0;F<G.count;F++){const q=F*R;w===!0&&(o.fromBufferAttribute(G,F),L[K+q+0]=o.x,L[K+q+1]=o.y,L[K+q+2]=o.z,L[K+q+3]=0),A===!0&&(o.fromBufferAttribute(W,F),L[K+q+4]=o.x,L[K+q+5]=o.y,L[K+q+6]=o.z,L[K+q+7]=0),N===!0&&(o.fromBufferAttribute(ee,F),L[K+q+8]=o.x,L[K+q+9]=o.y,L[K+q+10]=o.z,L[K+q+11]=ee.itemSize===4?o.w:1)}}x={count:v,texture:X,size:new rn(P,z)},a.set(d,x),d.addEventListener("dispose",Y)}let y=0;for(let w=0;w<p.length;w++)y+=p[w];const E=d.morphTargetsRelative?1:1-y;f.getUniforms().setValue(t,"morphTargetBaseInfluence",E),f.getUniforms().setValue(t,"morphTargetInfluences",p),f.getUniforms().setValue(t,"morphTargetsTexture",x.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",x.size)}else{const b=p===void 0?0:p.length;let v=r[d.id];if(v===void 0||v.length!==b){v=[];for(let A=0;A<b;A++)v[A]=[A,0];r[d.id]=v}for(let A=0;A<b;A++){const N=v[A];N[0]=A,N[1]=p[A]}v.sort(NFe);for(let A=0;A<8;A++)A<b&&v[A][1]?(l[A][0]=v[A][0],l[A][1]=v[A][1]):(l[A][0]=Number.MAX_SAFE_INTEGER,l[A][1]=0);l.sort(EFe);const x=d.morphAttributes.position,y=d.morphAttributes.normal;let E=0;for(let A=0;A<8;A++){const N=l[A],C=N[0],T=N[1];C!==Number.MAX_SAFE_INTEGER&&T?(x&&d.getAttribute("morphTarget"+A)!==x[C]&&d.setAttribute("morphTarget"+A,x[C]),y&&d.getAttribute("morphNormal"+A)!==y[C]&&d.setAttribute("morphNormal"+A,y[C]),i[A]=T,E+=T):(x&&d.hasAttribute("morphTarget"+A)===!0&&d.deleteAttribute("morphTarget"+A),y&&d.hasAttribute("morphNormal"+A)===!0&&d.deleteAttribute("morphNormal"+A),i[A]=0)}const w=d.morphTargetsRelative?1:1-E;f.getUniforms().setValue(t,"morphTargetBaseInfluence",w),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function TFe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}class XZ extends us{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:nf,d!==nf&&d!==sg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===nf&&(r=md),r===void 0&&d===sg&&(r=tf),super(null,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:ca,this.minFilter=c!==void 0?c:ca,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 YZ=new us,QZ=new XZ(1,1);QZ.compareFunction=DZ;const ZZ=new UZ,JZ=new hLe,eJ=new qZ,GV=[],WV=[],qV=new Float32Array(16),KV=new Float32Array(9),XV=new Float32Array(4);function Fg(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=GV[i];if(a===void 0&&(a=new Float32Array(i),GV[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ci(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function ki(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function CM(t,e){let n=WV[e];n===void 0&&(n=new Int32Array(e),WV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function CFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function kFe(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(Ci(n,e))return;t.uniform2fv(this.addr,e),ki(n,e)}}function jFe(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(Ci(n,e))return;t.uniform3fv(this.addr,e),ki(n,e)}}function PFe(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(Ci(n,e))return;t.uniform4fv(this.addr,e),ki(n,e)}}function RFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;XV.set(r),t.uniformMatrix2fv(this.addr,!1,XV),ki(n,r)}}function DFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;KV.set(r),t.uniformMatrix3fv(this.addr,!1,KV),ki(n,r)}}function OFe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ci(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ki(n,e)}else{if(Ci(n,r))return;qV.set(r),t.uniformMatrix4fv(this.addr,!1,qV),ki(n,r)}}function LFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function IFe(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(Ci(n,e))return;t.uniform2iv(this.addr,e),ki(n,e)}}function FFe(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(Ci(n,e))return;t.uniform3iv(this.addr,e),ki(n,e)}}function UFe(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(Ci(n,e))return;t.uniform4iv(this.addr,e),ki(n,e)}}function zFe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function BFe(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(Ci(n,e))return;t.uniform2uiv(this.addr,e),ki(n,e)}}function $Fe(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(Ci(n,e))return;t.uniform3uiv(this.addr,e),ki(n,e)}}function HFe(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(Ci(n,e))return;t.uniform4uiv(this.addr,e),ki(n,e)}}function VFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?QZ:YZ;n.setTexture2D(e||a,i)}function GFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||JZ,i)}function WFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||eJ,i)}function qFe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||ZZ,i)}function KFe(t){switch(t){case 5126:return CFe;case 35664:return kFe;case 35665:return jFe;case 35666:return PFe;case 35674:return RFe;case 35675:return DFe;case 35676:return OFe;case 5124:case 35670:return LFe;case 35667:case 35671:return IFe;case 35668:case 35672:return FFe;case 35669:case 35673:return UFe;case 5125:return zFe;case 36294:return BFe;case 36295:return $Fe;case 36296:return HFe;case 35678:case 36198:case 36298:case 36306:case 35682:return VFe;case 35679:case 36299:case 36307:return GFe;case 35680:case 36300:case 36308:case 36293:return WFe;case 36289:case 36303:case 36311:case 36292:return qFe}}function XFe(t,e){t.uniform1fv(this.addr,e)}function YFe(t,e){const n=Fg(e,this.size,2);t.uniform2fv(this.addr,n)}function QFe(t,e){const n=Fg(e,this.size,3);t.uniform3fv(this.addr,n)}function ZFe(t,e){const n=Fg(e,this.size,4);t.uniform4fv(this.addr,n)}function JFe(t,e){const n=Fg(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function eUe(t,e){const n=Fg(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function tUe(t,e){const n=Fg(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function nUe(t,e){t.uniform1iv(this.addr,e)}function rUe(t,e){t.uniform2iv(this.addr,e)}function iUe(t,e){t.uniform3iv(this.addr,e)}function aUe(t,e){t.uniform4iv(this.addr,e)}function sUe(t,e){t.uniform1uiv(this.addr,e)}function oUe(t,e){t.uniform2uiv(this.addr,e)}function lUe(t,e){t.uniform3uiv(this.addr,e)}function cUe(t,e){t.uniform4uiv(this.addr,e)}function uUe(t,e,n){const r=this.cache,i=e.length,a=CM(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||YZ,a[o])}function dUe(t,e,n){const r=this.cache,i=e.length,a=CM(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||JZ,a[o])}function hUe(t,e,n){const r=this.cache,i=e.length,a=CM(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||eJ,a[o])}function fUe(t,e,n){const r=this.cache,i=e.length,a=CM(n,i);Ci(r,a)||(t.uniform1iv(this.addr,a),ki(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||ZZ,a[o])}function mUe(t){switch(t){case 5126:return XFe;case 35664:return YFe;case 35665:return QFe;case 35666:return ZFe;case 35674:return JFe;case 35675:return eUe;case 35676:return tUe;case 5124:case 35670:return nUe;case 35667:case 35671:return rUe;case 35668:case 35672:return iUe;case 35669:case 35673:return aUe;case 5125:return sUe;case 36294:return oUe;case 36295:return lUe;case 36296:return cUe;case 35678:case 36198:case 36298:case 36306:case 35682:return uUe;case 35679:case 36299:case 36307:return dUe;case 35680:case 36300:case 36308:case 36293:return hUe;case 36289:case 36303:case 36311:case 36292:return fUe}}class pUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=KFe(n.type)}}class gUe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=mUe(n.type)}}class xUe{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}}const ck=/(\w+)(\])?(\[|\.)?/g;function YV(t,e){t.seq.push(e),t.map[e.id]=e}function bUe(t,e,n){const r=t.name,i=r.length;for(ck.lastIndex=0;;){const a=ck.exec(r),o=ck.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){YV(n,u===void 0?new pUe(l,t,e):new gUe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new xUe(l),YV(n,f)),n=f}}}class H1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);bUe(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function QV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const yUe=37297;let vUe=0;function _Ue(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}function wUe(t){const e=cr.getPrimaries(cr.workingColorSpace),n=cr.getPrimaries(t);let r;switch(e===n?r="":e===fS&&n===hS?r="LinearDisplayP3ToLinearSRGB":e===hS&&n===fS&&(r="LinearSRGBToLinearDisplayP3"),t){case ou:case AM:return[r,"LinearTransferOETF"];case ua:case iO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function ZV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+_Ue(t.getShaderSource(e),o)}else return i}function SUe(t,e){const n=wUe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function MUe(t,e){let n;switch(e){case SOe:n="Linear";break;case MOe:n="Reinhard";break;case EOe:n="OptimizedCineon";break;case NOe:n="ACESFilmic";break;case AOe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function EUe(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(db).join(`
- `)}function NUe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function AUe(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function db(t){return t!==""}function JV(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 e7(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const TUe=/^[ \t]*#include +<([\w\d./]+)>/gm;function CP(t){return t.replace(TUe,kUe)}const CUe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function kUe(t,e){let n=gn[e];if(n===void 0){const r=CUe.get(e);if(r!==void 0)n=gn[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return CP(n)}const jUe=/#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 t7(t){return t.replace(jUe,PUe)}function PUe(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function n7(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 RUe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===SZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Q4e?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===Mc&&(e="SHADOWMAP_TYPE_VSM"),e}function DUe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case ig:case ag:e="ENVMAP_TYPE_CUBE";break;case NM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function OUe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case ag:e="ENVMAP_MODE_REFRACTION";break}return e}function LUe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case nO:e="ENVMAP_BLENDING_MULTIPLY";break;case _Oe:e="ENVMAP_BLENDING_MIX";break;case wOe:e="ENVMAP_BLENDING_ADD";break}return e}function IUe(t){const e=t.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}function FUe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=RUe(n),u=DUe(n),d=OUe(n),f=LUe(n),p=IUe(n),g=n.isWebGL2?"":EUe(n),b=NUe(a),v=i.createProgram();let x,y,E=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(x=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(db).join(`
- `),x.length>0&&(x+=`
- `),y=[g,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b].filter(db).join(`
- `),y.length>0&&(y+=`
- `)):(x=[n7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",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(db).join(`
- `),y=[g,n7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,b,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 "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",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!==Ed?"#define TONE_MAPPING":"",n.toneMapping!==Ed?gn.tonemapping_pars_fragment:"",n.toneMapping!==Ed?MUe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",gn.colorspace_pars_fragment,SUe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(db).join(`
- `)),o=CP(o),o=JV(o,n),o=e7(o,n),l=CP(l),l=JV(l,n),l=e7(l,n),o=t7(o),l=t7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(E=`#version 300 es
- `,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+x,y=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===vV?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===vV?"":"#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(`
- `)+`
- `+y);const w=E+x+o,A=E+y+l,N=QV(i,i.VERTEX_SHADER,w),C=QV(i,i.FRAGMENT_SHADER,A);i.attachShader(v,N),i.attachShader(v,C),n.index0AttributeName!==void 0?i.bindAttribLocation(v,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(v,0,"position"),i.linkProgram(v);function T(z){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(v).trim(),X=i.getShaderInfoLog(N).trim(),R=i.getShaderInfoLog(C).trim();let Y=!0,J=!0;if(i.getProgramParameter(v,i.LINK_STATUS)===!1)if(Y=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,v,N,C);else{const G=ZV(i,N,"vertex"),W=ZV(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(v,i.VALIDATE_STATUS)+`
- Program Info Log: `+L+`
- `+G+`
- `+W)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(X===""||R==="")&&(J=!1);J&&(z.diagnostics={runnable:Y,programLog:L,vertexShader:{log:X,prefix:x},fragmentShader:{log:R,prefix:y}})}i.deleteShader(N),i.deleteShader(C),D=new H1(i,v),k=AUe(i,v)}let D;this.getUniforms=function(){return D===void 0&&T(this),D};let k;this.getAttributes=function(){return k===void 0&&T(this),k};let P=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(v,yUe)),P},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=vUe++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=N,this.fragmentShader=C,this}let UUe=0;class zUe{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.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 r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new BUe(e),n.set(e,r)),r}}class BUe{constructor(e){this.id=UUe++,this.code=e,this.usedTimes=0}}function $Ue(t,e,n,r,i,a,o){const l=new zZ,c=new zUe,u=[],d=i.isWebGL2,f=i.logarithmicDepthBuffer,p=i.vertexTextures;let g=i.precision;const b={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 v(k){return k===0?"uv":`uv${k}`}function x(k,P,z,L,X){const R=L.fog,Y=X.geometry,J=k.isMeshStandardMaterial?L.environment:null,G=(k.isMeshStandardMaterial?n:e).get(k.envMap||J),W=G&&G.mapping===NM?G.image.height:null,ee=b[k.type];k.precision!==null&&(g=i.getMaxPrecision(k.precision),g!==k.precision&&console.warn("THREE.WebGLProgram.getParameters:",k.precision,"not supported, using",g,"instead."));const K=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,F=K!==void 0?K.length:0;let q=0;Y.morphAttributes.position!==void 0&&(q=1),Y.morphAttributes.normal!==void 0&&(q=2),Y.morphAttributes.color!==void 0&&(q=3);let ne,re,se,de;if(ee){const Xt=is[ee];ne=Xt.vertexShader,re=Xt.fragmentShader}else ne=k.vertexShader,re=k.fragmentShader,c.update(k),se=c.getVertexShaderID(k),de=c.getFragmentShaderID(k);const pe=t.getRenderTarget(),Ce=X.isInstancedMesh===!0,oe=X.isBatchedMesh===!0,ae=!!k.map,ge=!!k.matcap,ue=!!G,Le=!!k.aoMap,V=!!k.lightMap,$=!!k.bumpMap,Z=!!k.normalMap,B=!!k.displacementMap,U=!!k.emissiveMap,Q=!!k.metalnessMap,Me=!!k.roughnessMap,Te=k.anisotropy>0,fe=k.clearcoat>0,H=k.iridescence>0,I=k.sheen>0,ce=k.transmission>0,we=Te&&!!k.anisotropyMap,Se=fe&&!!k.clearcoatMap,_e=fe&&!!k.clearcoatNormalMap,st=fe&&!!k.clearcoatRoughnessMap,Ve=H&&!!k.iridescenceMap,it=H&&!!k.iridescenceThicknessMap,ct=I&&!!k.sheenColorMap,Fe=I&&!!k.sheenRoughnessMap,me=!!k.specularMap,Ke=!!k.specularColorMap,qe=!!k.specularIntensityMap,Qe=ce&&!!k.transmissionMap,ut=ce&&!!k.thicknessMap,ie=!!k.gradientMap,He=!!k.alphaMap,ve=k.alphaTest>0,Be=!!k.alphaHash,je=!!k.extensions,Ne=!!Y.attributes.uv1,Xe=!!Y.attributes.uv2,mt=!!Y.attributes.uv3;let At=Ed;return k.toneMapped&&(pe===null||pe.isXRRenderTarget===!0)&&(At=t.toneMapping),{isWebGL2:d,shaderID:ee,shaderType:k.type,shaderName:k.name,vertexShader:ne,fragmentShader:re,defines:k.defines,customVertexShaderID:se,customFragmentShaderID:de,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:g,batching:oe,instancing:Ce,instancingColor:Ce&&X.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:pe===null?t.outputColorSpace:pe.isXRRenderTarget===!0?pe.texture.colorSpace:ou,map:ae,matcap:ge,envMap:ue,envMapMode:ue&&G.mapping,envMapCubeUVHeight:W,aoMap:Le,lightMap:V,bumpMap:$,normalMap:Z,displacementMap:p&&B,emissiveMap:U,normalMapObjectSpace:Z&&k.normalMapType===UOe,normalMapTangentSpace:Z&&k.normalMapType===RZ,metalnessMap:Q,roughnessMap:Me,anisotropy:Te,anisotropyMap:we,clearcoat:fe,clearcoatMap:Se,clearcoatNormalMap:_e,clearcoatRoughnessMap:st,iridescence:H,iridescenceMap:Ve,iridescenceThicknessMap:it,sheen:I,sheenColorMap:ct,sheenRoughnessMap:Fe,specularMap:me,specularColorMap:Ke,specularIntensityMap:qe,transmission:ce,transmissionMap:Qe,thicknessMap:ut,gradientMap:ie,opaque:k.transparent===!1&&k.blending===Rp,alphaMap:He,alphaTest:ve,alphaHash:Be,combine:k.combine,mapUv:ae&&v(k.map.channel),aoMapUv:Le&&v(k.aoMap.channel),lightMapUv:V&&v(k.lightMap.channel),bumpMapUv:$&&v(k.bumpMap.channel),normalMapUv:Z&&v(k.normalMap.channel),displacementMapUv:B&&v(k.displacementMap.channel),emissiveMapUv:U&&v(k.emissiveMap.channel),metalnessMapUv:Q&&v(k.metalnessMap.channel),roughnessMapUv:Me&&v(k.roughnessMap.channel),anisotropyMapUv:we&&v(k.anisotropyMap.channel),clearcoatMapUv:Se&&v(k.clearcoatMap.channel),clearcoatNormalMapUv:_e&&v(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:st&&v(k.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&v(k.iridescenceMap.channel),iridescenceThicknessMapUv:it&&v(k.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&v(k.sheenColorMap.channel),sheenRoughnessMapUv:Fe&&v(k.sheenRoughnessMap.channel),specularMapUv:me&&v(k.specularMap.channel),specularColorMapUv:Ke&&v(k.specularColorMap.channel),specularIntensityMapUv:qe&&v(k.specularIntensityMap.channel),transmissionMapUv:Qe&&v(k.transmissionMap.channel),thicknessMapUv:ut&&v(k.thicknessMap.channel),alphaMapUv:He&&v(k.alphaMap.channel),vertexTangents:!!Y.attributes.tangent&&(Z||Te),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,vertexUv1s:Ne,vertexUv2s:Xe,vertexUv3s:mt,pointsUvs:X.isPoints===!0&&!!Y.attributes.uv&&(ae||He),fog:!!R,useFog:k.fog===!0,fogExp2:R&&R.isFogExp2,flatShading:k.flatShading===!0,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:X.isSkinnedMesh===!0,morphTargets:Y.morphAttributes.position!==void 0,morphNormals:Y.morphAttributes.normal!==void 0,morphColors:Y.morphAttributes.color!==void 0,morphTargetsCount:F,morphTextureStride:q,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:k.dithering,shadowMapEnabled:t.shadowMap.enabled&&z.length>0,shadowMapType:t.shadowMap.type,toneMapping:At,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ae&&k.map.isVideoTexture===!0&&cr.getTransfer(k.map.colorSpace)===Sr,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===jc,flipSided:k.side===cs,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionDerivatives:je&&k.extensions.derivatives===!0,extensionFragDepth:je&&k.extensions.fragDepth===!0,extensionDrawBuffers:je&&k.extensions.drawBuffers===!0,extensionShaderTextureLOD:je&&k.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()}}function y(k){const P=[];if(k.shaderID?P.push(k.shaderID):(P.push(k.customVertexShaderID),P.push(k.customFragmentShaderID)),k.defines!==void 0)for(const z in k.defines)P.push(z),P.push(k.defines[z]);return k.isRawShaderMaterial===!1&&(E(P,k),w(P,k),P.push(t.outputColorSpace)),P.push(k.customProgramCacheKey),P.join()}function E(k,P){k.push(P.precision),k.push(P.outputColorSpace),k.push(P.envMapMode),k.push(P.envMapCubeUVHeight),k.push(P.mapUv),k.push(P.alphaMapUv),k.push(P.lightMapUv),k.push(P.aoMapUv),k.push(P.bumpMapUv),k.push(P.normalMapUv),k.push(P.displacementMapUv),k.push(P.emissiveMapUv),k.push(P.metalnessMapUv),k.push(P.roughnessMapUv),k.push(P.anisotropyMapUv),k.push(P.clearcoatMapUv),k.push(P.clearcoatNormalMapUv),k.push(P.clearcoatRoughnessMapUv),k.push(P.iridescenceMapUv),k.push(P.iridescenceThicknessMapUv),k.push(P.sheenColorMapUv),k.push(P.sheenRoughnessMapUv),k.push(P.specularMapUv),k.push(P.specularColorMapUv),k.push(P.specularIntensityMapUv),k.push(P.transmissionMapUv),k.push(P.thicknessMapUv),k.push(P.combine),k.push(P.fogExp2),k.push(P.sizeAttenuation),k.push(P.morphTargetsCount),k.push(P.morphAttributeCount),k.push(P.numDirLights),k.push(P.numPointLights),k.push(P.numSpotLights),k.push(P.numSpotLightMaps),k.push(P.numHemiLights),k.push(P.numRectAreaLights),k.push(P.numDirLightShadows),k.push(P.numPointLightShadows),k.push(P.numSpotLightShadows),k.push(P.numSpotLightShadowsWithMaps),k.push(P.numLightProbes),k.push(P.shadowMapType),k.push(P.toneMapping),k.push(P.numClippingPlanes),k.push(P.numClipIntersection),k.push(P.depthPacking)}function w(k,P){l.disableAll(),P.isWebGL2&&l.enable(0),P.supportsVertexTextures&&l.enable(1),P.instancing&&l.enable(2),P.instancingColor&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),k.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.skinning&&l.enable(4),P.morphTargets&&l.enable(5),P.morphNormals&&l.enable(6),P.morphColors&&l.enable(7),P.premultipliedAlpha&&l.enable(8),P.shadowMapEnabled&&l.enable(9),P.useLegacyLights&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),k.push(l.mask)}function A(k){const P=b[k.type];let z;if(P){const L=is[P];z=oO.clone(L.uniforms)}else z=k.uniforms;return z}function N(k,P){let z;for(let L=0,X=u.length;L<X;L++){const R=u[L];if(R.cacheKey===P){z=R,++z.usedTimes;break}}return z===void 0&&(z=new FUe(t,P,k,a),u.push(z)),z}function C(k){if(--k.usedTimes===0){const P=u.indexOf(k);u[P]=u[u.length-1],u.pop(),k.destroy()}}function T(k){c.remove(k)}function D(){c.dispose()}return{getParameters:x,getProgramCacheKey:y,getUniforms:A,acquireProgram:N,releaseProgram:C,releaseShaderCache:T,programs:u,dispose:D}}function HUe(){let t=new WeakMap;function e(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function n(a){t.delete(a)}function r(a,o,l){t.get(a)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function VUe(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 r7(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 i7(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,g,b,v,x){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:p,material:g,groupOrder:b,renderOrder:f.renderOrder,z:v,group:x},t[e]=y):(y.id=f.id,y.object=f,y.geometry=p,y.material=g,y.groupOrder=b,y.renderOrder=f.renderOrder,y.z=v,y.group=x),e++,y}function l(f,p,g,b,v,x){const y=o(f,p,g,b,v,x);g.transmission>0?r.push(y):g.transparent===!0?i.push(y):n.push(y)}function c(f,p,g,b,v,x){const y=o(f,p,g,b,v,x);g.transmission>0?r.unshift(y):g.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,p){n.length>1&&n.sort(f||VUe),r.length>1&&r.sort(p||r7),i.length>1&&i.sort(p||r7)}function d(){for(let f=e,p=t.length;f<p;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:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function GUe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new i7,t.set(r,[o])):i>=a.length?(o=new i7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function WUe(){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 ze,color:new Yt};break;case"SpotLight":n={position:new ze,direction:new ze,color:new Yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ze,color:new Yt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ze,skyColor:new Yt,groundColor:new Yt};break;case"RectAreaLight":n={color:new Yt,position:new ze,halfWidth:new ze,halfHeight:new ze};break}return t[e.id]=n,n}}}function qUe(){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 rn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let KUe=0;function XUe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function YUe(t,e){const n=new WUe,r=qUe(),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 d=0;d<9;d++)i.probe.push(new ze);const a=new ze,o=new vr,l=new vr;function c(d,f){let p=0,g=0,b=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let v=0,x=0,y=0,E=0,w=0,A=0,N=0,C=0,T=0,D=0,k=0;d.sort(XUe);const P=f===!0?Math.PI:1;for(let L=0,X=d.length;L<X;L++){const R=d[L],Y=R.color,J=R.intensity,G=R.distance,W=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)p+=Y.r*J*P,g+=Y.g*J*P,b+=Y.b*J*P;else if(R.isLightProbe){for(let ee=0;ee<9;ee++)i.probe[ee].addScaledVector(R.sh.coefficients[ee],J);k++}else if(R.isDirectionalLight){const ee=n.get(R);if(ee.color.copy(R.color).multiplyScalar(R.intensity*P),R.castShadow){const K=R.shadow,F=r.get(R);F.shadowBias=K.bias,F.shadowNormalBias=K.normalBias,F.shadowRadius=K.radius,F.shadowMapSize=K.mapSize,i.directionalShadow[v]=F,i.directionalShadowMap[v]=W,i.directionalShadowMatrix[v]=R.shadow.matrix,A++}i.directional[v]=ee,v++}else if(R.isSpotLight){const ee=n.get(R);ee.position.setFromMatrixPosition(R.matrixWorld),ee.color.copy(Y).multiplyScalar(J*P),ee.distance=G,ee.coneCos=Math.cos(R.angle),ee.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),ee.decay=R.decay,i.spot[y]=ee;const K=R.shadow;if(R.map&&(i.spotLightMap[T]=R.map,T++,K.updateMatrices(R),R.castShadow&&D++),i.spotLightMatrix[y]=K.matrix,R.castShadow){const F=r.get(R);F.shadowBias=K.bias,F.shadowNormalBias=K.normalBias,F.shadowRadius=K.radius,F.shadowMapSize=K.mapSize,i.spotShadow[y]=F,i.spotShadowMap[y]=W,C++}y++}else if(R.isRectAreaLight){const ee=n.get(R);ee.color.copy(Y).multiplyScalar(J),ee.halfWidth.set(R.width*.5,0,0),ee.halfHeight.set(0,R.height*.5,0),i.rectArea[E]=ee,E++}else if(R.isPointLight){const ee=n.get(R);if(ee.color.copy(R.color).multiplyScalar(R.intensity*P),ee.distance=R.distance,ee.decay=R.decay,R.castShadow){const K=R.shadow,F=r.get(R);F.shadowBias=K.bias,F.shadowNormalBias=K.normalBias,F.shadowRadius=K.radius,F.shadowMapSize=K.mapSize,F.shadowCameraNear=K.camera.near,F.shadowCameraFar=K.camera.far,i.pointShadow[x]=F,i.pointShadowMap[x]=W,i.pointShadowMatrix[x]=R.shadow.matrix,N++}i.point[x]=ee,x++}else if(R.isHemisphereLight){const ee=n.get(R);ee.skyColor.copy(R.color).multiplyScalar(J*P),ee.groundColor.copy(R.groundColor).multiplyScalar(J*P),i.hemi[w]=ee,w++}}E>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Tt.LTC_FLOAT_1,i.rectAreaLTC2=Tt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Tt.LTC_HALF_1,i.rectAreaLTC2=Tt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=p,i.ambient[1]=g,i.ambient[2]=b;const z=i.hash;(z.directionalLength!==v||z.pointLength!==x||z.spotLength!==y||z.rectAreaLength!==E||z.hemiLength!==w||z.numDirectionalShadows!==A||z.numPointShadows!==N||z.numSpotShadows!==C||z.numSpotMaps!==T||z.numLightProbes!==k)&&(i.directional.length=v,i.spot.length=y,i.rectArea.length=E,i.point.length=x,i.hemi.length=w,i.directionalShadow.length=A,i.directionalShadowMap.length=A,i.pointShadow.length=N,i.pointShadowMap.length=N,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=A,i.pointShadowMatrix.length=N,i.spotLightMatrix.length=C+T-D,i.spotLightMap.length=T,i.numSpotLightShadowsWithMaps=D,i.numLightProbes=k,z.directionalLength=v,z.pointLength=x,z.spotLength=y,z.rectAreaLength=E,z.hemiLength=w,z.numDirectionalShadows=A,z.numPointShadows=N,z.numSpotShadows=C,z.numSpotMaps=T,z.numLightProbes=k,i.version=KUe++)}function u(d,f){let p=0,g=0,b=0,v=0,x=0;const y=f.matrixWorldInverse;for(let E=0,w=d.length;E<w;E++){const A=d[E];if(A.isDirectionalLight){const N=i.directional[p];N.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),N.direction.sub(a),N.direction.transformDirection(y),p++}else if(A.isSpotLight){const N=i.spot[b];N.position.setFromMatrixPosition(A.matrixWorld),N.position.applyMatrix4(y),N.direction.setFromMatrixPosition(A.matrixWorld),a.setFromMatrixPosition(A.target.matrixWorld),N.direction.sub(a),N.direction.transformDirection(y),b++}else if(A.isRectAreaLight){const N=i.rectArea[v];N.position.setFromMatrixPosition(A.matrixWorld),N.position.applyMatrix4(y),l.identity(),o.copy(A.matrixWorld),o.premultiply(y),l.extractRotation(o),N.halfWidth.set(A.width*.5,0,0),N.halfHeight.set(0,A.height*.5,0),N.halfWidth.applyMatrix4(l),N.halfHeight.applyMatrix4(l),v++}else if(A.isPointLight){const N=i.point[g];N.position.setFromMatrixPosition(A.matrixWorld),N.position.applyMatrix4(y),g++}else if(A.isHemisphereLight){const N=i.hemi[x];N.direction.setFromMatrixPosition(A.matrixWorld),N.direction.transformDirection(y),x++}}}return{setup:c,setupView:u,state:i}}function a7(t,e){const n=new YUe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function o(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function QUe(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new a7(t,e),n.set(a,[c])):o>=l.length?(c=new a7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class ZUe extends Ig{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=IOe,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 JUe extends Ig{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 eze=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,tze=`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 nze(t,e,n){let r=new TM;const i=new rn,a=new rn,o=new hr,l=new ZUe({depthPacking:FOe}),c=new JUe,u={},d=n.maxTextureSize,f={[Bd]:cs,[cs]:Bd,[jc]:jc},p=new $d({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new rn},radius:{value:4}},vertexShader:eze,fragmentShader:tze}),g=p.clone();g.defines.HORIZONTAL_PASS=1;const b=new ka;b.setAttribute("position",new Us(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Ko(b,p),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=SZ;let y=this.type;this.render=function(N,C,T){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||N.length===0)return;const D=t.getRenderTarget(),k=t.getActiveCubeFace(),P=t.getActiveMipmapLevel(),z=t.state;z.setBlending(Md),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const L=y!==Mc&&this.type===Mc,X=y===Mc&&this.type!==Mc;for(let R=0,Y=N.length;R<Y;R++){const J=N[R],G=J.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",J,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const W=G.getFrameExtents();if(i.multiply(W),a.copy(G.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/W.x),i.x=a.x*W.x,G.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/W.y),i.y=a.y*W.y,G.mapSize.y=a.y)),G.map===null||L===!0||X===!0){const K=this.type!==Mc?{minFilter:ca,magFilter:ca}:{};G.map!==null&&G.map.dispose(),G.map=new kf(i.x,i.y,K),G.map.texture.name=J.name+".shadowMap",G.camera.updateProjectionMatrix()}t.setRenderTarget(G.map),t.clear();const ee=G.getViewportCount();for(let K=0;K<ee;K++){const F=G.getViewport(K);o.set(a.x*F.x,a.y*F.y,a.x*F.z,a.y*F.w),z.viewport(o),G.updateMatrices(J,K),r=G.getFrustum(),A(C,T,G.camera,J,this.type)}G.isPointLightShadow!==!0&&this.type===Mc&&E(G,T),G.needsUpdate=!1}y=this.type,x.needsUpdate=!1,t.setRenderTarget(D,k,P)};function E(N,C){const T=e.update(v);p.defines.VSM_SAMPLES!==N.blurSamples&&(p.defines.VSM_SAMPLES=N.blurSamples,g.defines.VSM_SAMPLES=N.blurSamples,p.needsUpdate=!0,g.needsUpdate=!0),N.mapPass===null&&(N.mapPass=new kf(i.x,i.y)),p.uniforms.shadow_pass.value=N.map.texture,p.uniforms.resolution.value=N.mapSize,p.uniforms.radius.value=N.radius,t.setRenderTarget(N.mapPass),t.clear(),t.renderBufferDirect(C,null,T,p,v,null),g.uniforms.shadow_pass.value=N.mapPass.texture,g.uniforms.resolution.value=N.mapSize,g.uniforms.radius.value=N.radius,t.setRenderTarget(N.map),t.clear(),t.renderBufferDirect(C,null,T,g,v,null)}function w(N,C,T,D){let k=null;const P=T.isPointLight===!0?N.customDistanceMaterial:N.customDepthMaterial;if(P!==void 0)k=P;else if(k=T.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const z=k.uuid,L=C.uuid;let X=u[z];X===void 0&&(X={},u[z]=X);let R=X[L];R===void 0&&(R=k.clone(),X[L]=R),k=R}if(k.visible=C.visible,k.wireframe=C.wireframe,D===Mc?k.side=C.shadowSide!==null?C.shadowSide:C.side:k.side=C.shadowSide!==null?C.shadowSide:f[C.side],k.alphaMap=C.alphaMap,k.alphaTest=C.alphaTest,k.map=C.map,k.clipShadows=C.clipShadows,k.clippingPlanes=C.clippingPlanes,k.clipIntersection=C.clipIntersection,k.displacementMap=C.displacementMap,k.displacementScale=C.displacementScale,k.displacementBias=C.displacementBias,k.wireframeLinewidth=C.wireframeLinewidth,k.linewidth=C.linewidth,T.isPointLight===!0&&k.isMeshDistanceMaterial===!0){const z=t.properties.get(k);z.light=T}return k}function A(N,C,T,D,k){if(N.visible===!1)return;if(N.layers.test(C.layers)&&(N.isMesh||N.isLine||N.isPoints)&&(N.castShadow||N.receiveShadow&&k===Mc)&&(!N.frustumCulled||r.intersectsObject(N))){N.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,N.matrixWorld);const L=e.update(N),X=N.material;if(Array.isArray(X)){const R=L.groups;for(let Y=0,J=R.length;Y<J;Y++){const G=R[Y],W=X[G.materialIndex];if(W&&W.visible){const ee=w(N,W,D,k);N.onBeforeShadow(t,N,C,T,L,ee,G),t.renderBufferDirect(T,null,L,ee,N,G),N.onAfterShadow(t,N,C,T,L,ee,G)}}}else if(X.visible){const R=w(N,X,D,k);N.onBeforeShadow(t,N,C,T,L,R,null),t.renderBufferDirect(T,null,L,R,N,null),N.onAfterShadow(t,N,C,T,L,R,null)}}const z=N.children;for(let L=0,X=z.length;L<X;L++)A(z[L],C,T,D,k)}}function rze(t,e,n){const r=n.isWebGL2;function i(){let ve=!1;const Be=new hr;let je=null;const Ne=new hr(0,0,0,0);return{setMask:function(Xe){je!==Xe&&!ve&&(t.colorMask(Xe,Xe,Xe,Xe),je=Xe)},setLocked:function(Xe){ve=Xe},setClear:function(Xe,mt,At,Rt,Xt){Xt===!0&&(Xe*=Rt,mt*=Rt,At*=Rt),Be.set(Xe,mt,At,Rt),Ne.equals(Be)===!1&&(t.clearColor(Xe,mt,At,Rt),Ne.copy(Be))},reset:function(){ve=!1,je=null,Ne.set(-1,0,0,0)}}}function a(){let ve=!1,Be=null,je=null,Ne=null;return{setTest:function(Xe){Xe?oe(t.DEPTH_TEST):ae(t.DEPTH_TEST)},setMask:function(Xe){Be!==Xe&&!ve&&(t.depthMask(Xe),Be=Xe)},setFunc:function(Xe){if(je!==Xe){switch(Xe){case mOe:t.depthFunc(t.NEVER);break;case pOe:t.depthFunc(t.ALWAYS);break;case gOe:t.depthFunc(t.LESS);break;case uS:t.depthFunc(t.LEQUAL);break;case xOe:t.depthFunc(t.EQUAL);break;case bOe:t.depthFunc(t.GEQUAL);break;case yOe:t.depthFunc(t.GREATER);break;case vOe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}je=Xe}},setLocked:function(Xe){ve=Xe},setClear:function(Xe){Ne!==Xe&&(t.clearDepth(Xe),Ne=Xe)},reset:function(){ve=!1,Be=null,je=null,Ne=null}}}function o(){let ve=!1,Be=null,je=null,Ne=null,Xe=null,mt=null,At=null,Rt=null,Xt=null;return{setTest:function(Lt){ve||(Lt?oe(t.STENCIL_TEST):ae(t.STENCIL_TEST))},setMask:function(Lt){Be!==Lt&&!ve&&(t.stencilMask(Lt),Be=Lt)},setFunc:function(Lt,Sn,$t){(je!==Lt||Ne!==Sn||Xe!==$t)&&(t.stencilFunc(Lt,Sn,$t),je=Lt,Ne=Sn,Xe=$t)},setOp:function(Lt,Sn,$t){(mt!==Lt||At!==Sn||Rt!==$t)&&(t.stencilOp(Lt,Sn,$t),mt=Lt,At=Sn,Rt=$t)},setLocked:function(Lt){ve=Lt},setClear:function(Lt){Xt!==Lt&&(t.clearStencil(Lt),Xt=Lt)},reset:function(){ve=!1,Be=null,je=null,Ne=null,Xe=null,mt=null,At=null,Rt=null,Xt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let p={},g={},b=new WeakMap,v=[],x=null,y=!1,E=null,w=null,A=null,N=null,C=null,T=null,D=null,k=new Yt(0,0,0),P=0,z=!1,L=null,X=null,R=null,Y=null,J=null;const G=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,ee=0;const K=t.getParameter(t.VERSION);K.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(K)[1]),W=ee>=1):K.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),W=ee>=2);let F=null,q={};const ne=t.getParameter(t.SCISSOR_BOX),re=t.getParameter(t.VIEWPORT),se=new hr().fromArray(ne),de=new hr().fromArray(re);function pe(ve,Be,je,Ne){const Xe=new Uint8Array(4),mt=t.createTexture();t.bindTexture(ve,mt),t.texParameteri(ve,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(ve,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let At=0;At<je;At++)r&&(ve===t.TEXTURE_3D||ve===t.TEXTURE_2D_ARRAY)?t.texImage3D(Be,0,t.RGBA,1,1,Ne,0,t.RGBA,t.UNSIGNED_BYTE,Xe):t.texImage2D(Be+At,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Xe);return mt}const Ce={};Ce[t.TEXTURE_2D]=pe(t.TEXTURE_2D,t.TEXTURE_2D,1),Ce[t.TEXTURE_CUBE_MAP]=pe(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ce[t.TEXTURE_2D_ARRAY]=pe(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ce[t.TEXTURE_3D]=pe(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),oe(t.DEPTH_TEST),c.setFunc(uS),U(!1),Q(BH),oe(t.CULL_FACE),Z(Md);function oe(ve){p[ve]!==!0&&(t.enable(ve),p[ve]=!0)}function ae(ve){p[ve]!==!1&&(t.disable(ve),p[ve]=!1)}function ge(ve,Be){return g[ve]!==Be?(t.bindFramebuffer(ve,Be),g[ve]=Be,r&&(ve===t.DRAW_FRAMEBUFFER&&(g[t.FRAMEBUFFER]=Be),ve===t.FRAMEBUFFER&&(g[t.DRAW_FRAMEBUFFER]=Be)),!0):!1}function ue(ve,Be){let je=v,Ne=!1;if(ve)if(je=b.get(Be),je===void 0&&(je=[],b.set(Be,je)),ve.isWebGLMultipleRenderTargets){const Xe=ve.texture;if(je.length!==Xe.length||je[0]!==t.COLOR_ATTACHMENT0){for(let mt=0,At=Xe.length;mt<At;mt++)je[mt]=t.COLOR_ATTACHMENT0+mt;je.length=Xe.length,Ne=!0}}else je[0]!==t.COLOR_ATTACHMENT0&&(je[0]=t.COLOR_ATTACHMENT0,Ne=!0);else je[0]!==t.BACK&&(je[0]=t.BACK,Ne=!0);Ne&&(n.isWebGL2?t.drawBuffers(je):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(je))}function Le(ve){return x!==ve?(t.useProgram(ve),x=ve,!0):!1}const V={[Rh]:t.FUNC_ADD,[J4e]:t.FUNC_SUBTRACT,[eOe]:t.FUNC_REVERSE_SUBTRACT};if(r)V[GH]=t.MIN,V[WH]=t.MAX;else{const ve=e.get("EXT_blend_minmax");ve!==null&&(V[GH]=ve.MIN_EXT,V[WH]=ve.MAX_EXT)}const $={[tOe]:t.ZERO,[nOe]:t.ONE,[rOe]:t.SRC_COLOR,[vP]:t.SRC_ALPHA,[cOe]:t.SRC_ALPHA_SATURATE,[oOe]:t.DST_COLOR,[aOe]:t.DST_ALPHA,[iOe]:t.ONE_MINUS_SRC_COLOR,[_P]:t.ONE_MINUS_SRC_ALPHA,[lOe]:t.ONE_MINUS_DST_COLOR,[sOe]:t.ONE_MINUS_DST_ALPHA,[uOe]:t.CONSTANT_COLOR,[dOe]:t.ONE_MINUS_CONSTANT_COLOR,[hOe]:t.CONSTANT_ALPHA,[fOe]:t.ONE_MINUS_CONSTANT_ALPHA};function Z(ve,Be,je,Ne,Xe,mt,At,Rt,Xt,Lt){if(ve===Md){y===!0&&(ae(t.BLEND),y=!1);return}if(y===!1&&(oe(t.BLEND),y=!0),ve!==Z4e){if(ve!==E||Lt!==z){if((w!==Rh||C!==Rh)&&(t.blendEquation(t.FUNC_ADD),w=Rh,C=Rh),Lt)switch(ve){case Rp:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case $H:t.blendFunc(t.ONE,t.ONE);break;case HH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case VH:t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}else switch(ve){case Rp:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case $H:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case HH:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case VH:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ve);break}A=null,N=null,T=null,D=null,k.set(0,0,0),P=0,E=ve,z=Lt}return}Xe=Xe||Be,mt=mt||je,At=At||Ne,(Be!==w||Xe!==C)&&(t.blendEquationSeparate(V[Be],V[Xe]),w=Be,C=Xe),(je!==A||Ne!==N||mt!==T||At!==D)&&(t.blendFuncSeparate($[je],$[Ne],$[mt],$[At]),A=je,N=Ne,T=mt,D=At),(Rt.equals(k)===!1||Xt!==P)&&(t.blendColor(Rt.r,Rt.g,Rt.b,Xt),k.copy(Rt),P=Xt),E=ve,z=!1}function B(ve,Be){ve.side===jc?ae(t.CULL_FACE):oe(t.CULL_FACE);let je=ve.side===cs;Be&&(je=!je),U(je),ve.blending===Rp&&ve.transparent===!1?Z(Md):Z(ve.blending,ve.blendEquation,ve.blendSrc,ve.blendDst,ve.blendEquationAlpha,ve.blendSrcAlpha,ve.blendDstAlpha,ve.blendColor,ve.blendAlpha,ve.premultipliedAlpha),c.setFunc(ve.depthFunc),c.setTest(ve.depthTest),c.setMask(ve.depthWrite),l.setMask(ve.colorWrite);const Ne=ve.stencilWrite;u.setTest(Ne),Ne&&(u.setMask(ve.stencilWriteMask),u.setFunc(ve.stencilFunc,ve.stencilRef,ve.stencilFuncMask),u.setOp(ve.stencilFail,ve.stencilZFail,ve.stencilZPass)),Te(ve.polygonOffset,ve.polygonOffsetFactor,ve.polygonOffsetUnits),ve.alphaToCoverage===!0?oe(t.SAMPLE_ALPHA_TO_COVERAGE):ae(t.SAMPLE_ALPHA_TO_COVERAGE)}function U(ve){L!==ve&&(ve?t.frontFace(t.CW):t.frontFace(t.CCW),L=ve)}function Q(ve){ve!==X4e?(oe(t.CULL_FACE),ve!==X&&(ve===BH?t.cullFace(t.BACK):ve===Y4e?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ae(t.CULL_FACE),X=ve}function Me(ve){ve!==R&&(W&&t.lineWidth(ve),R=ve)}function Te(ve,Be,je){ve?(oe(t.POLYGON_OFFSET_FILL),(Y!==Be||J!==je)&&(t.polygonOffset(Be,je),Y=Be,J=je)):ae(t.POLYGON_OFFSET_FILL)}function fe(ve){ve?oe(t.SCISSOR_TEST):ae(t.SCISSOR_TEST)}function H(ve){ve===void 0&&(ve=t.TEXTURE0+G-1),F!==ve&&(t.activeTexture(ve),F=ve)}function I(ve,Be,je){je===void 0&&(F===null?je=t.TEXTURE0+G-1:je=F);let Ne=q[je];Ne===void 0&&(Ne={type:void 0,texture:void 0},q[je]=Ne),(Ne.type!==ve||Ne.texture!==Be)&&(F!==je&&(t.activeTexture(je),F=je),t.bindTexture(ve,Be||Ce[ve]),Ne.type=ve,Ne.texture=Be)}function ce(){const ve=q[F];ve!==void 0&&ve.type!==void 0&&(t.bindTexture(ve.type,null),ve.type=void 0,ve.texture=void 0)}function we(){try{t.compressedTexImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Se(){try{t.compressedTexImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function _e(){try{t.texSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function st(){try{t.texSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ve(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function it(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function ct(){try{t.texStorage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Fe(){try{t.texStorage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function me(){try{t.texImage2D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function Ke(){try{t.texImage3D.apply(t,arguments)}catch(ve){console.error("THREE.WebGLState:",ve)}}function qe(ve){se.equals(ve)===!1&&(t.scissor(ve.x,ve.y,ve.z,ve.w),se.copy(ve))}function Qe(ve){de.equals(ve)===!1&&(t.viewport(ve.x,ve.y,ve.z,ve.w),de.copy(ve))}function ut(ve,Be){let je=f.get(Be);je===void 0&&(je=new WeakMap,f.set(Be,je));let Ne=je.get(ve);Ne===void 0&&(Ne=t.getUniformBlockIndex(Be,ve.name),je.set(ve,Ne))}function ie(ve,Be){const Ne=f.get(Be).get(ve);d.get(Be)!==Ne&&(t.uniformBlockBinding(Be,Ne,ve.__bindingPointIndex),d.set(Be,Ne))}function He(){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),r===!0&&(t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),t.bindFramebuffer(t.READ_FRAMEBUFFER,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),p={},F=null,q={},g={},b=new WeakMap,v=[],x=null,y=!1,E=null,w=null,A=null,N=null,C=null,T=null,D=null,k=new Yt(0,0,0),P=0,z=!1,L=null,X=null,R=null,Y=null,J=null,se.set(0,0,t.canvas.width,t.canvas.height),de.set(0,0,t.canvas.width,t.canvas.height),l.reset(),c.reset(),u.reset()}return{buffers:{color:l,depth:c,stencil:u},enable:oe,disable:ae,bindFramebuffer:ge,drawBuffers:ue,useProgram:Le,setBlending:Z,setMaterial:B,setFlipSided:U,setCullFace:Q,setLineWidth:Me,setPolygonOffset:Te,setScissorTest:fe,activeTexture:H,bindTexture:I,unbindTexture:ce,compressedTexImage2D:we,compressedTexImage3D:Se,texImage2D:me,texImage3D:Ke,updateUBOMapping:ut,uniformBlockBinding:ie,texStorage2D:ct,texStorage3D:Fe,texSubImage2D:_e,texSubImage3D:st,compressedTexSubImage2D:Ve,compressedTexSubImage3D:it,scissor:qe,viewport:Qe,reset:He}}function ize(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=i.maxSamples,p=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),b=new WeakMap;let v;const x=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function E(H,I){return y?new OffscreenCanvas(H,I):pS("canvas")}function w(H,I,ce,we){let Se=1;if((H.width>we||H.height>we)&&(Se=we/Math.max(H.width,H.height)),Se<1||I===!0)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap){const _e=I?mS:Math.floor,st=_e(Se*H.width),Ve=_e(Se*H.height);v===void 0&&(v=E(st,Ve));const it=ce?E(st,Ve):v;return it.width=st,it.height=Ve,it.getContext("2d").drawImage(H,0,0,st,Ve),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+H.width+"x"+H.height+") to ("+st+"x"+Ve+")."),it}else return"data"in H&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+H.width+"x"+H.height+")."),H;return H}function A(H){return TP(H.width)&&TP(H.height)}function N(H){return l?!1:H.wrapS!==Go||H.wrapT!==Go||H.minFilter!==ca&&H.minFilter!==mo}function C(H,I){return H.generateMipmaps&&I&&H.minFilter!==ca&&H.minFilter!==mo}function T(H){t.generateMipmap(H)}function D(H,I,ce,we,Se=!1){if(l===!1)return I;if(H!==null){if(t[H]!==void 0)return t[H];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let _e=I;if(I===t.RED&&(ce===t.FLOAT&&(_e=t.R32F),ce===t.HALF_FLOAT&&(_e=t.R16F),ce===t.UNSIGNED_BYTE&&(_e=t.R8)),I===t.RED_INTEGER&&(ce===t.UNSIGNED_BYTE&&(_e=t.R8UI),ce===t.UNSIGNED_SHORT&&(_e=t.R16UI),ce===t.UNSIGNED_INT&&(_e=t.R32UI),ce===t.BYTE&&(_e=t.R8I),ce===t.SHORT&&(_e=t.R16I),ce===t.INT&&(_e=t.R32I)),I===t.RG&&(ce===t.FLOAT&&(_e=t.RG32F),ce===t.HALF_FLOAT&&(_e=t.RG16F),ce===t.UNSIGNED_BYTE&&(_e=t.RG8)),I===t.RGBA){const st=Se?dS:cr.getTransfer(we);ce===t.FLOAT&&(_e=t.RGBA32F),ce===t.HALF_FLOAT&&(_e=t.RGBA16F),ce===t.UNSIGNED_BYTE&&(_e=st===Sr?t.SRGB8_ALPHA8:t.RGBA8),ce===t.UNSIGNED_SHORT_4_4_4_4&&(_e=t.RGBA4),ce===t.UNSIGNED_SHORT_5_5_5_1&&(_e=t.RGB5_A1)}return(_e===t.R16F||_e===t.R32F||_e===t.RG16F||_e===t.RG32F||_e===t.RGBA16F||_e===t.RGBA32F)&&e.get("EXT_color_buffer_float"),_e}function k(H,I,ce){return C(H,ce)===!0||H.isFramebufferTexture&&H.minFilter!==ca&&H.minFilter!==mo?Math.log2(Math.max(I.width,I.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?I.mipmaps.length:1}function P(H){return H===ca||H===qH||H===LC?t.NEAREST:t.LINEAR}function z(H){const I=H.target;I.removeEventListener("dispose",z),X(I),I.isVideoTexture&&b.delete(I)}function L(H){const I=H.target;I.removeEventListener("dispose",L),Y(I)}function X(H){const I=r.get(H);if(I.__webglInit===void 0)return;const ce=H.source,we=x.get(ce);if(we){const Se=we[I.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&R(H),Object.keys(we).length===0&&x.delete(ce)}r.remove(H)}function R(H){const I=r.get(H);t.deleteTexture(I.__webglTexture);const ce=H.source,we=x.get(ce);delete we[I.__cacheKey],o.memory.textures--}function Y(H){const I=H.texture,ce=r.get(H),we=r.get(I);if(we.__webglTexture!==void 0&&(t.deleteTexture(we.__webglTexture),o.memory.textures--),H.depthTexture&&H.depthTexture.dispose(),H.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(ce.__webglFramebuffer[Se]))for(let _e=0;_e<ce.__webglFramebuffer[Se].length;_e++)t.deleteFramebuffer(ce.__webglFramebuffer[Se][_e]);else t.deleteFramebuffer(ce.__webglFramebuffer[Se]);ce.__webglDepthbuffer&&t.deleteRenderbuffer(ce.__webglDepthbuffer[Se])}else{if(Array.isArray(ce.__webglFramebuffer))for(let Se=0;Se<ce.__webglFramebuffer.length;Se++)t.deleteFramebuffer(ce.__webglFramebuffer[Se]);else t.deleteFramebuffer(ce.__webglFramebuffer);if(ce.__webglDepthbuffer&&t.deleteRenderbuffer(ce.__webglDepthbuffer),ce.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ce.__webglMultisampledFramebuffer),ce.__webglColorRenderbuffer)for(let Se=0;Se<ce.__webglColorRenderbuffer.length;Se++)ce.__webglColorRenderbuffer[Se]&&t.deleteRenderbuffer(ce.__webglColorRenderbuffer[Se]);ce.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ce.__webglDepthRenderbuffer)}if(H.isWebGLMultipleRenderTargets)for(let Se=0,_e=I.length;Se<_e;Se++){const st=r.get(I[Se]);st.__webglTexture&&(t.deleteTexture(st.__webglTexture),o.memory.textures--),r.remove(I[Se])}r.remove(I),r.remove(H)}let J=0;function G(){J=0}function W(){const H=J;return H>=c&&console.warn("THREE.WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+c),J+=1,H}function ee(H){const I=[];return I.push(H.wrapS),I.push(H.wrapT),I.push(H.wrapR||0),I.push(H.magFilter),I.push(H.minFilter),I.push(H.anisotropy),I.push(H.internalFormat),I.push(H.format),I.push(H.type),I.push(H.generateMipmaps),I.push(H.premultiplyAlpha),I.push(H.flipY),I.push(H.unpackAlignment),I.push(H.colorSpace),I.join()}function K(H,I){const ce=r.get(H);if(H.isVideoTexture&&Te(H),H.isRenderTargetTexture===!1&&H.version>0&&ce.__version!==H.version){const we=H.image;if(we===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(we.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{oe(ce,H,I);return}}n.bindTexture(t.TEXTURE_2D,ce.__webglTexture,t.TEXTURE0+I)}function F(H,I){const ce=r.get(H);if(H.version>0&&ce.__version!==H.version){oe(ce,H,I);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ce.__webglTexture,t.TEXTURE0+I)}function q(H,I){const ce=r.get(H);if(H.version>0&&ce.__version!==H.version){oe(ce,H,I);return}n.bindTexture(t.TEXTURE_3D,ce.__webglTexture,t.TEXTURE0+I)}function ne(H,I){const ce=r.get(H);if(H.version>0&&ce.__version!==H.version){ae(ce,H,I);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ce.__webglTexture,t.TEXTURE0+I)}const re={[MP]:t.REPEAT,[Go]:t.CLAMP_TO_EDGE,[EP]:t.MIRRORED_REPEAT},se={[ca]:t.NEAREST,[qH]:t.NEAREST_MIPMAP_NEAREST,[LC]:t.NEAREST_MIPMAP_LINEAR,[mo]:t.LINEAR,[TOe]:t.LINEAR_MIPMAP_NEAREST,[b0]:t.LINEAR_MIPMAP_LINEAR},de={[zOe]:t.NEVER,[WOe]:t.ALWAYS,[BOe]:t.LESS,[DZ]:t.LEQUAL,[$Oe]:t.EQUAL,[GOe]:t.GEQUAL,[HOe]:t.GREATER,[VOe]:t.NOTEQUAL};function pe(H,I,ce){if(ce?(t.texParameteri(H,t.TEXTURE_WRAP_S,re[I.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,re[I.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,re[I.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,se[I.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,se[I.minFilter])):(t.texParameteri(H,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(H,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(I.wrapS!==Go||I.wrapT!==Go)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(H,t.TEXTURE_MAG_FILTER,P(I.magFilter)),t.texParameteri(H,t.TEXTURE_MIN_FILTER,P(I.minFilter)),I.minFilter!==ca&&I.minFilter!==mo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),I.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,de[I.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const we=e.get("EXT_texture_filter_anisotropic");if(I.magFilter===ca||I.minFilter!==LC&&I.minFilter!==b0||I.type===Ic&&e.has("OES_texture_float_linear")===!1||l===!1&&I.type===y0&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(t.texParameterf(H,we.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function Ce(H,I){let ce=!1;H.__webglInit===void 0&&(H.__webglInit=!0,I.addEventListener("dispose",z));const we=I.source;let Se=x.get(we);Se===void 0&&(Se={},x.set(we,Se));const _e=ee(I);if(_e!==H.__cacheKey){Se[_e]===void 0&&(Se[_e]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ce=!0),Se[_e].usedTimes++;const st=Se[H.__cacheKey];st!==void 0&&(Se[H.__cacheKey].usedTimes--,st.usedTimes===0&&R(I)),H.__cacheKey=_e,H.__webglTexture=Se[_e].texture}return ce}function oe(H,I,ce){let we=t.TEXTURE_2D;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(we=t.TEXTURE_2D_ARRAY),I.isData3DTexture&&(we=t.TEXTURE_3D);const Se=Ce(H,I),_e=I.source;n.bindTexture(we,H.__webglTexture,t.TEXTURE0+ce);const st=r.get(_e);if(_e.version!==st.__version||Se===!0){n.activeTexture(t.TEXTURE0+ce);const Ve=cr.getPrimaries(cr.workingColorSpace),it=I.colorSpace===go?null:cr.getPrimaries(I.colorSpace),ct=I.colorSpace===go||Ve===it?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,ct);const Fe=N(I)&&A(I.image)===!1;let me=w(I.image,Fe,!1,d);me=fe(I,me);const Ke=A(me)||l,qe=a.convert(I.format,I.colorSpace);let Qe=a.convert(I.type),ut=D(I.internalFormat,qe,Qe,I.colorSpace,I.isVideoTexture);pe(we,I,Ke);let ie;const He=I.mipmaps,ve=l&&I.isVideoTexture!==!0&&ut!==jZ,Be=st.__version===void 0||Se===!0,je=k(I,me,Ke);if(I.isDepthTexture)ut=t.DEPTH_COMPONENT,l?I.type===Ic?ut=t.DEPTH_COMPONENT32F:I.type===md?ut=t.DEPTH_COMPONENT24:I.type===tf?ut=t.DEPTH24_STENCIL8:ut=t.DEPTH_COMPONENT16:I.type===Ic&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===nf&&ut===t.DEPTH_COMPONENT&&I.type!==rO&&I.type!==md&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=md,Qe=a.convert(I.type)),I.format===sg&&ut===t.DEPTH_COMPONENT&&(ut=t.DEPTH_STENCIL,I.type!==tf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=tf,Qe=a.convert(I.type))),Be&&(ve?n.texStorage2D(t.TEXTURE_2D,1,ut,me.width,me.height):n.texImage2D(t.TEXTURE_2D,0,ut,me.width,me.height,0,qe,Qe,null));else if(I.isDataTexture)if(He.length>0&&Ke){ve&&Be&&n.texStorage2D(t.TEXTURE_2D,je,ut,He[0].width,He[0].height);for(let Ne=0,Xe=He.length;Ne<Xe;Ne++)ie=He[Ne],ve?n.texSubImage2D(t.TEXTURE_2D,Ne,0,0,ie.width,ie.height,qe,Qe,ie.data):n.texImage2D(t.TEXTURE_2D,Ne,ut,ie.width,ie.height,0,qe,Qe,ie.data);I.generateMipmaps=!1}else ve?(Be&&n.texStorage2D(t.TEXTURE_2D,je,ut,me.width,me.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,me.width,me.height,qe,Qe,me.data)):n.texImage2D(t.TEXTURE_2D,0,ut,me.width,me.height,0,qe,Qe,me.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){ve&&Be&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,ut,He[0].width,He[0].height,me.depth);for(let Ne=0,Xe=He.length;Ne<Xe;Ne++)ie=He[Ne],I.format!==po?qe!==null?ve?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ne,0,0,0,ie.width,ie.height,me.depth,qe,ie.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ne,ut,ie.width,ie.height,me.depth,0,ie.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ne,0,0,0,ie.width,ie.height,me.depth,qe,Qe,ie.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ne,ut,ie.width,ie.height,me.depth,0,qe,Qe,ie.data)}else{ve&&Be&&n.texStorage2D(t.TEXTURE_2D,je,ut,He[0].width,He[0].height);for(let Ne=0,Xe=He.length;Ne<Xe;Ne++)ie=He[Ne],I.format!==po?qe!==null?ve?n.compressedTexSubImage2D(t.TEXTURE_2D,Ne,0,0,ie.width,ie.height,qe,ie.data):n.compressedTexImage2D(t.TEXTURE_2D,Ne,ut,ie.width,ie.height,0,ie.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ve?n.texSubImage2D(t.TEXTURE_2D,Ne,0,0,ie.width,ie.height,qe,Qe,ie.data):n.texImage2D(t.TEXTURE_2D,Ne,ut,ie.width,ie.height,0,qe,Qe,ie.data)}else if(I.isDataArrayTexture)ve?(Be&&n.texStorage3D(t.TEXTURE_2D_ARRAY,je,ut,me.width,me.height,me.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,qe,Qe,me.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,ut,me.width,me.height,me.depth,0,qe,Qe,me.data);else if(I.isData3DTexture)ve?(Be&&n.texStorage3D(t.TEXTURE_3D,je,ut,me.width,me.height,me.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,qe,Qe,me.data)):n.texImage3D(t.TEXTURE_3D,0,ut,me.width,me.height,me.depth,0,qe,Qe,me.data);else if(I.isFramebufferTexture){if(Be)if(ve)n.texStorage2D(t.TEXTURE_2D,je,ut,me.width,me.height);else{let Ne=me.width,Xe=me.height;for(let mt=0;mt<je;mt++)n.texImage2D(t.TEXTURE_2D,mt,ut,Ne,Xe,0,qe,Qe,null),Ne>>=1,Xe>>=1}}else if(He.length>0&&Ke){ve&&Be&&n.texStorage2D(t.TEXTURE_2D,je,ut,He[0].width,He[0].height);for(let Ne=0,Xe=He.length;Ne<Xe;Ne++)ie=He[Ne],ve?n.texSubImage2D(t.TEXTURE_2D,Ne,0,0,qe,Qe,ie):n.texImage2D(t.TEXTURE_2D,Ne,ut,qe,Qe,ie);I.generateMipmaps=!1}else ve?(Be&&n.texStorage2D(t.TEXTURE_2D,je,ut,me.width,me.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,qe,Qe,me)):n.texImage2D(t.TEXTURE_2D,0,ut,qe,Qe,me);C(I,Ke)&&T(we),st.__version=_e.version,I.onUpdate&&I.onUpdate(I)}H.__version=I.version}function ae(H,I,ce){if(I.image.length!==6)return;const we=Ce(H,I),Se=I.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+ce);const _e=r.get(Se);if(Se.version!==_e.__version||we===!0){n.activeTexture(t.TEXTURE0+ce);const st=cr.getPrimaries(cr.workingColorSpace),Ve=I.colorSpace===go?null:cr.getPrimaries(I.colorSpace),it=I.colorSpace===go||st===Ve?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,I.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,I.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,it);const ct=I.isCompressedTexture||I.image[0].isCompressedTexture,Fe=I.image[0]&&I.image[0].isDataTexture,me=[];for(let Ne=0;Ne<6;Ne++)!ct&&!Fe?me[Ne]=w(I.image[Ne],!1,!0,u):me[Ne]=Fe?I.image[Ne].image:I.image[Ne],me[Ne]=fe(I,me[Ne]);const Ke=me[0],qe=A(Ke)||l,Qe=a.convert(I.format,I.colorSpace),ut=a.convert(I.type),ie=D(I.internalFormat,Qe,ut,I.colorSpace),He=l&&I.isVideoTexture!==!0,ve=_e.__version===void 0||we===!0;let Be=k(I,Ke,qe);pe(t.TEXTURE_CUBE_MAP,I,qe);let je;if(ct){He&&ve&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ie,Ke.width,Ke.height);for(let Ne=0;Ne<6;Ne++){je=me[Ne].mipmaps;for(let Xe=0;Xe<je.length;Xe++){const mt=je[Xe];I.format!==po?Qe!==null?He?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,0,0,mt.width,mt.height,Qe,mt.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,ie,mt.width,mt.height,0,mt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):He?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,0,0,mt.width,mt.height,Qe,ut,mt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe,ie,mt.width,mt.height,0,Qe,ut,mt.data)}}}else{je=I.mipmaps,He&&ve&&(je.length>0&&Be++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Be,ie,me[0].width,me[0].height));for(let Ne=0;Ne<6;Ne++)if(Fe){He?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,me[Ne].width,me[Ne].height,Qe,ut,me[Ne].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,ie,me[Ne].width,me[Ne].height,0,Qe,ut,me[Ne].data);for(let Xe=0;Xe<je.length;Xe++){const At=je[Xe].image[Ne].image;He?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,0,0,At.width,At.height,Qe,ut,At.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,ie,At.width,At.height,0,Qe,ut,At.data)}}else{He?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,0,0,Qe,ut,me[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,0,ie,Qe,ut,me[Ne]);for(let Xe=0;Xe<je.length;Xe++){const mt=je[Xe];He?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,0,0,Qe,ut,mt.image[Ne]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+Ne,Xe+1,ie,Qe,ut,mt.image[Ne])}}}C(I,qe)&&T(t.TEXTURE_CUBE_MAP),_e.__version=Se.version,I.onUpdate&&I.onUpdate(I)}H.__version=I.version}function ge(H,I,ce,we,Se,_e){const st=a.convert(ce.format,ce.colorSpace),Ve=a.convert(ce.type),it=D(ce.internalFormat,st,Ve,ce.colorSpace);if(!r.get(I).__hasExternalTextures){const Fe=Math.max(1,I.width>>_e),me=Math.max(1,I.height>>_e);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,_e,it,Fe,me,I.depth,0,st,Ve,null):n.texImage2D(Se,_e,it,Fe,me,0,st,Ve,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),Me(I)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,we,Se,r.get(ce).__webglTexture,0,Q(I)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,we,Se,r.get(ce).__webglTexture,_e),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ue(H,I,ce){if(t.bindRenderbuffer(t.RENDERBUFFER,H),I.depthBuffer&&!I.stencilBuffer){let we=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ce||Me(I)){const Se=I.depthTexture;Se&&Se.isDepthTexture&&(Se.type===Ic?we=t.DEPTH_COMPONENT32F:Se.type===md&&(we=t.DEPTH_COMPONENT24));const _e=Q(I);Me(I)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,_e,we,I.width,I.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,_e,we,I.width,I.height)}else t.renderbufferStorage(t.RENDERBUFFER,we,I.width,I.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,H)}else if(I.depthBuffer&&I.stencilBuffer){const we=Q(I);ce&&Me(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,we,t.DEPTH24_STENCIL8,I.width,I.height):Me(I)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,we,t.DEPTH24_STENCIL8,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,I.width,I.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,H)}else{const we=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let Se=0;Se<we.length;Se++){const _e=we[Se],st=a.convert(_e.format,_e.colorSpace),Ve=a.convert(_e.type),it=D(_e.internalFormat,st,Ve,_e.colorSpace),ct=Q(I);ce&&Me(I)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,ct,it,I.width,I.height):Me(I)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ct,it,I.width,I.height):t.renderbufferStorage(t.RENDERBUFFER,it,I.width,I.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Le(H,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),K(I.depthTexture,0);const we=r.get(I.depthTexture).__webglTexture,Se=Q(I);if(I.depthTexture.format===nf)Me(I)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,we,0);else if(I.depthTexture.format===sg)Me(I)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,we,0);else throw new Error("Unknown depthTexture format")}function V(H){const I=r.get(H),ce=H.isWebGLCubeRenderTarget===!0;if(H.depthTexture&&!I.__autoAllocateDepthBuffer){if(ce)throw new Error("target.depthTexture not supported in Cube render targets");Le(I.__webglFramebuffer,H)}else if(ce){I.__webglDepthbuffer=[];for(let we=0;we<6;we++)n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer[we]),I.__webglDepthbuffer[we]=t.createRenderbuffer(),ue(I.__webglDepthbuffer[we],H,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,I.__webglFramebuffer),I.__webglDepthbuffer=t.createRenderbuffer(),ue(I.__webglDepthbuffer,H,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function $(H,I,ce){const we=r.get(H);I!==void 0&&ge(we.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ce!==void 0&&V(H)}function Z(H){const I=H.texture,ce=r.get(H),we=r.get(I);H.addEventListener("dispose",L),H.isWebGLMultipleRenderTargets!==!0&&(we.__webglTexture===void 0&&(we.__webglTexture=t.createTexture()),we.__version=I.version,o.memory.textures++);const Se=H.isWebGLCubeRenderTarget===!0,_e=H.isWebGLMultipleRenderTargets===!0,st=A(H)||l;if(Se){ce.__webglFramebuffer=[];for(let Ve=0;Ve<6;Ve++)if(l&&I.mipmaps&&I.mipmaps.length>0){ce.__webglFramebuffer[Ve]=[];for(let it=0;it<I.mipmaps.length;it++)ce.__webglFramebuffer[Ve][it]=t.createFramebuffer()}else ce.__webglFramebuffer[Ve]=t.createFramebuffer()}else{if(l&&I.mipmaps&&I.mipmaps.length>0){ce.__webglFramebuffer=[];for(let Ve=0;Ve<I.mipmaps.length;Ve++)ce.__webglFramebuffer[Ve]=t.createFramebuffer()}else ce.__webglFramebuffer=t.createFramebuffer();if(_e)if(i.drawBuffers){const Ve=H.texture;for(let it=0,ct=Ve.length;it<ct;it++){const Fe=r.get(Ve[it]);Fe.__webglTexture===void 0&&(Fe.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&H.samples>0&&Me(H)===!1){const Ve=_e?I:[I];ce.__webglMultisampledFramebuffer=t.createFramebuffer(),ce.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ce.__webglMultisampledFramebuffer);for(let it=0;it<Ve.length;it++){const ct=Ve[it];ce.__webglColorRenderbuffer[it]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ce.__webglColorRenderbuffer[it]);const Fe=a.convert(ct.format,ct.colorSpace),me=a.convert(ct.type),Ke=D(ct.internalFormat,Fe,me,ct.colorSpace,H.isXRRenderTarget===!0),qe=Q(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,qe,Ke,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+it,t.RENDERBUFFER,ce.__webglColorRenderbuffer[it])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(ce.__webglDepthRenderbuffer=t.createRenderbuffer(),ue(ce.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Se){n.bindTexture(t.TEXTURE_CUBE_MAP,we.__webglTexture),pe(t.TEXTURE_CUBE_MAP,I,st);for(let Ve=0;Ve<6;Ve++)if(l&&I.mipmaps&&I.mipmaps.length>0)for(let it=0;it<I.mipmaps.length;it++)ge(ce.__webglFramebuffer[Ve][it],H,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,it);else ge(ce.__webglFramebuffer[Ve],H,I,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Ve,0);C(I,st)&&T(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(_e){const Ve=H.texture;for(let it=0,ct=Ve.length;it<ct;it++){const Fe=Ve[it],me=r.get(Fe);n.bindTexture(t.TEXTURE_2D,me.__webglTexture),pe(t.TEXTURE_2D,Fe,st),ge(ce.__webglFramebuffer,H,Fe,t.COLOR_ATTACHMENT0+it,t.TEXTURE_2D,0),C(Fe,st)&&T(t.TEXTURE_2D)}n.unbindTexture()}else{let Ve=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(l?Ve=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Ve,we.__webglTexture),pe(Ve,I,st),l&&I.mipmaps&&I.mipmaps.length>0)for(let it=0;it<I.mipmaps.length;it++)ge(ce.__webglFramebuffer[it],H,I,t.COLOR_ATTACHMENT0,Ve,it);else ge(ce.__webglFramebuffer,H,I,t.COLOR_ATTACHMENT0,Ve,0);C(I,st)&&T(Ve),n.unbindTexture()}H.depthBuffer&&V(H)}function B(H){const I=A(H)||l,ce=H.isWebGLMultipleRenderTargets===!0?H.texture:[H.texture];for(let we=0,Se=ce.length;we<Se;we++){const _e=ce[we];if(C(_e,I)){const st=H.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Ve=r.get(_e).__webglTexture;n.bindTexture(st,Ve),T(st),n.unbindTexture()}}}function U(H){if(l&&H.samples>0&&Me(H)===!1){const I=H.isWebGLMultipleRenderTargets?H.texture:[H.texture],ce=H.width,we=H.height;let Se=t.COLOR_BUFFER_BIT;const _e=[],st=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Ve=r.get(H),it=H.isWebGLMultipleRenderTargets===!0;if(it)for(let ct=0;ct<I.length;ct++)n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ve.__webglFramebuffer);for(let ct=0;ct<I.length;ct++){_e.push(t.COLOR_ATTACHMENT0+ct),H.depthBuffer&&_e.push(st);const Fe=Ve.__ignoreDepthValues!==void 0?Ve.__ignoreDepthValues:!1;if(Fe===!1&&(H.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),it&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Ve.__webglColorRenderbuffer[ct]),Fe===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[st]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[st])),it){const me=r.get(I[ct]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,me,0)}t.blitFramebuffer(0,0,ce,we,0,0,ce,we,Se,t.NEAREST),g&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,_e)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),it)for(let ct=0;ct<I.length;ct++){n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.RENDERBUFFER,Ve.__webglColorRenderbuffer[ct]);const Fe=r.get(I[ct]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Ve.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+ct,t.TEXTURE_2D,Fe,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Ve.__webglMultisampledFramebuffer)}}function Q(H){return Math.min(f,H.samples)}function Me(H){const I=r.get(H);return l&&H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Te(H){const I=o.render.frame;b.get(H)!==I&&(b.set(H,I),H.update())}function fe(H,I){const ce=H.colorSpace,we=H.format,Se=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||H.format===AP||ce!==ou&&ce!==go&&(cr.getTransfer(ce)===Sr?l===!1?e.has("EXT_sRGB")===!0&&we===po?(H.format=AP,H.minFilter=mo,H.generateMipmaps=!1):I=IZ.sRGBToLinear(I):(we!==po||Se!==Nd)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ce)),I}this.allocateTextureUnit=W,this.resetTextureUnits=G,this.setTexture2D=K,this.setTexture2DArray=F,this.setTexture3D=q,this.setTextureCube=ne,this.rebindTextures=$,this.setupRenderTarget=Z,this.updateRenderTargetMipmap=B,this.updateMultisampleRenderTarget=U,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=Me}function aze(t,e,n){const r=n.isWebGL2;function i(a,o=go){let l;const c=cr.getTransfer(o);if(a===Nd)return t.UNSIGNED_BYTE;if(a===NZ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===AZ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===COe)return t.BYTE;if(a===kOe)return t.SHORT;if(a===rO)return t.UNSIGNED_SHORT;if(a===EZ)return t.INT;if(a===md)return t.UNSIGNED_INT;if(a===Ic)return t.FLOAT;if(a===y0)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===jOe)return t.ALPHA;if(a===po)return t.RGBA;if(a===POe)return t.LUMINANCE;if(a===ROe)return t.LUMINANCE_ALPHA;if(a===nf)return t.DEPTH_COMPONENT;if(a===sg)return t.DEPTH_STENCIL;if(a===AP)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===DOe)return t.RED;if(a===TZ)return t.RED_INTEGER;if(a===OOe)return t.RG;if(a===CZ)return t.RG_INTEGER;if(a===kZ)return t.RGBA_INTEGER;if(a===IC||a===FC||a===UC||a===zC)if(c===Sr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===IC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===FC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===UC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===zC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===IC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===FC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===UC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===zC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===KH||a===XH||a===YH||a===QH)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===KH)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===XH)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===YH)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===QH)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===jZ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===ZH||a===JH)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===ZH)return c===Sr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===JH)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===eV||a===tV||a===nV||a===rV||a===iV||a===aV||a===sV||a===oV||a===lV||a===cV||a===uV||a===dV||a===hV||a===fV)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===eV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===tV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===nV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===rV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===iV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===aV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===sV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===oV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===lV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===cV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===uV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===dV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===hV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===fV)return c===Sr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===BC||a===mV||a===pV)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===BC)return c===Sr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===mV)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===pV)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===LOe||a===gV||a===xV||a===bV)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===BC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===gV)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===xV)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===bV)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===tf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class sze extends Cs{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class hb extends $a{constructor(){super(),this.isGroup=!0,this.type="Group"}}const oze={type:"move"};class uk{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new hb,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 hb,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ze,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ze),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new hb,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ze,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ze),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 r of e.hand.values())this._getHandJoint(n,r)}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,r){let i=null,a=null,o=null;const l=this._targetRay,c=this._grip,u=this._hand;if(e&&n.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(const v of e.hand.values()){const x=n.getJointPose(v,r),y=this._getHandJoint(u,v);x!==null&&(y.matrix.fromArray(x.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=x.radius),y.visible=x!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],p=d.position.distanceTo(f.position),g=.02,b=.005;u.inputState.pinching&&p>g+b?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=g-b&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(oze)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new hb;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class lze extends $f{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,g=null,b=null;const v=n.getContextAttributes();let x=null,y=null;const E=[],w=[],A=new rn;let N=null;const C=new Cs;C.layers.enable(1),C.viewport=new hr;const T=new Cs;T.layers.enable(2),T.viewport=new hr;const D=[C,T],k=new sze;k.layers.enable(1),k.layers.enable(2);let P=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let re=E[ne];return re===void 0&&(re=new uk,E[ne]=re),re.getTargetRaySpace()},this.getControllerGrip=function(ne){let re=E[ne];return re===void 0&&(re=new uk,E[ne]=re),re.getGripSpace()},this.getHand=function(ne){let re=E[ne];return re===void 0&&(re=new uk,E[ne]=re),re.getHandSpace()};function L(ne){const re=w.indexOf(ne.inputSource);if(re===-1)return;const se=E[re];se!==void 0&&(se.update(ne.inputSource,ne.frame,u||o),se.dispatchEvent({type:ne.type,data:ne.inputSource}))}function X(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",R);for(let ne=0;ne<E.length;ne++){const re=w[ne];re!==null&&(w[ne]=null,E[ne].disconnect(re))}P=null,z=null,e.setRenderTarget(x),g=null,p=null,f=null,i=null,y=null,q.stop(),r.isPresenting=!1,e.setPixelRatio(N),e.setSize(A.width,A.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){a=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ne){u=ne},this.getBaseLayer=function(){return p!==null?p:g},this.getBinding=function(){return f},this.getFrame=function(){return b},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(x=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",X),i.addEventListener("inputsourceschange",R),v.xrCompatible!==!0&&await n.makeXRCompatible(),N=e.getPixelRatio(),e.getSize(A),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const re={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:a};g=new XRWebGLLayer(i,n,re),i.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),y=new kf(g.framebufferWidth,g.framebufferHeight,{format:po,type:Nd,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let re=null,se=null,de=null;v.depth&&(de=v.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,re=v.stencil?sg:nf,se=v.stencil?tf:md);const pe={colorFormat:n.RGBA8,depthFormat:de,scaleFactor:a};f=new XRWebGLBinding(i,n),p=f.createProjectionLayer(pe),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),y=new kf(p.textureWidth,p.textureHeight,{format:po,type:Nd,depthTexture:new XZ(p.textureWidth,p.textureHeight,se,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const Ce=e.properties.get(y);Ce.__ignoreDepthValues=p.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),q.setContext(i),q.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function R(ne){for(let re=0;re<ne.removed.length;re++){const se=ne.removed[re],de=w.indexOf(se);de>=0&&(w[de]=null,E[de].disconnect(se))}for(let re=0;re<ne.added.length;re++){const se=ne.added[re];let de=w.indexOf(se);if(de===-1){for(let Ce=0;Ce<E.length;Ce++)if(Ce>=w.length){w.push(se),de=Ce;break}else if(w[Ce]===null){w[Ce]=se,de=Ce;break}if(de===-1)break}const pe=E[de];pe&&pe.connect(se)}}const Y=new ze,J=new ze;function G(ne,re,se){Y.setFromMatrixPosition(re.matrixWorld),J.setFromMatrixPosition(se.matrixWorld);const de=Y.distanceTo(J),pe=re.projectionMatrix.elements,Ce=se.projectionMatrix.elements,oe=pe[14]/(pe[10]-1),ae=pe[14]/(pe[10]+1),ge=(pe[9]+1)/pe[5],ue=(pe[9]-1)/pe[5],Le=(pe[8]-1)/pe[0],V=(Ce[8]+1)/Ce[0],$=oe*Le,Z=oe*V,B=de/(-Le+V),U=B*-Le;re.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(U),ne.translateZ(B),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert();const Q=oe+B,Me=ae+B,Te=$-U,fe=Z+(de-U),H=ge*ae/Me*Q,I=ue*ae/Me*Q;ne.projectionMatrix.makePerspective(Te,fe,H,I,Q,Me),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}function W(ne,re){re===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(re.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;k.near=T.near=C.near=ne.near,k.far=T.far=C.far=ne.far,(P!==k.near||z!==k.far)&&(i.updateRenderState({depthNear:k.near,depthFar:k.far}),P=k.near,z=k.far);const re=ne.parent,se=k.cameras;W(k,re);for(let de=0;de<se.length;de++)W(se[de],re);se.length===2?G(k,C,T):k.projectionMatrix.copy(C.projectionMatrix),ee(ne,k,re)};function ee(ne,re,se){se===null?ne.matrix.copy(re.matrixWorld):(ne.matrix.copy(se.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(re.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(re.projectionMatrix),ne.projectionMatrixInverse.copy(re.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=_0*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(p===null&&g===null))return c},this.setFoveation=function(ne){c=ne,p!==null&&(p.fixedFoveation=ne),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=ne)};let K=null;function F(ne,re){if(d=re.getViewerPose(u||o),b=re,d!==null){const se=d.views;g!==null&&(e.setRenderTargetFramebuffer(y,g.framebuffer),e.setRenderTarget(y));let de=!1;se.length!==k.cameras.length&&(k.cameras.length=0,de=!0);for(let pe=0;pe<se.length;pe++){const Ce=se[pe];let oe=null;if(g!==null)oe=g.getViewport(Ce);else{const ge=f.getViewSubImage(p,Ce);oe=ge.viewport,pe===0&&(e.setRenderTargetTextures(y,ge.colorTexture,p.ignoreDepthValues?void 0:ge.depthStencilTexture),e.setRenderTarget(y))}let ae=D[pe];ae===void 0&&(ae=new Cs,ae.layers.enable(pe),ae.viewport=new hr,D[pe]=ae),ae.matrix.fromArray(Ce.transform.matrix),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.projectionMatrix.fromArray(Ce.projectionMatrix),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert(),ae.viewport.set(oe.x,oe.y,oe.width,oe.height),pe===0&&(k.matrix.copy(ae.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),de===!0&&k.cameras.push(ae)}}for(let se=0;se<E.length;se++){const de=w[se],pe=E[se];de!==null&&pe!==void 0&&pe.update(de,re,u||o)}K&&K(ne,re),re.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:re}),b=null}const q=new KZ;q.setAnimationLoop(F),this.setAnimationLoop=function(ne){K=ne},this.dispose=function(){}}}function cze(t,e){function n(x,y){x.matrixAutoUpdate===!0&&x.updateMatrix(),y.value.copy(x.matrix)}function r(x,y){y.color.getRGB(x.fogColor.value,GZ(t)),y.isFog?(x.fogNear.value=y.near,x.fogFar.value=y.far):y.isFogExp2&&(x.fogDensity.value=y.density)}function i(x,y,E,w,A){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(x,y):y.isMeshToonMaterial?(a(x,y),f(x,y)):y.isMeshPhongMaterial?(a(x,y),d(x,y)):y.isMeshStandardMaterial?(a(x,y),p(x,y),y.isMeshPhysicalMaterial&&g(x,y,A)):y.isMeshMatcapMaterial?(a(x,y),b(x,y)):y.isMeshDepthMaterial?a(x,y):y.isMeshDistanceMaterial?(a(x,y),v(x,y)):y.isMeshNormalMaterial?a(x,y):y.isLineBasicMaterial?(o(x,y),y.isLineDashedMaterial&&l(x,y)):y.isPointsMaterial?c(x,y,E,w):y.isSpriteMaterial?u(x,y):y.isShadowMaterial?(x.color.value.copy(y.color),x.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(x,y){x.opacity.value=y.opacity,y.color&&x.diffuse.value.copy(y.color),y.emissive&&x.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.bumpMap&&(x.bumpMap.value=y.bumpMap,n(y.bumpMap,x.bumpMapTransform),x.bumpScale.value=y.bumpScale,y.side===cs&&(x.bumpScale.value*=-1)),y.normalMap&&(x.normalMap.value=y.normalMap,n(y.normalMap,x.normalMapTransform),x.normalScale.value.copy(y.normalScale),y.side===cs&&x.normalScale.value.negate()),y.displacementMap&&(x.displacementMap.value=y.displacementMap,n(y.displacementMap,x.displacementMapTransform),x.displacementScale.value=y.displacementScale,x.displacementBias.value=y.displacementBias),y.emissiveMap&&(x.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,x.emissiveMapTransform)),y.specularMap&&(x.specularMap.value=y.specularMap,n(y.specularMap,x.specularMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest);const E=e.get(y).envMap;if(E&&(x.envMap.value=E,x.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,x.reflectivity.value=y.reflectivity,x.ior.value=y.ior,x.refractionRatio.value=y.refractionRatio),y.lightMap){x.lightMap.value=y.lightMap;const w=t._useLegacyLights===!0?Math.PI:1;x.lightMapIntensity.value=y.lightMapIntensity*w,n(y.lightMap,x.lightMapTransform)}y.aoMap&&(x.aoMap.value=y.aoMap,x.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,x.aoMapTransform))}function o(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform))}function l(x,y){x.dashSize.value=y.dashSize,x.totalSize.value=y.dashSize+y.gapSize,x.scale.value=y.scale}function c(x,y,E,w){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.size.value=y.size*E,x.scale.value=w*.5,y.map&&(x.map.value=y.map,n(y.map,x.uvTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function u(x,y){x.diffuse.value.copy(y.color),x.opacity.value=y.opacity,x.rotation.value=y.rotation,y.map&&(x.map.value=y.map,n(y.map,x.mapTransform)),y.alphaMap&&(x.alphaMap.value=y.alphaMap,n(y.alphaMap,x.alphaMapTransform)),y.alphaTest>0&&(x.alphaTest.value=y.alphaTest)}function d(x,y){x.specular.value.copy(y.specular),x.shininess.value=Math.max(y.shininess,1e-4)}function f(x,y){y.gradientMap&&(x.gradientMap.value=y.gradientMap)}function p(x,y){x.metalness.value=y.metalness,y.metalnessMap&&(x.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,x.metalnessMapTransform)),x.roughness.value=y.roughness,y.roughnessMap&&(x.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,x.roughnessMapTransform)),e.get(y).envMap&&(x.envMapIntensity.value=y.envMapIntensity)}function g(x,y,E){x.ior.value=y.ior,y.sheen>0&&(x.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),x.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(x.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,x.sheenColorMapTransform)),y.sheenRoughnessMap&&(x.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,x.sheenRoughnessMapTransform))),y.clearcoat>0&&(x.clearcoat.value=y.clearcoat,x.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(x.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,x.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(x.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,x.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(x.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,x.clearcoatNormalMapTransform),x.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===cs&&x.clearcoatNormalScale.value.negate())),y.iridescence>0&&(x.iridescence.value=y.iridescence,x.iridescenceIOR.value=y.iridescenceIOR,x.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],x.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(x.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,x.iridescenceMapTransform)),y.iridescenceThicknessMap&&(x.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,x.iridescenceThicknessMapTransform))),y.transmission>0&&(x.transmission.value=y.transmission,x.transmissionSamplerMap.value=E.texture,x.transmissionSamplerSize.value.set(E.width,E.height),y.transmissionMap&&(x.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,x.transmissionMapTransform)),x.thickness.value=y.thickness,y.thicknessMap&&(x.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,x.thicknessMapTransform)),x.attenuationDistance.value=y.attenuationDistance,x.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(x.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(x.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,x.anisotropyMapTransform))),x.specularIntensity.value=y.specularIntensity,x.specularColor.value.copy(y.specularColor),y.specularColorMap&&(x.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,x.specularColorMapTransform)),y.specularIntensityMap&&(x.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,x.specularIntensityMapTransform))}function b(x,y){y.matcap&&(x.matcap.value=y.matcap)}function v(x,y){const E=e.get(y).light;x.referencePosition.value.setFromMatrixPosition(E.matrixWorld),x.nearDistance.value=E.shadow.camera.near,x.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function uze(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(E,w){const A=w.program;r.uniformBlockBinding(E,A)}function u(E,w){let A=i[E.id];A===void 0&&(b(E),A=d(E),i[E.id]=A,E.addEventListener("dispose",x));const N=w.program;r.updateUBOMapping(E,N);const C=e.render.frame;a[E.id]!==C&&(p(E),a[E.id]=C)}function d(E){const w=f();E.__bindingPointIndex=w;const A=t.createBuffer(),N=E.__size,C=E.usage;return t.bindBuffer(t.UNIFORM_BUFFER,A),t.bufferData(t.UNIFORM_BUFFER,N,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,w,A),A}function f(){for(let E=0;E<l;E++)if(o.indexOf(E)===-1)return o.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(E){const w=i[E.id],A=E.uniforms,N=E.__cache;t.bindBuffer(t.UNIFORM_BUFFER,w);for(let C=0,T=A.length;C<T;C++){const D=A[C];if(g(D,C,N)===!0){const k=D.__offset,P=Array.isArray(D.value)?D.value:[D.value];let z=0;for(let L=0;L<P.length;L++){const X=P[L],R=v(X);typeof X=="number"?(D.__data[0]=X,t.bufferSubData(t.UNIFORM_BUFFER,k+z,D.__data)):X.isMatrix3?(D.__data[0]=X.elements[0],D.__data[1]=X.elements[1],D.__data[2]=X.elements[2],D.__data[3]=X.elements[0],D.__data[4]=X.elements[3],D.__data[5]=X.elements[4],D.__data[6]=X.elements[5],D.__data[7]=X.elements[0],D.__data[8]=X.elements[6],D.__data[9]=X.elements[7],D.__data[10]=X.elements[8],D.__data[11]=X.elements[0]):(X.toArray(D.__data,z),z+=R.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,k,D.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function g(E,w,A){const N=E.value;if(A[w]===void 0){if(typeof N=="number")A[w]=N;else{const C=Array.isArray(N)?N:[N],T=[];for(let D=0;D<C.length;D++)T.push(C[D].clone());A[w]=T}return!0}else if(typeof N=="number"){if(A[w]!==N)return A[w]=N,!0}else{const C=Array.isArray(A[w])?A[w]:[A[w]],T=Array.isArray(N)?N:[N];for(let D=0;D<C.length;D++){const k=C[D];if(k.equals(T[D])===!1)return k.copy(T[D]),!0}}return!1}function b(E){const w=E.uniforms;let A=0;const N=16;let C=0;for(let T=0,D=w.length;T<D;T++){const k=w[T],P={boundary:0,storage:0},z=Array.isArray(k.value)?k.value:[k.value];for(let L=0,X=z.length;L<X;L++){const R=z[L],Y=v(R);P.boundary+=Y.boundary,P.storage+=Y.storage}if(k.__data=new Float32Array(P.storage/Float32Array.BYTES_PER_ELEMENT),k.__offset=A,T>0){C=A%N;const L=N-C;C!==0&&L-P.boundary<0&&(A+=N-C,k.__offset=A)}A+=P.storage}return C=A%N,C>0&&(A+=N-C),E.__size=A,E.__cache={},this}function v(E){const w={boundary:0,storage:0};return typeof E=="number"?(w.boundary=4,w.storage=4):E.isVector2?(w.boundary=8,w.storage=8):E.isVector3||E.isColor?(w.boundary=16,w.storage=12):E.isVector4?(w.boundary=16,w.storage=16):E.isMatrix3?(w.boundary=48,w.storage=48):E.isMatrix4?(w.boundary=64,w.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),w}function x(E){const w=E.target;w.removeEventListener("dispose",x);const A=o.indexOf(w.__bindingPointIndex);o.splice(A,1),t.deleteBuffer(i[w.id]),delete i[w.id],delete a[w.id]}function y(){for(const E in i)t.deleteBuffer(i[E]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}class kP{constructor(e={}){const{canvas:n=oLe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!1}=e;this.isWebGLRenderer=!0;let p;r!==null?p=r.getContextAttributes().alpha:p=o;const g=new Uint32Array(4),b=new Int32Array(4);let v=null,x=null;const y=[],E=[];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=ua,this._useLegacyLights=!1,this.toneMapping=Ed,this.toneMappingExposure=1;const w=this;let A=!1,N=0,C=0,T=null,D=-1,k=null;const P=new hr,z=new hr;let L=null;const X=new Yt(0);let R=0,Y=n.width,J=n.height,G=1,W=null,ee=null;const K=new hr(0,0,Y,J),F=new hr(0,0,Y,J);let q=!1;const ne=new TM;let re=!1,se=!1,de=null;const pe=new vr,Ce=new rn,oe=new ze,ae={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ge(){return T===null?G:1}let ue=r;function Le(ye,$e){for(let Ye=0;Ye<ye.length;Ye++){const nt=ye[Ye],ke=n.getContext(nt,$e);if(ke!==null)return ke}return null}try{const ye={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${EM}`),n.addEventListener("webglcontextlost",He,!1),n.addEventListener("webglcontextrestored",ve,!1),n.addEventListener("webglcontextcreationerror",Be,!1),ue===null){const $e=["webgl2","webgl","experimental-webgl"];if(w.isWebGL1Renderer===!0&&$e.shift(),ue=Le($e,ye),ue===null)throw Le($e)?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(ye){throw console.error("THREE.WebGLRenderer: "+ye.message),ye}let V,$,Z,B,U,Q,Me,Te,fe,H,I,ce,we,Se,_e,st,Ve,it,ct,Fe,me,Ke,qe,Qe;function ut(){V=new _Fe(ue),$=new mFe(ue,V,e),V.init($),Ke=new aze(ue,V,$),Z=new rze(ue,V,$),B=new MFe(ue),U=new HUe,Q=new ize(ue,V,Z,U,$,Ke,B),Me=new gFe(w),Te=new vFe(w),fe=new jLe(ue,$),qe=new hFe(ue,V,fe,$),H=new wFe(ue,fe,B,qe),I=new TFe(ue,H,fe,B),ct=new AFe(ue,$,Q),st=new pFe(U),ce=new $Ue(w,Me,Te,V,$,qe,st),we=new cze(w,U),Se=new GUe,_e=new QUe(V,$),it=new dFe(w,Me,Te,Z,I,p,c),Ve=new nze(w,I,$),Qe=new uze(ue,B,$,Z),Fe=new fFe(ue,V,B,$),me=new SFe(ue,V,B,$),B.programs=ce.programs,w.capabilities=$,w.extensions=V,w.properties=U,w.renderLists=Se,w.shadowMap=Ve,w.state=Z,w.info=B}ut();const ie=new lze(w,ue);this.xr=ie,this.getContext=function(){return ue},this.getContextAttributes=function(){return ue.getContextAttributes()},this.forceContextLoss=function(){const ye=V.get("WEBGL_lose_context");ye&&ye.loseContext()},this.forceContextRestore=function(){const ye=V.get("WEBGL_lose_context");ye&&ye.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(ye){ye!==void 0&&(G=ye,this.setSize(Y,J,!1))},this.getSize=function(ye){return ye.set(Y,J)},this.setSize=function(ye,$e,Ye=!0){if(ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Y=ye,J=$e,n.width=Math.floor(ye*G),n.height=Math.floor($e*G),Ye===!0&&(n.style.width=ye+"px",n.style.height=$e+"px"),this.setViewport(0,0,ye,$e)},this.getDrawingBufferSize=function(ye){return ye.set(Y*G,J*G).floor()},this.setDrawingBufferSize=function(ye,$e,Ye){Y=ye,J=$e,G=Ye,n.width=Math.floor(ye*Ye),n.height=Math.floor($e*Ye),this.setViewport(0,0,ye,$e)},this.getCurrentViewport=function(ye){return ye.copy(P)},this.getViewport=function(ye){return ye.copy(K)},this.setViewport=function(ye,$e,Ye,nt){ye.isVector4?K.set(ye.x,ye.y,ye.z,ye.w):K.set(ye,$e,Ye,nt),Z.viewport(P.copy(K).multiplyScalar(G).floor())},this.getScissor=function(ye){return ye.copy(F)},this.setScissor=function(ye,$e,Ye,nt){ye.isVector4?F.set(ye.x,ye.y,ye.z,ye.w):F.set(ye,$e,Ye,nt),Z.scissor(z.copy(F).multiplyScalar(G).floor())},this.getScissorTest=function(){return q},this.setScissorTest=function(ye){Z.setScissorTest(q=ye)},this.setOpaqueSort=function(ye){W=ye},this.setTransparentSort=function(ye){ee=ye},this.getClearColor=function(ye){return ye.copy(it.getClearColor())},this.setClearColor=function(){it.setClearColor.apply(it,arguments)},this.getClearAlpha=function(){return it.getClearAlpha()},this.setClearAlpha=function(){it.setClearAlpha.apply(it,arguments)},this.clear=function(ye=!0,$e=!0,Ye=!0){let nt=0;if(ye){let ke=!1;if(T!==null){const xe=T.texture.format;ke=xe===kZ||xe===CZ||xe===TZ}if(ke){const xe=T.texture.type,le=xe===Nd||xe===md||xe===rO||xe===tf||xe===NZ||xe===AZ,Ae=it.getClearColor(),Oe=it.getClearAlpha(),Ie=Ae.r,Re=Ae.g,Je=Ae.b;le?(g[0]=Ie,g[1]=Re,g[2]=Je,g[3]=Oe,ue.clearBufferuiv(ue.COLOR,0,g)):(b[0]=Ie,b[1]=Re,b[2]=Je,b[3]=Oe,ue.clearBufferiv(ue.COLOR,0,b))}else nt|=ue.COLOR_BUFFER_BIT}$e&&(nt|=ue.DEPTH_BUFFER_BIT),Ye&&(nt|=ue.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ue.clear(nt)},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",He,!1),n.removeEventListener("webglcontextrestored",ve,!1),n.removeEventListener("webglcontextcreationerror",Be,!1),Se.dispose(),_e.dispose(),U.dispose(),Me.dispose(),Te.dispose(),I.dispose(),qe.dispose(),Qe.dispose(),ce.dispose(),ie.dispose(),ie.removeEventListener("sessionstart",Xt),ie.removeEventListener("sessionend",Lt),de&&(de.dispose(),de=null),Sn.stop()};function He(ye){ye.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function ve(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const ye=B.autoReset,$e=Ve.enabled,Ye=Ve.autoUpdate,nt=Ve.needsUpdate,ke=Ve.type;ut(),B.autoReset=ye,Ve.enabled=$e,Ve.autoUpdate=Ye,Ve.needsUpdate=nt,Ve.type=ke}function Be(ye){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ye.statusMessage)}function je(ye){const $e=ye.target;$e.removeEventListener("dispose",je),Ne($e)}function Ne(ye){Xe(ye),U.remove(ye)}function Xe(ye){const $e=U.get(ye).programs;$e!==void 0&&($e.forEach(function(Ye){ce.releaseProgram(Ye)}),ye.isShaderMaterial&&ce.releaseShaderCache(ye))}this.renderBufferDirect=function(ye,$e,Ye,nt,ke,xe){$e===null&&($e=ae);const le=ke.isMesh&&ke.matrixWorld.determinant()<0,Ae=qt(ye,$e,Ye,nt,ke);Z.setMaterial(nt,le);let Oe=Ye.index,Ie=1;if(nt.wireframe===!0){if(Oe=H.getWireframeAttribute(Ye),Oe===void 0)return;Ie=2}const Re=Ye.drawRange,Je=Ye.attributes.position;let xt=Re.start*Ie,Nt=(Re.start+Re.count)*Ie;xe!==null&&(xt=Math.max(xt,xe.start*Ie),Nt=Math.min(Nt,(xe.start+xe.count)*Ie)),Oe!==null?(xt=Math.max(xt,0),Nt=Math.min(Nt,Oe.count)):Je!=null&&(xt=Math.max(xt,0),Nt=Math.min(Nt,Je.count));const Et=Nt-xt;if(Et<0||Et===1/0)return;qe.setup(ke,nt,Ae,Ye,Oe);let Ct,jt=Fe;if(Oe!==null&&(Ct=fe.get(Oe),jt=me,jt.setIndex(Ct)),ke.isMesh)nt.wireframe===!0?(Z.setLineWidth(nt.wireframeLinewidth*ge()),jt.setMode(ue.LINES)):jt.setMode(ue.TRIANGLES);else if(ke.isLine){let wt=nt.linewidth;wt===void 0&&(wt=1),Z.setLineWidth(wt*ge()),ke.isLineSegments?jt.setMode(ue.LINES):ke.isLineLoop?jt.setMode(ue.LINE_LOOP):jt.setMode(ue.LINE_STRIP)}else ke.isPoints?jt.setMode(ue.POINTS):ke.isSprite&&jt.setMode(ue.TRIANGLES);if(ke.isBatchedMesh)jt.renderMultiDraw(ke._multiDrawStarts,ke._multiDrawCounts,ke._multiDrawCount);else if(ke.isInstancedMesh)jt.renderInstances(xt,Et,ke.count);else if(Ye.isInstancedBufferGeometry){const wt=Ye._maxInstanceCount!==void 0?Ye._maxInstanceCount:1/0,tn=Math.min(Ye.instanceCount,wt);jt.renderInstances(xt,Et,tn)}else jt.render(xt,Et)};function mt(ye,$e,Ye){ye.transparent===!0&&ye.side===jc&&ye.forceSinglePass===!1?(ye.side=cs,ye.needsUpdate=!0,qn(ye,$e,Ye),ye.side=Bd,ye.needsUpdate=!0,qn(ye,$e,Ye),ye.side=jc):qn(ye,$e,Ye)}this.compile=function(ye,$e,Ye=null){Ye===null&&(Ye=ye),x=_e.get(Ye),x.init(),E.push(x),Ye.traverseVisible(function(ke){ke.isLight&&ke.layers.test($e.layers)&&(x.pushLight(ke),ke.castShadow&&x.pushShadow(ke))}),ye!==Ye&&ye.traverseVisible(function(ke){ke.isLight&&ke.layers.test($e.layers)&&(x.pushLight(ke),ke.castShadow&&x.pushShadow(ke))}),x.setupLights(w._useLegacyLights);const nt=new Set;return ye.traverse(function(ke){const xe=ke.material;if(xe)if(Array.isArray(xe))for(let le=0;le<xe.length;le++){const Ae=xe[le];mt(Ae,Ye,ke),nt.add(Ae)}else mt(xe,Ye,ke),nt.add(xe)}),E.pop(),x=null,nt},this.compileAsync=function(ye,$e,Ye=null){const nt=this.compile(ye,$e,Ye);return new Promise(ke=>{function xe(){if(nt.forEach(function(le){U.get(le).currentProgram.isReady()&&nt.delete(le)}),nt.size===0){ke(ye);return}setTimeout(xe,10)}V.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let At=null;function Rt(ye){At&&At(ye)}function Xt(){Sn.stop()}function Lt(){Sn.start()}const Sn=new KZ;Sn.setAnimationLoop(Rt),typeof self<"u"&&Sn.setContext(self),this.setAnimationLoop=function(ye){At=ye,ie.setAnimationLoop(ye),ye===null?Sn.stop():Sn.start()},ie.addEventListener("sessionstart",Xt),ie.addEventListener("sessionend",Lt),this.render=function(ye,$e){if($e!==void 0&&$e.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;ye.matrixWorldAutoUpdate===!0&&ye.updateMatrixWorld(),$e.parent===null&&$e.matrixWorldAutoUpdate===!0&&$e.updateMatrixWorld(),ie.enabled===!0&&ie.isPresenting===!0&&(ie.cameraAutoUpdate===!0&&ie.updateCamera($e),$e=ie.getCamera()),ye.isScene===!0&&ye.onBeforeRender(w,ye,$e,T),x=_e.get(ye,E.length),x.init(),E.push(x),pe.multiplyMatrices($e.projectionMatrix,$e.matrixWorldInverse),ne.setFromProjectionMatrix(pe),se=this.localClippingEnabled,re=st.init(this.clippingPlanes,se),v=Se.get(ye,y.length),v.init(),y.push(v),$t(ye,$e,0,w.sortObjects),v.finish(),w.sortObjects===!0&&v.sort(W,ee),this.info.render.frame++,re===!0&&st.beginShadows();const Ye=x.state.shadowsArray;if(Ve.render(Ye,ye,$e),re===!0&&st.endShadows(),this.info.autoReset===!0&&this.info.reset(),it.render(v,ye),x.setupLights(w._useLegacyLights),$e.isArrayCamera){const nt=$e.cameras;for(let ke=0,xe=nt.length;ke<xe;ke++){const le=nt[ke];Cn(v,ye,le,le.viewport)}}else Cn(v,ye,$e);T!==null&&(Q.updateMultisampleRenderTarget(T),Q.updateRenderTargetMipmap(T)),ye.isScene===!0&&ye.onAfterRender(w,ye,$e),qe.resetDefaultState(),D=-1,k=null,E.pop(),E.length>0?x=E[E.length-1]:x=null,y.pop(),y.length>0?v=y[y.length-1]:v=null};function $t(ye,$e,Ye,nt){if(ye.visible===!1)return;if(ye.layers.test($e.layers)){if(ye.isGroup)Ye=ye.renderOrder;else if(ye.isLOD)ye.autoUpdate===!0&&ye.update($e);else if(ye.isLight)x.pushLight(ye),ye.castShadow&&x.pushShadow(ye);else if(ye.isSprite){if(!ye.frustumCulled||ne.intersectsSprite(ye)){nt&&oe.setFromMatrixPosition(ye.matrixWorld).applyMatrix4(pe);const le=I.update(ye),Ae=ye.material;Ae.visible&&v.push(ye,le,Ae,Ye,oe.z,null)}}else if((ye.isMesh||ye.isLine||ye.isPoints)&&(!ye.frustumCulled||ne.intersectsObject(ye))){const le=I.update(ye),Ae=ye.material;if(nt&&(ye.boundingSphere!==void 0?(ye.boundingSphere===null&&ye.computeBoundingSphere(),oe.copy(ye.boundingSphere.center)):(le.boundingSphere===null&&le.computeBoundingSphere(),oe.copy(le.boundingSphere.center)),oe.applyMatrix4(ye.matrixWorld).applyMatrix4(pe)),Array.isArray(Ae)){const Oe=le.groups;for(let Ie=0,Re=Oe.length;Ie<Re;Ie++){const Je=Oe[Ie],xt=Ae[Je.materialIndex];xt&&xt.visible&&v.push(ye,le,xt,Ye,oe.z,Je)}}else Ae.visible&&v.push(ye,le,Ae,Ye,oe.z,null)}}const xe=ye.children;for(let le=0,Ae=xe.length;le<Ae;le++)$t(xe[le],$e,Ye,nt)}function Cn(ye,$e,Ye,nt){const ke=ye.opaque,xe=ye.transmissive,le=ye.transparent;x.setupLightsView(Ye),re===!0&&st.setGlobalState(w.clippingPlanes,Ye),xe.length>0&&nr(ke,xe,$e,Ye),nt&&Z.viewport(P.copy(nt)),ke.length>0&&Hn(ke,$e,Ye),xe.length>0&&Hn(xe,$e,Ye),le.length>0&&Hn(le,$e,Ye),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function nr(ye,$e,Ye,nt){if((Ye.isScene===!0?Ye.overrideMaterial:null)!==null)return;const xe=$.isWebGL2;de===null&&(de=new kf(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?y0:Nd,minFilter:b0,samples:xe?4:0})),w.getDrawingBufferSize(Ce),xe?de.setSize(Ce.x,Ce.y):de.setSize(mS(Ce.x),mS(Ce.y));const le=w.getRenderTarget();w.setRenderTarget(de),w.getClearColor(X),R=w.getClearAlpha(),R<1&&w.setClearColor(16777215,.5),w.clear();const Ae=w.toneMapping;w.toneMapping=Ed,Hn(ye,Ye,nt),Q.updateMultisampleRenderTarget(de),Q.updateRenderTargetMipmap(de);let Oe=!1;for(let Ie=0,Re=$e.length;Ie<Re;Ie++){const Je=$e[Ie],xt=Je.object,Nt=Je.geometry,Et=Je.material,Ct=Je.group;if(Et.side===jc&&xt.layers.test(nt.layers)){const jt=Et.side;Et.side=cs,Et.needsUpdate=!0,Jr(xt,Ye,nt,Nt,Et,Ct),Et.side=jt,Et.needsUpdate=!0,Oe=!0}}Oe===!0&&(Q.updateMultisampleRenderTarget(de),Q.updateRenderTargetMipmap(de)),w.setRenderTarget(le),w.setClearColor(X,R),w.toneMapping=Ae}function Hn(ye,$e,Ye){const nt=$e.isScene===!0?$e.overrideMaterial:null;for(let ke=0,xe=ye.length;ke<xe;ke++){const le=ye[ke],Ae=le.object,Oe=le.geometry,Ie=nt===null?le.material:nt,Re=le.group;Ae.layers.test(Ye.layers)&&Jr(Ae,$e,Ye,Oe,Ie,Re)}}function Jr(ye,$e,Ye,nt,ke,xe){ye.onBeforeRender(w,$e,Ye,nt,ke,xe),ye.modelViewMatrix.multiplyMatrices(Ye.matrixWorldInverse,ye.matrixWorld),ye.normalMatrix.getNormalMatrix(ye.modelViewMatrix),ke.onBeforeRender(w,$e,Ye,nt,ye,xe),ke.transparent===!0&&ke.side===jc&&ke.forceSinglePass===!1?(ke.side=cs,ke.needsUpdate=!0,w.renderBufferDirect(Ye,$e,nt,ke,ye,xe),ke.side=Bd,ke.needsUpdate=!0,w.renderBufferDirect(Ye,$e,nt,ke,ye,xe),ke.side=jc):w.renderBufferDirect(Ye,$e,nt,ke,ye,xe),ye.onAfterRender(w,$e,Ye,nt,ke,xe)}function qn(ye,$e,Ye){$e.isScene!==!0&&($e=ae);const nt=U.get(ye),ke=x.state.lights,xe=x.state.shadowsArray,le=ke.state.version,Ae=ce.getParameters(ye,ke.state,xe,$e,Ye),Oe=ce.getProgramCacheKey(Ae);let Ie=nt.programs;nt.environment=ye.isMeshStandardMaterial?$e.environment:null,nt.fog=$e.fog,nt.envMap=(ye.isMeshStandardMaterial?Te:Me).get(ye.envMap||nt.environment),Ie===void 0&&(ye.addEventListener("dispose",je),Ie=new Map,nt.programs=Ie);let Re=Ie.get(Oe);if(Re!==void 0){if(nt.currentProgram===Re&&nt.lightsStateVersion===le)return Ft(ye,Ae),Re}else Ae.uniforms=ce.getUniforms(ye),ye.onBuild(Ye,Ae,w),ye.onBeforeCompile(Ae,w),Re=ce.acquireProgram(Ae,Oe),Ie.set(Oe,Re),nt.uniforms=Ae.uniforms;const Je=nt.uniforms;return(!ye.isShaderMaterial&&!ye.isRawShaderMaterial||ye.clipping===!0)&&(Je.clippingPlanes=st.uniform),Ft(ye,Ae),nt.needsLights=en(ye),nt.lightsStateVersion=le,nt.needsLights&&(Je.ambientLightColor.value=ke.state.ambient,Je.lightProbe.value=ke.state.probe,Je.directionalLights.value=ke.state.directional,Je.directionalLightShadows.value=ke.state.directionalShadow,Je.spotLights.value=ke.state.spot,Je.spotLightShadows.value=ke.state.spotShadow,Je.rectAreaLights.value=ke.state.rectArea,Je.ltc_1.value=ke.state.rectAreaLTC1,Je.ltc_2.value=ke.state.rectAreaLTC2,Je.pointLights.value=ke.state.point,Je.pointLightShadows.value=ke.state.pointShadow,Je.hemisphereLights.value=ke.state.hemi,Je.directionalShadowMap.value=ke.state.directionalShadowMap,Je.directionalShadowMatrix.value=ke.state.directionalShadowMatrix,Je.spotShadowMap.value=ke.state.spotShadowMap,Je.spotLightMatrix.value=ke.state.spotLightMatrix,Je.spotLightMap.value=ke.state.spotLightMap,Je.pointShadowMap.value=ke.state.pointShadowMap,Je.pointShadowMatrix.value=ke.state.pointShadowMatrix),nt.currentProgram=Re,nt.uniformsList=null,Re}function yt(ye){if(ye.uniformsList===null){const $e=ye.currentProgram.getUniforms();ye.uniformsList=H1.seqWithValue($e.seq,ye.uniforms)}return ye.uniformsList}function Ft(ye,$e){const Ye=U.get(ye);Ye.outputColorSpace=$e.outputColorSpace,Ye.batching=$e.batching,Ye.instancing=$e.instancing,Ye.instancingColor=$e.instancingColor,Ye.skinning=$e.skinning,Ye.morphTargets=$e.morphTargets,Ye.morphNormals=$e.morphNormals,Ye.morphColors=$e.morphColors,Ye.morphTargetsCount=$e.morphTargetsCount,Ye.numClippingPlanes=$e.numClippingPlanes,Ye.numIntersection=$e.numClipIntersection,Ye.vertexAlphas=$e.vertexAlphas,Ye.vertexTangents=$e.vertexTangents,Ye.toneMapping=$e.toneMapping}function qt(ye,$e,Ye,nt,ke){$e.isScene!==!0&&($e=ae),Q.resetTextureUnits();const xe=$e.fog,le=nt.isMeshStandardMaterial?$e.environment:null,Ae=T===null?w.outputColorSpace:T.isXRRenderTarget===!0?T.texture.colorSpace:ou,Oe=(nt.isMeshStandardMaterial?Te:Me).get(nt.envMap||le),Ie=nt.vertexColors===!0&&!!Ye.attributes.color&&Ye.attributes.color.itemSize===4,Re=!!Ye.attributes.tangent&&(!!nt.normalMap||nt.anisotropy>0),Je=!!Ye.morphAttributes.position,xt=!!Ye.morphAttributes.normal,Nt=!!Ye.morphAttributes.color;let Et=Ed;nt.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(Et=w.toneMapping);const Ct=Ye.morphAttributes.position||Ye.morphAttributes.normal||Ye.morphAttributes.color,jt=Ct!==void 0?Ct.length:0,wt=U.get(nt),tn=x.state.lights;if(re===!0&&(se===!0||ye!==k)){const ei=ye===k&&nt.id===D;st.setState(nt,ye,ei)}let Vt=!1;nt.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==tn.state.version||wt.outputColorSpace!==Ae||ke.isBatchedMesh&&wt.batching===!1||!ke.isBatchedMesh&&wt.batching===!0||ke.isInstancedMesh&&wt.instancing===!1||!ke.isInstancedMesh&&wt.instancing===!0||ke.isSkinnedMesh&&wt.skinning===!1||!ke.isSkinnedMesh&&wt.skinning===!0||ke.isInstancedMesh&&wt.instancingColor===!0&&ke.instanceColor===null||ke.isInstancedMesh&&wt.instancingColor===!1&&ke.instanceColor!==null||wt.envMap!==Oe||nt.fog===!0&&wt.fog!==xe||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==st.numPlanes||wt.numIntersection!==st.numIntersection)||wt.vertexAlphas!==Ie||wt.vertexTangents!==Re||wt.morphTargets!==Je||wt.morphNormals!==xt||wt.morphColors!==Nt||wt.toneMapping!==Et||$.isWebGL2===!0&&wt.morphTargetsCount!==jt)&&(Vt=!0):(Vt=!0,wt.__version=nt.version);let hn=wt.currentProgram;Vt===!0&&(hn=qn(nt,$e,ke));let _n=!1,kn=!1,Ht=!1;const sn=hn.getUniforms(),cn=wt.uniforms;if(Z.useProgram(hn.program)&&(_n=!0,kn=!0,Ht=!0),nt.id!==D&&(D=nt.id,kn=!0),_n||k!==ye){sn.setValue(ue,"projectionMatrix",ye.projectionMatrix),sn.setValue(ue,"viewMatrix",ye.matrixWorldInverse);const ei=sn.map.cameraPosition;ei!==void 0&&ei.setValue(ue,oe.setFromMatrixPosition(ye.matrixWorld)),$.logarithmicDepthBuffer&&sn.setValue(ue,"logDepthBufFC",2/(Math.log(ye.far+1)/Math.LN2)),(nt.isMeshPhongMaterial||nt.isMeshToonMaterial||nt.isMeshLambertMaterial||nt.isMeshBasicMaterial||nt.isMeshStandardMaterial||nt.isShaderMaterial)&&sn.setValue(ue,"isOrthographic",ye.isOrthographicCamera===!0),k!==ye&&(k=ye,kn=!0,Ht=!0)}if(ke.isSkinnedMesh){sn.setOptional(ue,ke,"bindMatrix"),sn.setOptional(ue,ke,"bindMatrixInverse");const ei=ke.skeleton;ei&&($.floatVertexTextures?(ei.boneTexture===null&&ei.computeBoneTexture(),sn.setValue(ue,"boneTexture",ei.boneTexture,Q)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ke.isBatchedMesh&&(sn.setOptional(ue,ke,"batchingTexture"),sn.setValue(ue,"batchingTexture",ke._matricesTexture,Q));const Ur=Ye.morphAttributes;if((Ur.position!==void 0||Ur.normal!==void 0||Ur.color!==void 0&&$.isWebGL2===!0)&&ct.update(ke,Ye,hn),(kn||wt.receiveShadow!==ke.receiveShadow)&&(wt.receiveShadow=ke.receiveShadow,sn.setValue(ue,"receiveShadow",ke.receiveShadow)),nt.isMeshGouraudMaterial&&nt.envMap!==null&&(cn.envMap.value=Oe,cn.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),kn&&(sn.setValue(ue,"toneMappingExposure",w.toneMappingExposure),wt.needsLights&>(cn,Ht),xe&&nt.fog===!0&&we.refreshFogUniforms(cn,xe),we.refreshMaterialUniforms(cn,nt,G,J,de),H1.upload(ue,yt(wt),cn,Q)),nt.isShaderMaterial&&nt.uniformsNeedUpdate===!0&&(H1.upload(ue,yt(wt),cn,Q),nt.uniformsNeedUpdate=!1),nt.isSpriteMaterial&&sn.setValue(ue,"center",ke.center),sn.setValue(ue,"modelViewMatrix",ke.modelViewMatrix),sn.setValue(ue,"normalMatrix",ke.normalMatrix),sn.setValue(ue,"modelMatrix",ke.matrixWorld),nt.isShaderMaterial||nt.isRawShaderMaterial){const ei=nt.uniformsGroups;for(let Vn=0,jo=ei.length;Vn<jo;Vn++)if($.isWebGL2){const Kn=ei[Vn];Qe.update(Kn,hn),Qe.bind(Kn,hn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return hn}function gt(ye,$e){ye.ambientLightColor.needsUpdate=$e,ye.lightProbe.needsUpdate=$e,ye.directionalLights.needsUpdate=$e,ye.directionalLightShadows.needsUpdate=$e,ye.pointLights.needsUpdate=$e,ye.pointLightShadows.needsUpdate=$e,ye.spotLights.needsUpdate=$e,ye.spotLightShadows.needsUpdate=$e,ye.rectAreaLights.needsUpdate=$e,ye.hemisphereLights.needsUpdate=$e}function en(ye){return ye.isMeshLambertMaterial||ye.isMeshToonMaterial||ye.isMeshPhongMaterial||ye.isMeshStandardMaterial||ye.isShadowMaterial||ye.isShaderMaterial&&ye.lights===!0}this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(ye,$e,Ye){U.get(ye.texture).__webglTexture=$e,U.get(ye.depthTexture).__webglTexture=Ye;const nt=U.get(ye);nt.__hasExternalTextures=!0,nt.__hasExternalTextures&&(nt.__autoAllocateDepthBuffer=Ye===void 0,nt.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),nt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ye,$e){const Ye=U.get(ye);Ye.__webglFramebuffer=$e,Ye.__useDefaultFramebuffer=$e===void 0},this.setRenderTarget=function(ye,$e=0,Ye=0){T=ye,N=$e,C=Ye;let nt=!0,ke=null,xe=!1,le=!1;if(ye){const Oe=U.get(ye);Oe.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(ue.FRAMEBUFFER,null),nt=!1):Oe.__webglFramebuffer===void 0?Q.setupRenderTarget(ye):Oe.__hasExternalTextures&&Q.rebindTextures(ye,U.get(ye.texture).__webglTexture,U.get(ye.depthTexture).__webglTexture);const Ie=ye.texture;(Ie.isData3DTexture||Ie.isDataArrayTexture||Ie.isCompressedArrayTexture)&&(le=!0);const Re=U.get(ye).__webglFramebuffer;ye.isWebGLCubeRenderTarget?(Array.isArray(Re[$e])?ke=Re[$e][Ye]:ke=Re[$e],xe=!0):$.isWebGL2&&ye.samples>0&&Q.useMultisampledRTT(ye)===!1?ke=U.get(ye).__webglMultisampledFramebuffer:Array.isArray(Re)?ke=Re[Ye]:ke=Re,P.copy(ye.viewport),z.copy(ye.scissor),L=ye.scissorTest}else P.copy(K).multiplyScalar(G).floor(),z.copy(F).multiplyScalar(G).floor(),L=q;if(Z.bindFramebuffer(ue.FRAMEBUFFER,ke)&&$.drawBuffers&&nt&&Z.drawBuffers(ye,ke),Z.viewport(P),Z.scissor(z),Z.setScissorTest(L),xe){const Oe=U.get(ye.texture);ue.framebufferTexture2D(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,ue.TEXTURE_CUBE_MAP_POSITIVE_X+$e,Oe.__webglTexture,Ye)}else if(le){const Oe=U.get(ye.texture),Ie=$e||0;ue.framebufferTextureLayer(ue.FRAMEBUFFER,ue.COLOR_ATTACHMENT0,Oe.__webglTexture,Ye||0,Ie)}D=-1},this.readRenderTargetPixels=function(ye,$e,Ye,nt,ke,xe,le){if(!(ye&&ye.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=U.get(ye).__webglFramebuffer;if(ye.isWebGLCubeRenderTarget&&le!==void 0&&(Ae=Ae[le]),Ae){Z.bindFramebuffer(ue.FRAMEBUFFER,Ae);try{const Oe=ye.texture,Ie=Oe.format,Re=Oe.type;if(Ie!==po&&Ke.convert(Ie)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Je=Re===y0&&(V.has("EXT_color_buffer_half_float")||$.isWebGL2&&V.has("EXT_color_buffer_float"));if(Re!==Nd&&Ke.convert(Re)!==ue.getParameter(ue.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Re===Ic&&($.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!Je){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$e>=0&&$e<=ye.width-nt&&Ye>=0&&Ye<=ye.height-ke&&ue.readPixels($e,Ye,nt,ke,Ke.convert(Ie),Ke.convert(Re),xe)}finally{const Oe=T!==null?U.get(T).__webglFramebuffer:null;Z.bindFramebuffer(ue.FRAMEBUFFER,Oe)}}},this.copyFramebufferToTexture=function(ye,$e,Ye=0){const nt=Math.pow(2,-Ye),ke=Math.floor($e.image.width*nt),xe=Math.floor($e.image.height*nt);Q.setTexture2D($e,0),ue.copyTexSubImage2D(ue.TEXTURE_2D,Ye,0,0,ye.x,ye.y,ke,xe),Z.unbindTexture()},this.copyTextureToTexture=function(ye,$e,Ye,nt=0){const ke=$e.image.width,xe=$e.image.height,le=Ke.convert(Ye.format),Ae=Ke.convert(Ye.type);Q.setTexture2D(Ye,0),ue.pixelStorei(ue.UNPACK_FLIP_Y_WEBGL,Ye.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ye.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,Ye.unpackAlignment),$e.isDataTexture?ue.texSubImage2D(ue.TEXTURE_2D,nt,ye.x,ye.y,ke,xe,le,Ae,$e.image.data):$e.isCompressedTexture?ue.compressedTexSubImage2D(ue.TEXTURE_2D,nt,ye.x,ye.y,$e.mipmaps[0].width,$e.mipmaps[0].height,le,$e.mipmaps[0].data):ue.texSubImage2D(ue.TEXTURE_2D,nt,ye.x,ye.y,le,Ae,$e.image),nt===0&&Ye.generateMipmaps&&ue.generateMipmap(ue.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(ye,$e,Ye,nt,ke=0){if(w.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const xe=ye.max.x-ye.min.x+1,le=ye.max.y-ye.min.y+1,Ae=ye.max.z-ye.min.z+1,Oe=Ke.convert(nt.format),Ie=Ke.convert(nt.type);let Re;if(nt.isData3DTexture)Q.setTexture3D(nt,0),Re=ue.TEXTURE_3D;else if(nt.isDataArrayTexture)Q.setTexture2DArray(nt,0),Re=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,nt.flipY),ue.pixelStorei(ue.UNPACK_PREMULTIPLY_ALPHA_WEBGL,nt.premultiplyAlpha),ue.pixelStorei(ue.UNPACK_ALIGNMENT,nt.unpackAlignment);const Je=ue.getParameter(ue.UNPACK_ROW_LENGTH),xt=ue.getParameter(ue.UNPACK_IMAGE_HEIGHT),Nt=ue.getParameter(ue.UNPACK_SKIP_PIXELS),Et=ue.getParameter(ue.UNPACK_SKIP_ROWS),Ct=ue.getParameter(ue.UNPACK_SKIP_IMAGES),jt=Ye.isCompressedTexture?Ye.mipmaps[0]:Ye.image;ue.pixelStorei(ue.UNPACK_ROW_LENGTH,jt.width),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,jt.height),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,ye.min.x),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,ye.min.y),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,ye.min.z),Ye.isDataTexture||Ye.isData3DTexture?ue.texSubImage3D(Re,ke,$e.x,$e.y,$e.z,xe,le,Ae,Oe,Ie,jt.data):Ye.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ue.compressedTexSubImage3D(Re,ke,$e.x,$e.y,$e.z,xe,le,Ae,Oe,jt.data)):ue.texSubImage3D(Re,ke,$e.x,$e.y,$e.z,xe,le,Ae,Oe,Ie,jt),ue.pixelStorei(ue.UNPACK_ROW_LENGTH,Je),ue.pixelStorei(ue.UNPACK_IMAGE_HEIGHT,xt),ue.pixelStorei(ue.UNPACK_SKIP_PIXELS,Nt),ue.pixelStorei(ue.UNPACK_SKIP_ROWS,Et),ue.pixelStorei(ue.UNPACK_SKIP_IMAGES,Ct),ke===0&&nt.generateMipmaps&&ue.generateMipmap(Re),Z.unbindTexture()},this.initTexture=function(ye){ye.isCubeTexture?Q.setTextureCube(ye,0):ye.isData3DTexture?Q.setTexture3D(ye,0):ye.isDataArrayTexture||ye.isCompressedArrayTexture?Q.setTexture2DArray(ye,0):Q.setTexture2D(ye,0),Z.unbindTexture()},this.resetState=function(){N=0,C=0,T=null,Z.reset(),qe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ml}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===iO?"display-p3":"srgb",n.unpackColorSpace=cr.workingColorSpace===AM?"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===ua?rf:PZ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===rf?ua:ou}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 dze extends kP{}dze.prototype.isWebGL1Renderer=!0;class uO{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Yt(e),this.near=n,this.far=r}clone(){return new uO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class hze extends $a{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 fze{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=NP,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Vc()}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,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];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=Vc()),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]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}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=Vc()),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 Ra=new ze;class pd{constructor(e,n,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=r,this.normalized=i}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,r=this.data.count;n<r;n++)Ra.fromBufferAttribute(this,n),Ra.applyMatrix4(e),this.setXYZ(n,Ra.x,Ra.y,Ra.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Ra.fromBufferAttribute(this,n),Ra.applyNormalMatrix(e),this.setXYZ(n,Ra.x,Ra.y,Ra.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Ra.fromBufferAttribute(this,n),Ra.transformDirection(e),this.setXYZ(n,Ra.x,Ra.y,Ra.z);return this}setX(e,n){return this.normalized&&(n=lr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=lr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=lr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=lr(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=vl(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=vl(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=vl(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=vl(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=lr(n,this.array),r=lr(r,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this}setXYZ(e,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(n=lr(n,this.array),r=lr(r,this.array),i=lr(i,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e=e*this.data.stride+this.offset,this.normalized&&(n=lr(n,this.array),r=lr(r,this.array),i=lr(i,this.array),a=lr(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,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 r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new Us(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 pd(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 r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+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 mze extends us{constructor(e=null,n=1,r=1,i,a,o,l,c,u=ca,d=ca,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function pze(t,e){return t.z-e.z}function gze(t,e){return e.z-t.z}class xze{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.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",Xu=new vr,s7=new vr,bze=new vr,o7=new vr,dk=new TM,J_=new _o,Mh=new Al,eb=new ze,hk=new xze,wa=new Ko,e1=[];function yze(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let o=0;o<r;o++)e.setComponent(a+n,o,t.getComponent(a,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class vze extends Ko{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ka,i),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=r,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),r=new mze(n,e,e,po,Ic);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,p=new u.constructor(r*d),g=new c.constructor(p,d,f);g.setUsage(c.usage),n.setAttribute(l,g)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new Us(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(ap,new Us(o,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 r in n.attributes){if(r===ap)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.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 _o);const e=this._geometryCount,n=this.boundingBox,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Xu),this.getBoundingBoxAt(i,J_).applyMatrix4(Xu),n.union(J_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Al);const e=this._geometryCount,n=this.boundingSphere,r=this._active;n.makeEmpty();for(let i=0;i<e;i++)r[i]!==!1&&(this.getMatrixAt(i,Xu),this.getBoundingSphereAt(i,Mh).applyMatrix4(Xu),n.union(Mh))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,p=this._active,g=this._matricesTexture,b=this._matricesTexture.image.data;f.push(!0),p.push(!0);const v=this._geometryCount;this._geometryCount++,bze.toArray(b,v*16),g.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new _o,sphereInitialized:!1,sphere:new Al});const x=this.geometry.getAttribute(ap);for(let y=0;y<i.vertexCount;y++)x.setX(i.vertexStart+y,v);return x.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),o=n.getIndex(),l=this._reservedRanges[e];if(i&&o.count>l.indexCount||n.attributes.position.count>l.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=l.vertexStart,u=l.vertexCount;for(const g in r.attributes){if(g===ap)continue;const b=n.getAttribute(g),v=r.getAttribute(g);yze(b,v,c);const x=b.itemSize;for(let y=b.count,E=u;y<E;y++){const w=c+y;for(let A=0;A<x;A++)v.setComponent(w,A,0)}v.needsUpdate=!0}if(i){const g=l.indexStart;for(let b=0;b<o.count;b++)a.setX(g+b,c+o.getX(b));for(let b=o.count,v=l.indexCount;b<v;b++)a.setX(g+b,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],p=n.getAttribute("position");return f.count=i?o.count:p.count,this._visibilityChanged=!0,e}deleteGeometry(e){const n=this._active;return e>=n.length||n[e]===!1?this:(n[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.box,o=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let p=d;l&&(p=l.getX(p)),a.expandByPoint(eb.fromBufferAttribute(c,p))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,J_),J_.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,p=u.start+u.count;f<p;f++){let g=f;l&&(g=l.getX(g)),eb.fromBufferAttribute(c,g),d=Math.max(d,a.center.distanceToSquared(eb))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;wa.material=this.material,wa.geometry.index=c.index,wa.geometry.attributes=c.attributes,wa.geometry.boundingBox===null&&(wa.geometry.boundingBox=new _o),wa.geometry.boundingSphere===null&&(wa.geometry.boundingSphere=new Al);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];wa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,wa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,wa.geometry.boundingBox),this.getBoundingSphereAt(u,wa.geometry.boundingSphere),wa.raycast(e,e1);for(let f=0,p=e1.length;f<p;f++){const g=e1[f];g.object=this,g.batchId=u,n.push(g)}e1.length=0}wa.material=null,wa.geometry.index=null,wa.geometry.attributes={},wa.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,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,p=this.perObjectFrustumCulled;p&&(o7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),dk.setFromProjectionMatrix(o7,e.isWebGPURenderer?v0:Ml));let g=0;if(this.sortObjects){s7.copy(this.matrixWorld).invert(),eb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(s7);for(let x=0,y=c.length;x<y;x++)if(c[x]){this.getMatrixAt(x,Xu),this.getBoundingSphereAt(x,Mh).applyMatrix4(Xu);let E=!1;if(p&&(E=!dk.intersectsSphere(Mh)),!E){const w=eb.distanceTo(Mh.center);hk.push(f[x],w)}}const b=hk.list,v=this.customSort;v===null?b.sort(a.transparent?gze:pze):v.call(this,b,r);for(let x=0,y=b.length;x<y;x++){const E=b[x];u[g]=E.start*l,d[g]=E.count,g++}hk.reset()}else for(let b=0,v=c.length;b<v;b++)if(c[b]){let x=!1;if(p&&(this.getMatrixAt(b,Xu),this.getBoundingSphereAt(b,Mh).applyMatrix4(Xu),x=!dk.intersectsSphere(Mh)),!x){const y=f[b];u[g]=y.start*l,d[g]=y.count,g++}}this._multiDrawCount=g,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class _y extends Ig{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Yt(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 l7=new ze,c7=new ze,u7=new vr,fk=new sO,t1=new Al;class _ze extends $a{constructor(e=new ka,n=new _y){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,r=[0];for(let i=1,a=n.count;i<a;i++)l7.fromBufferAttribute(n,i-1),c7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=l7.distanceTo(c7);e.setAttribute("lineDistance",new ai(r,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),t1.copy(r.boundingSphere),t1.applyMatrix4(i),t1.radius+=a,e.ray.intersectsSphere(t1)===!1)return;u7.copy(i).invert(),fk.copy(e.ray).applyMatrix4(u7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new ze,d=new ze,f=new ze,p=new ze,g=this.isLineSegments?2:1,b=r.index,x=r.attributes.position;if(b!==null){const y=Math.max(0,o.start),E=Math.min(b.count,o.start+o.count);for(let w=y,A=E-1;w<A;w+=g){const N=b.getX(w),C=b.getX(w+1);if(u.fromBufferAttribute(x,N),d.fromBufferAttribute(x,C),fk.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const D=e.ray.origin.distanceTo(p);D<e.near||D>e.far||n.push({distance:D,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{const y=Math.max(0,o.start),E=Math.min(x.count,o.start+o.count);for(let w=y,A=E-1;w<A;w+=g){if(u.fromBufferAttribute(x,w),d.fromBufferAttribute(x,w+1),fk.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(p);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const d7=new ze,h7=new ze;class kM extends _ze{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,r=[];for(let i=0,a=n.count;i<a;i+=2)d7.fromBufferAttribute(n,i),h7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+d7.distanceTo(h7);e.setAttribute("lineDistance",new ai(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class wze extends ka{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new ze,a=new ze;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],p=f.start,g=f.count;for(let b=p,v=p+g;b<v;b+=3)for(let x=0;x<3;x++){const y=l.getX(b+x),E=l.getX(b+(x+1)%3);i.fromBufferAttribute(o,y),a.fromBufferAttribute(o,E),f7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(o,d),a.fromBufferAttribute(o,f),f7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new ai(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function f7(t,e,n){const r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}class Sze extends Ig{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=RZ,this.normalScale=new rn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=nO,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 Mze extends _y{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 tJ extends $a{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Yt(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 mk=new vr,m7=new ze,p7=new ze;class Eze{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new rn(512,512),this.map=null,this.mapPass=null,this.matrix=new vr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new TM,this._frameExtents=new rn(1,1),this._viewportCount=1,this._viewports=[new hr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;m7.setFromMatrixPosition(e.matrixWorld),n.position.copy(m7),p7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(p7),n.updateMatrixWorld(),mk.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mk),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(mk)}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 g7=new vr,tb=new ze,pk=new ze;class Nze extends Eze{constructor(){super(new Cs(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new rn(4,2),this._viewportCount=6,this._viewports=[new hr(2,1,1,1),new hr(0,1,1,1),new hr(3,1,1,1),new hr(1,1,1,1),new hr(3,0,1,1),new hr(1,0,1,1)],this._cubeDirections=[new ze(1,0,0),new ze(-1,0,0),new ze(0,0,1),new ze(0,0,-1),new ze(0,1,0),new ze(0,-1,0)],this._cubeUps=[new ze(0,1,0),new ze(0,1,0),new ze(0,1,0),new ze(0,1,0),new ze(0,0,1),new ze(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),tb.setFromMatrixPosition(e.matrixWorld),r.position.copy(tb),pk.copy(r.position),pk.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(pk),r.updateMatrixWorld(),i.makeTranslation(-tb.x,-tb.y,-tb.z),g7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(g7)}}class Aze extends tJ{constructor(e,n,r=0,i=2){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Nze}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 Tze extends tJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class Cze extends ka{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 jP extends fze{constructor(e,n,r=1){super(e,n),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=r}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 x7{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,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,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(da(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const b7=new ze,n1=new ze;class kze{constructor(e=new ze,n=new ze){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){b7.subVectors(e,this.start),n1.subVectors(this.end,this.start);const r=n1.dot(n1);let a=n1.dot(b7)/r;return n&&(a=da(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).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 jze extends kM{constructor(e=1){const n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new ka;i.setAttribute("position",new ai(n,3)),i.setAttribute("color",new ai(r,3));const a=new _y({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Yt,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.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:EM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=EM);class Tl{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),Tl.nextNameID=Tl.nextNameID||0,this.$name.id=`lil-gui-name-${++Tl.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",o=>o.stopPropagation()),this.domElement.addEventListener("keyup",o=>o.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(r)}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 Pze extends Tl{constructor(e,n,r){super(e,n,r,"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 PP(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 Rze={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:PP,toHexString:PP},w0={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},Dze={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=w0.fromHexString(t);e[0]=(r>>16&255)/255*n,e[1]=(r>>8&255)/255*n,e[2]=(r&255)/255*n},toHexString([t,e,n],r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return w0.toHexString(i)}},Oze={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=w0.fromHexString(t);e.r=(r>>16&255)/255*n,e.g=(r>>8&255)/255*n,e.b=(r&255)/255*n},toHexString({r:t,g:e,b:n},r=1){r=255/r;const i=t*r<<16^e*r<<8^n*r<<0;return w0.toHexString(i)}},Lze=[Rze,w0,Dze,Oze];function Ize(t){return Lze.find(e=>e.match(t))}class Fze extends Tl{constructor(e,n,r,i){super(e,n,r,"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=Ize(this.initialValue),this._rgbScale=i,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=PP(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 gk extends Tl{constructor(e,n,r){super(e,n,r,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",i=>{i.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class Uze extends Tl{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);const l=o!==void 0;this.step(l?o:this._getImplicitStep(),l),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 E=parseFloat(this.$input.value);isNaN(E)||(this._stepExplicit&&(E=this._snap(E)),this.setValue(this._clamp(E)))},r=E=>{const w=parseFloat(this.$input.value);isNaN(w)||(this._snapClampSetValue(w+E),this.$input.value=this.getValue())},i=E=>{E.key==="Enter"&&this.$input.blur(),E.code==="ArrowUp"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E))),E.code==="ArrowDown"&&(E.preventDefault(),r(this._step*this._arrowKeyMultiplier(E)*-1))},a=E=>{this._inputFocused&&(E.preventDefault(),r(this._step*this._normalizeMouseWheel(E)))};let o=!1,l,c,u,d,f;const p=5,g=E=>{l=E.clientX,c=u=E.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",b),window.addEventListener("mouseup",v)},b=E=>{if(o){const w=E.clientX-l,A=E.clientY-c;Math.abs(A)>p?(E.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(w)>p&&v()}if(!o){const w=E.clientY-u;f-=w*this._step*this._arrowKeyMultiplier(E),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=E.clientY},v=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",v)},x=()=>{this._inputFocused=!0},y=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",g),this.$input.addEventListener("focus",x),this.$input.addEventListener("blur",y)}_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=(y,E,w,A,N)=>(y-E)/(w-E)*(N-A)+A,n=y=>{const E=this.$slider.getBoundingClientRect();let w=e(y,E.left,E.right,this._min,this._max);this._snapClampSetValue(w)},r=y=>{this._setDraggingStyle(!0),n(y.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=y=>{n(y.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=y=>{y.preventDefault(),this._setDraggingStyle(!0),n(y.touches[0].clientX),o=!1},d=y=>{y.touches.length>1||(this._hasScrollBar?(l=y.touches[0].clientX,c=y.touches[0].clientY,o=!0):u(y),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",p))},f=y=>{if(o){const E=y.touches[0].clientX-l,w=y.touches[0].clientY-c;Math.abs(E)>Math.abs(w)?u(y):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p))}else y.preventDefault(),n(y.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p)},g=this._callOnFinishChange.bind(this),b=400;let v;const x=y=>{if(Math.abs(y.deltaX)<Math.abs(y.deltaY)&&this._hasScrollBar)return;y.preventDefault();const w=this._normalizeMouseWheel(y)*this._step;this._snapClampSetValue(this.getValue()+w),this.$input.value=this.getValue(),clearTimeout(v),v=setTimeout(g,b)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",x,{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:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_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 zze extends Tl{constructor(e,n,r,i){super(e,n,r,"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(i)}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 r=document.createElement("option");r.textContent=n,this.$select.appendChild(r)}),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 Bze extends Tl{constructor(e,n,r){super(e,n,r,"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",i=>{i.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 $ze=`.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 Hze(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 y7=!1;class gS{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="Controls",closeFolders:o=!1,injectStyles:l=!0,touchStyles:c=!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",u=>{(u.code==="Enter"||u.code==="Space")&&(u.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"),c&&this.domElement.classList.add("allow-touch-styles"),!y7&&l&&(Hze($ze),y7=!0),r?r.appendChild(this.domElement):n&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),i&&this.domElement.style.setProperty("--width",i+"px"),this._closeFolders=o}add(e,n,r,i,a){if(Object(r)===r)return new zze(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new Uze(this,e,n,r,i,a);case"boolean":return new Pze(this,e,n);case"string":return new Bze(this,e,n);case"function":return new gk(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new Fze(this,e,n,r)}addFolder(e){const n=new gS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof gk||r._name in e.controllers&&r.load(e.controllers[r._name])}),n&&e.folders&&this.folders.forEach(r=>{r._title in e.folders&&r.load(e.folders[r._title])}),this}save(e=!0){const n={controllers:{},folders:{}};return this.controllers.forEach(r=>{if(!(r instanceof gk)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.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 r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.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 xk(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class dO{constructor(e,n,r,i){this.size=e,this.width=n,this.height=r,this.charLength=i,this.chars=""}static parse(e){const n=e.split(" "),r=n[0],i=r.split("x");return new dO(r,+i[0],+i[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 hO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class v7 extends hO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Yu extends hO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class _7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class xS{constructor(e){this.lines=[],this.preamble=new _7(-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 r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=o;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((n=>this.parseCommand(n)))}parseCommand(e,n=!0){var r;const i=e.trim().split(";"),a=i[0],o=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new v7(e,c,u,o);case"t0":return new Yu(e,c,o,0);case"t1":return new Yu(e,c,o,1);case"t2":return new Yu(e,c,o,2);case"t3":return new Yu(e,c,o,3);case"t4":return new Yu(e,c,o,4);case"t5":return new Yu(e,c,o,5);case"t6":return new Yu(e,c,o,6);case"t7":return new Yu(e,c,o,7);default:return new hO(e,c,u,o)}}parseMove(e){return e.reduce(((n,r)=>{const i=r.charAt(0).toLowerCase();return i!="x"&&i!="y"&&i!="z"&&i!="e"&&i!="r"&&i!="f"&&i!="i"&&i!="j"||(n[i]=parseFloat(r.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,r,i,a)=>{if(i%2==0)return n;let o=a[i-1];return o=o.toLowerCase(),this.isAlpha(o)&&(n[o]=parseFloat(r)),n}),{})}groupIntoLayers(e){var n;for(let r=0;r<e.length;r++){const i=e[r];if(i instanceof v7){const a=i.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 o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new _7(this.layers.length,[],r,o))}}this.maxLayer.commands.push(i)}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 r;for(const i of e){const a=i.comment;if(!a)continue;const o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=dO.parse(a.slice(o+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}xS.prototype.parseGcode=xS.prototype.parseGCode;const w7={type:"change"},bk={type:"start"},S7={type:"end"},r1=new sO,M7=new rd,Vze=Math.cos(70*OZ.DEG2RAD);class Gze extends $f{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new ze,this.cursor=new ze,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:Bm.ROTATE,MIDDLE:Bm.DOLLY,RIGHT:Bm.PAN},this.touches={ONE:$m.ROTATE,TWO:$m.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 l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function($){$.addEventListener("keydown",ge),this._domElementKeyEvents=$},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ge),this._domElementKeyEvents=null},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(w7),r.update(),a=i.NONE},this.update=(function(){const $=new ze,Z=new jf().setFromUnitVectors(e.up,new ze(0,1,0)),B=Z.clone().invert(),U=new ze,Q=new jf,Me=new ze,Te=2*Math.PI;return function(fe=null){const H=r.object.position;$.copy(H).sub(r.target),$.applyQuaternion(Z),l.setFromVector3($),r.autoRotate&&a===i.NONE&&P((function(Se){return Se!==null?2*Math.PI/60*r.autoRotateSpeed*Se:2*Math.PI/60/60*r.autoRotateSpeed})(fe)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let I=r.minAzimuthAngle,ce=r.maxAzimuthAngle;isFinite(I)&&isFinite(ce)&&(I<-Math.PI?I+=Te:I>Math.PI&&(I-=Te),ce<-Math.PI?ce+=Te:ce>Math.PI&&(ce-=Te),l.theta=I<=ce?Math.max(I,Math.min(ce,l.theta)):l.theta>(I+ce)/2?Math.max(I,l.theta):Math.min(ce,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=W(l.radius):l.radius=W(l.radius*u),$.setFromSpherical(l),$.applyQuaternion(B),H.copy(r.target).add($),r.object.lookAt(r.target),r.enableDamping===!0?(c.theta*=1-r.dampingFactor,c.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(c.set(0,0,0),d.set(0,0,0));let we=!1;if(r.zoomToCursor&&C){let Se=null;if(r.object.isPerspectiveCamera){const _e=$.length();Se=W(_e*u);const st=_e-Se;r.object.position.addScaledVector(A,st),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const _e=new ze(N.x,N.y,0);_e.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),we=!0;const st=new ze(N.x,N.y,0);st.unproject(r.object),r.object.position.sub(st).add(_e),r.object.updateMatrixWorld(),Se=$.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;Se!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(Se).add(r.object.position):(r1.origin.copy(r.object.position),r1.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(r1.direction))<Vze?e.lookAt(r.target):(M7.setFromNormalAndCoplanarPoint(r.object.up,r.target),r1.intersectPlane(M7,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),we=!0);return u=1,C=!1,!!(we||U.distanceToSquared(r.object.position)>o||8*(1-Q.dot(r.object.quaternion))>o||Me.distanceToSquared(r.target)>0)&&(r.dispatchEvent(w7),U.copy(r.object.position),Q.copy(r.object.quaternion),Me.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",ue),r.domElement.removeEventListener("pointerdown",pe),r.domElement.removeEventListener("pointercancel",oe),r.domElement.removeEventListener("wheel",ae),r.domElement.removeEventListener("pointermove",Ce),r.domElement.removeEventListener("pointerup",oe),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",ge),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new x7,c=new x7;let u=1;const d=new ze,f=new rn,p=new rn,g=new rn,b=new rn,v=new rn,x=new rn,y=new rn,E=new rn,w=new rn,A=new ze,N=new rn;let C=!1;const T=[],D={};function k(){return Math.pow(.95,r.zoomSpeed)}function P($){c.theta-=$}function z($){c.phi-=$}const L=(function(){const $=new ze;return function(Z,B){$.setFromMatrixColumn(B,0),$.multiplyScalar(-Z),d.add($)}})(),X=(function(){const $=new ze;return function(Z,B){r.screenSpacePanning===!0?$.setFromMatrixColumn(B,1):($.setFromMatrixColumn(B,0),$.crossVectors(r.object.up,$)),$.multiplyScalar(Z),d.add($)}})(),R=(function(){const $=new ze;return function(Z,B){const U=r.domElement;if(r.object.isPerspectiveCamera){const Q=r.object.position;$.copy(Q).sub(r.target);let Me=$.length();Me*=Math.tan(r.object.fov/2*Math.PI/180),L(2*Z*Me/U.clientHeight,r.object.matrix),X(2*B*Me/U.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(Z*(r.object.right-r.object.left)/r.object.zoom/U.clientWidth,r.object.matrix),X(B*(r.object.top-r.object.bottom)/r.object.zoom/U.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function Y($){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function J($){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=$:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function G($){if(!r.zoomToCursor)return;C=!0;const Z=r.domElement.getBoundingClientRect(),B=$.clientX-Z.left,U=$.clientY-Z.top,Q=Z.width,Me=Z.height;N.x=B/Q*2-1,N.y=-U/Me*2+1,A.set(N.x,N.y,1).unproject(r.object).sub(r.object.position).normalize()}function W($){return Math.max(r.minDistance,Math.min(r.maxDistance,$))}function ee($){f.set($.clientX,$.clientY)}function K($){b.set($.clientX,$.clientY)}function F(){if(T.length===1)f.set(T[0].pageX,T[0].pageY);else{const $=.5*(T[0].pageX+T[1].pageX),Z=.5*(T[0].pageY+T[1].pageY);f.set($,Z)}}function q(){if(T.length===1)b.set(T[0].pageX,T[0].pageY);else{const $=.5*(T[0].pageX+T[1].pageX),Z=.5*(T[0].pageY+T[1].pageY);b.set($,Z)}}function ne(){const $=T[0].pageX-T[1].pageX,Z=T[0].pageY-T[1].pageY,B=Math.sqrt($*$+Z*Z);y.set(0,B)}function re($){if(T.length==1)p.set($.pageX,$.pageY);else{const B=V($),U=.5*($.pageX+B.x),Q=.5*($.pageY+B.y);p.set(U,Q)}g.subVectors(p,f).multiplyScalar(r.rotateSpeed);const Z=r.domElement;P(2*Math.PI*g.x/Z.clientHeight),z(2*Math.PI*g.y/Z.clientHeight),f.copy(p)}function se($){if(T.length===1)v.set($.pageX,$.pageY);else{const Z=V($),B=.5*($.pageX+Z.x),U=.5*($.pageY+Z.y);v.set(B,U)}x.subVectors(v,b).multiplyScalar(r.panSpeed),R(x.x,x.y),b.copy(v)}function de($){const Z=V($),B=$.pageX-Z.x,U=$.pageY-Z.y,Q=Math.sqrt(B*B+U*U);E.set(0,Q),w.set(0,Math.pow(E.y/y.y,r.zoomSpeed)),Y(w.y),y.copy(E)}function pe($){r.enabled!==!1&&(T.length===0&&(r.domElement.setPointerCapture($.pointerId),r.domElement.addEventListener("pointermove",Ce),r.domElement.addEventListener("pointerup",oe)),(function(Z){T.push(Z)})($),$.pointerType==="touch"?(function(Z){switch(Le(Z),T.length){case 1:switch(r.touches.ONE){case $m.ROTATE:if(r.enableRotate===!1)return;F(),a=i.TOUCH_ROTATE;break;case $m.PAN:if(r.enablePan===!1)return;q(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case $m.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ne(),r.enablePan&&q(),a=i.TOUCH_DOLLY_PAN;break;case $m.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ne(),r.enableRotate&&F(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(bk)})($):(function(Z){let B;switch(Z.button){case 0:B=r.mouseButtons.LEFT;break;case 1:B=r.mouseButtons.MIDDLE;break;case 2:B=r.mouseButtons.RIGHT;break;default:B=-1}switch(B){case Bm.DOLLY:if(r.enableZoom===!1)return;(function(U){G(U),y.set(U.clientX,U.clientY)})(Z),a=i.DOLLY;break;case Bm.ROTATE:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(r.enablePan===!1)return;K(Z),a=i.PAN}else{if(r.enableRotate===!1)return;ee(Z),a=i.ROTATE}break;case Bm.PAN:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(r.enableRotate===!1)return;ee(Z),a=i.ROTATE}else{if(r.enablePan===!1)return;K(Z),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(bk)})($))}function Ce($){r.enabled!==!1&&($.pointerType==="touch"?(function(Z){switch(Le(Z),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;re(Z),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;se(Z),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(B){r.enableZoom&&de(B),r.enablePan&&se(B)})(Z),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(B){r.enableZoom&&de(B),r.enableRotate&&re(B)})(Z),r.update();break;default:a=i.NONE}})($):(function(Z){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(B){p.set(B.clientX,B.clientY),g.subVectors(p,f).multiplyScalar(r.rotateSpeed);const U=r.domElement;P(2*Math.PI*g.x/U.clientHeight),z(2*Math.PI*g.y/U.clientHeight),f.copy(p),r.update()})(Z);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(B){E.set(B.clientX,B.clientY),w.subVectors(E,y),w.y>0?Y(k()):w.y<0&&J(k()),y.copy(E),r.update()})(Z);break;case i.PAN:if(r.enablePan===!1)return;(function(B){v.set(B.clientX,B.clientY),x.subVectors(v,b).multiplyScalar(r.panSpeed),R(x.x,x.y),b.copy(v),r.update()})(Z)}})($))}function oe($){(function(Z){delete D[Z.pointerId];for(let B=0;B<T.length;B++)if(T[B].pointerId==Z.pointerId)return void T.splice(B,1)})($),T.length===0&&(r.domElement.releasePointerCapture($.pointerId),r.domElement.removeEventListener("pointermove",Ce),r.domElement.removeEventListener("pointerup",oe)),r.dispatchEvent(S7),a=i.NONE}function ae($){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&($.preventDefault(),r.dispatchEvent(bk),(function(Z){G(Z),Z.deltaY<0?J(k()):Z.deltaY>0&&Y(k()),r.update()})($),r.dispatchEvent(S7))}function ge($){r.enabled!==!1&&r.enablePan!==!1&&(function(Z){let B=!1;switch(Z.code){case r.keys.UP:Z.ctrlKey||Z.metaKey||Z.shiftKey?z(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,r.keyPanSpeed),B=!0;break;case r.keys.BOTTOM:Z.ctrlKey||Z.metaKey||Z.shiftKey?z(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(0,-r.keyPanSpeed),B=!0;break;case r.keys.LEFT:Z.ctrlKey||Z.metaKey||Z.shiftKey?P(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(r.keyPanSpeed,0),B=!0;break;case r.keys.RIGHT:Z.ctrlKey||Z.metaKey||Z.shiftKey?P(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):R(-r.keyPanSpeed,0),B=!0}B&&(Z.preventDefault(),r.update())})($)}function ue($){r.enabled!==!1&&$.preventDefault()}function Le($){let Z=D[$.pointerId];Z===void 0&&(Z=new rn,D[$.pointerId]=Z),Z.set($.pageX,$.pageY)}function V($){const Z=$.pointerId===T[0].pointerId?T[1]:T[0];return D[Z.pointerId]}r.domElement.addEventListener("contextmenu",ue),r.domElement.addEventListener("pointerdown",pe),r.domElement.addEventListener("pointercancel",oe),r.domElement.addEventListener("wheel",ae,{passive:!1}),this.update()}}Tt.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new rn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},is.line={uniforms:oO.merge([Tt.common,Tt.fog,Tt.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 nJ extends $d{constructor(e){super({type:"LineMaterial",uniforms:oO.clone(is.line.uniforms),vertexShader:is.line.vertexShader,fragmentShader:is.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 E7=new _o,i1=new ze;class rJ extends Cze{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 ai([-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 ai([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){const n=this.attributes.instanceStart,r=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),r.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 r=new jP(n,6,1);return this.setAttribute("instanceStart",new pd(r,3,0)),this.setAttribute("instanceEnd",new pd(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new jP(n,6,1);return this.setAttribute("instanceColorStart",new pd(r,3,0)),this.setAttribute("instanceColorEnd",new pd(r,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 wze(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new _o);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),E7.setFromBufferAttribute(n),this.boundingBox.union(E7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Al),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)i1.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(i1)),i1.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(i1));this.boundingSphere.radius=Math.sqrt(i),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 N7=new ze,A7=new ze,ia=new hr,aa=new hr,dl=new hr,yk=new ze,vk=new vr,sa=new kze,T7=new ze,a1=new _o,s1=new Al,hl=new hr;let fl,Oh;function C7(t,e,n){return hl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),hl.multiplyScalar(1/hl.w),hl.x=Oh/n.width,hl.y=Oh/n.height,hl.applyMatrix4(t.projectionMatrixInverse),hl.multiplyScalar(1/hl.w),Math.abs(Math.max(hl.x,hl.y))}class Wze extends Ko{constructor(e=new rJ,n=new nJ({color:16777215*Math.random()})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let o=0,l=0,c=n.count;o<c;o++,l+=2)N7.fromBufferAttribute(n,o),A7.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+N7.distanceTo(A7);const a=new jP(i,2,1);return e.setAttribute("instanceDistanceStart",new pd(a,1,0)),e.setAttribute("instanceDistanceEnd",new pd(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||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;fl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Oh=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),s1.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Oh:u=C7(i,Math.max(i.near,s1.distanceToPoint(fl.origin)),c.resolution),s1.radius+=u,fl.intersectsSphere(s1)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),a1.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Oh:d=C7(i,Math.max(i.near,a1.distanceToPoint(fl.origin)),c.resolution),a1.expandByScalar(d),fl.intersectsBox(a1)!==!1&&(r?(function(f,p){const g=f.matrixWorld,b=f.geometry,v=b.attributes.instanceStart,x=b.attributes.instanceEnd;for(let y=0,E=Math.min(b.instanceCount,v.count);y<E;y++){sa.start.fromBufferAttribute(v,y),sa.end.fromBufferAttribute(x,y),sa.applyMatrix4(g);const w=new ze,A=new ze;fl.distanceSqToSegment(sa.start,sa.end,A,w),A.distanceTo(w)<.5*Oh&&p.push({point:A,pointOnLine:w,distance:fl.origin.distanceTo(A),object:f,face:null,faceIndex:y,uv:null,uv1:null})}})(this,n):(function(f,p,g){const b=p.projectionMatrix,v=f.material.resolution,x=f.matrixWorld,y=f.geometry,E=y.attributes.instanceStart,w=y.attributes.instanceEnd,A=Math.min(y.instanceCount,E.count),N=-p.near;fl.at(1,dl),dl.w=1,dl.applyMatrix4(p.matrixWorldInverse),dl.applyMatrix4(b),dl.multiplyScalar(1/dl.w),dl.x*=v.x/2,dl.y*=v.y/2,dl.z=0,yk.copy(dl),vk.multiplyMatrices(p.matrixWorldInverse,x);for(let C=0,T=A;C<T;C++){if(ia.fromBufferAttribute(E,C),aa.fromBufferAttribute(w,C),ia.w=1,aa.w=1,ia.applyMatrix4(vk),aa.applyMatrix4(vk),ia.z>N&&aa.z>N)continue;if(ia.z>N){const L=ia.z-aa.z,X=(ia.z-N)/L;ia.lerp(aa,X)}else if(aa.z>N){const L=aa.z-ia.z,X=(aa.z-N)/L;aa.lerp(ia,X)}ia.applyMatrix4(b),aa.applyMatrix4(b),ia.multiplyScalar(1/ia.w),aa.multiplyScalar(1/aa.w),ia.x*=v.x/2,ia.y*=v.y/2,aa.x*=v.x/2,aa.y*=v.y/2,sa.start.copy(ia),sa.start.z=0,sa.end.copy(aa),sa.end.z=0;const D=sa.closestPointToPointParameter(yk,!0);sa.at(D,T7);const k=OZ.lerp(ia.z,aa.z,D),P=k>=-1&&k<=1,z=yk.distanceTo(T7)<.5*Oh;if(P&&z){sa.start.fromBufferAttribute(E,C),sa.end.fromBufferAttribute(w,C),sa.start.applyMatrix4(x),sa.end.applyMatrix4(x);const L=new ze,X=new ze;fl.distanceSqToSegment(sa.start,sa.end,X,L),g.push({point:X,pointOnLine:L,distance:fl.origin.distanceTo(X),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class qze extends kM{constructor(e,n,r,i,a=4473924,o=8947848){a=new Yt(a),o=new Yt(o);const l=Math.round(e/n);r=Math.round(r/i)*i/2;const c=[],u=[];let d=0;for(let p=-1*(e=l*n/2);p<=e;p+=n){c.push(p,0,-1*r,p,0,r);const g=p===0?a:o;g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3}for(let p=-1*r;p<=r;p+=i){c.push(-1*e,0,p,e,0,p);const g=p===0?a:o;g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3,g.toArray(u,d),d+=3}const f=new ka;f.setAttribute("position",new ai(c,3)),f.setAttribute("color",new ai(u,3)),super(f,new _y({vertexColors:!0,toneMapped:!1}))}}function Kze(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new ka,d=[];return d.push(-o,-l,-c,-o,l,-c,-o,l,-c,o,l,-c,o,l,-c,o,-l,-c,o,-l,-c,-o,-l,-c,-o,-l,c,-o,l,c,-o,l,c,o,l,c,o,l,c,o,-l,c,o,-l,c,-o,-l,c,-o,-l,-c,-o,-l,c,-o,l,-c,-o,l,c,o,l,-c,o,l,c,o,-l,-c,o,-l,c),u.setAttribute("position",new ai(d,3)),u})(t,e,n),a=new kM(i,new Mze({color:new Yt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var Nb=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,o=0,l=n(new Nb.Panel("FPS","#0ff","#002")),c=n(new Nb.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new Nb.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:e,addPanel:n,showPanel:r,begin:function(){i=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(c.update(d-i,200),d>=a+1e3&&(l.update(1e3*o/(d-a),100),a=d,o=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};Nb.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,p=15*o,g=74*o,b=30*o,v=document.createElement("canvas");v.width=l,v.height=c,v.style.cssText="width:80px;height:48px";var x=v.getContext("2d");return x.font="bold "+9*o+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=n,x.fillRect(0,0,l,c),x.fillStyle=e,x.fillText(t,u,d),x.fillRect(f,p,g,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f,p,g,b),{dom:v,update:function(y,E){r=Math.min(r,y),i=Math.max(i,y),x.fillStyle=n,x.globalAlpha=1,x.fillRect(0,0,l,p),x.fillStyle=e,x.fillText(a(y)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),x.drawImage(v,f+o,p,g-o,b,f,p,g-o,b),x.fillRect(f+g-o,p,o,b),x.fillStyle=n,x.globalAlpha=.9,x.fillRect(f+g-o,p,o,a((1-y/E)*b))}}};var Xze=Nb;class k7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new gS,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 gS,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 r=e.addFolder("Camera rotation");r.add(this.watchedObject.camera.rotation,"x").listen(),r.add(this.watchedObject.camera.rotation,"y").listen(),r.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 Yze extends ka{constructor(e=[new ze],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new ze,o=new ze,l=new rn,c=[],u=[],d=[],f=[];function p(g){const[b,v,x]=(function(y){const E=e[y],w=new ze,A=new ze,N=new ze,C=new ze;w.copy(E).sub(e[y-1]||E).normalize().add((e[y+1]||E).clone().sub(E).normalize()).normalize();let T=Number.MAX_VALUE;const D=Math.abs(w.x),k=Math.abs(w.y),P=Math.abs(w.z);return D<=T&&(T=D,A.set(1,0,0)),k<=T&&(T=k,A.set(0,1,0)),P<=T&&A.set(0,0,1),C.crossVectors(w,A).normalize(),A.crossVectors(w,C),N.crossVectors(w,A),[E,A,N]})(g);for(let y=0;y<=i;y++){const E=y/i*Math.PI*2,w=Math.sin(E),A=-Math.cos(E);o.x=A*v.x+w*x.x,o.y=A*v.y+w*x.y,o.z=A*v.z+w*x.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=b.x+n*o.x*.5,a.y=b.y+n*o.y*.5,a.z=b.z+r*o.z*.5,c.push(a.x,a.y,a.z)}}(function(){for(let g=0;g<e.length;g++)p(g);p(closed===!1?e.length-1:0),(function(){for(let g=0;g<e.length;g++)for(let b=0;b<=i;b++)l.x=g/e.length,l.y=b/i,d.push(l.x,l.y)})(),(function(){for(let g=1;g<e.length;g++)for(let b=1;b<=i;b++){const v=(i+1)*(g-1)+(b-1),x=(i+1)*g+(b-1),y=(i+1)*g+b,E=(i+1)*(g-1)+b;f.push(v,x,E),f.push(x,y,E)}})()})(),this.setIndex(f),this.setAttribute("position",new ai(c,3)),this.setAttribute("normal",new ai(u,3)),this.setAttribute("uv",new ai(d,2))}}class Ab{static get initial(){const e=new Ab;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const _k={h:0,s:0,l:0};class Op{constructor(e){var n,r,i,a,o,l,c,u,d;if(this.minLayerThreshold=.05,this.renderExtrusion=!0,this.renderTravel=!1,this.renderTubes=!1,this.extrusionWidth=.6,this.singleLayerMode=!1,this.initialCameraPosition=[-100,400,450],this.debug=!1,this.inches=!1,this.nonTravelmoves=[],this.disableGradient=!1,this.state=Ab.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Op.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Yt(14737632),this._travelColor=new Yt(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 xS(this.minLayerThreshold),this.scene=new hze,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Yt(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=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(o=e.renderTravel)!==null&&o!==void 0?o:this.renderTravel,this.nonTravelmoves=(l=e.nonTravelMoves)!==null&&l!==void 0?l:this.nonTravelmoves,this.renderTubes=(c=e.renderTubes)!==null&&c!==void 0?c:this.renderTubes,this.extrusionWidth=(u=e.extrusionWidth)!==null&&u!==void 0?u:this.extrusionWidth,this.devMode=(d=e.devMode)!==null&&d!==void 0?d:this.devMode,this.stats=this.devMode?new Xze:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Yt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Yt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Yt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[g,b]of Object.entries(e.toolColors))this._toolColors[parseInt(g)]=new Yt(b)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+EM),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 kP({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 kP({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,g.appendChild(this.canvas)}this.camera=new Cs(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,p=.8*f;this.scene.fog=new uO(this._backgroundColor,p,f),this.resize(),this.controls=new Gze(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,r]of e.entries())this._extrusionColor[n]=new Yt(r)}else this._extrusionColor=new Yt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Op.defaultExtrusionColor:this._extrusionColor instanceof Yt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Op.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Yt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Yt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Yt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Yt(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 jze(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 Tze(13421772,.3*Math.PI),n=new Aze(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 hb;return n.name=e,n.quaternion.setFromEuler(new yy(-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=Ab.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 xk(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 r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}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,r,i,a,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const p of d.commands)if(p.gcode!="g20"){if(p.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.extrusion=[];const g=p;this.state.t=g.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(p.gcode)>-1){const g=p,b={x:(n=g.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=g.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=g.params.z)!==null&&i!==void 0?i:this.state.z,r:(a=g.params.r)!==null&&a!==void 0?a:this.state.r,e:(o=g.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=g.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=g.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const v=((u=g.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(p.gcode)>-1;(b.x!=this.state.x||b.y!=this.state.y||b.z!=this.state.z)&&(v&&this.renderExtrusion||!v&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(f,this.state,b,v,p.gcode=="g2"||p.gcode=="g02"):this.addLineSegment(f,this.state,b,v))}this.state.x=b.x,this.state.y=b.y,this.state.z=b.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(_k),a=new Yt().setHSL(_k.h,_k.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:a,l=(i=this._lastSegmentColor)!==null&&i!==void 0?i:o,c=e.extrusion.splice(-3),u=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,o.getHex(),e.height),this.addTubeLine([...u,...c],l.getHex(),e.height)):(this.addLine(e.extrusion,o.getHex()),this.addLine([...u,...c],l.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 qze(this.buildVolume.x,10,this.buildVolume.y,10));const e=Kze(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 xS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=Ab.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,r,i){(i?e.extrusion:e.travel).push(n.x,n.y,n.z,r.x,r.y,r.z)}addArcSegment(e,n,r,i,a){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,p=r.z;let g=r.r,b=r.i,v=r.j;if(g){const Y=d-l,J=f-c,G=Math.sqrt(Math.pow(Y/2,2)+Math.pow(J/2,2));g=Math.max(g,G);const W=Math.pow(Y,2)+Math.pow(J,2),ee=Math.pow(g,2)-W/4;let K=Math.sqrt(ee/W);(a&&g<0||!a&&g>0)&&(K=-K),b=Y/2+J*K,v=J/2-Y*K}const x=l==d&&c==f,y=l+b,E=c+v,w=Math.sqrt(b*b+v*v),A=Math.atan2(-v,-b),N=Math.atan2(f-E,d-y);let C;x?C=2*Math.PI:(C=a?A-N:N-A,C<0&&(C+=2*Math.PI));let T=w*C/1.8;this.inches&&(T*=25),T<1&&(T=1);let D=C/T;D*=a?-1:1;const k=[];k.push({x:l,y:c,z:u});const P=(u-p)/T;let z=l,L=c,X=u,R=A;for(let Y=0;Y<T-1;Y++)R+=D,z=y+w*Math.cos(R),L=E+w*Math.sin(R),X+=P,k.push({x:z,y:L,z:X});k.push({x:r.x,y:r.y,z:r.z});for(let Y=0;Y<k.length-1;Y++)o.push(k[Y].x,k[Y].y,k[Y].z,k[Y+1].x,k[Y+1].y,k[Y+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ka;i.setAttribute("position",new ai(e,3)),this.disposables.push(i);const a=new _y({color:n});this.disposables.push(a);const o=new kM(i,a);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new ze(l[0],l[1],l[2]),u=new ze(l[3],l[4],l[5]),d=new ze(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((o=>{var l;const c=new Yze(o,this.extrusionWidth,this.lineHeight||r,4);(l=this._geometries)[n]||(l[n]=[]),this._geometries[n].push(c)}))}addThickLine(e,n){var r;if(!e.length||!this.lineWidth)return;const i=new rJ;this.disposables.push(i);const a=new nJ({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new Wze(i,a);(r=this.group)===null||r===void 0||r.add(o)}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=>xk(this,void 0,void 0,(function*(){var n,r;e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove("dragging");const i=((r=(n=e.dataTransfer)===null||n===void 0?void 0:n.files)!==null&&r!==void 0?r:[])[0];this.clear(),yield this._readFromStream(i.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 r=this._geometries[e].pop();n.addGeometry(r)}}}createBatchMesh(e){var n;const r=this._geometries[e],i=new Sze({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new vze(r.length,a,void 0,i);return this.disposables.push(o),(n=this.group)===null||n===void 0||n.add(o),o}_readFromStream(e){var n,r;return xk(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new k7(this):typeof this.devMode=="object"&&(this.devGui=new k7(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())}}Op.defaultExtrusionColor=new Yt("hotpink");function Qze({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=S.useRef(null),a=S.useRef(null),o=S.useRef(null),l=S.useRef(!1),[c,u]=S.useState(!0),[d,f]=S.useState(null),[p,g]=S.useState(!1),[b,v]=S.useState(0),[x,y]=S.useState(0),E=S.useMemo(()=>JSON.stringify(n),[n]);S.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const N=i.current,C=N.parentElement?.getBoundingClientRect();C&&(N.width=C.width,N.height=C.height);const T=n&&n.length>1,D=n?.[0]||"#00ae42",k=new Op({canvas:N,buildVolume:e,backgroundColor:1710618,extrusionColor:T?n:D,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=k,fetch(t).then(async z=>{if(!z.ok)throw z.status===404&&(await z.json().catch(()=>({}))).detail?.includes("sliced")?(g(!0),new Error("not_sliced")):new Error("Failed to load G-code");return z.text()}).then(z=>{const L=new Set,X=/^(\s*)T(\d+)(\s*;.*)?$/gim;let R;for(;(R=X.exec(z))!==null;){const K=parseInt(R[2],10);K<=15&&L.add(K)}const Y=new Map,J=Array.from(L).sort((K,F)=>K-F);J.forEach((K,F)=>{Y.set(K,F%8)});const G=[];J.forEach((K,F)=>{const q=n?.[K]||"#00ae42";G[F%8]=q});const W=z.split(`
- `).map(K=>{const F=K.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(F){const q=parseInt(F[2],10);if(q>15)return`; FILTERED: ${K.trim()}`;const ne=Y.get(q)??0;return`${F[1]}T${ne}${F[3]||""}`}return K}).join(`
- `);G.length>0&&(k.extrusionColor=G),k.processGCode(W);const ee=k.layers?.length||0;y(ee),v(ee),k.render(),u(!1)}).catch(z=>{z.message!=="not_sliced"&&f(z.message),u(!1)});const P=()=>{if(N.parentElement&&a.current){const z=N.parentElement.getBoundingClientRect();N.width=z.width,N.height=z.height,a.current.resize()}};return window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,E]);const w=S.useCallback(N=>{if(!a.current)return;const C=Math.max(1,Math.min(N,x));v(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[x]),A=N=>{w(parseInt(N.target.value,10))};return s.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[s.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center",children:[s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),p&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center max-w-sm px-4",children:[s.jsx(Tce,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),s.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer."})]})}),d&&!p&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("div",{className:"text-center text-red-400",children:s.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!p&&x>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Hs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>w(b-1),disabled:b<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(ff,{className:"w-4 h-4"})}),s.jsx("input",{type:"range",min:1,max:x,value:b,onChange:A,className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green"}),s.jsx("button",{onClick:()=>w(b+1),disabled:b>=x,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(Bs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[b," / ",x]})]})})]})}function iJ({archiveId:t,title:e,onClose:n}){const[r,i]=S.useState(null),[a,o]=S.useState(null),[l,c]=S.useState(!0);S.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),S.useEffect(()=>{be.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${be.getArchiveForSlicer(t,d)}`;kc(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Kr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(zt,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="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:[s.jsx(ks,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="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:[s.jsx(nce,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&s.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(K4e,{url:a.has_source?be.getSource3mfDownloadUrl(t):be.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(Qze,{gcodeUrl:be.getArchiveGcode(t),filamentColors:a.filament_colors,className:"w-full h-full"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const j7={"000000":"Black","001489":"Blue","002e96":"Blue","0047bb":"Blue","00482b":"Pine Green","004ea8":"Blue","0056b8":"Cobalt Blue","0069b1":"Lake Blue","0072ce":"Blue","0078bf":"Marine Blue","0085ad":"Light Blue","0086d6":"Cyan","008bda":"Blue","009639":"Green","009bd8":"Cyan","009fa1":"Teal","00a6a0":"Green","00ae42":"Bambu Green","00b1b7":"Turquoise","00bb31":"Green","018814":"Candy Green","042f56":"Dark Blue","0a2989":"Blue","0a2ca5":"Blue","0c2340":"Navy Blue","0c3b95":"Blue",101820:"Black","147bd1":"Blue","164b35":"Green","16b08e":"Malachite Green","1d7c6a":"Oxide Green Metallic","1f79e5":"Lake Blue","2140b4":"Blue","25282a":"Black","2842ad":"Royal Blue","2d2b28":"Onyx Black Sparkle",324585:"Indigo Blue",353533:"Gray","39541a":"Forest Green","39699e":"Cobalt Blue Metallic","3b665e":"Green","3f5443":"Alpine Green Sparkle","3f8e43":"Mistletoe Green",424379:"Nebulae","43403d":"Iron Gray Metallic",482960:"Indigo Purple","483d8b":"Royal Purple Sparkle","489fdf":"Azure","4c241c":"Rosewood","4ce4a0":"Green","4d3324":"Dark Chocolate","4d5054":"Lava Gray","4dafda":"Cyan","4f3f24":"Black Walnut",515151:"Dark Gray","515a6c":"Gray",545454:"Dark Gray",565656:"Titan Gray","56b7e6":"Sky Blue",583061:"Violet Purple","5898dd":"Blue",594177:"Purple","5b492f":"Brown","5b6579":"Blue Gray","5c9748":"Matcha Green","5e43b7":"Purple","5e4b3c":"Copper","5f6367":"Titan Gray","61b0ff":"Translucent Light Blue","61bf36":"Green","61c680":"Grass Green","6667ab":"Lavender Blue","684a43":"Brown",686865:"Black","68724d":"Dark Green",688197:"Blue Gray","69398e":"Iris Purple","6e88bc":"Jeans Blue","6ee53c":"Lime Green","6f5034":"Cocoa Brown","7248bd":"Lavender","748c45":"Translucent Olive",757575:"Nardo Gray","75aed8":"Blue","77edd7":"Translucent Teal","789d4a":"Olive","792b36":"Crimson Red Sparkle","7ac0e9":"Glow Blue","7ae1bf":"Mint","7cd82b":"Lime Green","7d6556":"Dark Brown","8344b0":"Purple","847d48":"Bronze","854ce4":"Purple","8671cb":"Purple",875718:"Peanut Brown","87909a":"Silver","898d8d":"Gray","8a949e":"Gray","8e8e8e":"Translucent Gray","8e9089":"Gray","90ff1a":"Neon Green",918669:"Classic Birch",939393:"Gray",950051:"Plum","951e23":"Burgundy Red",959698:"Silver","96d8af":"Light Jade","96dcb9":"Mint","995f11":"Clay Brown","999d9d":"Gray","9b9ea0":"Ash Gray","9d2235":"Maroon Red","9d432c":"Brown","9e007e":"Purple","9ea2a2":"Gray","9f332a":"Brick Red",a1ffac:"Glow Green",a3d8e1:"Ice Blue",a6a9aa:"Silver",a8a8aa:"Gray",a8c6ee:"Baby Blue",aa6443:"Copper Brown Metallic",ad4e38:"Red Granite",adb1b2:"Gray",ae835b:"Caramel",ae96d4:"Lilac Purple",af1685:"Purple",afb1ae:"Gray",b15533:"Terracotta",b28b33:"Gold",b39b84:"Iridium Gold Metallic",b50011:"Red",b8acd6:"Lavender",b8cde9:"Ice Blue",ba9594:"Rose Gold",bb3d43:"Dark Red",bc0900:"Red",becf00:"Bright Green",c0df16:"Green",c12e1f:"Red",c2e189:"Apple Green",c3e2d6:"Light Cyan",c5ed48:"Lime",c6001a:"Red",c6c6c6:"Gray",c8102e:"Red",c8c8c8:"Silver",c98935:"Ochre Yellow",c9a381:"Translucent Brown",cbc6b8:"Bone White",cdceca:"Gray",cea629:"Classic Gold Sparkle",d02727:"Candy Red",d1d3d5:"Light Gray",d32941:"Red",d3b7a7:"Latte Brown",d6001c:"Red",d6abff:"Translucent Purple",d6cca3:"White Oak",dc3a27:"Orange",dd3c22:"Vermilion Red",de4343:"Scarlet Red",dfd1a7:"Beige",e02928:"Red",e4bd68:"Gold",e5b03d:"Gold",e83100:"Red",e8afcf:"Sakura Pink",e8dbb7:"Desert Tan",eaeae4:"White",eaeceb:"Silver",ec008c:"Magenta",ed0000:"Red",eeb1c1:"Pink",efe255:"Yellow",f0f1a8:"Clear",f17b8f:"Glow Pink",f3cfb2:"Champagne",f3e600:"Yellow",f48438:"Orange",f4a925:"Gold",f4d53f:"Yellow",f4ee2a:"Yellow",f5547c:"Hot Pink",f55a74:"Pink",f5b6cd:"Cherry Pink",f5dbab:"Mellow Yellow",f5f1dd:"White",f68b1b:"Neon Orange",f74e02:"Orange",f75403:"Orange",f7ada6:"Pink",f7d959:"Lemon Yellow",f7e6de:"Beige",f7f3f0:"White Marble",f8ff80:"Glow Yellow",f99963:"Mandarin Orange",f9c1bd:"Translucent Pink",f9dfb9:"Cream",f9ef41:"Yellow",f9f7f2:"Nature",f9f7f4:"White",fce300:"Yellow",fce900:"Yellow",fec600:"Sunflower Yellow",fedb00:"Yellow",ff4800:"Orange",ff671f:"Orange",ff6a13:"Orange",ff7f41:"Orange",ff9016:"Pumpkin Orange",ff911a:"Translucent Orange",ff9d5b:"Glow Orange",ffb549:"Sunflower Yellow",ffc72c:"Tangerine Yellow",ffce00:"Yellow",ffd00b:"Yellow",ffe133:"Yellow",fffaf2:"White",ffffff:"White"};function Zze(t){if(!t||t.length<6)return"Unknown";const e=t.replace("#",""),n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),i=parseInt(e.substring(4,6),16),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,p=r/255,g=i/255;a===f?c=((p-g)/d+(p<g?6:0))/6:a===p?c=((g-f)/d+2)/6:c=((f-p)/d+4)/6}return c=c*360,l<.15?"Black":l>.85?"White":u<.15?l<.4?"Dark Gray":l>.6?"Light Gray":"Gray":c<15||c>=345?"Red":c<45?"Orange":c<70?"Yellow":c<150?"Green":c<200?"Cyan":c<260?"Blue":c<290?"Purple":c<345?"Pink":"Unknown"}function Gc(t){const e=t.replace("#","").toLowerCase().substring(0,6);return j7[e]?j7[e]:Zze(t)}const Jze={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},eBe=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 aJ({archiveId:t,archiveName:e,onClose:n,onSuccess:r}){const i=an(),[a,o]=S.useState(null),[l,c]=S.useState(null),[u,d]=S.useState(!1),[f,p]=S.useState(!1),[g,b]=S.useState(Jze),[v,x]=S.useState({});S.useEffect(()=>{x({})},[a,l]),S.useEffect(()=>{const G=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[n]);const{data:y,isLoading:E}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:w}=lt({queryKey:["archive-plates",t],queryFn:()=>be.getArchivePlates(t)});S.useEffect(()=>{w?.plates?.length===1&&c(w.plates[0].index)},[w]);const{data:A}=lt({queryKey:["archive-filaments",t,l],queryFn:()=>be.getArchiveFilamentRequirements(t,l??void 0),enabled:l!==null||!w?.is_multi_plate}),{data:N}=lt({queryKey:["printer-status",a],queryFn:()=>be.getPrinterStatus(a),enabled:!!a}),C=ht({mutationFn:()=>{if(!a)throw new Error("No printer selected");return be.reprintArchive(t,a,{plate_id:l??void 0,ams_mapping:Y,...g})},onSuccess:()=>{r(),n()}}),T=y?.filter(G=>G.is_active)||[],D=w?.is_multi_plate??!1,k=w?.plates??[],P=G=>G?`#${G.replace("#","").substring(0,6)}`:"#808080",z=(G,W,ee,K)=>{const F=String.fromCharCode(65+(G>=128?G-128:G));return ee?`HT-${F}`:`AMS-${F} Slot ${W+1}`},L=(G,W,ee)=>G*4+W,X=S.useMemo(()=>{const G=[];if(N?.ams?.forEach(W=>{const ee=W.tray.length===1;W.tray.forEach(K=>{if(K.tray_type){const F=P(K.tray_color);G.push({type:K.tray_type,color:F,colorName:Gc(F),amsId:W.id,trayId:K.id,isHt:ee,isExternal:!1,label:z(W.id,K.id,ee),globalTrayId:L(W.id,K.id)})}})}),N?.vt_tray?.tray_type){const W=P(N.vt_tray.tray_color);G.push({type:N.vt_tray.tray_type,color:W,colorName:Gc(W),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return G},[N]),R=S.useMemo(()=>{if(!A?.filaments||A.filaments.length===0)return[];const G=K=>K?K.replace("#","").toLowerCase().substring(0,6):"",W=(K,F,q=40)=>{const ne=G(K),re=G(F);if(!ne||!re||ne.length<6||re.length<6)return!1;const se=parseInt(ne.substring(0,2),16),de=parseInt(ne.substring(2,4),16),pe=parseInt(ne.substring(4,6),16),Ce=parseInt(re.substring(0,2),16),oe=parseInt(re.substring(2,4),16),ae=parseInt(re.substring(4,6),16);return Math.abs(se-Ce)<=q&&Math.abs(de-oe)<=q&&Math.abs(pe-ae)<=q},ee=new Set(Object.values(v));return A.filaments.map(K=>{const F=K.slot_id||0;if(F>0&&v[F]!==void 0){const ae=v[F],ge=X.find(ue=>ue.globalTrayId===ae);if(ge){const ue=ge.type?.toUpperCase()===K.type?.toUpperCase(),Le=G(ge.color)===G(K.color)||W(ge.color,K.color);let V;return ue&&Le?V="match":ue?V="type_only":V="mismatch",{...K,loaded:ge,hasFilament:!0,typeMatch:ue,colorMatch:Le,status:V,isManual:!0}}}const q=X.find(ae=>!ee.has(ae.globalTrayId)&&ae.type?.toUpperCase()===K.type?.toUpperCase()&&G(ae.color)===G(K.color)),ne=!q&&X.find(ae=>!ee.has(ae.globalTrayId)&&ae.type?.toUpperCase()===K.type?.toUpperCase()&&W(ae.color,K.color)),re=!q&&!ne&&X.find(ae=>!ee.has(ae.globalTrayId)&&ae.type?.toUpperCase()===K.type?.toUpperCase()),se=q||ne||re||void 0;se&&ee.add(se.globalTrayId);const de=!!se,pe=de,Ce=!!q||!!ne;let oe;return q||ne?oe="match":re?oe="type_only":oe="mismatch",{...K,loaded:se,hasFilament:de,typeMatch:pe,colorMatch:Ce,status:oe,isManual:!1}})},[A,X,v]),Y=S.useMemo(()=>{if(R.length===0)return;const G=Math.max(...R.map(ee=>ee.slot_id||0));if(G<=0)return;const W=new Array(G).fill(-1);return R.forEach(ee=>{ee.slot_id&&ee.slot_id>0&&(W[ee.slot_id-1]=ee.loaded?.globalTrayId??-1)}),W},[R]),J=R.some(G=>G.status==="mismatch");return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",children:s.jsx(_t,{className:"w-full max-w-lg",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Re-print"}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:["Send ",s.jsx("span",{className:"text-white",children:e})," to a printer"]}),E?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):T.length===0?s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:"No active printers available"}):s.jsx("div",{className:"space-y-2 mb-6",children:T.map(G=>s.jsxs("button",{onClick:()=>o(G.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${a===G.id?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${a===G.id?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Qr,{className:`w-5 h-5 ${a===G.id?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-white font-medium",children:G.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[G.model||"Unknown model"," • ",G.ip_address]})]})]},G.id))}),D&&k.length>1&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Hs,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!l&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(yn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:k.map(G=>s.jsxs("button",{onClick:()=>c(G.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${l===G.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[G.has_thumbnail&&G.thumbnail_url?s.jsx("img",{src:G.thumbnail_url,alt:`Plate ${G.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(Hs,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white font-medium truncate",children:G.name||`Plate ${G.index}`}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[G.objects?.length>0?G.objects.slice(0,3).join(", ")+(G.objects.length>3?"...":""):`${G.filaments.length} filament${G.filaments.length!==1?"s":""}`,G.print_time_seconds?` • ${eBe(G.print_time_seconds)}`:""]})]}),l===G.index&&s.jsx(Aa,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},G.index))})]}),a&&(D?l!==null:!0)&&R.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Filament Check"}),s.jsxs("button",{onClick:async()=>{if(a){d(!0);try{await be.refreshPrinterStatus(a),await new Promise(G=>setTimeout(G,500)),await i.refetchQueries({queryKey:["printer-status",a]})}finally{d(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",title:"Re-read AMS status from printer",disabled:u,children:[s.jsx(Rr,{className:`w-3 h-3 ${u?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]}),J?s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(yn,{className:"w-3 h-3"}),"Type not found"]}):R.some(G=>G.status==="type_only")?s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(yn,{className:"w-3 h-3"}),"Color mismatch"]}):s.jsxs("span",{className:"text-xs text-bambu-green flex items-center gap-1",children:[s.jsx(Aa,{className:"w-3 h-3"}),"Ready"]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 space-y-2 text-xs",children:R.map((G,W)=>s.jsxs("div",{className:"grid items-center gap-2",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${G.type} - ${Gc(G.color)}`,children:s.jsx(qb,{className:"w-3 h-3 flex-shrink-0",fill:G.color,stroke:G.color})}),s.jsxs("span",{className:"text-white truncate",children:[G.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",G.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:G.loaded?.globalTrayId??"",onChange:ee=>{const K=G.slot_id||0;if(K>0){const F=ee.target.value;x(F===""?q=>{const ne={...q};return delete ne[K],ne}:q=>({...q,[K]:parseInt(F,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${G.status==="match"?"border-bambu-green/50 text-bambu-green":G.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${G.isManual?"ring-1 ring-blue-400/50":""}`,title:G.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),X.map(ee=>s.jsxs("option",{value:ee.globalTrayId,className:"bg-bambu-dark text-white",children:[ee.label,": ",ee.type," (",ee.colorName,")"]},ee.globalTrayId))]}),G.status==="match"?s.jsx(Aa,{className:"w-3 h-3 text-bambu-green"}):G.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(yn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(yn,{className:"w-3 h-3 text-orange-400"})})]},W))}),J&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]}),a&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("button",{onClick:()=>p(!f),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx($0,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),f?s.jsx(Xc,{className:"w-4 h-4 ml-auto"}):s.jsx(Qi,{className:"w-4 h-4 ml-auto"})]}),f&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[{key:"bed_levelling",label:"Bed Levelling",desc:"Auto-level bed before print"},{key:"flow_cali",label:"Flow Calibration",desc:"Calibrate extrusion flow"},{key:"vibration_cali",label:"Vibration Calibration",desc:"Reduce ringing artifacts"},{key:"layer_inspect",label:"First Layer Inspection",desc:"AI inspection of first layer"},{key:"timelapse",label:"Timelapse",desc:"Record timelapse video"}].map(({key:G,label:W,desc:ee})=>s.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:W}),s.jsx("p",{className:"text-xs text-bambu-gray",children:ee})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${g[G]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>b(K=>({...K,[G]:!K[G]})),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${g[G]?"translate-x-5":"translate-x-0.5"}`})})]},G))})]}),C.isError&&s.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:C.error.message||"Failed to start print"}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ee,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Ee,{onClick:()=>C.mutate(),disabled:!a||D&&!l||C.isPending,className:"flex-1",children:C.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Sending..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Qr,{className:"w-4 h-4"}),"Print"]})})]})]})})})}function tBe({onClose:t,initialFiles:e}){const n=an(),{showToast:r}=Wn(),i=S.useRef(null),[a,o]=S.useState(()=>e?.filter(T=>T.name.endsWith(".3mf")).map(T=>({file:T,status:"pending"}))||[]),[l,c]=S.useState(!1),[u,d]=S.useState(),[f,p]=S.useState(null);S.useEffect(()=>{const T=D=>{D.key==="Escape"&&t()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t]);const{data:g}=lt({queryKey:["printers"],queryFn:be.getPrinters}),b=ht({mutationFn:T=>be.uploadArchivesBulk(T,u),onSuccess:T=>{p(T),n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["archiveStats"]}),o(D=>D.map(k=>{const P=T.results.find(L=>L.filename===k.file.name),z=T.errors.find(L=>L.filename===k.file.name);return P?{...k,status:"success",archiveId:P.id}:z?{...k,status:"error",error:z.error}:k})),T.failed===0?r(`${T.uploaded} file${T.uploaded!==1?"s":""} uploaded`):T.uploaded===0?r(`Failed to upload ${T.failed} file${T.failed!==1?"s":""}`,"error"):r(`${T.uploaded} uploaded, ${T.failed} failed`,"warning")},onError:()=>{o(T=>T.map(D=>({...D,status:"error",error:"Upload failed"}))),r("Upload failed","error")}}),v=S.useCallback(T=>{T.preventDefault(),c(!0)},[]),x=S.useCallback(T=>{T.preventDefault(),c(!1)},[]),y=S.useCallback(T=>{T.preventDefault(),c(!1);const D=Array.from(T.dataTransfer.files).filter(k=>k.name.endsWith(".3mf"));D.length>0&&o(k=>[...k,...D.map(P=>({file:P,status:"pending"}))])},[]),E=S.useCallback(T=>{const D=Array.from(T.target.files||[]).filter(k=>k.name.endsWith(".3mf"));D.length>0&&o(k=>[...k,...D.map(P=>({file:P,status:"pending"}))]),i.current&&(i.current.value="")},[]),w=S.useCallback(T=>{o(D=>D.filter((k,P)=>P!==T))},[]),A=()=>{if(a.length===0)return;const T=a.filter(D=>D.status==="pending");T.length!==0&&(o(D=>D.map(k=>k.status==="pending"?{...k,status:"uploading"}:k)),b.mutate(T.map(D=>D.file)))},N=a.filter(T=>T.status==="pending").length,C=b.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Upload 3MF Files"}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:v,onDragLeave:x,onDrop:y,children:[s.jsx(xi,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:"Drag & drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:"or"}),s.jsx(Ee,{variant:"secondary",onClick:()=>i.current?.click(),disabled:C,children:"Browse Files"}),s.jsx("input",{ref:i,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:E})]})}),s.jsxs("div",{className:"px-4 pb-4",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Associate with printer (optional)"}),s.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:u||"",onChange:T=>d(T.target.value?Number(T.target.value):void 0),disabled:C,children:[s.jsx("option",{value:"",children:"No printer"}),g?.map(T=>s.jsx("option",{value:T.id,children:T.name},T.id))]})]}),a.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:a.map((T,D)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(b2,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:T.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(T.file.size/(1024*1024)).toFixed(1)," MB"]}),T.status==="pending"&&s.jsx("button",{onClick:()=>w(D),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:C,children:s.jsx(zt,{className:"w-4 h-4"})}),T.status==="uploading"&&s.jsx(ft,{className:"w-4 h-4 text-bambu-green animate-spin"}),T.status==="success"&&s.jsx(pr,{className:"w-4 h-4 text-bambu-green"}),T.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:T.error}),s.jsx(pa,{className:"w-4 h-4 text-red-400"})]})]},`${T.file.name}-${D}`))})}),f&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:f.uploaded})," uploaded",f.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:f.failed})," failed"]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ee,{variant:"secondary",onClick:t,className:"flex-1",children:f?"Close":"Cancel"}),!f&&s.jsx(Ee,{onClick:A,disabled:N===0||C,className:"flex-1",children:C?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(xi,{className:"w-4 h-4"}),"Upload ",N>0&&`(${N})`]})})]})]})})})}const nBe=["Adhesion failure","Spaghetti / Detached","Layer shift","Clogged nozzle","Filament runout","Warping","Stringing","Under-extrusion","Power failure","User cancelled","Other"],rBe=[{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"aborted",label:"Cancelled"},{value:"printing",label:"Printing"}];function sJ({archive:t,onClose:e,existingTags:n=[]}){S.useEffect(()=>{const se=de=>{de.key==="Escape"&&e()};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[e]);const r=an(),[i,a]=S.useState(t.print_name||""),[o,l]=S.useState(t.printer_id),[c,u]=S.useState(t.project_id??null),[d,f]=S.useState(t.notes||""),[p,g]=S.useState(t.tags||""),[b,v]=S.useState(t.failure_reason||""),[x,y]=S.useState(t.status),[E,w]=S.useState(t.quantity??1),[A,N]=S.useState(t.photos||[]),[C,T]=S.useState(!1),[D,k]=S.useState(!1),P=S.useRef(null),z=S.useRef(null),L=S.useRef(null),{data:X}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:R}=lt({queryKey:["projects"],queryFn:()=>be.getProjects()}),{data:Y}=lt({queryKey:["archives"],queryFn:()=>be.getArchives(void 0,1e3,0),enabled:n.length===0}),J=n.length>0?n:[...new Set(Y?.flatMap(se=>se.tags?.split(",").map(de=>de.trim())||[]).filter(Boolean)||[])].sort(),G=p.split(",").map(se=>se.trim()).filter(Boolean),W=J.filter(se=>!G.includes(se)),ee=se=>{if(!G.includes(se)){const de=[...G,se].join(", ");g(de)}L.current!==null&&clearTimeout(L.current),P.current?.focus()},K=se=>{const de=G.filter(pe=>pe!==se).join(", ");g(de)},F=ht({mutationFn:se=>be.updateArchive(t.id,se),onSuccess:()=>{r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["projects"]}),e()}}),q=async se=>{const de=se.target.files?.[0];if(de){T(!0);try{const pe=await be.uploadArchivePhoto(t.id,de);N(pe.photos),r.invalidateQueries({queryKey:["archives"]})}catch(pe){console.error("Failed to upload photo:",pe)}finally{T(!1),z.current&&(z.current.value="")}}},ne=async se=>{try{const de=await be.deleteArchivePhoto(t.id,se);N(de.photos||[]),r.invalidateQueries({queryKey:["archives"]})}catch(de){console.error("Failed to delete photo:",de)}},re=se=>{se.preventDefault();const de={print_name:i||void 0,printer_id:o,project_id:c,notes:d||void 0,tags:p||void 0,quantity:E};x!==t.status&&(de.status=x),x==="failed"||x==="aborted"?de.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(de.failure_reason=null),F.mutate(de)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:se=>se.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Edit Archive"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:re,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:se=>a(se.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsxs("select",{value:o??"",onChange:se=>l(se.target.value?Number(se.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:[s.jsx("option",{value:"",children:"No printer"}),X?.map(se=>s.jsx("option",{value:se.id,children:se.name},se.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(ma,{className:"w-4 h-4 inline mr-1"}),"Project"]}),s.jsxs("select",{value:c??"",onChange:se=>u(se.target.value?Number(se.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:[s.jsx("option",{value:"",children:"No project"}),R?.map(se=>s.jsx("option",{value:se.id,children:se.name},se.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Jce,{className:"w-4 h-4 inline mr-1"}),"Items Printed"]}),s.jsx("input",{type:"number",min:1,value:E,onChange:se=>w(Math.max(1,parseInt(se.target.value)||1)),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:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of items produced in this print job"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:se=>f(se.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..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),G.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:G.map(se=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[s.jsx($p,{className:"w-3 h-3"}),se,s.jsx("button",{type:"button",onClick:()=>K(se),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-3 h-3"})})]},se))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:P,type:"text",value:p,onChange:se=>g(se.target.value),onFocus:()=>{L.current!==null&&clearTimeout(L.current),k(!0)},onBlur:()=>{L.current=window.setTimeout(()=>k(!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:G.length>0?"Add more tags...":"Add tags..."}),D&&W.length>0&&s.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:[s.jsx("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:"Existing tags (click to add)"}),s.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:W.map(se=>s.jsx("button",{type:"button",onClick:()=>ee(se),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:se},se))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Status"}),s.jsx("select",{value:x,onChange:se=>{y(se.target.value),se.target.value==="completed"&&v("")},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:rBe.map(se=>s.jsx("option",{value:se.value,children:se.label},se.value))})]}),(x==="failed"||x==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Failure Reason"}),s.jsxs("select",{value:b,onChange:se=>v(se.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:[s.jsx("option",{value:"",children:"Select reason..."}),nBe.map(se=>s.jsx("option",{value:se,children:se},se))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(zp,{className:"w-4 h-4 inline mr-1"}),"Photos of Printed Result"]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[A.map(se=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:be.getArchivePhotoUrl(t.id,se),alt:"Print result",className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>ne(se),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(ln,{className:"w-3 h-3 text-white"})})]},se)),s.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:[s.jsx("input",{ref:z,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:q,className:"hidden",disabled:C}),C?s.jsx(ft,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(dr,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Click + to add photos of your printed result"})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{type:"submit",disabled:F.isPending,className:"flex-1",children:[s.jsx(Rs,{className:"w-4 h-4"}),F.isPending?"Saving...":"Save"]})]})]})]})})}function oJ({x:t,y:e,items:n,onClose:r}){const i=S.useRef(null),[a,o]=S.useState(null),l=S.useRef(null),[c,u]=S.useState({x:t,y:e,visible:!1}),[d,f]=S.useState(!1),[p,g]=S.useState({});S.useEffect(()=>{const x=w=>{i.current&&!i.current.contains(w.target)&&r()},y=w=>{w.key==="Escape"&&r()},E=()=>{r()};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),document.addEventListener("scroll",E,!0),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y),document.removeEventListener("scroll",E,!0),l.current&&clearTimeout(l.current)}},[r]),S.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const x=i.current.getBoundingClientRect(),y=window.innerWidth,E=window.innerHeight,w=8;let A=t,N=e;t+x.width>y-w&&(A=Math.max(w,y-x.width-w)),A<w&&(A=w),e+x.height>E-w&&(N=Math.max(w,E-x.height-w)),N<w&&(N=w);const C=180,T=y-A-x.width,D=A;f(T<C&&D>C),u({x:A,y:N,visible:!0})}},[t,e]);const b=(x,y)=>{l.current&&(clearTimeout(l.current),l.current=null);const E=y.getBoundingClientRect(),w=window.innerHeight,A=300,T=w-E.top-8<A&&E.top>A;g(D=>({...D,[x]:T?"bottom":"top"})),o(x)},v=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.jsx("div",{ref:i,className:"fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1",style:{left:c.x,top:c.y,visibility:c.visible?"visible":"hidden"},children:n.map((x,y)=>{if(x.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const E=x.submenu&&x.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:w=>E&&b(y,w.currentTarget),onMouseLeave:()=>E&&v(),children:[s.jsxs("button",{onMouseEnter:w=>E&&b(y,w.currentTarget.parentElement),onClick:()=>{E?o(a===y?null:y):x.disabled||(x.onClick(),r())},disabled:x.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${x.disabled?"text-bambu-gray cursor-not-allowed":x.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${E&&a===y?"bg-bambu-dark-tertiary":""}`,children:[x.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:x.icon}),s.jsx("span",{className:"flex-1",children:x.label}),E&&s.jsx(Bs,{className:"w-4 h-4 text-bambu-gray"})]}),E&&a===y&&s.jsx("div",{className:`absolute min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${d?"right-full mr-1":"left-full ml-1"} ${p[y]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>v(),children:x.submenu.map((w,A)=>s.jsxs("button",{onClick:()=>{w.disabled||(w.onClick(),r())},disabled:w.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${w.disabled?"text-bambu-gray cursor-not-allowed":w.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[w.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:w.icon}),w.label]},A))})]},y)})})}function iBe({selectedIds:t,existingTags:e,onClose:n}){const r=an(),{showToast:i}=Wn(),[a,o]=S.useState(""),[l,c]=S.useState(new Set),[u,d]=S.useState("add");S.useEffect(()=>{const v=x=>{x.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]);const f=ht({mutationFn:async()=>{const v=Array.from(l);let x=0;for(const y of t)try{const E=await be.getArchive(y),w=E.tags?E.tags.split(",").map(N=>N.trim()).filter(Boolean):[];let A;u==="add"?A=[...new Set([...w,...v])]:A=w.filter(N=>!l.has(N)),await be.updateArchive(y,{tags:A.join(", ")}),x++}catch(E){throw console.error(`Failed to update archive ${y}:`,E),new Error(`Failed on archive ${y}: ${E instanceof Error?E.message:"Unknown error"}`)}return{count:x,mode:u,tags:v}},onSuccess:({count:v,mode:x,tags:y})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${x==="add"?"Added":"Removed"} ${y.length} tag${y.length!==1?"s":""} ${x==="add"?"to":"from"} ${v} archive${v!==1?"s":""}`),n()},onError:v=>{i(v.message||"Failed to update tags","error")}}),p=v=>{c(x=>{const y=new Set(x);return y.has(v)?y.delete(v):y.add(v),y})},g=()=>{a.trim()&&!l.has(a.trim())&&(c(v=>new Set([...v,a.trim()])),o(""))},b=v=>{v.key==="Enter"&&(v.preventDefault(),g())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-md",children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($p,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ee,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Ee,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.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:v=>o(v.target.value),onKeyDown:b}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:g,disabled:!a.trim(),children:s.jsx(dr,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(v=>s.jsx("button",{onClick:()=>p(v),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(v)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:v},v))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(v=>s.jsxs("span",{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${u==="add"?"bg-green-500/20 text-green-400":"bg-red-500/20 text-red-400"}`,children:[v,s.jsx("button",{onClick:()=>p(v),className:"hover:opacity-70",children:s.jsx(zt,{className:"w-3 h-3"})})]},v))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ee,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Ee,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx($p,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function aBe({selectedIds:t,onClose:e}){const n=an(),{showToast:r}=Wn(),{data:i,isLoading:a}=lt({queryKey:["projects"],queryFn:()=>be.getProjects()});S.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=ht({mutationFn:async d=>(await be.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(p=>p.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=ht({mutationFn:async()=>{for(const d of t)await be.updateArchive(d,{project_id:null});return t.length},onSuccess:d=>{o(),r(`Removed ${d} archive${d!==1?"s":""} from project`),e()},onError:()=>{r("Failed to remove from project","error")}}),u=l.isPending||c.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ma,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),a?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:()=>c.mutate(),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:s.jsx(Wi,{className:"w-4 h-4 text-red-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&s.jsx(ft,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&s.jsxs("div",{className:"flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>s.jsxs("button",{onClick:()=>l.mutate(d.id),disabled:u,className:"w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50",children:[s.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{backgroundColor:d.color?`${d.color}20`:"rgb(var(--bambu-green) / 0.2)"},children:s.jsx(ma,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:d.name}),s.jsxs("p",{className:"text-sm text-bambu-gray truncate",children:[d.archive_count," archive",d.archive_count!==1?"s":"",d.status&&` • ${d.status}`]})]}),l.isPending&&l.variables===d.id&&s.jsx(ft,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&s.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:s.jsx(Ee,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function sBe(t,e){return new Date(t,e+1,0).getDate()}function oBe(t,e){return new Date(t,e,1).getDay()}const lBe=["January","February","March","April","May","June","July","August","September","October","November","December"],cBe=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function uBe({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=S.useState(r.getMonth()),[o,l]=S.useState(r.getFullYear()),[c,u]=S.useState(null),[d,f]=S.useState(null),p=S.useMemo(()=>{const N=new Map;return t.forEach(C=>{const T=fi(C.completed_at||C.created_at)||new Date,D=`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`,k=N.get(D)||[];k.push(C),N.set(D,k)}),N},[t]),g=sBe(o,i),b=oBe(o,i),v=()=>{i===0?(a(11),l(o-1)):a(i-1)},x=()=>{i===11?(a(0),l(o+1)):a(i+1)},y=()=>{a(r.getMonth()),l(r.getFullYear())},E=[];for(let N=0;N<b;N++)E.push(null);for(let N=1;N<=g;N++)E.push(N);const w=c?p.get(c)||[]:[],A=N=>{N!==c&&f(null),u(N)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(ff,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:[lBe[i]," ",o]}),s.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"})]}),s.jsx("button",{onClick:x,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Bs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:cBe.map(N=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:N},N))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:E.map((N,C)=>{if(N===null)return s.jsx("div",{className:"aspect-square"},`empty-${C}`);const T=`${o}-${String(i+1).padStart(2,"0")}-${String(N).padStart(2,"0")}`,D=p.get(T)||[],k=D.length>0,P=N===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),z=T===c,L=D.filter(R=>R.status==="completed").length,X=D.filter(R=>R.status==="failed").length;return s.jsxs("button",{onClick:()=>A(z?null:T),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${z?"bg-bambu-green text-white":P?"bg-bambu-green/20 text-white ring-2 ring-bambu-green":k?"bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white":"hover:bg-bambu-dark-tertiary/50 text-bambu-gray"}`,children:[s.jsx("span",{className:`text-sm font-medium ${P&&!z?"text-bambu-green":""}`,children:N}),k&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${X>0&&L===0?"bg-red-400":X>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:D.length})]})]},N)})}),s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(N=>{const C=new Date(N.completed_at||N.created_at);return C.getMonth()===i&&C.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(N=>{const C=new Date(N.completed_at||N.created_at);return C.getMonth()===i&&C.getFullYear()===o&&N.status==="completed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(N=>{const C=new Date(N.completed_at||N.created_at);return C.getMonth()===i&&C.getFullYear()===o&&N.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:new Date(c+"T12:00:00").toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),w.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:w.map(N=>{const C=N.id===d||N.id===n;return s.jsxs("button",{onClick:()=>{f(N.id),e?.(N)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${C?"":"hover:bg-bambu-dark-tertiary"}`,style:C?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[N.thumbnail_path?s.jsx("img",{src:be.getArchiveThumbnail(N.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:N.print_name||N.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:N.status==="failed"?"text-red-400":"text-green-400",children:N.status==="failed"?"Failed":"Completed"}),N.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:N.filament_color.split(",").map((T,D)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:T}},D))})]})]})]},N.id)})}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function lJ({archiveId:t,archiveName:e,onClose:n}){const r=be.getArchiveQRCodeUrl(t,300);S.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 flex flex-col items-center",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),s.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:s.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),s.jsxs(Ee,{onClick:i,className:"w-full",children:[s.jsx(Yr,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function cJ({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=S.useState(0),[l,c]=S.useState(!1);if(S.useEffect(()=>{const g=b=>{b.key==="Escape"&&r(),b.key==="ArrowLeft"&&o(v=>Math.max(0,v-1)),b.key==="ArrowRight"&&o(v=>Math.min(n.length-1,v+1))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[r,n.length]),S.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=be.getArchivePhotoUrl(t,u),f=()=>{const g=document.createElement("a");g.href=d,g.download=`${e}_photo_${a+1}.jpg`,g.click()},p=()=>{i&&c(!0)};return s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:g=>g.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(Yr,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Ee,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:s.jsx(ln,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-6 h-6"})})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&s.jsx("button",{onClick:()=>o(g=>g-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(ff,{className:"w-8 h-8 text-white"})}),s.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&s.jsx("button",{onClick:()=>o(g=>g+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:s.jsx(Bs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((g,b)=>s.jsx("button",{onClick:()=>o(b),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${b===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:be.getArchivePhotoUrl(t,g),alt:`Thumbnail ${b+1}`,className:"w-full h-full object-cover"})},g))})]}),l&&s.jsx(Un,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function la(t){this.content=t}la.prototype={constructor:la,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 r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new la(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 la(n)},addToStart:function(t,e){return new la([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new la(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new la(i)},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=la.from(t),t.size?new la(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=la.from(t),t.size?new la(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=la.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}};la.from=function(t){if(t instanceof la)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new la(e)};function uJ(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=uJ(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function dJ(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),l=e.child(--a),c=o.nodeSize;if(o==l){n-=c,r-=c;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let u=0,d=Math.min(o.text.length,l.text.length);for(;u<d&&o.text[o.text.length-u-1]==l.text[l.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let u=dJ(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class vt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;if(u>e&&r(c,i+l,a||null,o)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,i+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",o=!0;return this.nodesBetween(e,n,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,n-c):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(o?o=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new vt(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,o=0;o<n;a++){let l=this.content[a],c=o+l.nodeSize;c>e&&((o<e||c>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=c}return new vt(r,i)}cutByIndex(e,n){return e==n?vt.empty:e==0&&n==this.content.length?this:new vt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new vt(i,a)}addToStart(e){return new vt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new vt(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,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return uJ(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return dJ(this,e,n,r)}findIndex(e){if(e==0)return o1(0,e);if(e==this.size)return o1(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?o1(n+1,a):o1(n,r);r=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 vt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new vt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return vt.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new vt(n||e,r)}static from(e){if(!e)return vt.empty;if(e instanceof vt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new vt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}vt.empty=new vt([],0);const wk={index:0,offset:0};function o1(t,e){return wk.index=t,wk.offset=e,wk}function bS(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 r=0;r<t.length;r++)if(!bS(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!bS(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let gr=class RP{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||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&&bS(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 r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return RP.none;if(e instanceof RP)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};gr.none=[];class yS extends Error{}class Dt{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=fJ(this.content,e+this.openStart,n);return r&&new Dt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Dt(hJ(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 Dt.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Dt(vt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Dt(e,r,i)}}Dt.empty=new Dt(vt.empty,0,0);function hJ(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||a.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(hJ(a.content,e-i-1,n-i-1)))}function fJ(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=fJ(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function dBe(t,e,n){if(n.openStart>t.depth)throw new yS("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new yS("Inconsistent open depths");return mJ(t,e,n,0)}function mJ(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=mJ(t,e,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return sf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=hBe(n,t);return sf(a,gJ(t,o,l,e,r))}else return sf(a,vS(t,e,r))}function pJ(t,e){if(!e.type.compatibleContent(t.type))throw new yS("Cannot join "+e.type.name+" onto "+t.type.name)}function DP(t,e,n){let r=t.node(n);return pJ(r,e.node(n)),r}function af(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Tb(t,e,n,r){let i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(af(t.nodeAfter,r),a++));for(let l=a;l<o;l++)af(i.child(l),r);e&&e.depth==n&&e.textOffset&&af(e.nodeBefore,r)}function sf(t,e){return t.type.checkContent(e),t.copy(e)}function gJ(t,e,n,r,i){let a=t.depth>i&&DP(t,e,i+1),o=r.depth>i&&DP(n,r,i+1),l=[];return Tb(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(pJ(a,o),af(sf(a,gJ(t,e,n,r,i+1)),l)):(a&&af(sf(a,vS(t,e,i+1)),l),Tb(e,n,i,l),o&&af(sf(o,vS(n,r,i+1)),l)),Tb(r,null,i,l),new vt(l)}function vS(t,e,n){let r=[];if(Tb(null,t,n,r),t.depth>n){let i=DP(t,e,n+1);af(sf(i,vS(t,e,n+1)),r)}return Tb(e,null,n,r),new vt(r)}function hBe(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(vt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class S0{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,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 r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}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 r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return gr.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let a=r.marks;for(var o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!i||!a[o].isInSet(i.marks))&&(a=a[o--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new _S(this,e,r);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 r=[],i=0,a=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(a),u=a-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;a=u-1,i+=c+1}return new S0(n,r,a)}static resolveCached(e,n){let r=P7.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else P7.set(e,r=new fBe);let i=r.elts[r.i]=S0.resolve(e,n);return r.i=(r.i+1)%mBe,i}}class fBe{constructor(){this.elts=[],this.i=0}}const mBe=12,P7=new WeakMap;class _S{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}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 pBe=Object.create(null);let Ad=class OP{constructor(e,n,r,i=gr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||vt.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,r,i=0){this.content.nodesBetween(e,n,r,i,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,r,i){return this.content.textBetween(e,n,r,i)}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,r){return this.type==e&&bS(this.attrs,n||e.defaultAttrs||pBe)&&gr.sameSet(this.marks,r||gr.none)}copy(e=null){return e==this.content?this:new OP(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new OP(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,r=!1){if(e==n)return Dt.empty;let i=this.resolve(e),a=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,a.pos-l);return new Dt(u,i.depth-o,a.depth-o)}replace(e,n,r){return dBe(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return S0.resolveCached(this,e)}resolveNoCache(e){return S0.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}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()+")"),xJ(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,r=vt.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),o=a&&a.matchFragment(this.content,n);return o?o.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=gr.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!gr.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 r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let i=vt.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Ad.prototype.text=void 0;class wS extends Ad{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):xJ(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 wS(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new wS(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 xJ(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Pf{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new gBe(e,n);if(r.next==null)return Pf.empty;let i=bJ(r);r.next&&r.err("Unexpected trailing text");let a=SBe(wBe(i));return MBe(a,r),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,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}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 r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(o,l){let c=o.matchFragment(e,r);if(c&&(!n||c.validEnd))return vt.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:f}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let p=a(f,l.concat(d));if(p)return p}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||c.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.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(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
- `)}}Pf.empty=new Pf(!0);class gBe{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 bJ(t){let e=[];do e.push(xBe(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function xBe(t){let e=[];do e.push(bBe(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function bBe(t){let e=_Be(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=yBe(t,e);else break;return e}function R7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function yBe(t,e){let n=R7(t),r=n;return t.eat(",")&&(t.next!="}"?r=R7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function vBe(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function _Be(t){if(t.eat("(")){let e=bJ(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=vBe(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 wBe(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,c){let u={term:c,to:l};return e[o].push(u),u}function i(o,l){o.forEach(c=>c.to=l)}function a(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=a(o.exprs[c],l);if(c==o.exprs.length-1)return u;i(u,l=n())}else if(o.type=="star"){let c=n();return r(l,c),i(a(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(a(o.expr,l),c),i(a(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(a(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(a(o.expr,c),d),c=d}if(o.max==-1)i(a(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(a(o.expr,c),d),c=d}return[r(c)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function yJ(t,e){return e-t}function D7(t,e){let n=[];return r(e),n.sort(yJ);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let o=0;o<a.length;o++){let{term:l,to:c}=a[o];!l&&n.indexOf(c)==-1&&r(c)}}}function SBe(t){let e=Object.create(null);return n(D7(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<i.length;d++)i[d][0]==l&&(u=i[d][1]);D7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new Pf(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(yJ);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function MBe(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function vJ(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function _J(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function wJ(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function SJ(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new NBe(t,r,e[r]);return n}let O7=class MJ{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=SJ(e,r.attrs),this.defaultAttrs=vJ(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Pf.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:_J(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ad(this,this.computeAttrs(e),vt.from(n),gr.setFrom(r))}createChecked(e=null,n,r){return n=vt.from(n),this.checkContent(n),new Ad(this,this.computeAttrs(e),n,gr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=vt.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(vt.empty,!0);return a?new Ad(this,e,n.append(a),gr.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).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){wJ(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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:gr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,o)=>r[a]=new MJ(a,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function EBe(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class NBe{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?EBe(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class jM{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=SJ(e,i.attrs),this.excluded=null;let a=vJ(this.attrs);this.instance=a?new gr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new gr(this,_J(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new jM(a,i++,n,o)),r}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){wJ(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class EJ{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=la.from(e.nodes),n.marks=la.from(e.marks||{}),this.nodes=O7.compile(this.spec.nodes,this),this.marks=jM.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=Pf.parse(o,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=l=="_"?null:l?L7(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:L7(this,o.split(" "))}this.nodeFromJSON=i=>Ad.fromJSON(this,i),this.markFromJSON=i=>gr.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof O7){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,r,i)}text(e,n){let r=this.nodes.text;return new wS(r,r.defaultAttrs,e,gr.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 L7(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],o=a;if(a)n.push(a);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function ABe(t){return t.tag!=null}function TBe(t){return t.style!=null}let Cb=class LP{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(ABe(i))this.tags.push(i);else if(TBe(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new F7(this,n,!1);return r.addAll(e,gr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new F7(this,n,!0);return r.addAll(e,gr.none,n.from,n.to),Dt.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(jBe(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let o=a.getAttrs(e);if(o===!1)continue;a.attrs=o||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let o=this.styles[a],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let c=o.getAttrs(n);if(c===!1)continue;o.attrs=c||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<a)break}n.splice(o,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(o=>{r(o=U7(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=U7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new LP(e,LP.schemaRules(e)))}};const NJ={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},CBe={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},AJ={ol:!0,ul:!0},M0=1,IP=2,kb=4;function I7(t,e,n){return e!=null?(e?M0:0)|(e==="full"?IP:0):t&&t.whitespace=="pre"?M0|IP:n&~kb}class l1{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=gr.none,this.match=a||(o&kb?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(vt.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&M0)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=vt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(vt.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&&!NJ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class F7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=I7(null,n.preserveWhitespace,0)|(r?kb:0);i?a=new l1(i.type,i.attrs,gr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new l1(null,null,gr.none,!0,null,o):a=new l1(e.schema.topNodeType,null,gr.none,!0,null,o),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 r=e.nodeValue,i=this.top,a=i.options&IP?"full":this.localPreserveWS||(i.options&M0)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;AJ.hasOwnProperty(o)&&this.parser.normalizeLists&&kBe(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:CBe.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(NJ.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}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 r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,o,this,l);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)l=c;else break}}return n}addElementByRule(e,n,r,i){let a,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let c=this.enter(o,n.attrs||null,r,n.preserveWhitespace);c&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,r,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,r),this.findAround(e,c,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,l=0;o>=0;o--){let c=this.nodes[o],u=c.findWrapping(e);if(u&&(!i||i.length>u.length+l)&&(i=u,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=gr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):z7(l.type,e.type))&&(o=l.addToSet(o));return a.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=I7(e,a,o.options);o.options&kb&&o.content.length==0&&(l|=kb);let c=gr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):z7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new l1(e,n,c,i,null,l)),this.open++,r}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|=M0)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].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,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=a;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function kBe(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&AJ.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function jBe(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function U7(t){let e={};for(let n in t)e[n]=t[n];return e}function z7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class Hf{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Sk(n).createDocumentFragment());let i=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let l=0,c=0;for(;l<a.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(a.push([u,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=V1(Sk(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&V1(Sk(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return V1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Hf(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=B7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return B7(e.marks)}}function B7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Sk(t){return t.document||window.document}const $7=new WeakMap;function PBe(t){let e=$7.get(t);return e===void 0&&$7.set(t,e=RBe(t)),e}function RBe(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function V1(t,e,n,r){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 i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=PBe(r))&&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 o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:g,contentDOM:b}=V1(t,p,n,r);if(c.appendChild(g),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:c,contentDOM:l}}const TJ=65535,CJ=Math.pow(2,16);function DBe(t,e){return t+e*CJ}function H7(t){return t&TJ}function OBe(t){return(t-(t&TJ))/CJ}const kJ=1,jJ=2,G1=4,PJ=8;class FP{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&PJ)>0}get deletedBefore(){return(this.delInfo&(kJ|G1))>0}get deletedAfter(){return(this.delInfo&(jJ|G1))>0}get deletedAcross(){return(this.delInfo&G1)>0}}class Ps{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ps.empty)return Ps.empty}recover(e){let n=0,r=H7(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+OBe(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?i:0);if(c>e)break;let u=this.ranges[l+a],d=this.ranges[l+o],f=c+u;if(e<=f){let p=u?e==c?-1:e==f?1:n:n,g=c+i+(p<0?0:d);if(r)return g;let b=e==(n<0?c:f)?null:DBe(l/3,e-c),v=e==c?jJ:e==f?kJ:G1;return(n<0?e!=c:e!=f)&&(v|=PJ),new FP(g,v,b)}i+=d-u}return r?e+i:new FP(e+i,0,null)}touches(e,n){let r=0,i=H7(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[l+a],d=c+u;if(e<=d&&l==i*3)return!0;r+=this.ranges[l+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?a:0),c=o+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=d-u}}invert(){return new Ps(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ps.empty:new Ps(e<0?[0,-e,0]:[0,0,e])}}Ps.empty=new Ps([]);class E0{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new E0(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,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i: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,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new E0;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let o=this._maps[a],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new FP(e,i,null)}}const Mk=Object.create(null);class ja{getMap(){return Ps.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Mk[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Mk)throw new RangeError("Duplicate use of step JSON ID "+e);return Mk[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,r,i){try{return gi.ok(e.replace(n,r,i))}catch(a){if(a instanceof yS)return gi.fail(a.message);throw a}}}function fO(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(fO(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return vt.fromArray(r)}class gd extends ja{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new Dt(fO(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return gi.fromReplace(e,this.from,this.to,a)}invert(){return new Xo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new gd(n.pos,r.pos,this.mark)}merge(e){return e instanceof gd&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new gd(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 gd(n.from,n.to,e.markFromJSON(n.mark))}}ja.jsonID("addMark",gd);class Xo extends ja{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new Dt(fO(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return gi.fromReplace(e,this.from,this.to,r)}invert(){return new gd(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Xo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Xo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xo(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 Xo(n.from,n.to,e.markFromJSON(n.mark))}}ja.jsonID("removeMark",Xo);class xd extends ja{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 r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return gi.fromReplace(e,this.pos,this.pos+1,new Dt(vt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new xd(this.pos,n.marks[i]);return new xd(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 xd(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 xd(n.pos,e.markFromJSON(n.mark))}}ja.jsonID("addNodeMark",xd);class Rf extends ja{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 r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return gi.fromReplace(e,this.pos,this.pos+1,new Dt(vt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new xd(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))}}ja.jsonID("removeNodeMark",Rf);class qi extends ja{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&UP(e,this.from,this.to)?gi.fail("Structure replace would overwrite content"):gi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ps([this.from,this.to-this.from,this.slice.size])}invert(e){return new qi(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new qi(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof qi)||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?Dt.empty:new Dt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new qi(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?Dt.empty:new Dt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new qi(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 qi(n.from,n.to,Dt.fromJSON(e,n.slice),!!n.structure)}}ja.jsonID("replace",qi);class Xi extends ja{constructor(e,n,r,i,a,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=o,this.structure=l}apply(e){if(this.structure&&(UP(e,this.from,this.gapFrom)||UP(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 r=this.slice.insertAt(this.insert,n.content);return r?gi.fromReplace(e,this.from,this.to,r):gi.fail("Content does not fit in gap")}getMap(){return new Ps([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 Xi(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),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new Xi(n.pos,r.pos,i,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 Xi(n.from,n.to,n.gapFrom,n.gapTo,Dt.fromJSON(e,n.slice),n.insert,!!n.structure)}}ja.jsonID("replaceAround",Xi);function UP(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function LBe(t,e,n,r){let i=[],a=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let p=Math.max(u,e),g=Math.min(u+c.nodeSize,n),b=r.addToSet(f);for(let v=0;v<f.length;v++)f[v].isInSet(b)||(o&&o.to==p&&o.mark.eq(f[v])?o.to=g:i.push(o=new Xo(p,g,f[v])));l&&l.to==p?l.to=g:a.push(l=new gd(p,g,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function IBe(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;a++;let c=null;if(r instanceof jM){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],p;for(let g=0;g<i.length;g++){let b=i[g];b.step==a-1&&f.eq(i[g].style)&&(p=b)}p?(p.to=u,p.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new Xo(o.from,o.to,o.style)))}function mO(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new qi(l,d,Dt.empty));else{r=f;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new Xo(l,d,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,g=/\r?\n|\r/g,b;for(;p=g.exec(u.text);)b||(b=new Dt(vt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new qi(l+p.index,l+p.index+p[0].length,b))}}l=d}if(!r.validEnd){let c=r.fillBefore(vt.empty,!0);t.replace(l,l,new Dt(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function FBe(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ug(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!FBe(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function UBe(t,e,n){let{$from:r,$to:i,depth:a}=e,o=r.before(a+1),l=i.after(a+1),c=o,u=l,d=vt.empty,f=0;for(let b=a,v=!1;b>n;b--)v||r.index(b)>0?(v=!0,d=vt.from(r.node(b).copy(d)),f++):c--;let p=vt.empty,g=0;for(let b=a,v=!1;b>n;b--)v||i.after(b+1)<i.end(b)?(v=!0,p=vt.from(i.node(b).copy(p)),g++):u++;t.step(new Xi(c,u,o,l,new Dt(d.append(p),f,g),d.size-f,!0))}function pO(t,e,n=null,r=t){let i=zBe(t,e),a=i&&BBe(r,e);return a?i.map(V7).concat({type:e,attrs:n}).concat(a.map(V7)):null}function V7(t){return{type:t,attrs:null}}function zBe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let o=a.length?a[0]:e;return n.canReplaceWith(r,i,o)?a:null}function BBe(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),o=e.contentMatch.findWrapping(a.type);if(!o)return null;let c=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;c&&u<i;u++)c=c.matchType(n.child(u).type);return!c||!c.validEnd?null:o}function $Be(t,e,n){let r=vt.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=vt.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new Xi(i,a,i,a,new Dt(r,0,0),n.length,!0))}function HBe(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&VBe(t.doc,t.mapping.slice(a).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!b?u=!1:!g&&b&&(u=!0)}u===!1&&DJ(t,o,l,a),mO(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),p=d.map(l+o.nodeSize,1);return t.step(new Xi(f,p,f+1,p-1,new Dt(vt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&RJ(t,o,l,a),!1}})}function RJ(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let c=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function DJ(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
- `))}})}function VBe(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function GBe(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Xi(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Dt(vt.from(o),0,0),1,!0))}function Wc(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,d=n-2;u>a;u--,d--){let f=i.node(u),p=i.index(u);if(f.type.spec.isolating)return!1;let g=f.content.cutByIndex(p,f.childCount),b=r&&r[d+1];b&&(g=g.replaceChild(0,b.type.create(b.attrs)));let v=r&&r[d]||f;if(!f.canReplace(p+1,f.childCount)||!v.type.validContent(g))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function WBe(t,e,n=1,r){let i=t.doc.resolve(e),a=vt.empty,o=vt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=vt.from(i.node(l).copy(a));let d=r&&r[u];o=vt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new qi(e,e,new Dt(a.append(o),n,n),!0))}function Xd(t,e){let n=t.resolve(e),r=n.index();return OJ(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function qBe(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),o=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function OJ(t,e){return!!(t&&e&&!t.isLeaf&&qBe(t,e))}function PM(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,o,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),o=r.node(i+1)),a&&!a.isTextblock&&OJ(a,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function KBe(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);DJ(t,d.node(),d.before(),l)}o.inlineContent&&mO(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new qi(u,c.map(e+n,-1),Dt.empty,!0)),r===!0){let d=t.doc.resolve(u);RJ(t,d.node(),d.before(),t.steps.length)}return t}function XBe(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function LJ(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,c=r.index(o)+(l>0?1:0),u=r.node(o),d=!1;if(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function RM(t,e,n=e,r=Dt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return IJ(i,a,r)?new qi(e,n,r):new YBe(i,a,r).fit()}function IJ(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class YBe{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=vt.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=vt.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,l=i.depth;for(;o&&l&&a.childCount==1;)a=a.firstChild.content,o--,l--;let c=new Dt(a,o,l);return e>-1?new Xi(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new qi(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=Ek(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(vt.from(o),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Ek(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Dt(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Ek(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Dt(fb(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Dt(fb(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let v=0;v<a.length;v++)this.openFrontierNode(a[v]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:p}=this.frontier[n];if(i){for(let v=0;v<i.childCount;v++)d.push(i.child(v));f=f.matchFragment(i)}let g=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let v=l.child(u),x=f.matchType(v.type);if(!x)break;u++,(u>1||c==0||v.content.size)&&(f=x,d.push(FJ(v.mark(p.allowedMarks(v.marks)),u==1?c:0,u==l.childCount?g:-1)))}let b=u==l.childCount;b||(g=-1),this.placed=mb(this.placed,n,vt.from(d)),this.frontier[n].match=f,b&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,x=l;v<g;v++){let y=x.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),x=y.content}this.unplaced=b?e==0?Dt.empty:new Dt(fb(o.content,e-1,1),e-1,g<0?o.openEnd:e-1):new Dt(fb(o.content,e,u),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Nk(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:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Nk(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=Nk(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,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=mb(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=mb(this.placed,this.depth,vt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(vt.empty,!0);n.childCount&&(this.placed=mb(this.placed,this.frontier.length,n))}}function fb(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(fb(t.firstChild.content,e-1,n)))}function mb(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(mb(t.lastChild.content,e-1,n)))}function Ek(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function FJ(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,FJ(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(vt.empty,!0)))),t.copy(r)}function Nk(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,o);return l&&!QBe(n,a.content,o)?l:null}function QBe(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function ZBe(t){return t.spec.defining||t.spec.definingForContent}function JBe(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(IJ(i,a,r))return t.step(new qi(e,n,r));let o=zJ(i,a);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let p=i.depth,g=i.pos-1;p>0;p--,g--){let b=i.node(p).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;o.indexOf(p)>-1?l=p:i.before(p)==g&&o.splice(1,0,-p)}let c=o.indexOf(l),u=[],d=r.openStart;for(let p=r.content,g=0;;g++){let b=p.firstChild;if(u.push(b),g==r.openStart)break;p=b.content}for(let p=d-1;p>=0;p--){let g=u[p],b=ZBe(g.type);if(b&&!g.sameMarkup(i.node(Math.abs(l)-1)))d=p;else if(b||!g.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let g=(p+d+1)%(r.openStart+1),b=u[g];if(b)for(let v=0;v<o.length;v++){let x=o[(v+c)%o.length],y=!0;x<0&&(y=!1,x=-x);let E=i.node(x-1),w=i.index(x-1);if(E.canReplaceWith(w,w,b.type,b.marks))return t.replace(i.before(x),y?a.after(x):n,new Dt(UJ(r.content,0,r.openStart,g),g,r.openEnd))}}let f=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>f));p--){let g=o[p];g<0||(e=i.before(g),n=a.after(g))}}function UJ(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(UJ(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(vt.empty,!0))}return t}function e8e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=XBe(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Dt(vt.from(r),0,0))}function t8e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=zJ(r,i);for(let o=0;o<a.length;o++){let l=a[o],c=o==a.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function zJ(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class Lp extends ja{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return gi.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return gi.fromReplace(e,this.pos,this.pos+1,new Dt(vt.from(i),0,n.isLeaf?0:1))}getMap(){return Ps.empty}invert(e){return new Lp(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 Lp(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 Lp(n.pos,n.attr,n.value)}}ja.jsonID("attr",Lp);class N0 extends ja{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return gi.ok(r)}getMap(){return Ps.empty}invert(e){return new N0(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 N0(n.attr,n.value)}}ja.jsonID("docAttr",N0);let lg=class extends Error{};lg=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};lg.prototype=Object.create(Error.prototype);lg.prototype.constructor=lg;lg.prototype.name="TransformError";class BJ{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new E0}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new lg(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,r=Dt.empty){let i=RM(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Dt(vt.from(r),0,0))}delete(e,n){return this.replace(e,n,Dt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return JBe(this,e,n,r),this}replaceRangeWith(e,n,r){return e8e(this,e,n,r),this}deleteRange(e,n){return t8e(this,e,n),this}lift(e,n){return UBe(this,e,n),this}join(e,n=1){return KBe(this,e,n),this}wrap(e,n){return $Be(this,e,n),this}setBlockType(e,n=e,r,i=null){return HBe(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return GBe(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Lp(e,n,r)),this}setDocAttribute(e,n){return this.step(new N0(e,n)),this}addNodeMark(e,n){return this.step(new xd(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof gr)n.isInSet(r.marks)&&this.step(new Rf(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new Rf(e,a)),i=a.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return WBe(this,e,n,r),this}addMark(e,n,r){return LBe(this,e,n,r),this}removeMark(e,n,r){return IBe(this,e,n,r),this}clearIncompatible(e,n,r){return mO(this,e,n,r),this}}const Ak=Object.create(null);class bn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new n8e(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=Dt.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Dt.empty:n),l==0&&q7(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),q7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Jt(e):mp(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let o=n<0?mp(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):mp(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new zs(e.node(0))}static atStart(e){return mp(e,e,0,0,1)||new zs(e)}static atEnd(e){return mp(e,e,e.content.size,e.childCount,-1)||new zs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ak[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ak)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ak[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Jt.between(this.$anchor,this.$head).getBookmark()}}bn.prototype.visible=!0;class n8e{constructor(e,n){this.$from=e,this.$to=n}}let G7=!1;function W7(t){!G7&&!t.parent.inlineContent&&(G7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Jt extends bn{constructor(e,n=e){W7(e),W7(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return bn.near(r);let i=e.resolve(n.map(this.anchor));return new Jt(i.parent.inlineContent?i:r,r)}replace(e,n=Dt.empty){if(super.replace(e,n),n==Dt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Jt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new DM(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 Jt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=bn.findFrom(n,r,!0)||bn.findFrom(n,-r,!0);if(a)n=a.$head;else return bn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(bn.findFrom(e,-r,!0)||bn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Jt(e,n)}}bn.jsonID("text",Jt);class DM{constructor(e,n){this.anchor=e,this.head=n}map(e){return new DM(e.map(this.anchor),e.map(this.head))}resolve(e){return Jt.between(e.resolve(this.anchor),e.resolve(this.head))}}class Kt extends bn{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?bn.near(a):new Kt(a)}content(){return new Dt(vt.from(this.node),0,0)}eq(e){return e instanceof Kt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new gO(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Kt(e.resolve(n.anchor))}static create(e,n){return new Kt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Kt.prototype.visible=!1;bn.jsonID("node",Kt);class gO{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new DM(r,r):new gO(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Kt.isSelectable(r)?new Kt(n):bn.near(n)}}class zs extends bn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Dt.empty){if(n==Dt.empty){e.delete(0,e.doc.content.size);let r=bn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new zs(e)}map(e){return new zs(e)}eq(e){return e instanceof zs}getBookmark(){return r8e}}bn.jsonID("all",zs);const r8e={map(){return this},resolve(t){return new zs(t)}};function mp(t,e,n,r,i,a=!1){if(e.inlineContent)return Jt.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!a&&Kt.isSelectable(l))return Kt.create(t,n-(i<0?l.nodeSize:0))}else{let c=mp(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function q7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof qi||i instanceof Xi))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(bn.near(t.doc.resolve(o),n))}const K7=1,c1=2,X7=4;class i8e extends BJ{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|K7)&~c1,this.storedMarks=null,this}get selectionSet(){return(this.updated&K7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=c1,this}ensureMarks(e){return gr.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&c1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~c1,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||gr.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(bn.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|=X7,this}get scrolledIntoView(){return(this.updated&X7)>0}}function Y7(t,e){return!e||!t?t:t.bind(e)}class pb{constructor(e,n,r){this.name=e,this.init=Y7(n.init,r),this.apply=Y7(n.apply,r)}}const a8e=[new pb("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new pb("selection",{init(t,e){return t.selection||bn.atStart(e.doc)},apply(t){return t.selection}}),new pb("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new pb("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Tk{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=a8e.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new pb(r.key,r.spec.state,r))})}}class Mp{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 r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[o]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Mp(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new i8e(this)}static create(e){let n=new Tk(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Mp(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new Tk(this.schema,e.plugins),r=n.fields,i=new Mp(n);for(let a=0;a<r.length;a++){let o=r[a].name;i[o]=this.hasOwnProperty(o)?this[o]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Tk(e.schema,e.plugins),a=new Mp(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=Ad.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=bn.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function $J(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=$J(i,e,{})),n[r]=i}return n}class Fr{constructor(e){this.spec=e,this.props={},e.props&&$J(e.props,this,this.props),this.key=e.key?e.key.key:HJ("plugin")}getState(e){return e[this.key]}}const Ck=Object.create(null);function HJ(t){return t in Ck?t+"$"+ ++Ck[t]:(Ck[t]=0,t+"$")}class Li{constructor(e="key"){this.key=HJ(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const xO=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function VJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const GJ=(t,e,n)=>{let r=VJ(t,n);if(!r)return!1;let i=bO(r);if(!i){let o=r.blockRange(),l=o&&Ug(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(eee(t,i,e,-1))return!0;if(r.parent.content.size==0&&(cg(a,"end")||Kt.isSelectable(a)))for(let o=r.depth;;o--){let l=RM(t.doc,r.before(o),r.after(o),Dt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(cg(a,"end")?bn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Kt.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},s8e=(t,e,n)=>{let r=VJ(t,n);if(!r)return!1;let i=bO(r);return i?WJ(t,i,e):!1},o8e=(t,e,n)=>{let r=KJ(t,n);if(!r)return!1;let i=yO(r);return i?WJ(t,i,e):!1};function WJ(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,l=o,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=RM(t.doc,a,c,Dt.empty);if(!u||u.from!=a||u instanceof qi&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(Jt.create(d.doc,a)),n(d.scrollIntoView())}return!0}function cg(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const qJ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=bO(r)}let o=a&&a.nodeBefore;return!o||!Kt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Kt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function bO(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 KJ(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const XJ=(t,e,n)=>{let r=KJ(t,n);if(!r)return!1;let i=yO(r);if(!i)return!1;let a=i.nodeAfter;if(eee(t,i,e,1))return!0;if(r.parent.content.size==0&&(cg(a,"start")||Kt.isSelectable(a))){let o=RM(t.doc,r.before(),r.after(),Dt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(cg(a,"start")?bn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Kt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},YJ=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=yO(r)}let o=a&&a.nodeAfter;return!o||!Kt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Kt.create(t.doc,a.pos)).scrollIntoView()),!0)};function yO(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 l8e=(t,e)=>{let n=t.selection,r=n instanceof Kt,i;if(r){if(n.node.isTextblock||!Xd(t.doc,n.from))return!1;i=n.from}else if(i=PM(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Kt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},c8e=(t,e)=>{let n=t.selection,r;if(n instanceof Kt){if(n.node.isTextblock||!Xd(t.doc,n.to))return!1;r=n.to}else if(r=PM(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},u8e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Ug(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},QJ=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function vO(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 d8e=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=vO(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(bn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},ZJ=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof zs||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=vO(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,a.createAndFill());l.setSelection(Jt.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},JJ=(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(Wc(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ug(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function h8e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Kt&&e.selection.node.isBlock)return!r.parentOffset||!Wc(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,l,c=!1,u=!1;for(let g=r.depth;;g--)if(r.node(g).isBlock){c=r.end(g)==r.pos+(r.depth-g),u=r.start(g)==r.pos-(r.depth-g),l=vO(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),a.unshift(c&&l?{type:l}:null),o=g;break}else{if(g==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof Jt||e.selection instanceof zs)&&d.deleteSelection();let f=d.mapping.map(r.pos),p=Wc(d.doc,f,a.length,a);if(p||(a[0]=l?{type:l}:null,p=Wc(d.doc,f,a.length,a)),!p)return!1;if(d.split(f,a.length,a),!c&&u&&r.node(o).type!=l){let g=d.mapping.map(r.before(o)),b=d.doc.resolve(g);l&&r.node(o-1).canReplaceWith(b.index(),b.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const f8e=h8e(),m8e=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Kt.create(t.doc,i))),!0)};function p8e(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||Xd(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function eee(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&p8e(t,e,n))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&l.matchType(o[0]||a.type).validEnd){if(n){let g=e.pos+a.nodeSize,b=vt.empty;for(let y=o.length-1;y>=0;y--)b=vt.from(o[y].create(null,b));b=vt.from(i.copy(b));let v=t.tr.step(new Xi(e.pos-1,g,e.pos,g,new Dt(b,1,0),o.length,!0)),x=v.doc.resolve(g+2*o.length);x.nodeAfter&&x.nodeAfter.type==i.type&&Xd(v.doc,x.pos)&&v.join(x.pos),n(v.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:bn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),p=f&&Ug(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(u&&cg(a,"start",!0)&&cg(i,"end")){let g=i,b=[];for(;b.push(g),!g.isTextblock;)g=g.lastChild;let v=a,x=1;for(;!v.isTextblock;v=v.firstChild)x++;if(g.canReplace(g.childCount,g.childCount,v.content)){if(n){let y=vt.empty;for(let w=b.length-1;w>=0;w--)y=vt.from(b[w].copy(y));let E=t.tr.step(new Xi(e.pos-b.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new Dt(y,b.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function tee(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(Jt.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const g8e=tee(-1),x8e=tee(1);function b8e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&pO(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Q7(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function _O(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}_O(xO,GJ,qJ);_O(xO,XJ,YJ);_O(QJ,ZJ,JJ,f8e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function y8e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let l=r?n.tr:null;return v8e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function v8e(t,e,n,r=null){let i=!1,a=e,o=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 c=o.resolve(e.start-2);a=new _S(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new _S(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=pO(a,n,r,e);return l?(t&&_8e(t,e,l,i,n),!0):!1}function _8e(t,e,n,r,i){let a=vt.empty;for(let d=n.length-1;d>=0;d--)a=vt.from(n[d].type.create(n[d].attrs,a));t.step(new Xi(e.start-(r?2:0),e.end,e.start,e.end,new Dt(a,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,p=!0;d<f;d++,p=!1)!p&&Wc(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function w8e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?S8e(e,n,t,a):M8e(e,n,a):!0:!1}}function S8e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Xi(a-1,o,a,o,new Dt(vt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new _S(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Ug(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return Xd(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function M8e(t,e,n){let r=t.tr,i=n.parent;for(let g=n.end,b=n.endIndex-1,v=n.startIndex;b>v;b--)g-=i.child(b).nodeSize,r.delete(g-1,g+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?vt.empty:vt.from(i))))return!1;let f=a.pos,p=f+o.nodeSize;return r.step(new Xi(f-(l?1:0),p+(c?1:0),f+1,p-1,new Dt((l?vt.empty:vt.from(i.copy(vt.empty))).append(c?vt.empty:vt.from(i.copy(vt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function E8e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let l=a.parent,c=l.child(o-1);if(c.type!=t)return!1;if(n){let u=c.lastChild&&c.lastChild.type==l.type,d=vt.from(u?t.create():null),f=new Dt(vt.from(t.create(null,vt.from(l.type.create(null,d)))),u?3:1,0),p=a.start,g=a.end;n(e.tr.step(new Xi(p-(u?3:1),g,p,g,f,1,!0)).scrollIntoView())}return!0}}const ha=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ug=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let zP=null;const Nc=function(t,e,n){let r=zP||(zP=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},N8e=function(){zP=null},Df=function(t,e,n,r){return n&&(Z7(t,e,n,r,-1)||Z7(t,e,n,r,1))},A8e=/^(img|br|input|textarea|hr)$/i;function Z7(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:xo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||wy(t)||A8e.test(t.nodeName)||t.contentEditable=="false")return!1;e=ha(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?xo(t):0}else return!1}}function xo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function T8e(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=xo(t)}else if(t.parentNode&&!wy(t))e=ha(t),t=t.parentNode;else return null}}function C8e(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&&!wy(t))e=ha(t)+1,t=t.parentNode;else return null}}function k8e(t,e,n){for(let r=e==0,i=e==xo(t);r||i;){if(t==n)return!0;let a=ha(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==xo(t)}}function wy(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 OM=function(t){return t.focusNode&&Df(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Lh(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function j8e(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function P8e(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(xo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(xo(r.startContainer),r.startOffset)}}}const Ll=typeof navigator<"u"?navigator:null,J7=typeof document<"u"?document:null,Yd=Ll&&Ll.userAgent||"",BP=/Edge\/(\d+)/.exec(Yd),nee=/MSIE \d/.exec(Yd),$P=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Yd),ds=!!(nee||$P||BP),Td=nee?document.documentMode:$P?+$P[1]:BP?+BP[1]:0,wo=!ds&&/gecko\/(\d+)/i.test(Yd);wo&&+(/Firefox\/(\d+)/.exec(Yd)||[0,0])[1];const HP=!ds&&/Chrome\/(\d+)/.exec(Yd),Na=!!HP,ree=HP?+HP[1]:0,Ga=!ds&&!!Ll&&/Apple Computer/.test(Ll.vendor),dg=Ga&&(/Mobile\/\w+/.test(Yd)||!!Ll&&Ll.maxTouchPoints>2),uo=dg||(Ll?/Mac/.test(Ll.platform):!1),R8e=Ll?/Win/.test(Ll.platform):!1,Fc=/Android \d/.test(Yd),Sy=!!J7&&"webkitFontSmoothing"in J7.documentElement.style,D8e=Sy?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function O8e(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 vc(t,e){return typeof t=="number"?t:t[e]}function L8e(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function e9(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=ug(o);continue}let l=o,c=l==a.body,u=c?O8e(a):L8e(l),d=0,f=0;if(e.top<u.top+vc(r,"top")?f=-(u.top-e.top+vc(i,"top")):e.bottom>u.bottom-vc(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+vc(i,"top")-u.top:e.bottom-u.bottom+vc(i,"bottom")),e.left<u.left+vc(r,"left")?d=-(u.left-e.left+vc(i,"left")):e.right>u.right-vc(r,"right")&&(d=e.right-u.right+vc(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let g=l.scrollLeft,b=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let v=l.scrollLeft-g,x=l.scrollTop-b;e={left:e.left-v,top:e.top-x,right:e.right-v,bottom:e.bottom-x}}let p=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:ug(o)}}function I8e(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(a,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=n-20){r=l,i=c.top;break}}return{refDOM:r,refTop:i,stack:iee(t.dom)}}function iee(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ug(r));return e}function F8e({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;aee(n,r==0?0:r-e)}function aee(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let sp=null;function U8e(t){if(t.setActive)return t.setActive();if(sp)return t.focus(sp);let e=iee(t);t.focus(sp==null?{get preventScroll(){return sp={preventScroll:!0},!0}}:void 0),sp||(sp=!1,aee(e,0))}function see(t,e){let n,r=2e8,i,a=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=Nc(d).getClientRects();else continue;for(let g=0;g<p.length;g++){let b=p[g];if(b.top<=o&&b.bottom>=l){o=Math.max(b.bottom,o),l=Math.min(b.top,l);let v=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(v<r){n=d,r=v,i=v&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,d.nodeType==1&&v&&(a=f+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!c&&b.left<=e.left&&b.right>=e.left&&(c=d,u={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?z8e(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:see(n,i)}function z8e(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=Ju(r,1);if(a.top!=a.bottom&&wO(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function wO(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function B8e(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function $8e(t,e,n){let{node:r,offset:i}=see(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();a=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function H8e(t,e,n,r){let i=-1;for(let a=e,o=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&c.left>r.left||c.top>r.top?i=l.posBefore:(!o&&c.right<r.left||c.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(c.top+c.bottom)/2:r.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function oee(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let o=t.childNodes[a];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(wO(e,u))return oee(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function V8e(t,e){let n=t.dom.ownerDocument,r,i=0,a=P8e(n,e.left,e.top);a&&({node:r,offset:i}=a);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let u=t.dom.getBoundingClientRect();if(!wO(e,u)||(o=oee(t.dom,e,u),!o))return null}if(Ga)for(let u=o;r&&u;u=ug(u))u.draggable&&(r=void 0);if(o=B8e(o,e),r){if(wo&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;Sy&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=H8e(t,r,i,e))}l==null&&(l=$8e(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function t9(t){return t.top<t.bottom||t.left<t.right}function Ju(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(t9(r))return r}return Array.prototype.find.call(n,t9)||t.getBoundingClientRect()}const G8e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function lee(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=Sy||wo;if(r.nodeType==3)if(o&&(G8e.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Ju(Nc(r,i,i),n);if(wo&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Ju(Nc(r,i-1,i-1),-1);if(u.top==c.top){let d=Ju(Nc(r,i,i+1),-1);if(d.top!=c.top)return nb(d,d.left<u.left)}}return c}else{let c=i,u=i,d=n<0?1:-1;return n<0&&!i?(u++,d=-1):n>=0&&i==r.nodeValue.length?(c--,d=1):n<0?c--:u++,nb(Ju(Nc(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==xo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return kk(c.getBoundingClientRect(),!1)}if(a==null&&i<xo(r)){let c=r.childNodes[i];if(c.nodeType==1)return kk(c.getBoundingClientRect(),!0)}return kk(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==xo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?Nc(c,xo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return nb(Ju(u,1),!1)}if(a==null&&i<xo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?Nc(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return nb(Ju(u,-1),!0)}return nb(Ju(r.nodeType==3?Nc(r):r,-n),n>=0)}function nb(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 kk(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 cee(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function W8e(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return cee(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let o=lee(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=Nc(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const q8e=/[\u0590-\u08ac]/;function K8e(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!q8e.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:cee(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let g=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:v}=t.domSelectionRange(),x=b&&!g.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==v;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return p!=null&&(l.caretBidiLevel=p),x}):r.pos==r.start()||r.pos==r.end()}let n9=null,r9=null,i9=!1;function X8e(t,e,n){return n9==e&&r9==n?i9:(n9=e,r9=n,i9=n=="up"||n=="down"?W8e(t,e,n):K8e(t,e,n))}const So=0,a9=1,Vh=2,Il=3;class My{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=So,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){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,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.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,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>ha(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let o=this.children[r],l=a+o.size;if(l>e||o instanceof dee){i=e-a;break}a=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof uee&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?ha(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?ha(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let f=l;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=ha(p.dom)+1;break}e-=p.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let d=l+1;d<this.children.length;d++){let f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=ha(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,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:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let g=0,b=0;g<this.children.length;g++){let v=this.children[g],x=b+v.size;if(a>b&&o<x)return v.setSelection(e-b-v.border,n-b-v.border,r,i);b=x}let l=this.domFromPos(e,e?-1:1),c=n==e?l:this.domFromPos(n,n?-1:1),u=r.root.getSelection(),d=r.domSelectionRange(),f=!1;if((wo||Ga)&&e==n){let{node:g,offset:b}=l;if(g.nodeType==3){if(f=!!(b&&g.nodeValue[b-1]==`
- `),f&&b==g.nodeValue.length)for(let v=g,x;v;v=v.parentNode){if(x=v.nextSibling){x.nodeName=="BR"&&(l=c={node:x.parentNode,offset:ha(x)+1});break}let y=v.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let v=g.childNodes[b-1];f=v&&(v.nodeName=="BR"||v.contentEditable=="false")}}if(wo&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let g=d.focusNode.childNodes[d.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||f&&Ga)&&Df(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Df(c.node,c.offset,d.focusNode,d.focusOffset))return;let p=!1;if((u.extend||e==n)&&!(f&&wo)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>n){let b=l;l=c,c=b}let g=document.createRange();g.setEnd(c.node,c.offset),g.setStart(l.node,l.offset),u.removeAllRanges(),u.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 r=0,i=0;i<this.children.length;i++){let a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Vh:a9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Il:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Vh:Il}r=o}this.dirty=Vh}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Vh:a9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class uee extends My{constructor(e,n,r,i){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==So&&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 Y8e extends My{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}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 Of extends My{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Hf.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Of(e,n,o.dom,o.contentDOM||o.dom,o)}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!=So){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=So}}slice(e,n,r){let i=Of.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=GP(a,n,o,r)),e>0&&(a=GP(a,0,e,r));for(let l=0;l<a.length;l++)a[l].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Cd extends My{constructor(e,n,r,i,a,o,l,c,u){super(e,[],a,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,o){let l=a.nodeViews[n.type.name],c,u=l&&l(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=Hf.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=mee(d,r,n),u?c=new Q8e(e,n,r,i,d,f||null,p,u,a,o+1):n.isText?new LM(e,n,r,i,d,p,a):new Cd(e,n,r,i,d,f||null,p,a,o+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 r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>vt.empty)}return e}matchesNode(e,n,r){return this.dirty==So&&e.eq(this.node)&&SS(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,l=a&&a.pos<0,c=new J8e(this,o&&o.node,e);n6e(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?gr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,p)=>{c.syncToMarks(u.marks,r,e);let g;c.findNodeMatch(u,d,f,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(g=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,g,e)||c.updateNextNode(u,d,f,e,p,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Vh)&&(o&&this.protectLocalComposition(e,o),hee(this.contentDOM,this.children,e),dg&&r6e(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Jt)||r<n||i>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 o=a.nodeValue,l=i6e(this.node.content,o,r-n,i-n);return l<0?null:{node:a,pos:l,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){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 o=new Y8e(this,a,n,i);e.input.compositionNodes.push(o),this.children=GP(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Il||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=So}updateOuterDeco(e){if(SS(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=fee(this.dom,this.nodeDOM,VP(this.outerDeco,this.node,n),VP(e,this.node,n)),this.dom!=r&&(r.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 s9(t,e,n,r,i){mee(r,e,t);let a=new Cd(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class LM extends Cd{constructor(e,n,r,i,a,o,l){super(e,n,r,i,a,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Il||this.dirty!=So&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=So||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=So,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new LM(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}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 dee extends My{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==So&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Q8e extends Cd{constructor(e,n,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,u,d),this.spec=c}update(e,n,r,i){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,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}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 hee(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let o=e[a],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=o9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Of){let c=r?r.previousSibling:t.lastChild;hee(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=o9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const jb=function(t){t&&(this.nodeName=t)};jb.prototype=Object.create(null);const Gh=[new jb];function VP(t,e,n){if(t.length==0)return Gh;let r=n?Gh[0]:new jb,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new jb(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new jb(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+c:l=="style"?r.style=(r.style?r.style+";":"")+c:l!="nodeName"&&(r[l]=c))}}}return i}function fee(t,e,n,r){if(n==Gh&&r==Gh)return e;let i=e;for(let a=0;a<r.length;a++){let o=r[a],l=n[a];if(a){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Gh[0]),i=c}Z8e(i,l||Gh[0],o)}return i}function Z8e(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function mee(t,e,n){return fee(t,t,Gh,VP(e,n,t.nodeType!=1))}function SS(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 o9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class J8e{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=e6e(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=So,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Of.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=this.top.children.indexOf(o,this.index);else for(let l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,n,r)&&!this.preMatch.matched.has(u)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let o=this.top.children[i];return o.dirty==Il&&o.dom==o.contentDOM&&(o.dirty=Vh),o.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Cd){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,p=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Il&&SS(n,c.outerDeco));if(!p&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(f=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Vh,f.updateChildren(i,o+1),f.dirty=So),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!SS(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Cd.create(this.top,n,r,i,a,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,n,r,i,a){let o=Cd.create(this.top,e,n,r,i,a);o.contentDOM&&o.updateChildren(i,a+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let a=new uee(this.top,e,n,r);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 Of;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof LM)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ga||Na)&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new dee(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function e6e(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Of)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,a.set(l,i),o.push(l)}}return{index:i,matched:a,matches:o.reverse()}}function t6e(t,e){return t.type.side-e.type.side}function n6e(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let x=i[o++];x.widget&&(d?(f||(f=[d])).push(x):d=x)}if(d)if(f){f.sort(t6e);for(let x=0;x<f.length;x++)n(f[x],u,!!c)}else n(d,u,!!c);let p,g;if(c)g=-1,p=c,c=null;else if(u<t.childCount)g=u,p=t.child(u++);else break;for(let x=0;x<l.length;x++)l[x].to<=a&&l.splice(x--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let b=a+p.nodeSize;if(p.isText){let x=b;o<i.length&&i[o].from<x&&(x=i[o].from);for(let y=0;y<l.length;y++)l[y].to<x&&(x=l[y].to);x<b&&(c=p.cut(x-a),p=p.cut(0,x-a),b=x,g=-1)}else for(;o<i.length&&i[o].to<b;)o++;let v=p.isInline&&!p.isLeaf?l.filter(x=>!x.inline):l.slice();r(p,v,e.forChild(a,p),g),a=b}}function r6e(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 i6e(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let o=t.child(i++),l=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function GP(t,e,n,r,i){let a=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function SO(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(OM(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Kt.isSelectable(f)&&i.parent&&!(f.isInline&&k8e(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;u=new Kt(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let g=0;g<n.rangeCount;g++){let b=n.getRangeAt(g);f=Math.min(f,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(f<0)return null;[c,o]=p==t.state.selection.anchor?[p,f]:[f,p],l=r.resolve(o)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let d=r.resolve(c);if(!u){let f=e=="pointer"||t.state.selection.head<l.pos&&!a?1:-1;u=MO(t,d,l,f)}return u}function pee(t){return t.editable?t.hasFocus():xee(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function qc(t,e=!1){let n=t.state.selection;if(gee(t,n),!!pee(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Na){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Df(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)s6e(t);else{let{anchor:r,head:i}=n,a,o;l9&&!(n instanceof Jt)&&(n.$from.parent.inlineContent||(a=c9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=c9(t,n.to))),t.docView.setSelection(r,i,t,e),l9&&(a&&u9(a),o&&u9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&a6e(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const l9=Ga||Na&&ree<63;function c9(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(Ga&&i&&i.contentEditable=="false")return jk(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return jk(i);if(a)return jk(a)}}function jk(t){return t.contentEditable="true",Ga&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function u9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function a6e(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!pee(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function s6e(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ha(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&ds&&Td<=11&&(n.disabled=!0,n.disabled=!1)}function gee(t,e){if(e instanceof Kt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(d9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else d9(t)}function d9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function MO(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Jt.between(e,n,r)}function h9(t){return t.editable&&!t.hasFocus()?!1:xee(t)}function xee(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 o6e(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Df(e.node,e.offset,n.anchorNode,n.anchorOffset)}function WP(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&bn.findFrom(a,e)}function id(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function f9(t,e,n){let r=t.state.selection;if(r instanceof Jt)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return id(t,new Jt(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=WP(t.state,e);return i&&i instanceof Kt?id(t,i):!1}else if(!(uo&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Kt.isSelectable(a)?id(t,new Kt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):Sy?id(t,new Jt(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Kt&&r.node.isInline)return id(t,new Jt(e>0?r.$to:r.$from));{let i=WP(t.state,e);return i?id(t,i):!1}}}function MS(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Pb(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?l6e(t):c6e(t)}function l6e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(wo&&n.nodeType==1&&r<MS(n)&&Pb(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Pb(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(bee(n))break;{let l=n.previousSibling;for(;l&&Pb(l,-1);)i=n.parentNode,a=ha(l),l=l.previousSibling;if(l)n=l,r=MS(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?qP(t,n,r):i&&qP(t,i,a)}function c6e(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=MS(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Pb(l,1))a=n,o=++r;else break}else{if(bee(n))break;{let l=n.nextSibling;for(;l&&Pb(l,1);)a=l.parentNode,o=ha(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=MS(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&qP(t,a,o)}function bee(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function u6e(t,e){for(;t&&e==t.childNodes.length&&!wy(t);)e=ha(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 d6e(t,e){for(;t&&!e&&!wy(t);)e=ha(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 qP(t,e,n){if(e.nodeType!=3){let a,o;(o=u6e(e,n))?(e=o,n=0):(a=d6e(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(OM(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&qc(t)},50)}function m9(t,e){let n=t.state.doc.resolve(e);if(!(Na||R8e)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function p9(t,e,n){let r=t.state.selection;if(r instanceof Jt&&!r.empty||n.indexOf("s")>-1||uo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=WP(t.state,e);if(o&&o instanceof Kt)return id(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof zs?bn.near(o,e):bn.findFrom(o,e);return l?id(t,l):!1}return!1}function g9(t,e){if(!(t.state.selection instanceof Jt))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)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 o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function x9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function h6e(t){if(!Ga||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;x9(t,r,"true"),setTimeout(()=>x9(t,r,"false"),20)}return!1}function f6e(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function m6e(t,e){let n=e.keyCode,r=f6e(e);if(n==8||uo&&n==72&&r=="c")return g9(t,-1)||op(t,-1);if(n==46&&!e.shiftKey||uo&&n==68&&r=="c")return g9(t,1)||op(t,1);if(n==13||n==27)return!0;if(n==37||uo&&n==66&&r=="c"){let i=n==37?m9(t,t.state.selection.from)=="ltr"?-1:1:-1;return f9(t,i,r)||op(t,i)}else if(n==39||uo&&n==70&&r=="c"){let i=n==39?m9(t,t.state.selection.from)=="ltr"?1:-1:1;return f9(t,i,r)||op(t,i)}else{if(n==38||uo&&n==80&&r=="c")return p9(t,-1,r)||op(t,-1);if(n==40||uo&&n==78&&r=="c")return h6e(t)||p9(t,1,r)||op(t,1);if(r==(uo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function EO(t,e){t.someProp("transformCopied",g=>{e=g(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let g=r.firstChild;n.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let o=t.someProp("clipboardSerializer")||Hf.fromSchema(t.state.schema),l=Mee(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=See[u.nodeName.toLowerCase()]);){for(let g=d.length-1;g>=0;g--){let b=l.createElement(d[g]);for(;c.firstChild;)b.appendChild(c.firstChild);c.appendChild(b),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",g=>g(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:p,slice:e}}function yee(t,e,n,r,i){let a=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",p=>{e=p(e,a||r,t)}),a)return l=new Dt(vt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(f)l=f;else{let p=i.marks(),{schema:g}=t.state,b=Hf.fromSchema(g);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let x=o.appendChild(document.createElement("p"));v&&x.appendChild(b.serializeNode(g.text(v,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=b6e(n),Sy&&y6e(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Cb.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!p6e.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=v6e(b9(l,+d[1],+d[2]),d[4]);else if(l=Dt.maxOpen(g6e(l.content,i),!0),l.openStart||l.openEnd){let f=0,p=0;for(let g=l.content.firstChild;f<l.openStart&&!g.type.spec.isolating;f++,g=g.firstChild);for(let g=l.content.lastChild;p<l.openEnd&&!g.type.spec.isolating;p++,g=g.lastChild);l=b9(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const p6e=/^(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 g6e(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&a.length&&_ee(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=wee(o[o.length-1],a.length));let d=vee(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return vt.from(o)}return t}function vee(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,vt.from(t));return t}function _ee(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=_ee(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(vt.from(vee(n,t,i+1))))}}function wee(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,wee(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(vt.empty,!0);return t.copy(n.append(r))}function KP(t,e,n,r,i,a){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(a=0),i<r-1&&(l=KP(l,e,n,r,i+1,a)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,a<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(vt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function b9(t,e,n){return e<t.openStart&&(t=new Dt(KP(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Dt(KP(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const See={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 y9=null;function Mee(){return y9||(y9=document.implementation.createHTMLDocument("title"))}let Pk=null;function x6e(t){let e=window.trustedTypes;return e?(Pk||(Pk=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Pk.createHTML(t)):t}function b6e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Mee().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&See[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=x6e(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function y6e(t){let e=t.querySelectorAll(Na?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function v6e(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let c=n.nodes[r[l]];if(!c||c.hasRequiredAttrs())break;i=vt.from(c.create(r[l+1],i)),a++,o++}return new Dt(i,a,o)}const Wa={},qa={},_6e={touchstart:!0,touchmove:!0};class w6e{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 S6e(t){for(let e in Wa){let n=Wa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{E6e(t,r)&&!NO(t,r)&&(t.editable||!(r.type in qa))&&n(t,r)},_6e[e]?{passive:!0}:void 0)}Ga&&t.dom.addEventListener("input",()=>null),XP(t)}function bd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function M6e(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 XP(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>NO(t,r))})}function NO(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function E6e(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 N6e(t,e){!NO(t,e)&&Wa[e.type]&&(t.editable||!(e.type in qa))&&Wa[e.type](t,e)}qa.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Nee(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Fc&&Na&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),dg&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,Lh(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||m6e(t,n)?n.preventDefault():bd(t,"key")};qa.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};qa.keypress=(t,e)=>{let n=e;if(Nee(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||uo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Jt)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function IM(t){return{left:t.clientX,top:t.clientY}}function A6e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function AO(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,l=>o>a.depth?l(t,n,a.nodeAfter,a.before(o),i,!0):l(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Ip(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function T6e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Kt.isSelectable(r)?(Ip(t,new Kt(n)),!0):!1}function C6e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Kt&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o);if(Kt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Ip(t,Kt.create(t.state.doc,i)),!0):!1}function k6e(t,e,n,r,i){return AO(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?C6e(t,n):T6e(t,n))}function j6e(t,e,n,r){return AO(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function P6e(t,e,n,r){return AO(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||R6e(t,n,r)}function R6e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Ip(t,Jt.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),l=i.before(a);if(o.inlineContent)Ip(t,Jt.create(r,l+1,l+1+o.content.size));else if(Kt.isSelectable(o))Ip(t,Kt.create(r,l));else continue;return!0}}function TO(t){return ES(t)}const Eee=uo?"metaKey":"ctrlKey";Wa.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=TO(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&A6e(n,t.input.lastClick)&&!n[Eee]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(IM(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new D6e(t,o,n,!!r)):(a=="doubleClick"?j6e:P6e)(t,o.pos,o.inside,n)?n.preventDefault():bd(t,"pointer"))};class D6e{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Eee],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);a=d.parent,o=d.depth?d.before():0}const l=i?null:r.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;(r.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof Kt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&wo&&!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)),bd(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(()=>qc(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(IM(e))),this.updateAllowDefault(e),this.allowDefault||!n?bd(this.view,"pointer"):k6e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ga&&this.mightDrag&&!this.mightDrag.node.isAtom||Na&&!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)?(Ip(this.view,bn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):bd(this.view,"pointer")}move(e){this.updateAllowDefault(e),bd(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)}}Wa.touchstart=t=>{t.input.lastTouch=Date.now(),TO(t),bd(t,"pointer")};Wa.touchmove=t=>{t.input.lastTouch=Date.now(),bd(t,"pointer")};Wa.contextmenu=t=>TO(t);function Nee(t,e){return t.composing?!0:Ga&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const O6e=Fc?5e3:-1;qa.compositionstart=qa.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Jt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),ES(t,!0),t.markCursor=null;else if(ES(t,!e.selection.empty),wo&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}Aee(t,O6e)};qa.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++,Aee(t,20))};function Aee(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ES(t),e))}function Tee(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=I6e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function L6e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=T8e(e.focusNode,e.focusOffset),r=C8e(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function I6e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ES(t,e=!1){if(!(Fc&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Tee(t),e||t.docView&&t.docView.dirty){let n=SO(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function F6e(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 r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const A0=ds&&Td<15||dg&&D8e<604;Wa.copy=qa.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=A0?null:n.clipboardData,o=r.content(),{dom:l,text:c}=EO(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):F6e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function U6e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function z6e(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?T0(t,r.value,null,i,e):T0(t,r.textContent,r.innerHTML,i,e)},50)}function T0(t,e,n,r,i){let a=yee(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Dt.empty)))return!0;if(!a)return!1;let o=U6e(a),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cee(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," "):""}qa.paste=(t,e)=>{let n=e;if(t.composing&&!Fc)return;let r=A0?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&T0(t,Cee(r),r.getData("text/html"),i,n)?n.preventDefault():z6e(t,n)};class kee{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const B6e=uo?"altKey":"ctrlKey";function jee(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[B6e]}Wa.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(IM(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Kt?i.to-1:i.to))){if(r&&r.mightDrag)o=Kt.create(t.state.doc,r.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&&(o=Kt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=EO(t,l);(!n.dataTransfer.files.length||!Na||ree>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(A0?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",A0||n.dataTransfer.setData("text/plain",u),t.dragging=new kee(d,jee(t,n),o)};Wa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};qa.dragover=qa.dragenter=(t,e)=>e.preventDefault();qa.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(IM(n));if(!i)return;let a=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",b=>{o=b(o,t,!1)}):o=yee(t,Cee(n.dataTransfer),A0?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&jee(t,n));if(t.someProp("handleDrop",b=>b(t,n,o||Dt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?LJ(t.state.doc,a.pos,o):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:b}=r;b?b.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,p=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(p))return;let g=u.doc.resolve(d);if(f&&Kt.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Kt(g));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,x,y,E)=>b=E),u.setSelection(MO(t,g,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Wa.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())&&qc(t)},20))};Wa.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)};Wa.beforeinput=(t,e)=>{if(Na&&Fc&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Lh(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in qa)Wa[t]=qa[t];function C0(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 NS{constructor(e,n){this.toDOM=e,this.spec=n||of,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Ba(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof NS&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&C0(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class kd{constructor(e,n){this.attrs=e,this.spec=n||of}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new Ba(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof kd&&C0(this.attrs,e.attrs)&&C0(this.spec,e.spec)}static is(e){return e.type instanceof kd}destroy(){}}class CO{constructor(e,n){this.attrs=e,this.spec=n||of}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=a.pos?null:new Ba(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof CO&&C0(this.attrs,e.attrs)&&C0(this.spec,e.spec)}destroy(){}}class Ba{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ba(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,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Ba(e,e,new NS(n,r))}static inline(e,n,r,i){return new Ba(e,n,new kd(r,i))}static node(e,n,r,i){return new Ba(e,n,new CO(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof kd}get widget(){return this.type instanceof NS}}const pp=[],of={};class Pr{constructor(e,n){this.local=e.length?e:pp,this.children=n.length?n:pp}static create(e,n){return n.length?AS(n,e,0,of):Ma}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!a||a(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,a)}}map(e,n,r){return this==Ma||e.maps.length==0?this:this.mapInner(e,n,0,0,r||of)}mapInner(e,n,r,i,a){let o;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,i);c&&c.type.valid(n,c)?(o||(o=[])).push(c):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?$6e(this.children,o||[],e,n,r,i,a):o?new Pr(o.sort(lf),pp):Ma}add(e,n){return n.length?this==Ma?Pr.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=Ree(n,l,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(l,d,u+1):i.splice(a,0,c,c+l.nodeSize,AS(d,l,u+1,of)),a+=3}});let o=Pee(a?Dee(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new Pr(o.length?this.local.concat(o).sort(lf):this.local,i||this.children)}remove(e){return e.length==0||this==Ma?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let o,l=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(o,l+1);u!=Ma?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,o;a<e.length;a++)if(o=e[a])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new Pr(i,r):Ma}forChild(e,n){if(this==Ma)return this;if(n.isLeaf)return Pr.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let a=e+1,o=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>a&&c.type instanceof kd){let u=Math.max(a,c.from)-a,d=Math.min(o,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new Pr(i.sort(lf),pp);return r?new ud([l,r]):l}return r||Ma}eq(e){if(this==e)return!0;if(!(e instanceof Pr)||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 kO(this.localsInner(e))}localsInner(e){if(this==Ma)return pp;if(e.inlineContent||!this.local.some(kd.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof kd||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Pr.empty=new Pr([],[]);Pr.removeOverlap=kO;const Ma=Pr.empty;class ud{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,of));return ud.from(r)}forChild(e,n){if(n.isLeaf)return Pr.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Ma&&(a instanceof ud?r=r.concat(a.members):r.push(a))}return ud.from(r)}eq(e){if(!(e instanceof ud)||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,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let o=0;o<a.length;o++)n.push(a[o])}}return n?kO(r?n:n.sort(lf)):pp}static from(e){switch(e.length){case 0:return Ma;case 1:return e[0];default:return new ud(e.every(n=>n instanceof Pr)?e:e.reduce((n,r)=>n.concat(r instanceof Pr?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function $6e(t,e,n,r,i,a,o){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((p,g,b,v)=>{let x=v-b-(g-p);for(let y=0;y<l.length;y+=3){let E=l[y+1];if(E<0||p>E+d-f)continue;let w=l[y]+d-f;g>=w?l[y+1]=p<=w?-2:-1:p>=d&&x&&(l[y]+=x,l[y+1]+=x)}f+=x}),d=n.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[u+1]=-1;continue}let d=n.map(t[u]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let p=n.map(t[u+1]+a,-1),g=p-i,{index:b,offset:v}=r.content.findIndex(f),x=r.maybeChild(b);if(x&&v==f&&v+x.nodeSize==g){let y=l[u+2].mapInner(n,x,d+1,t[u]+a+1,o);y!=Ma?(l[u]=f,l[u+1]=g,l[u+2]=y):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=H6e(l,t,e,n,i,a,o),d=AS(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<d.children.length;f+=3){let g=d.children[f];for(;p<l.length&&l[p]<g;)p+=3;l.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new Pr(e.sort(lf),l)}function Pee(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Ba(i.from+e,i.to+e,i.type))}return n}function H6e(t,e,n,r,i,a,o){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+a+1);return n}function Ree(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,o;a<t.length;a++)(o=t[a])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[a]=null);return i}function Dee(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function AS(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Ree(t,l,c+n);if(u){a=!0;let d=AS(u,l,n+c+1,r);d!=Ma&&i.push(c,c+l.nodeSize,d)}});let o=Pee(a?Dee(t):t,-n).sort(lf);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new Pr(o,i):Ma}function lf(t,e){return t.from-e.from||t.to-e.to}function kO(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),v9(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),v9(e,i,r.copy(a.from,r.to)));break}}}return e}function v9(t,e,n){for(;e<t.length&&lf(n,t[e])>0;)e++;t.splice(e,0,n)}function Rk(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ma&&e.push(r)}),t.cursorWrapper&&e.push(Pr.create(t.state.doc,[t.cursorWrapper.deco])),ud.from(e)}const V6e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},G6e=ds&&Td<=11;class W6e{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 q6e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new W6e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);ds&&Td<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),G6e&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,V6e)),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(h9(this.view)){if(this.suppressingSelectionUpdates)return qc(this.view);if(ds&&Td<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Df(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,r;for(let a=e.focusNode;a;a=ug(a))n.add(a);for(let a=e.anchorNode;a;a=ug(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&h9(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(wo&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,p]=d;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of d){let g=p.parentNode;g&&g.nodeName=="LI"&&(!f||Y6e(e,f)!=g)&&p.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&OM(r)&&(u=SO(e))&&u.eq(bn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,qc(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),K6e(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||qc(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(ds&&Td<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:p}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(a=p)}let o=i&&i.parentNode==e.target?ha(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?ha(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let _9=new WeakMap,w9=!1;function K6e(t){if(!_9.has(t)&&(_9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=wo,w9)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."),w9=!0}}function S9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Df(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function X6e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return S9(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?S9(t,n):null}function Y6e(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function Q6e(t,e,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],OM(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Na&&t.input.lastKeyCode===8)for(let x=a;x>i;x--){let y=r.childNodes[x-1],E=y.pmViewDesc;if(y.nodeName=="BR"&&!E){a=x;break}if(!E||E.size)break}let f=t.state.doc,p=t.someProp("domParser")||Cb.fromSchema(t.state.schema),g=f.resolve(o),b=null,v=p.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:a,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Z6e,context:g});if(u&&u[0].pos!=null){let x=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=x),b={anchor:x+o,head:y+o}}return{doc:v,sel:b,from:o,to:l}}function Z6e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ga&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Ga&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const J6e=/^(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 e$e(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=SO(t,T);if(D&&!t.state.selection.eq(D)){if(Na&&Fc&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,Lh(13,"Enter"))))return;let k=t.state.tr.setSelection(D);T=="pointer"?k.setMeta("pointer",!0):T=="key"&&k.scrollIntoView(),a&&k.setMeta("composition",a),t.dispatch(k)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,u=Q6e(t,e,n),d=t.state.doc,f=d.slice(u.from,u.to),p,g;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,g="end"):(p=t.state.selection.from,g="start"),t.input.lastKeyCode=null;let b=r$e(f.content,u.doc.content,u.from,p,g);if(b&&t.input.domChangeCount++,(dg&&t.input.lastIOSEnter>Date.now()-225||Fc)&&i.some(T=>T.nodeType==1&&!J6e.test(T.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",T=>T(t,Lh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&c instanceof Jt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let T=M9(t,t.state.doc,u.sel);if(T&&!T.eq(t.state.selection)){let D=t.state.tr.setSelection(T);a&&D.setMeta("composition",a),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof Jt&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),ds&&Td<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)==" "&&(b.start--,b.endA--,b.endB--);let v=u.doc.resolveNoCache(b.start-u.from),x=u.doc.resolveNoCache(b.endB-u.from),y=d.resolve(b.start),E=v.sameParent(x)&&v.parent.inlineContent&&y.end()>=b.endA;if((dg&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!E&&v.pos<u.doc.content.size&&(!v.sameParent(x)||!v.parent.inlineContent)&&v.pos<x.pos&&!/\S/.test(u.doc.textBetween(v.pos,x.pos,"","")))&&t.someProp("handleKeyDown",T=>T(t,Lh(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&n$e(d,b.start,b.endA,v,x)&&t.someProp("handleKeyDown",T=>T(t,Lh(8,"Backspace")))){Fc&&Na&&t.domObserver.suppressSelectionUpdates();return}Na&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),Fc&&!E&&v.start()!=x.start()&&x.parentOffset==0&&v.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,x=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(T){return T(t,Lh(13,"Enter"))})},20));let w=b.start,A=b.endA,N=T=>{let D=T||t.state.tr.replace(w,A,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let k=M9(t,D.doc,u.sel);k&&!(Na&&t.composing&&k.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(k.head==w||k.head==D.mapping.map(A)-1)||ds&&k.empty&&k.head==w)&&D.setSelection(k)}return a&&D.setMeta("composition",a),D.scrollIntoView()},C;if(E)if(v.pos==x.pos){ds&&Td<=11&&v.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>qc(t),20));let T=N(t.state.tr.delete(w,A)),D=d.resolve(b.start).marksAcross(d.resolve(b.endA));D&&T.ensureMarks(D),t.dispatch(T)}else if(b.endA==b.endB&&(C=t$e(v.parent.content.cut(v.parentOffset,x.parentOffset),y.parent.content.cut(y.parentOffset,b.endA-y.start())))){let T=N(t.state.tr);C.type=="add"?T.addMark(w,A,C.mark):T.removeMark(w,A,C.mark),t.dispatch(T)}else if(v.parent.child(v.index()).isText&&v.index()==x.index()-(x.textOffset?0:1)){let T=v.parent.textBetween(v.parentOffset,x.parentOffset),D=()=>N(t.state.tr.insertText(T,w,A));t.someProp("handleTextInput",k=>k(t,w,A,T,D))||t.dispatch(D())}else t.dispatch(N());else t.dispatch(N())}function M9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:MO(t,e.resolve(n.anchor),e.resolve(n.head))}function t$e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,l,c;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<n.length;d++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[0],o="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(vt.from(u).eq(t))return{mark:l,type:o}}function n$e(t,e,n,r,i){if(n-e<=i.pos-r.pos||Dk(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=t.resolve(Dk(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Dk(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Dk(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function r$e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let c=Math.max(0,a-Math.min(o,l));r-=o+c-a}if(o<a&&t.size<e.size){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<e.size&&E9(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&E9(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function E9(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 Oee{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 w6e,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(k9),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=T9(this),A9(this),this.nodeViews=C9(this),this.docView=s9(this.state.doc,N9(this),Rk(this),this.dom,this),this.domObserver=new q6e(this,(r,i,a,o)=>e$e(this,r,i,a,o)),this.domObserver.start(),S6e(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&&XP(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(k9),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(Tee(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let g=C9(this);a$e(g,this.nodeViews)&&(this.nodeViews=g,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&XP(this),this.editable=T9(this),A9(this);let c=Rk(this),u=N9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let p=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&I8e(this);if(o){this.domObserver.stop();let g=f&&(ds||Na)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&i$e(i.selection,e.selection);if(f){let b=Na?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=L6e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=s9(e.doc,u,c,this.dom,this)),b&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&o6e(this))?qc(this,g):(gee(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&F8e(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Kt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&e9(this,n.getBoundingClientRect(),e)}else e9(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 r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new kee(e.slice,e.move,i<0?void 0:Kt.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(ds){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&&U8e(this.dom),qc(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 V8e(this,e)}coordsAtPos(e,n=1){return lee(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,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return X8e(this,n||this.state,e)}pasteHTML(e,n){return T0(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return T0(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return EO(this,e)}destroy(){this.docView&&(M6e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Rk(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,N8e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return N6e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ga&&this.root.nodeType===11&&j8e(this.dom.ownerDocument)==this.dom&&X6e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Oee.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function N9(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 r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ba.node(0,t.state.doc.content.size,e)]}function A9(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:Ba.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function T9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function i$e(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 C9(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function a$e(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function k9(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 Hd={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:"'"},TS={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},s$e=typeof navigator<"u"&&/Mac/.test(navigator.platform),o$e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var fa=0;fa<10;fa++)Hd[48+fa]=Hd[96+fa]=String(fa);for(var fa=1;fa<=24;fa++)Hd[fa+111]="F"+fa;for(var fa=65;fa<=90;fa++)Hd[fa]=String.fromCharCode(fa+32),TS[fa]=String.fromCharCode(fa);for(var Ok in Hd)TS.hasOwnProperty(Ok)||(TS[Ok]=Hd[Ok]);function l$e(t){var e=s$e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||o$e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?TS:Hd)[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 c$e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),u$e=typeof navigator<"u"&&/Win/.test(navigator.platform);function d$e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l++){let c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))c$e?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function h$e(t){let e=Object.create(null);for(let n in t)e[d$e(n)]=t[n];return e}function Lk(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 f$e(t){return new Fr({props:{handleKeyDown:Lee(t)}})}function Lee(t){let e=h$e(t);return function(n,r){let i=l$e(r),a,o=e[Lk(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Lk(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(u$e&&r.ctrlKey&&r.altKey)&&(a=Hd[r.keyCode])&&a!=i){let l=e[Lk(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var m$e=Object.defineProperty,jO=(t,e)=>{for(var n in e)m$e(t,n,{get:e[n],enumerable:!0})};function FM(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=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 r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var UM=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:r}=e,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(...b)=>{const v=this.buildProps(c,e),x=p(...b)(v);return o.push(x),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:FM({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)(o)]))}};return o}},Iee={};jO(Iee,{blur:()=>p$e,clearContent:()=>g$e,clearNodes:()=>x$e,command:()=>b$e,createParagraphNear:()=>y$e,cut:()=>v$e,deleteCurrentNode:()=>_$e,deleteNode:()=>w$e,deleteRange:()=>S$e,deleteSelection:()=>M$e,enter:()=>E$e,exitCode:()=>N$e,extendMarkRange:()=>A$e,first:()=>T$e,focus:()=>k$e,forEach:()=>j$e,insertContent:()=>P$e,insertContentAt:()=>O$e,joinBackward:()=>F$e,joinDown:()=>I$e,joinForward:()=>U$e,joinItemBackward:()=>z$e,joinItemForward:()=>B$e,joinTextblockBackward:()=>$$e,joinTextblockForward:()=>H$e,joinUp:()=>L$e,keyboardShortcut:()=>G$e,lift:()=>W$e,liftEmptyBlock:()=>q$e,liftListItem:()=>K$e,newlineInCode:()=>X$e,resetAttributes:()=>Y$e,scrollIntoView:()=>Q$e,selectAll:()=>Z$e,selectNodeBackward:()=>J$e,selectNodeForward:()=>eHe,selectParentNode:()=>tHe,selectTextblockEnd:()=>nHe,selectTextblockStart:()=>rHe,setContent:()=>iHe,setMark:()=>wHe,setMeta:()=>SHe,setNode:()=>MHe,setNodeSelection:()=>EHe,setTextDirection:()=>NHe,setTextSelection:()=>AHe,sinkListItem:()=>THe,splitBlock:()=>CHe,splitListItem:()=>kHe,toggleList:()=>jHe,toggleMark:()=>PHe,toggleNode:()=>RHe,toggleWrap:()=>DHe,undoInputRule:()=>OHe,unsetAllMarks:()=>LHe,unsetMark:()=>IHe,unsetTextDirection:()=>FHe,updateAttributes:()=>UHe,wrapIn:()=>zHe,wrapInList:()=>BHe});var p$e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),g$e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),x$e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),p=u.resolve(d.map(c+l.nodeSize)),g=f.blockRange(p);if(!g)return;const b=Ug(g);if(l.type.isTextblock){const{defaultType:v}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(g.start,v)}(b||b===0)&&e.lift(g,b)})}),!0},b$e=t=>e=>t(e),y$e=()=>({state:t,dispatch:e})=>ZJ(t,e),v$e=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new Jt(r.doc.resolve(Math.max(o-1,0)))),!0},_$e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const l=i.before(a),c=i.after(a);t.delete(l,c).scrollIntoView()}return!0}return!1};function vi(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 w$e=t=>({tr:e,state:n,dispatch:r})=>{const i=vi(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const c=a.before(o),u=a.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},S$e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},M$e=()=>({state:t,dispatch:e})=>xO(t,e),E$e=()=>({commands:t})=>t.keyboardShortcut("Enter"),N$e=()=>({state:t,dispatch:e})=>d8e(t,e);function PO(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function CS(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:PO(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Fee(t,e,n={}){return t.find(r=>r.type===e&&CS(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function j9(t,e,n={}){return!!Fee(t,e,n)}function RO(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(d=>d.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(d=>d.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!Fee([...i.node.marks],e,n)))return;let o=i.index,l=t.start()+i.offset,c=o+1,u=l+i.node.nodeSize;for(;o>0&&j9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&j9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function fu(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 A$e=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=fu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=RO(c,a,e);if(f&&f.from<=u&&f.to>=d){const p=Jt.create(o,f.from,f.to);n.setSelection(p)}}return!0},T$e=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Uee(t){return t instanceof Jt}function Wh(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function zee(t,e=null){if(!e)return null;const n=bn.atStart(t),r=bn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?Jt.create(t,Wh(0,i,a),Wh(t.content.size,i,a)):Jt.create(t,Wh(e,i,a),Wh(e,i,a))}function C$e(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function DO(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var k$e=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(DO()||C$e())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!Uee(n.state.selection))return o(),!0;const l=zee(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return a&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},j$e=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),P$e=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Bee=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Bee(r)}return t};function u1(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 Bee(n)}function k0(t,e,n){if(t instanceof Ad||t instanceof vt)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return vt.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}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),k0("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new EJ({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:u=>(o=!0,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(n.slice?Cb.fromSchema(c).parseSlice(u1(t),n.parseOptions):Cb.fromSchema(c).parse(u1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=Cb.fromSchema(e);return n.slice?a.parseSlice(u1(t),n.parseOptions).content:a.parse(u1(t),n.parseOptions)}return k0("",e,n)}function R$e(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof qi||i instanceof Xi))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(bn.near(t.doc.resolve(o),n))}var D$e=t=>!("type"in t),O$e=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=x=>{a.emit("contentError",{editor:a,error:x,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{k0(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{l=k0(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(x){return c(x),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,g=!0;if((D$e(l)?l:[l]).forEach(x=>{x.check(),p=p?x.isText&&x.marks.length===0:!1,g=g?x.isBlock:!1}),d===f&&g){const{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,f+=1)}let v;if(p){if(Array.isArray(e))v=e.map(x=>x.text||"").join("");else if(e instanceof vt){let x="";e.forEach(y=>{y.text&&(x+=y.text)}),v=x}else typeof e=="object"&&e&&e.text?v=e.text:v=e;r.insertText(v,d,f)}else{v=l;const x=r.doc.resolve(d),y=x.node(),E=x.parentOffset===0,w=y.isText||y.isTextblock,A=y.content.size>0;E&&w&&A&&(d=Math.max(0,d-1)),r.replaceWith(d,f,v)}n.updateSelection&&R$e(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:v}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:v})}return!0},L$e=()=>({state:t,dispatch:e})=>l8e(t,e),I$e=()=>({state:t,dispatch:e})=>c8e(t,e),F$e=()=>({state:t,dispatch:e})=>GJ(t,e),U$e=()=>({state:t,dispatch:e})=>XJ(t,e),z$e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=PM(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},B$e=()=>({state:t,dispatch:e,tr:n})=>{try{const r=PM(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},$$e=()=>({state:t,dispatch:e})=>s8e(t,e),H$e=()=>({state:t,dispatch:e})=>o8e(t,e);function $ee(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function V$e(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let l=0;l<e.length-1;l+=1){const c=e[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))i=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))DO()||$ee()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var G$e=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=V$e(t).split(/-(?!$)/),o=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Vd(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?vi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,p)=>{if(f.isText)return;const g=Math.max(r,p),b=Math.min(i,p+f.nodeSize);l.push({node:f,from:g,to:b})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>CS(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,p)=>f+p.to-p.from,0)>=c}var W$e=(t,e={})=>({state:n,dispatch:r})=>{const i=vi(t,n.schema);return Vd(n,i,e)?u8e(n,r):!1},q$e=()=>({state:t,dispatch:e})=>JJ(t,e),K$e=t=>({state:e,dispatch:n})=>{const r=vi(t,e.schema);return w8e(r)(e,n)},X$e=()=>({state:t,dispatch:e})=>QJ(t,e);function zM(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function P9(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var Y$e=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=zM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=vi(t,r.schema)),l==="mark"&&(o=fu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,P9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(P9(p.attrs,e))))})})}),c},Q$e=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Z$e=()=>({tr:t,dispatch:e})=>{if(e){const n=new zs(t.doc);t.setSelection(n)}return!0},J$e=()=>({state:t,dispatch:e})=>qJ(t,e),eHe=()=>({state:t,dispatch:e})=>YJ(t,e),tHe=()=>({state:t,dispatch:e})=>m8e(t,e),nHe=()=>({state:t,dispatch:e})=>x8e(t,e),rHe=()=>({state:t,dispatch:e})=>g8e(t,e);function YP(t,e,n={},r={}){return k0(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var iHe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=YP(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function Hee(t,e){const n=fu(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,c=>{o.push(...c.marks)});const l=o.find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Vee(t,e){const n=new BJ(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function aHe(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 sHe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function oHe(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function BM(t){return e=>oHe(e.$from,t)}function Wt(t,e,n){return t.config[e]===void 0&&t.parent?Wt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Wt(t.parent,e,n):null}):t.config[e]}function OO(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Wt(e,"addExtensions",n);return r?[e,...OO(r())]:e}).flat(10)}function LO(t,e){const n=Hf.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function Gee(t){return typeof t=="function"}function Qn(t,e=void 0,...n){return Gee(t)?e?t.bind(e)(...n):t(...n):t}function lHe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function hg(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Wee(t){const e=[],{nodeExtensions:n,markExtensions:r}=hg(t),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},c=Wt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(f=>{Object.entries(d.attributes).forEach(([p,g])=>{e.push({type:f,name:p,attribute:{...a,...g}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Wt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,f])=>{const p={...a,...f};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:o.name,name:d,attribute:p})})}),e}function Zr(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,p]=d.split(":").map(g=>g.trim());u.set(f,p)}),l.forEach(d=>{const[f,p]=d.split(":").map(g=>g.trim());u.set(f,p)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function kS(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,r)=>Zr(n,r),{})}function cHe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function R9(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):cHe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function D9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&lHe(n)?!1:n!=null))}function O9(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function uHe(t,e){var n;const r=Wee(t),{nodeExtensions:i,markExtensions:a}=hg(t),o=(n=i.find(u=>Wt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((y,E)=>{const w=Wt(E,"extendNodeSchema",f);return{...y,...w?w(u):{}}},{}),g=D9({...p,content:Qn(Wt(u,"content",f)),marks:Qn(Wt(u,"marks",f)),group:Qn(Wt(u,"group",f)),inline:Qn(Wt(u,"inline",f)),atom:Qn(Wt(u,"atom",f)),selectable:Qn(Wt(u,"selectable",f)),draggable:Qn(Wt(u,"draggable",f)),code:Qn(Wt(u,"code",f)),whitespace:Qn(Wt(u,"whitespace",f)),linebreakReplacement:Qn(Wt(u,"linebreakReplacement",f)),defining:Qn(Wt(u,"defining",f)),isolating:Qn(Wt(u,"isolating",f)),attrs:Object.fromEntries(d.map(O9))}),b=Qn(Wt(u,"parseHTML",f));b&&(g.parseDOM=b.map(y=>R9(y,d)));const v=Wt(u,"renderHTML",f);v&&(g.toDOM=y=>v({node:y,HTMLAttributes:kS(y,d)}));const x=Wt(u,"renderText",f);return x&&(g.toText=x),[u.name,g]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(x=>x.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((x,y)=>{const E=Wt(y,"extendMarkSchema",f);return{...x,...E?E(u):{}}},{}),g=D9({...p,inclusive:Qn(Wt(u,"inclusive",f)),excludes:Qn(Wt(u,"excludes",f)),group:Qn(Wt(u,"group",f)),spanning:Qn(Wt(u,"spanning",f)),code:Qn(Wt(u,"code",f)),attrs:Object.fromEntries(d.map(O9))}),b=Qn(Wt(u,"parseHTML",f));b&&(g.parseDOM=b.map(x=>R9(x,d)));const v=Wt(u,"renderHTML",f);return v&&(g.toDOM=x=>v({mark:x,HTMLAttributes:kS(x,d)})),[u.name,g]}));return new EJ({topNode:o,nodes:l,marks:c})}function dHe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function IO(t){return t.sort((n,r)=>{const i=Wt(n,"priority")||100,a=Wt(r,"priority")||100;return i>a?-1:i<a?1:0})}function qee(t){const e=IO(OO(t)),n=dHe(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Kee(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var p;c.isBlock&&u>r&&(l+=a);const g=o?.[c.type.name];if(g)return d&&(l+=g({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(p=c?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),l}function hHe(t,e){const n={from:0,to:t.content.size};return Kee(t,n,e)}function Xee(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function fHe(t,e){const n=vi(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const o=a.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function Yee(t,e){const n=zM(typeof e=="string"?e:e.name,t.schema);return n==="node"?fHe(t,e):n==="mark"?Hee(t,e):{}}function mHe(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function pHe(t){const e=mHe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).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 Qee(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),p=e.invert().map(d);r.push({oldRange:{from:f,to:p},newRange:{from:u,to:d}})})}),pHe(r)}function FO(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=RO(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var gHe=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const l=i.node(a);l?.type.name===e?o=l:a-=1}return[o,a]};function Ik(t,e){return e.nodes[t]||e.marks[t]||null}function W1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var xHe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function QP(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?fu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>CS(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:p})=>{const g=f.pos,b=p.pos;t.doc.nodesBetween(g,b,(v,x)=>{if(!v.isText&&!v.marks.length)return;const y=Math.max(g,x),E=Math.min(b,x+v.nodeSize),w=E-y;o+=w,l.push(...v.marks.map(A=>({mark:A,from:y,to:E})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>CS(f.mark.attrs,n,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,p)=>f+p.to-p.from,0);return(c>0?c+u:c)>=o}function bHe(t,e,n={}){if(!e)return Vd(t,null,n)||QP(t,null,n);const r=zM(e,t.schema);return r==="node"?Vd(t,e,n):r==="mark"?QP(t,e,n):!1}var yHe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=BM(l=>l.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},vHe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function L9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function I9(t,e){const{nodeExtensions:n}=hg(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Qn(Wt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function $M(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&($M(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function Zee(t){return t instanceof Kt}function _He(t,e,n){var r;const{selection:i}=e;let a=null;if(Uee(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,p)=>{if(u)return!1;if(d.isInline){const g=!p||p.type.allowsMarkType(n),b=!!n.isInSet(d.marks)||!d.marks.some(v=>v.type.excludes(n));u=g&&b}return!u}),u})}var wHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=fu(t,r.schema);if(i)if(o){const u=Hee(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(p,g)=>{const b=Math.max(g,d),v=Math.min(g+p.nodeSize,f);p.marks.find(y=>y.type===c)?p.marks.forEach(y=>{c===y.type&&n.addMark(b,v,c.create({...y.attrs,...e}))}):n.addMark(b,v,c.create(e))})});return _He(r,n,c)},SHe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),MHe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=vi(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>Q7(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Q7(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},EHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Wh(t,0,r.content.size),a=Kt.create(r,i);e.setSelection(a)}return!0},NHe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=a.from,l=a.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},AHe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=Jt.atStart(r).from,l=Jt.atEnd(r).to,c=Wh(i,o,l),u=Wh(a,o,l),d=Jt.create(r,c,u);e.setSelection(d)}return!0},THe=t=>({state:e,dispatch:n})=>{const r=vi(t,e.schema);return E8e(r)(e,n)};function F9(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var CHe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=W1(u,l.node().type.name,l.node().attrs);if(a instanceof Kt&&a.node.isBlock)return!l.parentOffset||!Wc(o,l.pos)?!1:(r&&(t&&F9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:aHe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let g=f&&p?[{type:p,attrs:d}]:void 0,b=Wc(e.doc,e.mapping.map(l.pos),1,g);if(!g&&!b&&Wc(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(b=!0,g=p?[{type:p,attrs:d}]:void 0),r){if(b&&(a instanceof Jt&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,g),p&&!f&&!l.parentOffset&&l.parent.type!==p)){const v=e.mapping.map(l.before()),x=e.doc.resolve(v);l.node(-1).canReplaceWith(x.index(),x.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}t&&F9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},kHe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=vi(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const p=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let y=vt.empty;const E=c.index(-1)?1:c.index(-2)?2:3;for(let D=c.depth-E;D>=c.depth-3;D-=1)y=vt.from(c.node(D).copy(y));const w=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A={...W1(p,c.node().type.name,c.node().attrs),...e},N=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;y=y.append(vt.from(l.createAndFill(null,N)||void 0));const C=c.before(c.depth-(E-1));n.replace(C,c.after(-w),new Dt(y,4-E,0));let T=-1;n.doc.nodesBetween(C,n.doc.content.size,(D,k)=>{if(T>-1)return!1;D.isTextblock&&D.content.size===0&&(T=k+1)}),T>-1&&n.setSelection(Jt.near(n.doc.resolve(T))),n.scrollIntoView()}return!0}const g=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...W1(p,f.type.name,f.attrs),...e},v={...W1(p,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const x=g?[{type:l,attrs:b},{type:g,attrs:v}]:[{type:l,attrs:b}];if(!Wc(n.doc,c.pos,2))return!1;if(i){const{selection:y,storedMarks:E}=r,{splittableMarks:w}=a.extensionManager,A=E||y.$to.parentOffset&&y.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!A||!i)return!0;const N=A.filter(C=>w.includes(C.type.name));n.ensureMarks(N)}return!0},Fk=(t,e)=>{const n=BM(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Xd(t.doc,n.pos)&&t.join(n.pos),!0},Uk=(t,e)=>{const n=BM(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===i?.type&&Xd(t.doc,r)&&t.join(r),!0},jHe=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:p}=i.extensionManager,g=vi(t,o.schema),b=vi(e,o.schema),{selection:v,storedMarks:x}=o,{$from:y,$to:E}=v,w=y.blockRange(E),A=x||v.$to.parentOffset&&v.$from.marks();if(!w)return!1;const N=BM(C=>I9(C.type.name,f))(v);if(w.depth>=1&&N&&w.depth-N.depth<=1){if(N.node.type===g)return u.liftListItem(b);if(I9(N.node.type.name,f)&&g.validContent(N.node.content)&&l)return c().command(()=>(a.setNodeMarkup(N.pos,g),!0)).command(()=>Fk(a,g)).command(()=>Uk(a,g)).run()}return!n||!A||!l?c().command(()=>d().wrapInList(g,r)?!0:u.clearNodes()).wrapInList(g,r).command(()=>Fk(a,g)).command(()=>Uk(a,g)).run():c().command(()=>{const C=d().wrapInList(g,r),T=A.filter(D=>p.includes(D.type.name));return a.ensureMarks(T),C?!0:u.clearNodes()}).wrapInList(g,r).command(()=>Fk(a,g)).command(()=>Uk(a,g)).run()},PHe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=fu(t,r.schema);return QP(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},RHe=(t,e,n={})=>({state:r,commands:i})=>{const a=vi(t,r.schema),o=vi(e,r.schema),l=Vd(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(a,{...c,...n})},DHe=(t,e={})=>({state:n,commands:r})=>{const i=vi(t,n.schema);return Vd(n,i,e)?r.lift(i):r.wrapIn(i,e)},OHe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const o=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else o.delete(a.from,a.to)}return!0}}return!1},LHe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},IHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=fu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:p,to:g}=l;const b=(a=u.marks().find(x=>x.type===c))==null?void 0:a.attrs,v=RO(u,c,b);v&&(p=v.from,g=v.to),n.removeMark(p,g,c)}else f.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},FHe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},UHe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=zM(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=vi(t,r.schema)),l==="mark"&&(o=fu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let p,g,b,v;n.selection.empty?r.doc.nodesBetween(d,f,(x,y)=>{a&&a===x.type&&(c=!0,b=Math.max(y,d),v=Math.min(y+x.nodeSize,f),p=y,g=x)}):r.doc.nodesBetween(d,f,(x,y)=>{y<d&&a&&a===x.type&&(c=!0,b=Math.max(y,d),v=Math.min(y+x.nodeSize,f),p=y,g=x),y>=d&&y<=f&&(a&&a===x.type&&(c=!0,i&&n.setNodeMarkup(y,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(E=>{if(o===E.type&&(c=!0,i)){const w=Math.max(y,d),A=Math.min(y+x.nodeSize,f);n.addMark(w,A,o.create({...E.attrs,...e}))}}))}),g&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(x=>{o===x.type&&i&&n.addMark(b,v,o.create({...x.attrs,...e}))}))}),c},zHe=(t,e={})=>({state:n,dispatch:r})=>{const i=vi(t,n.schema);return b8e(i,e)(n,r)},BHe=(t,e={})=>({state:n,dispatch:r})=>{const i=vi(t,n.schema);return y8e(i,e)(n,r)},$He=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},HM=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},HHe=(t,e)=>{if(PO(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function d1(t){var e;const{editor:n,from:r,to:i,text:a,rules:o,plugin:l}=t,{view:c}=n;if(c.composing)return!1;const u=c.state.doc.resolve(r);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(p=>p.type.spec.code))return!1;let d=!1;const f=xHe(u)+a;return o.forEach(p=>{if(d)return;const g=HHe(f,p.find);if(!g)return;const b=c.state.tr,v=FM({state:c.state,transaction:b}),x={from:r-(g[0].length-a.length),to:i},{commands:y,chain:E,can:w}=new UM({editor:n,state:v});p.handler({state:v,range:x,match:g,commands:y,chain:E,can:w})===null||!b.steps.length||(p.undoable&&b.setMeta(l,{transform:b,from:r,to:i,text:a}),c.dispatch(b),d=!0)}),d}function VHe(t){const{editor:e,rules:n}=t,r=new Fr({state:{init(){return null},apply(i,a,o){const l=i.getMeta(r);if(l)return l;const c=i.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=LO(vt.from(d),o.schema);const{from:f}=c,p=f+d.length;d1({editor:e,from:f,to:p,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return d1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&d1({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?d1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function GHe(t){return Object.prototype.toString.call(t).slice(8,-1)}function h1(t){return GHe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Jee(t,e){const n={...t};return h1(t)&&h1(e)&&Object.keys(e).forEach(r=>{h1(e[r])&&h1(t[r])?n[r]=Jee(t[r],e[r]):n[r]=e[r]}),n}var UO=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{...Qn(Wt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Qn(Wt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Jee(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}},Qd=class ete extends UO{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new ete(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(u=>u?.type.name===n.name))return!1;const c=o.find(u=>u?.type.name===n.name);return c&&r.removeStoredMark(c),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function WHe(t){return typeof t=="number"}var qHe=class{constructor(t){this.find=t.find,this.handler=t.handler}},KHe=(t,e,n)=>{if(PO(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function XHe(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new UM({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(g,b)=>{var v,x,y,E,w;if((x=(v=g.type)==null?void 0:v.spec)!=null&&x.code||!(g.isText||g.isTextblock||g.isInline))return;const A=(w=(E=(y=g.content)==null?void 0:y.size)!=null?E:g.nodeSize)!=null?w:0,N=Math.max(r,b),C=Math.min(i,b+A);if(N>=C)return;const T=g.isText?g.text||"":g.textBetween(N-b,C-b,void 0,"");KHe(T,a.find,o).forEach(k=>{if(k.index===void 0)return;const P=N+k.index+1,z=P+k[0].length,L={from:n.tr.mapping.map(P),to:n.tr.mapping.map(z)},X=a.handler({state:n,range:L,match:k,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(X)})}),f.every(g=>g!==null)}var f1=null,YHe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function QHe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:p,rule:g,pasteEvt:b})=>{const v=d.tr,x=FM({state:d,transaction:v});if(!(!XHe({editor:e,state:x,from:Math.max(f-1,0),to:p.b-1,rule:g,pasteEvent:b,dropEvent:l})||!v.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return n.map(d=>new Fr({view(f){const p=b=>{var v;r=(v=f.dom.parentElement)!=null&&v.contains(b.target)?f.dom.parentElement:null,r&&(f1=e)},g=()=>{f1&&(f1=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(a=r===f.dom.parentElement,l=p,!a){const g=f1;g?.isEditable&&setTimeout(()=>{const b=g.state.selection;b&&g.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,p)=>{var g;const b=(g=p.clipboardData)==null?void 0:g.getData("text/html");return o=p,i=!!b?.includes("data-pm-slice"),!1}}},appendTransaction:(f,p,g)=>{const b=f[0],v=b.getMeta("uiEvent")==="paste"&&!i,x=b.getMeta("uiEvent")==="drop"&&!a,y=b.getMeta("applyPasteRules"),E=!!y;if(!v&&!x&&!E)return;if(E){let{text:N}=y;typeof N=="string"?N=N:N=LO(vt.from(N),g.schema);const{from:C}=y,T=C+N.length,D=YHe(N);return c({rule:d,state:g,from:C,to:{b:T},pasteEvt:D})}const w=p.doc.content.findDiffStart(g.doc.content),A=p.doc.content.findDiffEnd(g.doc.content);if(!(!WHe(w)||!A||w===A.b))return c({rule:d,state:g,from:w,to:A,pasteEvt:o})}}))}var VM=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=qee(t),this.schema=uHe(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:Ik(e.name,this.schema)},r=Wt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return IO([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ik(r.name,this.schema)},a=[],o=Wt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Wt(r,"exitable",i)&&(l.ArrowRight=()=>Qd.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([g,b])=>[g,()=>b({editor:t})]));l={...l,...p}}const c=f$e(l);a.push(c);const u=Wt(r,"addInputRules",i);if(L9(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const g=VHe({editor:t,rules:p}),b=Array.isArray(g)?g:[g];a.push(...b)}}const d=Wt(r,"addPasteRules",i);if(L9(r,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const g=QHe({editor:t,rules:p});a.push(...g)}}const f=Wt(r,"addProseMirrorPlugins",i);if(f){const p=f();a.push(...p)}return a})}get attributes(){return Wee(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=hg(this.extensions);return Object.fromEntries(e.filter(n=>!!Wt(n,"addNodeView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:vi(n.name,this.schema)},a=Wt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,p)=>{const g=kS(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:p,editor:t,extension:n,HTMLAttributes:g})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=hg(this.extensions);return Object.fromEntries(e.filter(n=>!!Wt(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:fu(n.name,this.schema)},a=Wt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=kS(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{hVe(l,t,f)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ik(e.name,this.schema)};e.type==="mark"&&((n=Qn(Wt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Wt(e,"onBeforeCreate",r),a=Wt(e,"onCreate",r),o=Wt(e,"onUpdate",r),l=Wt(e,"onSelectionUpdate",r),c=Wt(e,"onTransaction",r),u=Wt(e,"onFocus",r),d=Wt(e,"onBlur",r),f=Wt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};VM.resolve=qee;VM.sort=IO;VM.flatten=OO;var ZHe={};jO(ZHe,{ClipboardTextSerializer:()=>nte,Commands:()=>rte,Delete:()=>ite,Drop:()=>ate,Editable:()=>ste,FocusEvents:()=>lte,Keymap:()=>cte,Paste:()=>ute,Tabindex:()=>dte,TextDirection:()=>hte,focusEventsPluginKey:()=>ote});var fr=class tte extends UO{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new tte(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},nte=fr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Fr({key:new Li("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=Xee(n);return Kee(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),rte=fr.create({name:"commands",addCommands(){return{...Iee}}}),ite=fr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{var o,l,c,u;if((u=(c=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=Vee(t.before,[t,...e]);Qee(d).forEach(g=>{d.mapping.mapResult(g.oldRange.from).deletedAfter&&d.mapping.mapResult(g.oldRange.to).deletedBefore&&d.before.nodesBetween(g.oldRange.from,g.oldRange.to,(b,v)=>{const x=v+b.nodeSize-2,y=g.oldRange.from<=v&&x<=g.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:v,to:x,newFrom:d.mapping.map(v),newTo:d.mapping.map(x),deletedRange:g.oldRange,newRange:g.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((g,b)=>{var v,x;if(g instanceof Xo){const y=p.slice(b).map(g.from,-1),E=p.slice(b).map(g.to),w=p.invert().map(y,-1),A=p.invert().map(E),N=(v=d.doc.nodeAt(y-1))==null?void 0:v.marks.some(T=>T.eq(g.mark)),C=(x=d.doc.nodeAt(E))==null?void 0:x.marks.some(T=>T.eq(g.mark));this.editor.emit("delete",{type:"mark",mark:g.mark,from:g.from,to:g.to,deletedRange:{from:w,to:A},newRange:{from:y,to:E},partial:!!(C||N),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),ate=fr.create({name:"drop",addProseMirrorPlugins(){return[new Fr({key:new Li("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),ste=fr.create({name:"editable",addProseMirrorPlugins(){return[new Fr({key:new Li("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ote=new Li("focusEvents"),lte=fr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Fr({key:ote,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),cte=fr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:p,parent:g}=f,b=f.parent.isTextblock&&p>0?l.doc.resolve(p-1):f,v=b.parent.type.spec.isolating,x=f.pos-f.parentOffset,y=v&&b.parent.childCount===1?x===f.pos:bn.atStart(u).from===p;return!d||!g.type.isTextblock||g.textContent.length||!y||y&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.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()},i={...r},a={...r,"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 DO()||$ee()?a:i},addProseMirrorPlugins(){return[new Fr({key:new Li("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(v=>v.getMeta("composition")))return;const r=t.some(v=>v.docChanged)&&!e.doc.eq(n.doc),i=t.some(v=>v.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=bn.atStart(e.doc).from,u=bn.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!$M(n.doc))return;const p=n.tr,g=FM({state:n,transaction:p}),{commands:b}=new UM({editor:this.editor,state:g});if(b.clearNodes(),!!p.steps.length)return p}})]}}),ute=fr.create({name:"paste",addProseMirrorPlugins(){return[new Fr({key:new Li("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),dte=fr.create({name:"tabindex",addProseMirrorPlugins(){return[new Fr({key:new Li("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),hte=fr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=hg(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 Fr({key:new Li("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),JHe=class gp{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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,r=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,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},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 gp(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 gp(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 gp(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+(a?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const c=new gp(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new gp(l,this.editor,i,i?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 r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&a.every(c=>n[c]===o.node.attrs[c])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},eVe=`.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 tVe(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var nVe=class extends $He{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:r})=>{throw r},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:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=zee(e,this.options.autofocus);this.editorState=Mp.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=tVe(eVe,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=Gee(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[ste,nte.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),rte,lte,cte,dte,ate,ute,ite,hte.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new VM(r,this)}createCommandManager(){this.commandManager=new UM({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=YP(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=YP(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Oee(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 r=this.view.dom;r.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(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),l=o?.getMeta("focus"),c=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),c&&this.emit("blur",{editor:this,event:c.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(u=>u.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Yee(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return bHe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return LO(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return hHe(this.state.doc,{blockSeparator:e,textSerializers:{...Xee(this.schema),...n}})}get isEmpty(){return $M(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 JHe(e,this)}get $doc(){return this.$pos(0)}};function fg(t){return new HM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Qn(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:a}=e,o=r[r.length-1],l=r[0];if(o){const c=l.search(/\S/),u=n.from+l.indexOf(o),d=u+o.length;if(FO(n.from,n.to,e.doc).filter(g=>g.mark.type.excluded.find(v=>v===t.type&&v!==g.mark.type)).filter(g=>g.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const p=n.from+c+o.length;a.addMark(n.from+c,p,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function fte(t){return new HM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=Qn(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,o+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function ZP(t){return new HM({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=Qn(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.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 mg(t){return new HM({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=Qn(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&pO(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:p}=e,{splittableMarks:g}=t.editor.extensionManager,b=p||f.$to.parentOffset&&f.$from.marks();if(b){const v=b.filter(x=>g.includes(x.type.name));o.ensureMarks(v)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Xd(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var rVe=t=>"touches"in t,iVe=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=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,c=o.clientY-this.startY;this.handleResize(l,c)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),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=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,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),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.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"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(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,rVe(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:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,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 r=this.startWidth,i=this.startHeight;const a=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:c&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,o;if(!n){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(u=Math.min(this.maxSize.width,u)),(i=this.maxSize)!=null&&i.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(a=this.maxSize)!=null&&a.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function aVe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Kt){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var sVe={};jO(sVe,{createAtomBlockMarkdownSpec:()=>oVe,createBlockMarkdownSpec:()=>lVe,createInlineMarkdownSpec:()=>dVe,parseAttributes:()=>zO,parseIndentedBlocks:()=>JP,renderNestedMarkdownContent:()=>$O,serializeAttributes:()=>BO});function zO(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const p=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[1])||"0",10),g=n[p];g&&(e[u]=g.slice(1,-1))});const c=r.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 c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function BO(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function oVe(t){const{nodeName:e,name:n,parseAttributes:r=zO,serializeAttributes:i=BO,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(p=>{p in d&&(f[p]=d[p])}),f};return{parseMarkdown:(d,f)=>{const p={...a,...d.attributes};return f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),g=(f=d.match(p))==null?void 0:f.index;return g!==void 0?g:-1},tokenize(d,f,p){const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=d.match(g);if(!b)return;const v=b[1]||"",x=r(v);if(!o.find(E=>!(E in x)))return{type:e,raw:b[0],attributes:x}}},renderMarkdown:d=>{const f=u(d.attrs||{}),p=i(f),g=p?` {${p}}`:"";return`:::${c}${g} :::`}}}function lVe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=zO,serializeAttributes:a=BO,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const p={};return c.forEach(g=>{g in f&&(p[g]=f[g])}),p};return{parseMarkdown:(f,p)=>{let g;if(r){const v=r(f);g=typeof v=="string"?[{type:"text",text:v}]:v}else l==="block"?g=p.parseChildren(f.tokens||[]):g=p.parseInline(f.tokens||[]);const b={...o,...f.attributes};return p.createNode(e,b,g)},markdownTokenizer:{name:e,level:"block",start(f){var p;const g=new RegExp(`^:::${u}`,"m"),b=(p=f.match(g))==null?void 0:p.index;return b!==void 0?b:-1},tokenize(f,p,g){var b;const v=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=f.match(v);if(!x)return;const[y,E=""]=x,w=i(E);let A=1;const N=y.length;let C="";const T=/^:::([\w-]*)(\s.*)?/gm,D=f.slice(N);for(T.lastIndex=0;;){const k=T.exec(D);if(k===null)break;const P=k.index,z=k[1];if(!((b=k[2])!=null&&b.endsWith(":::"))){if(z)A+=1;else if(A-=1,A===0){const L=D.slice(0,P);C=L.trim();const X=f.slice(0,N+P+k[0].length);let R=[];if(C)if(l==="block")for(R=g.blockTokens(L),R.forEach(Y=>{Y.text&&(!Y.tokens||Y.tokens.length===0)&&(Y.tokens=g.inlineTokens(Y.text))});R.length>0;){const Y=R[R.length-1];if(Y.type==="paragraph"&&(!Y.text||Y.text.trim()===""))R.pop();else break}else R=g.inlineTokens(C);return{type:e,raw:X,attributes:w,content:C,tokens:R}}}}}},renderMarkdown:(f,p)=>{const g=d(f.attrs||{}),b=a(g),v=b?` {${b}}`:"",x=p.renderChildren(f.content||[],`
- `);return`:::${u}${v}
- ${x}
- :::`}}}function cVe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function uVe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function dVe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=cVe,serializeAttributes:a=uVe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=p=>{if(!c)return p;const g={};return c.forEach(b=>{b in p&&(g[b]=p[b])}),g},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,g)=>{const b={...o,...p.attributes};if(l)return g.createNode(e,b);const v=r?r(p):p.content||"";return v?g.createNode(e,b,[g.createTextNode(v)]):g.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(p){const g=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),b=p.match(g),v=b?.index;return v!==void 0?v:-1},tokenize(p,g,b){const v=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),x=p.match(v);if(!x)return;let y="",E="";if(l){const[,A]=x;E=A}else{const[,A,N]=x;E=A,y=N||""}const w=i(E.trim());return{type:e,raw:x[0],content:y.trim(),attributes:w}}},renderMarkdown:p=>{let g="";r?g=r(p):p.content&&p.content.length>0&&(g=p.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const b=d(p.attrs||{}),v=a(b),x=v?` ${v}`:"";return l?`[${u}${x}]`:`[${u}${x}]${g}[/${u}]`}}}function JP(t,e,n){var r,i,a,o;const l=t.split(`
- `),c=[];let u="",d=0;const f=e.baseIndentSize||2;for(;d<l.length;){const p=l[d],g=p.match(e.itemPattern);if(!g){if(c.length>0)break;if(p.trim()===""){d+=1,u=`${u}${p}
- `;continue}else return}const b=e.extractItemData(g),{indentLevel:v,mainContent:x}=b;u=`${u}${p}
- `;const y=[x];for(d+=1;d<l.length;){const N=l[d];if(N.trim()===""){const T=l.slice(d+1).findIndex(P=>P.trim()!=="");if(T===-1)break;if((((i=(r=l[d+1+T].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>v){y.push(N),u=`${u}${N}
- `,d+=1;continue}else break}if((((o=(a=N.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>v)y.push(N),u=`${u}${N}
- `,d+=1;else break}let E;const w=y.slice(1);if(w.length>0){const N=w.map(C=>C.slice(v+f)).join(`
- `);N.trim()&&(e.customNestedParser?E=e.customNestedParser(N):E=n.blockTokens(N))}const A=e.createToken(b,E);c.push(A)}if(c.length!==0)return{items:c,raw:u}}function $O(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(p=>p?e.indent(p):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function hVe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(g=>{if(g!==o)return!1;f=g}),!f)return;let p=!1;if(Object.keys(n).forEach(g=>{n[g]!==f.attrs[g]&&(p=!0)}),p){const g=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,g)}}),a.docChanged&&e.view.dispatch(a)}var ms=class mte extends UO{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new mte(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Lf(t){return new qHe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=Qn(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),p=f+l.length;if(FO(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(x=>x===t.type&&x!==b.mark.type)).filter(b=>b.to>f).length)return null;p<n.to&&o.delete(p,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}var zk,U9;function fVe(){return U9||(U9=1,zk=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 r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])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),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),zk}var mVe=fVe();const pVe=Co(mVe);var gVe=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},xVe=({contentComponent:t})=>{const e=yR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function bVe(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:yoe.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var yVe=class extends Cr.Component{constructor(t){var e;super(t),this.editorContentRef=Cr.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=bVe(),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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:gVe(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(xVe,{contentComponent:t.contentComponent})]})}},vVe=S.forwardRef((t,e)=>{const n=Cr.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Cr.createElement(yVe,{key:n,innerRef:e,...t})}),_Ve=Cr.memo(vVe),wVe=typeof window<"u"?S.useLayoutEffect:S.useEffect,SVe=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(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function MVe(t){var e;const[n]=S.useState(()=>new SVe(t.editor)),r=sq.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:pVe);return wVe(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var EVe=!1,eR=typeof window>"u",NVe=eR||!!(typeof window<"u"&&window.next),AVe=class pte{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?eR||NVe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new nVe(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(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?pte.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((r,i)=>r===e[i]))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 TVe(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new AVe(n)),i=yR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(i),S.useEffect(r.onRender(e)),MVe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var CVe=S.createContext({editor:null});CVe.Consumer;var kVe=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),jVe=()=>S.useContext(kVe);Cr.forwardRef((t,e)=>{const{onDragStart:n}=jVe(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Cr.createContext({markViewContentRef:()=>{}});var jS=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},PVe=/^\s*>\s$/,RVe=ms.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return jS("blockquote",{...Zr(this.options.HTMLAttributes,t),children:jS("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.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[mg({find:PVe,type:this.type})]}}),DVe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,OVe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,LVe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,IVe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,FVe=Qd.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 jS("strong",{...Zr(this.options.HTMLAttributes,t),children:jS("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[fg({find:DVe,type:this.type}),fg({find:LVe,type:this.type})]},addPasteRules(){return[Lf({find:OVe,type:this.type}),Lf({find:IVe,type:this.type})]}}),UVe=/(^|[^`])`([^`]+)`(?!`)$/,zVe=/(^|[^`])`([^`]+)`(?!`)/g,BVe=Qd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Zr(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[fg({find:UVe,type:this.type})]},addPasteRules(){return[Lf({find:zVe,type:this.type})]}}),Bk=4,$Ve=/^```([a-z]+)?[\s\n]$/,HVe=/^~~~([a-z]+)?[\s\n]$/,VVe=ms.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Bk,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(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Zr(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 r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
- `):r=`\`\`\`${i}
- \`\`\``,r},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:Bk,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=i,g=r.doc.textBetween(u,d,`
- `,`
- `).split(`
- `).map(b=>l+b).join(`
- `);return c.replaceWith(u,d,r.schema.text(g)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Bk,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),g=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let b=0,v=0;const x=u-d;for(let C=0;C<g.length;C+=1){if(v+g[C].length>=x){b=C;break}v+=g[C].length+1}const E=((c=g[b].match(/^ */))==null?void 0:c[0])||"",w=Math.min(E.length,n);if(w===0)return!0;let A=d;for(let C=0;C<b;C+=1)A+=g[C].length+1;return l.delete(A,A+w),u-A<=w&&l.setSelection(Jt.create(l.doc,A)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,p=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(g=>{var b;const v=((b=g.match(/^ */))==null?void 0:b[0])||"",x=Math.min(v.length,n);return g.slice(x)}).join(`
- `);return l.replaceWith(c,u,r.schema.text(p)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
- `);return!a||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(bn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[ZP({find:$Ve,type:this.type,getAttributes:t=>({language:t[1]})}),ZP({find:HVe,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Fr({key:new Li("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(Jt.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),GVe=ms.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),WVe=ms.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",Zr(this.options.HTMLAttributes,t)]},renderText(){return`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(p=>l.includes(p.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),qVe=ms.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]}`,Zr(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 r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,i="#".repeat(r);return t.content?`${i} ${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=>ZP({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),KVe=ms.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Zr(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!aVe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return Zee(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(Jt.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Kt.create(o.doc,c.pos)):o.setSelection(Jt.create(o.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(Jt.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[fte({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),XVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,YVe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,QVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ZVe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,JVe=Qd.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",Zr(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[fg({find:XVe,type:this.type}),fg({find:QVe,type:this.type})]},addPasteRules(){return[Lf({find:YVe,type:this.type}),Lf({find:ZVe,type:this.type})]}});const e7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",t7e="ελ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",tR="numeric",nR="ascii",rR="alpha",Rb="asciinumeric",gb="alphanumeric",iR="domain",gte="emoji",n7e="scheme",r7e="slashscheme",$k="whitespace";function i7e(t,e){return t in e||(e[t]=[]),e[t]}function qh(t,e,n){e[tR]&&(e[Rb]=!0,e[gb]=!0),e[nR]&&(e[Rb]=!0,e[rR]=!0),e[Rb]&&(e[gb]=!0),e[rR]&&(e[gb]=!0),e[gb]&&(e[iR]=!0),e[gte]&&(e[iR]=!0);for(const r in e){const i=i7e(r,n);i.indexOf(t)<0&&i.push(t)}}function a7e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function as(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}as.groups={};as.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||as.groups;let i;return e&&e.j?i=e:(i=new as(e),n&&r&&qh(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||as.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new as,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new as,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(a7e(o.t,r),n);qh(a,c,r)}else n&&qh(a,n,r);o.t=a}return i.j[t]=o,o}};const fn=(t,e,n,r,i)=>t.ta(e,n,r,i),$r=(t,e,n,r,i)=>t.tr(e,n,r,i),z9=(t,e,n,r,i)=>t.ts(e,n,r,i),St=(t,e,n,r,i)=>t.tt(e,n,r,i),Ec="WORD",aR="UWORD",xte="ASCIINUMERICAL",bte="ALPHANUMERICAL",j0="LOCALHOST",sR="TLD",oR="UTLD",q1="SCHEME",xp="SLASH_SCHEME",HO="NUM",lR="WS",VO="NL",Db="OPENBRACE",Ob="CLOSEBRACE",PS="OPENBRACKET",RS="CLOSEBRACKET",DS="OPENPAREN",OS="CLOSEPAREN",LS="OPENANGLEBRACKET",IS="CLOSEANGLEBRACKET",FS="FULLWIDTHLEFTPAREN",US="FULLWIDTHRIGHTPAREN",zS="LEFTCORNERBRACKET",BS="RIGHTCORNERBRACKET",$S="LEFTWHITECORNERBRACKET",HS="RIGHTWHITECORNERBRACKET",VS="FULLWIDTHLESSTHAN",GS="FULLWIDTHGREATERTHAN",WS="AMPERSAND",qS="APOSTROPHE",KS="ASTERISK",ad="AT",XS="BACKSLASH",YS="BACKTICK",QS="CARET",dd="COLON",GO="COMMA",ZS="DOLLAR",ml="DOT",JS="EQUALS",WO="EXCLAMATION",oo="HYPHEN",Lb="PERCENT",e2="PIPE",t2="PLUS",n2="POUND",Ib="QUERY",qO="QUOTE",yte="FULLWIDTHMIDDLEDOT",KO="SEMI",pl="SLASH",Fb="TILDE",r2="UNDERSCORE",vte="EMOJI",i2="SYM";var _te=Object.freeze({__proto__:null,ALPHANUMERICAL:bte,AMPERSAND:WS,APOSTROPHE:qS,ASCIINUMERICAL:xte,ASTERISK:KS,AT:ad,BACKSLASH:XS,BACKTICK:YS,CARET:QS,CLOSEANGLEBRACKET:IS,CLOSEBRACE:Ob,CLOSEBRACKET:RS,CLOSEPAREN:OS,COLON:dd,COMMA:GO,DOLLAR:ZS,DOT:ml,EMOJI:vte,EQUALS:JS,EXCLAMATION:WO,FULLWIDTHGREATERTHAN:GS,FULLWIDTHLEFTPAREN:FS,FULLWIDTHLESSTHAN:VS,FULLWIDTHMIDDLEDOT:yte,FULLWIDTHRIGHTPAREN:US,HYPHEN:oo,LEFTCORNERBRACKET:zS,LEFTWHITECORNERBRACKET:$S,LOCALHOST:j0,NL:VO,NUM:HO,OPENANGLEBRACKET:LS,OPENBRACE:Db,OPENBRACKET:PS,OPENPAREN:DS,PERCENT:Lb,PIPE:e2,PLUS:t2,POUND:n2,QUERY:Ib,QUOTE:qO,RIGHTCORNERBRACKET:BS,RIGHTWHITECORNERBRACKET:HS,SCHEME:q1,SEMI:KO,SLASH:pl,SLASH_SCHEME:xp,SYM:i2,TILDE:Fb,TLD:sR,UNDERSCORE:r2,UTLD:oR,UWORD:aR,WORD:Ec,WS:lR});const _c=/[a-z]/,rb=new RegExp("\\p{L}","u"),Hk=new RegExp("\\p{Emoji}","u"),wc=/\d/,Vk=/\s/,B9="\r",Gk=`
- `,s7e="️",o7e="",Wk="";let m1=null,p1=null;function l7e(t=[]){const e={};as.groups=e;const n=new as;m1==null&&(m1=$9(e7e)),p1==null&&(p1=$9(t7e)),St(n,"'",qS),St(n,"{",Db),St(n,"}",Ob),St(n,"[",PS),St(n,"]",RS),St(n,"(",DS),St(n,")",OS),St(n,"<",LS),St(n,">",IS),St(n,"(",FS),St(n,")",US),St(n,"「",zS),St(n,"」",BS),St(n,"『",$S),St(n,"』",HS),St(n,"<",VS),St(n,">",GS),St(n,"&",WS),St(n,"*",KS),St(n,"@",ad),St(n,"`",YS),St(n,"^",QS),St(n,":",dd),St(n,",",GO),St(n,"$",ZS),St(n,".",ml),St(n,"=",JS),St(n,"!",WO),St(n,"-",oo),St(n,"%",Lb),St(n,"|",e2),St(n,"+",t2),St(n,"#",n2),St(n,"?",Ib),St(n,'"',qO),St(n,"/",pl),St(n,";",KO),St(n,"~",Fb),St(n,"_",r2),St(n,"\\",XS),St(n,"・",yte);const r=$r(n,wc,HO,{[tR]:!0});$r(r,wc,r);const i=$r(r,_c,xte,{[Rb]:!0}),a=$r(r,rb,bte,{[gb]:!0}),o=$r(n,_c,Ec,{[nR]:!0});$r(o,wc,i),$r(o,_c,o),$r(i,wc,i),$r(i,_c,i);const l=$r(n,rb,aR,{[rR]:!0});$r(l,_c),$r(l,wc,a),$r(l,rb,l),$r(a,wc,a),$r(a,_c),$r(a,rb,a);const c=St(n,Gk,VO,{[$k]:!0}),u=St(n,B9,lR,{[$k]:!0}),d=$r(n,Vk,lR,{[$k]:!0});St(n,Wk,d),St(u,Gk,c),St(u,Wk,d),$r(u,Vk,d),St(d,B9),St(d,Gk),$r(d,Vk,d),St(d,Wk,d);const f=$r(n,Hk,vte,{[gte]:!0});St(f,"#"),$r(f,Hk,f),St(f,s7e,f);const p=St(f,o7e);St(p,"#"),$r(p,Hk,f);const g=[[_c,o],[wc,i]],b=[[_c,null],[rb,l],[wc,a]];for(let v=0;v<m1.length;v++)Qu(n,m1[v],sR,Ec,g);for(let v=0;v<p1.length;v++)Qu(n,p1[v],oR,aR,b);qh(sR,{tld:!0,ascii:!0},e),qh(oR,{utld:!0,alpha:!0},e),Qu(n,"file",q1,Ec,g),Qu(n,"mailto",q1,Ec,g),Qu(n,"http",xp,Ec,g),Qu(n,"https",xp,Ec,g),Qu(n,"ftp",xp,Ec,g),Qu(n,"ftps",xp,Ec,g),qh(q1,{scheme:!0,ascii:!0},e),qh(xp,{slashscheme:!0,ascii:!0},e),t=t.sort((v,x)=>v[0]>x[0]?1:-1);for(let v=0;v<t.length;v++){const x=t[v][0],E=t[v][1]?{[n7e]:!0}:{[r7e]:!0};x.indexOf("-")>=0?E[iR]=!0:_c.test(x)?wc.test(x)?E[Rb]=!0:E[nR]=!0:E[tR]=!0,z9(n,x,x,E)}return z9(n,"localhost",j0,{ascii:!0}),n.jd=new as(i2),{start:n,tokens:Object.assign({groups:e},_te)}}function wte(t,e){const n=c7e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,p=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,p=0,d=l):f>=0&&(f+=n[o].length,p++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=p,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function c7e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Qu(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new as(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new as(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function $9(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const P0={defaultProtocol:"http",events:null,format:H9,formatHref:H9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function XO(t,e=null){let n=Object.assign({},P0);t&&(n=Object.assign(n,t instanceof XO?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}XO.prototype={o:P0,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:P0[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function H9(t){return t}function Ste(t,e){this.t="token",this.v=t,this.tk=e}Ste.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},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")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:a,eventListeners:f}}};function GM(t,e){class n extends Ste{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const V9=GM("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),G9=GM("text"),u7e=GM("nl"),g1=GM("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!==j0&&t[1].t===dd}}),io=t=>new as(t);function d7e({groups:t}){const e=t.domain.concat([WS,KS,ad,XS,YS,QS,ZS,JS,oo,HO,Lb,e2,t2,n2,pl,i2,Fb,r2]),n=[qS,dd,GO,ml,WO,Lb,Ib,qO,KO,LS,IS,Db,Ob,RS,PS,DS,OS,FS,US,zS,BS,$S,HS,VS,GS],r=[WS,qS,KS,XS,YS,QS,ZS,JS,oo,Db,Ob,Lb,e2,t2,n2,Ib,pl,i2,Fb,r2],i=io(),a=St(i,Fb);fn(a,r,a),fn(a,t.domain,a);const o=io(),l=io(),c=io();fn(i,t.domain,o),fn(i,t.scheme,l),fn(i,t.slashscheme,c),fn(o,r,a),fn(o,t.domain,o);const u=St(o,ad);St(a,ad,u),St(l,ad,u),St(c,ad,u);const d=St(a,ml);fn(d,r,a),fn(d,t.domain,a);const f=io();fn(u,t.domain,f),fn(f,t.domain,f);const p=St(f,ml);fn(p,t.domain,f);const g=io(V9);fn(p,t.tld,g),fn(p,t.utld,g),St(u,j0,g);const b=St(f,oo);St(b,oo,b),fn(b,t.domain,f),fn(g,t.domain,f),St(g,ml,p),St(g,oo,b);const v=St(g,dd);fn(v,t.numeric,V9);const x=St(o,oo),y=St(o,ml);St(x,oo,x),fn(x,t.domain,o),fn(y,r,a),fn(y,t.domain,o);const E=io(g1);fn(y,t.tld,E),fn(y,t.utld,E),fn(E,t.domain,o),fn(E,r,a),St(E,ml,y),St(E,oo,x),St(E,ad,u);const w=St(E,dd),A=io(g1);fn(w,t.numeric,A);const N=io(g1),C=io();fn(N,e,N),fn(N,n,C),fn(C,e,N),fn(C,n,C),St(E,pl,N),St(A,pl,N);const T=St(l,dd),D=St(c,dd),k=St(D,pl),P=St(k,pl);fn(l,t.domain,o),St(l,ml,y),St(l,oo,x),fn(c,t.domain,o),St(c,ml,y),St(c,oo,x),fn(T,t.domain,N),St(T,pl,N),St(T,Ib,N),fn(P,t.domain,N),fn(P,e,N),St(P,pl,N);const z=[[Db,Ob],[PS,RS],[DS,OS],[LS,IS],[FS,US],[zS,BS],[$S,HS],[VS,GS]];for(let L=0;L<z.length;L++){const[X,R]=z[L],Y=St(N,X);St(C,X,Y),St(Y,R,N);const J=io(g1);fn(Y,e,J);const G=io();fn(Y,n),fn(J,e,J),fn(J,n,G),fn(G,e,J),fn(G,n,G),St(J,R,N),St(G,R,N)}return St(i,j0,E),St(i,VO,u7e),{start:i,tokens:_te}}function h7e(t,e,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=null,p=-1;for(;i<r&&!(c=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(u=c||l.go(n[i].t));)c=null,l=u,l.accepts()?(p=0,f=l):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(qk(G9,e,o)),o=[]),i-=p,d-=p;const g=f.t,b=n.slice(i-d,i);a.push(qk(g,e,b))}}return o.length>0&&a.push(qk(G9,e,o)),a}function qk(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const f7e=typeof console<"u"&&console&&console.warn||(()=>{}),m7e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Mr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function p7e(){return as.groups={},Mr.scanner=null,Mr.parser=null,Mr.tokenQueue=[],Mr.pluginQueue=[],Mr.customSchemes=[],Mr.initialized=!1,Mr}function W9(t,e=!1){if(Mr.initialized&&f7e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${m7e}`),!/^[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`);Mr.customSchemes.push([t,e])}function g7e(){Mr.scanner=l7e(Mr.customSchemes);for(let t=0;t<Mr.tokenQueue.length;t++)Mr.tokenQueue[t][1]({scanner:Mr.scanner});Mr.parser=d7e(Mr.scanner.tokens);for(let t=0;t<Mr.pluginQueue.length;t++)Mr.pluginQueue[t][1]({scanner:Mr.scanner,parser:Mr.parser});return Mr.initialized=!0,Mr}function YO(t){return Mr.initialized||g7e(),h7e(Mr.parser.start,t,wte(Mr.scanner.start,t))}YO.scan=wte;function Mte(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 r=new XO(n),i=YO(t),a=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var QO="[\0- -\u2029 ]",x7e=new RegExp(QO),b7e=new RegExp(`${QO}$`),y7e=new RegExp(QO,"g");function v7e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function _7e(t){return new Fr({key:new Li("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,l=Vee(n.doc,[...e]);if(Qee(l).forEach(({newRange:u})=>{const d=sHe(r.doc,u,g=>g.isTextblock);let f,p;if(d.length>1)f=d[0],p=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const g=r.doc.textBetween(u.from,u.to," "," ");if(!b7e.test(g))return;f=d[0],p=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&p){const g=p.split(x7e).filter(Boolean);if(g.length<=0)return!1;const b=g[g.length-1],v=f.pos+p.lastIndexOf(b);if(!b)return!1;const x=YO(b).map(y=>y.toObject(t.defaultProtocol));if(!v7e(x))return!1;x.filter(y=>y.isLink).map(y=>({...y,from:v+y.start+1,to:v+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{FO(y.from,y.to,r.doc).some(E=>E.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function w7e(t){return new Fr({key:new Li("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(p=>p.nodeName==="A")}if(!o)return!1;const l=Yee(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(a=o?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function S7e(t){return new Fr({key:new Li("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Mte(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||i!==void 0&&!i(u.href)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function Eh(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(y7e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Ete=Qd.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"){W9(t);return}W9(t.scheme,t.optionalSlashes)})},onDestroy(){p7e()},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)=>!!Eh(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=>!!Eh(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=>!!Eh(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Zr(this.options.HTMLAttributes,t),0]:["a",Zr(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 r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Eh(r,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:r=>!!Eh(r,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[Lf({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Mte(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Eh(o,n),protocols:n,defaultProtocol:r}));i.length&&i.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(_7e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Eh(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(w7e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(S7e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),M7e=Ete,E7e=Object.defineProperty,N7e=(t,e)=>{for(var n in e)E7e(t,n,{get:e[n],enumerable:!0})},A7e="listItem",q9="textStyle",K9=/^\s*([-+*])\s$/,Nte=ms.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",Zr(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(A7e,this.editor.getAttributes(q9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=mg({find:K9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=mg({find:K9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(q9),editor:this.editor})),[t]}}),Ate=ms.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Zr(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(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>$O(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.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)}}}),T7e={};N7e(T7e,{findListItemPos:()=>Ey,getNextListDepth:()=>ZO,handleBackspace:()=>cR,handleDelete:()=>uR,hasListBefore:()=>Tte,hasListItemAfter:()=>C7e,hasListItemBefore:()=>Cte,listItemHasSubList:()=>kte,nextListIsDeeper:()=>jte,nextListIsHigher:()=>Pte});var Ey=(t,e)=>{const{$from:n}=e.selection,r=vi(t,e.schema);let i=null,a=n.depth,o=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},ZO=(t,e)=>{const n=Ey(t,e);if(!n)return!1;const[,r]=gHe(e,t,n.$pos.pos+4);return r},Tte=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},Cte=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},kte=(t,e,n)=>{if(!n)return!1;const r=vi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},cR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Vd(t.state,e)&&Tte(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((p,g)=>{p.type.name===e&&u.push({node:p,pos:g})});const d=u.at(-1);if(!d)return!1;const f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Vd(t.state,e)||!vHe(t.state))return!1;const r=Ey(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=kte(e,t.state,a);return Cte(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},jte=(t,e)=>{const n=ZO(t,e),r=Ey(t,e);return!r||!n?!1:n>r.depth},Pte=(t,e)=>{const n=ZO(t,e),r=Ey(t,e);return!r||!n?!1:n<r.depth},uR=(t,e)=>{if(!Vd(t.state,e)||!yHe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:jte(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Pte(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},C7e=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},Rte=fr.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&&uR(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&&uR(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&cR(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&cR(t,n,r)&&(e=!0)}),e}}}}),X9=/^(\s*)(\d+)\.\s+(.*)$/,k7e=/^\s/;function j7e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(X9);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const p=[i];for(;f<t.length;){const g=t[f];if(g.match(X9))break;if(g.trim()==="")p.push(g),d+=`
- `,f+=1;else if(g.match(k7e))p.push(g),d+=`
- ${g.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:p.join(`
- `)}),r=f,n=f}return[e,r]}function Dte(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const l=o.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const g=n.blockTokens(d);u.push(...g)}let f=a+1;const p=[];for(;f<t.length&&t[f].indent>e;)p.push(t[f]),f+=1;if(p.length>0){const g=Math.min(...p.map(v=>v.indent)),b=Dte(p,g,n);u.push({type:"list",ordered:!0,start:p[0].number,items:b,raw:p.map(v=>v.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function P7e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var R7e="listItem",Y9="textStyle",Q9=/^(\d+)\.\s$/,Ote=ms.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",Zr(this.options.HTMLAttributes,n),0]:["ol",Zr(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?P7e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},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 r;const i=t.split(`
- `),[a,o]=j7e(i);if(a.length===0)return;const l=Dte(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).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(R7e,this.editor.getAttributes(Y9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=mg({find:Q9,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=mg({find:Q9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Y9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),D7e=/^\s*(\[([( |x])?\])\s$/,O7e=ms.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",Zr(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 r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return $O(t,e,i)},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:r})=>{const i=document.createElement("li"),a=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,p;l.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const g=n();if(typeof g!="number")return!1;const b=p.doc.nodeAt(g);return p.setNodeMarkup(g,void 0,{...b?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[mg({find:D7e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),L7e=ms.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",Zr(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 r=a=>{const o=JP(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(a)},i=JP(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.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()}}});fr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Nte.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Ate.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Rte.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Ote.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(O7e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(L7e.configure(this.options.taskList)),t}});var I7e=ms.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Zr(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()}}}),F7e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,U7e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,z7e=Qd.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",Zr(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[fg({find:F7e,type:this.type})]},addPasteRules(){return[Lf({find:U7e,type:this.type})]}}),B7e=ms.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Lte=Qd.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",Zr(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 i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[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()}}}),$7e=Lte;function H7e(t={}){return new Fr({view(e){return new V7e(e,t)}})}class V7e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,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,r,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let g=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(g){let b=g.getBoundingClientRect(),v=f?b.bottom:b.top;f&&p&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*l;r={left:b.left,right:b.right,top:v-x,bottom:v+x}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.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 u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,g=f.height/c.offsetHeight;u=f.left-c.scrollLeft*p,d=f.top-c.scrollTop*g}this.element.style.left=(r.left-u)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"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}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=LJ(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Wr extends bn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Wr.valid(r)?new Wr(r):bn.near(r)}content(){return Dt.empty}eq(e){return e instanceof Wr&&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 Wr(e.resolve(n.pos))}getBookmark(){return new JO(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!G7e(e)||!W7e(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Wr.valid(e))return e;let i=e.pos,a=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){a=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let c=e.doc.resolve(i);if(Wr.valid(c))return c}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Kt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let l=e.doc.resolve(i);if(Wr.valid(l))return l}return null}}}Wr.prototype.visible=!1;Wr.findFrom=Wr.findGapCursorFrom;bn.jsonID("gapcursor",Wr);class JO{constructor(e){this.pos=e}map(e){return new JO(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Wr.valid(n)?new Wr(n):bn.near(n)}}function Ite(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function G7e(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Ite(i.type))return!0;if(i.inlineContent)return!1}}return!0}function W7e(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Ite(i.type))return!0;if(i.inlineContent)return!1}}return!0}function q7e(){return new Fr({props:{decorations:Q7e,createSelectionBetween(t,e,n){return e.pos==n.pos&&Wr.valid(n)?new Wr(n):null},handleClick:X7e,handleKeyDown:K7e,handleDOMEvents:{beforeinput:Y7e}}})}const K7e=Lee({ArrowLeft:x1("horiz",-1),ArrowRight:x1("horiz",1),ArrowUp:x1("vert",-1),ArrowDown:x1("vert",1)});function x1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof Jt){if(!a.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=Wr.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new Wr(u))),!0):!1}}function X7e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Wr.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Kt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Wr(r))),!0)}function Y7e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Wr))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=vt.empty;for(let o=r.length-1;o>=0;o--)i=vt.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Dt(i,0,0));return a.setSelection(Jt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function Q7e(t){if(!(t.selection instanceof Wr))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Pr.create(t.doc,[Ba.widget(t.selection.head,e,{key:"gapcursor"})])}var a2=200,Yi=function(){};Yi.prototype.append=function(e){return e.length?(e=Yi.from(e),!this.length&&e||e.length<a2&&this.leafAppend(e)||this.length<a2&&e.leafPrepend(this)||this.appendInner(e)):this};Yi.prototype.prepend=function(e){return e.length?Yi.from(e).append(this):this};Yi.prototype.appendInner=function(e){return new Z7e(this,e)};Yi.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Yi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Yi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Yi.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Yi.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Yi.from=function(e){return e instanceof Yi?e:e&&e.length?new Fte(e):Yi.empty};var Fte=(function(t){function e(r){t.call(this),this.values=r}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(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,l){for(var c=a;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,o,l){for(var c=a-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=a2)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=a2)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Yi);Yi.empty=new Fte([]);var Z7e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.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(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Yi);const J7e=500;class Wo{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){i||(i=this.remapping(r,p+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new gl(f.map));let g=f.step.map(i.slice(a)),b;g&&o.maybeStep(g).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],u.push(new gl(b,void 0,void 0,u.length+d.length))),a--,b&&i.appendMap(b,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Wo(this.items.slice(0,r).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:l}}addTransform(e,n,r,i){let a=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),p=new gl(e.mapping.maps[d],f,n),g;(g=c&&c.merge(p))&&(p=g,d?a.pop():l=l.slice(0,l.length-1)),a.push(p),n&&(o++,n=void 0),i||(c=p)}let u=o-r.depth;return u>t9e&&(l=e9e(l,u),o-=u),new Wo(l.append(a),o)}remapping(e,n){let r=new E0;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Wo(this.items.append(e.map(n=>new gl(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let c=n;this.items.forEach(p=>{let g=a.getMirror(--c);if(g==null)return;o=Math.min(o,g);let b=a.maps[g];if(p.step){let v=e.steps[g].invert(e.docs[g]),x=p.selection&&p.selection.map(a.slice(c+1,g));x&&l++,r.push(new gl(b,v,x))}else r.push(new gl(b))},i);let u=[];for(let p=n;p<o;p++)u.push(new gl(a.maps[p]));let d=this.items.slice(0,i).append(u).append(r),f=new Wo(d,l);return f.emptyItemCount()>J7e&&(f=f.compress(this.items.length-r.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),r=n.maps.length,i=[],a=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&a++;else if(o.step){let c=o.step.map(n.slice(r)),u=c&&c.getMap();if(r--,u&&n.appendMap(u,r),c){let d=o.selection&&o.selection.map(n.slice(r));d&&a++;let f=new gl(u.invert(),c,d),p,g=i.length-1;(p=i.length&&i[g].merge(f))?i[g]=p:i.push(f)}}else o.map&&r--},this.items.length,0),new Wo(Yi.from(i.reverse()),a)}}Wo.empty=new Wo(Yi.empty,0);function e9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class gl{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new gl(n.getMap().invert(),n,this.selection)}}}class sd{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const t9e=20;function n9e(t,e,n,r){let i=n.getMeta(cf),a;if(i)return i.historyState;n.getMeta(a9e)&&(t=new sd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(cf))return o.getMeta(cf).redo?new sd(t.done.addTransform(n,void 0,r,K1(e)),t.undone,Z9(n.mapping.maps),t.prevTime,t.prevComposition):new sd(t.done,t.undone.addTransform(n,void 0,r,K1(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),c=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!r9e(n,t.prevRanges)),u=o?Kk(t.prevRanges,n.mapping):Z9(n.mapping.maps);return new sd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,K1(e)),Wo.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new sd(t.done.rebased(n,a),t.undone.rebased(n,a),Kk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new sd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Kk(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function r9e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function Z9(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function Kk(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function i9e(t,e,n){let r=K1(e),i=cf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new sd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(cf,{redo:n,historyState:c})}let Xk=!1,J9=null;function K1(t){let e=t.plugins;if(J9!=e){Xk=!1,J9=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Xk=!0;break}}return Xk}const cf=new Li("history"),a9e=new Li("closeHistory");function s9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Fr({key:cf,state:{init(){return new sd(Wo.empty,Wo.empty,null,0,-1)},apply(e,n,r){return n9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?zte:r=="historyRedo"?Bte:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function Ute(t,e){return(n,r)=>{let i=cf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=i9e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const zte=Ute(!1,!0),Bte=Ute(!0,!0);fr.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 r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}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 Fr({key:new Li("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-i,l=0,c=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(l,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var o9e=fr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[H7e(this.options)]}});fr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Fr({key:new Li("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Pr.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(i>=u&&i<=u+c.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((c,u)=>{if(c.isText||!(i>=u&&i<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";a.push(Ba.node(u,u+c.nodeSize,{class:this.options.className}))}),Pr.create(t,a)}}})]}});var l9e=fr.create({name:"gapCursor",addProseMirrorPlugins(){return[q7e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Qn(Wt(t,"allowGapCursor",n)))!=null?e:null}}});fr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Fr({key:new Li("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&$M(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=Ba.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),Pr.create(t,i)}}})]}});fr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Fr({key:new Li("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Zee(n.selection)||t.view.dragging?null:Pr.create(n.doc,[Ba.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function eG({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var c9e=fr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Li(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Fr({key:e,appendTransaction:(i,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,p=u.nodes[n];if(d)return c.insert(f,p.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!eG({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!eG({node:o,types:r})}}})]}}),u9e=fr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>zte(t,e),redo:()=>({state:t,dispatch:e})=>Bte(t,e)}},addProseMirrorPlugins(){return[s9e(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()}}}),d9e=fr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(FVe.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(RVe.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Nte.configure(this.options.bulletList)),this.options.code!==!1&&i.push(BVe.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(VVe.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(GVe.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(o9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(l9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(WVe.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(qVe.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(u9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(KVe.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(JVe.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Ate.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Rte.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Ete.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Ote.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(I7e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(z7e.configure(this.options.strike)),this.options.text!==!1&&i.push(B7e.configure(this.options.text)),this.options.underline!==!1&&i.push(Lte.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(c9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),h9e=d9e,f9e=fr.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")}}}),m9e=f9e,p9e=20,$te=(t,e=0)=>{const n=[];return!t.children.length||e>p9e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...$te(r,e+1))}),n},g9e=t=>{if(!t.children.length)return;const e=$te(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${a}`)})},Hte=Qd.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&g9e(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Zr(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,r)=>{if(n.isTextblock)return!0;n.marks.filter(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),x9e=fr.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 r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="background-color")return l.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()}}}),Vte=fr.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 r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.slice(1).join(":").trim();if(o==="color")return l.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()}}}),b9e=fr.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()}}}),y9e=fr.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()}}}),v9e=fr.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()}}});fr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(x9e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(Vte.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(b9e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(y9e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(v9e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Hte.configure(this.options.textStyle)),t}});var _9e=Vte,w9e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,S9e=ms.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",Zr(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,i,a,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",c=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",u=(o=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return u?``:``},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:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new iVe({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const p=a();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,p)=>d.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),u=c.dom;return u.style.visibility="hidden",u.style.pointerEvents="none",l.onload=()=>{u.style.visibility="",u.style.pointerEvents=""},c}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[fte({find:w9e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),M9e=S9e;function dR({content:t,onChange:e,placeholder:n}){const r=TVe({extensions:[h9e.configure({heading:!1,codeBlock:!1,code:!1}),$7e,M7e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),m9e.configure({types:["paragraph"]}),Hte,_9e,M9e.configure({HTMLAttributes:{style:"max-width: 100%; height: auto;"}})],content:t,onUpdate:({editor:o})=>{e(o.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(!r)return null;const i=({onClick:o,isActive:l=!1,children:c,title:u})=>s.jsx("button",{type:"button",onClick:o,title:u,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${l?"bg-bambu-dark-tertiary text-bambu-green":"text-bambu-gray"}`,children:c}),a=()=>{const o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[s.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:s.jsx(wle,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(cue,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(Jde,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:s.jsx(M2,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(cW,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:s.jsx(Gde,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:s.jsx(Bde,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:s.jsx(Hde,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:s.jsx(B0,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(IR,{className:"w-4 h-4"})})]}),s.jsx(_Ve,{editor:r})]})}function Gte({archiveId:t,archiveName:e,onClose:n}){const r=an(),[i,a]=S.useState(!1),[o,l]=S.useState(null),[c,u]=S.useState({}),{data:d,isLoading:f,error:p}=lt({queryKey:["archive-project-page",t],queryFn:()=>be.getArchiveProjectPage(t)}),g=ht({mutationFn:N=>be.updateArchiveProjectPage(t,N),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});S.useEffect(()=>{const N=C=>{C.key==="Escape"&&(o!==null?l(null):i?y():n())};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[o,i,n]);const b=[...d?.model_pictures||[],...d?.profile_pictures||[]],v=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},x=()=>{g.mutate(c)},y=()=>{a(!1),u({})},E=N=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],T=new DOMParser().parseFromString(N,"text/html"),D=k=>{if(k.nodeType===Node.TEXT_NODE)return k.textContent||"";if(k.nodeType===Node.ELEMENT_NODE){const P=k,z=P.tagName.toLowerCase();if(!C.includes(z))return Array.from(P.childNodes).map(D).join("");let L="";if(z==="a"&&P.getAttribute("href")){const R=P.getAttribute("href");R?.toLowerCase().startsWith("http")&&(L=` href="${R}" target="_blank" rel="noopener noreferrer"`)}if(z==="img"){const R=P.getAttribute("src");if(!R?.toLowerCase().startsWith("http"))return"";L=` src="${R}" style="max-width: 100%; height: auto;"`}const X=Array.from(P.childNodes).map(D).join("");return["br","img"].includes(z)?`<${z}${L} />`:`<${z}${L}>${X}</${z}>`}return""};return Array.from(T.body.childNodes).map(D).join("")},w=d&&(d.title||d.description||d.designer||d.profile_title||b.length>0),A=N=>{N.target===N.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:A,children:[s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ua,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&w&&s.jsxs(Ee,{variant:"ghost",size:"sm",onClick:v,children:[s.jsx(gf,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Ee,{variant:"ghost",size:"sm",onClick:y,children:"Cancel"}),s.jsxs(Ee,{variant:"primary",size:"sm",onClick:x,disabled:g.isPending,children:[s.jsx(Rs,{className:"w-4 h-4 mr-1"}),"Save"]})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),p&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!w&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ua,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&w&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:N=>u({...c,title:N.target.value}),placeholder:"Title",className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold"}):d.title&&s.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Nj,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:N=>u({...c,designer:N.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Nj,{className:"w-4 h-4"}),s.jsx("span",{children:d.designer}),d.designer_user_id&&s.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:s.jsx(Kr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(qr,{className:"w-4 h-4"}),s.jsx("span",{children:d.creation_date})]}),i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ua,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:N=>u({...c,license:N.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Ua,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(dR,{content:c.description||"",onChange:N=>u({...c,description:N}),placeholder:"Enter description..."}):s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.description||"")}})]}),(d.profile_title||d.profile_description||i)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:N=>u({...c,profile_title:N.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),s.jsx(dR,{content:c.profile_description||"",onChange:N=>u({...c,profile_description:N}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:E(d.profile_description)}}),d.profile_user_name&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),b.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[s.jsx(z0,{className:"w-4 h-4"}),"Images (",b.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:b.map((N,C)=>s.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:N.url,alt:N.name,className:"w-full h-full object-cover"})},N.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("a",{href:`https://makerworld.com/en/models/${d.design_model_id}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&b[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick:N=>{N.stopPropagation(),l(Math.max(0,o-1))},disabled:o===0,className:"absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(ff,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:b[o].url,alt:b[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:N=>N.stopPropagation()}),s.jsx("button",{onClick:N=>{N.stopPropagation(),l(Math.min(b.length-1,o+1))},disabled:o===b.length-1,className:"absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30",children:s.jsx(Bs,{className:"w-6 h-6 text-white"})}),s.jsx("button",{onClick:()=>l(null),className:"absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary",children:s.jsx(zt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",b.length]})]})]})}const E9e=[.25,.5,.75,1,1.5,2,3,4];function lp(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function N9e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Wn(),a=S.useRef(null),o=S.useRef(null),[l,c]=S.useState(!1),[u,d]=S.useState(0),[f,p]=S.useState(0),[g,b]=S.useState(0),[v,x]=S.useState(0),[y,E]=S.useState(1),[w,A]=S.useState(null),[N,C]=S.useState(null),[T,D]=S.useState(.8),[k,P]=S.useState(!1),{data:z,isLoading:L}=lt({queryKey:["timelapse-info",t],queryFn:()=>be.getTimelapseInfo(t)}),{data:X}=lt({queryKey:["timelapse-thumbnails",t],queryFn:()=>be.getTimelapseThumbnails(t,15)}),R=ht({mutationFn:()=>be.processTimelapse(t,{trimStart:g,trimEnd:v,speed:y,saveMode:"replace"},w||void 0),onSuccess:F=>{i(F.message,"success"),r?.(),n()},onError:F=>{i(F.message||"Processing failed","error")}});S.useEffect(()=>{z?.duration&&v===0&&x(z.duration)},[z?.duration,v]),S.useEffect(()=>{const F=q=>{q.key==="Escape"&&n()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[n]),S.useEffect(()=>{const F=a.current;if(!F)return;const q=()=>{const de=F.currentTime;d(de),de>=v&&(F.currentTime=g)},ne=()=>{p(F.duration),v===0&&x(F.duration)},re=()=>c(!0),se=()=>c(!1);return F.addEventListener("timeupdate",q),F.addEventListener("durationchange",ne),F.addEventListener("play",re),F.addEventListener("pause",se),()=>{F.removeEventListener("timeupdate",q),F.removeEventListener("durationchange",ne),F.removeEventListener("play",re),F.removeEventListener("pause",se)}},[g,v]),S.useEffect(()=>{const F=o.current,q=a.current;!F||!q||!N||(F.currentTime=q.currentTime,F.playbackRate=q.playbackRate,l&&!k?F.play().catch(()=>{}):F.pause())},[l,N,k]),S.useEffect(()=>{o.current&&(o.current.volume=k?0:T)},[T,k]),S.useEffect(()=>{a.current&&(a.current.playbackRate=y),o.current&&(o.current.playbackRate=y)},[y]);const Y=S.useCallback(()=>{const F=a.current;F&&(l?F.pause():(F.currentTime<g&&(F.currentTime=g),F.play()))},[l,g]),J=F=>{const q=a.current;q&&(q.currentTime=Math.max(g,Math.min(v,F)))},G=F=>{const q=F.target.files?.[0];q&&(N&&URL.revokeObjectURL(N),A(q),C(URL.createObjectURL(q)))},W=()=>{N&&URL.revokeObjectURL(N),A(null),C(null)};S.useEffect(()=>()=>{N&&URL.revokeObjectURL(N)},[N]);const ee=v-g,K=ee/y;return L?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(ft,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(_d,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ee,{variant:"primary",size:"sm",onClick:()=>R.mutate(),disabled:R.isPending,children:R.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rs,{className:"w-4 h-4"}),"Save"]})}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:Y,muted:!!N}),!l&&s.jsx("button",{onClick:Y,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:s.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:s.jsx(Yc,{className:"w-8 h-8 text-white"})})}),N&&s.jsx("audio",{ref:o,src:N,loop:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(gde,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[lp(g)," - ",lp(v)," (",lp(ee),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:X?.thumbnails.map((F,q)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${F})`}},q))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${g/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-v)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${g/f*100}%`,right:`${(f-v)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:g,onChange:F=>{const q=parseFloat(F.target.value);q<v-1&&(b(q),a.current&&a.current.currentTime<q&&(a.current.currentTime=q))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:v,onChange:F=>{const q=parseFloat(F.target.value);q>g+1&&x(q)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:F=>J(parseFloat(F.target.value)),className:`w-full 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`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:Y,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(DR,{className:"w-5 h-5 text-white"}):s.jsx(Yc,{className:"w-5 h-5 text-white"})})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(v2,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[y,"x (output: ",lp(K),")"]})]}),s.jsx("div",{className:"flex gap-1",children:E9e.map(F=>s.jsxs("button",{onClick:()=>E(F),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${y===F?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[F,"x"]},F))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Ej,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),w?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(Ej,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:w.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(w.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>P(!k),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:k?s.jsx(che,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(ohe,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:T,onChange:F=>D(parseFloat(F.target.value)),className:`w-20 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`}),s.jsx("button",{onClick:W,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(ln,{className:"w-4 h-4 text-red-400"})})]}):s.jsxs("label",{className:"flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors",children:[s.jsx(xi,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:G,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",lp(f)," @ ",z?.width,"x",z?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",lp(K)," @ ",y,"x speed",w&&" + music overlay"]})]})]}),R.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(ft,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const A9e=[.25,.5,.75,1,1.5,2,3,4];function Wte({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=S.useRef(null),[l,c]=S.useState(!0),[u,d]=S.useState(1),[f,p]=S.useState(0),[g,b]=S.useState(0),[v,x]=S.useState(!1);S.useEffect(()=>{const T=o.current;T&&(T.playbackRate=u)},[u]),S.useEffect(()=>{const T=D=>{D.key==="Escape"&&i()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[i]),S.useEffect(()=>{const T=o.current;if(!T)return;const D=()=>p(T.currentTime),k=()=>b(T.duration),P=()=>c(!0),z=()=>c(!1);return T.addEventListener("timeupdate",D),T.addEventListener("durationchange",k),T.addEventListener("play",P),T.addEventListener("pause",z),()=>{T.removeEventListener("timeupdate",D),T.removeEventListener("durationchange",k),T.removeEventListener("play",P),T.removeEventListener("pause",z)}},[]);const y=()=>{const T=o.current;T&&(l?T.pause():T.play())},E=T=>{const D=o.current;D&&(D.currentTime=parseFloat(T.target.value))},w=()=>{const T=o.current;T&&(T.currentTime=Math.max(0,T.currentTime-5))},A=()=>{const T=o.current;T&&(T.currentTime=Math.min(g,T.currentTime+5))},N=T=>{const D=Math.floor(T/60),k=Math.floor(T%60);return`${D}:${k.toString().padStart(2,"0")}`},C=()=>{const T=document.createElement("a");T.href=t,T.download=n,T.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(_d,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>x(!0),children:[s.jsx(Jo,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(Yr,{className:"w-4 h-4"}),"Download"]}),s.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:y}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:N(f)}),s.jsx("input",{type:"range",min:0,max:g||100,value:f,onChange:E,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`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:N(g)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:w,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(Tde,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:y,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(DR,{className:"w-5 h-5 text-white"}):s.jsx(Yc,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:A,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(sw,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),s.jsx("div",{className:"flex gap-1",children:A9e.map(T=>s.jsxs("button",{onClick:()=>d(T),className:`px-2 py-1 text-xs rounded transition-colors ${u===T?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[T,"x"]},T))})]})]})]})]})]}),v&&r&&s.jsx(N9e,{archiveId:r,timelapseSrc:t,onClose:()=>x(!1),onSave:a})]})}function eL({archiveId:t,archiveName:e,onClose:n}){const r=an(),{showToast:i}=Wn(),[a,o]=S.useState(null),[l,c]=S.useState("asap"),[u,d]=S.useState(""),[f,p]=S.useState(!1),[g,b]=S.useState(!1),[v,x]=S.useState(!1),[y,E]=S.useState(!1),[w,A]=S.useState({}),{data:N}=lt({queryKey:["printers"],queryFn:()=>be.getPrinters()}),{data:C}=lt({queryKey:["archive-filaments",t],queryFn:()=>be.getArchiveFilamentRequirements(t)}),{data:T}=lt({queryKey:["printer-status",a],queryFn:()=>be.getPrinterStatus(a),enabled:!!a});S.useEffect(()=>{N?.length===1&&!a&&o(N[0].id)},[N,a]),S.useEffect(()=>{A({})},[a]),S.useEffect(()=>{const W=ee=>{ee.key==="Escape"&&n()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[n]);const D=W=>W?`#${W.replace("#","").substring(0,6)}`:"#808080",k=(W,ee,K,F)=>{const q=String.fromCharCode(65+(W>=128?W-128:W));return K?`HT-${q}`:`AMS-${q} Slot ${ee+1}`},P=(W,ee,K)=>W*4+ee,z=S.useMemo(()=>{const W=[];if(T?.ams?.forEach(ee=>{const K=ee.tray.length===1;ee.tray.forEach(F=>{if(F.tray_type){const q=D(F.tray_color);W.push({type:F.tray_type,color:q,colorName:Gc(q),amsId:ee.id,trayId:F.id,isHt:K,isExternal:!1,label:k(ee.id,F.id,K),globalTrayId:P(ee.id,F.id)})}})}),T?.vt_tray?.tray_type){const ee=D(T.vt_tray.tray_color);W.push({type:T.vt_tray.tray_type,color:ee,colorName:Gc(ee),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return W},[T]),L=S.useMemo(()=>{if(!C?.filaments||C.filaments.length===0)return[];const W=F=>F?F.replace("#","").toLowerCase().substring(0,6):"",ee=(F,q,ne=40)=>{const re=W(F),se=W(q);if(!re||!se||re.length<6||se.length<6)return!1;const de=parseInt(re.substring(0,2),16),pe=parseInt(re.substring(2,4),16),Ce=parseInt(re.substring(4,6),16),oe=parseInt(se.substring(0,2),16),ae=parseInt(se.substring(2,4),16),ge=parseInt(se.substring(4,6),16);return Math.abs(de-oe)<=ne&&Math.abs(pe-ae)<=ne&&Math.abs(Ce-ge)<=ne},K=new Set(Object.values(w));return C.filaments.map(F=>{const q=F.slot_id||0;if(q>0&&w[q]!==void 0){const ge=w[q],ue=z.find(Le=>Le.globalTrayId===ge);if(ue){const Le=ue.type?.toUpperCase()===F.type?.toUpperCase(),V=W(ue.color)===W(F.color)||ee(ue.color,F.color);let $;return Le&&V?$="match":Le?$="type_only":$="mismatch",{...F,loaded:ue,hasFilament:!0,typeMatch:Le,colorMatch:V,status:$,isManual:!0}}}const ne=z.find(ge=>!K.has(ge.globalTrayId)&&ge.type?.toUpperCase()===F.type?.toUpperCase()&&W(ge.color)===W(F.color)),re=!ne&&z.find(ge=>!K.has(ge.globalTrayId)&&ge.type?.toUpperCase()===F.type?.toUpperCase()&&ee(ge.color,F.color)),se=!ne&&!re&&z.find(ge=>!K.has(ge.globalTrayId)&&ge.type?.toUpperCase()===F.type?.toUpperCase()),de=ne||re||se||void 0;de&&K.add(de.globalTrayId);const pe=!!de,Ce=pe,oe=!!ne||!!re;let ae;return ne||re?ae="match":se?ae="type_only":ae="mismatch",{...F,loaded:de,hasFilament:pe,typeMatch:Ce,colorMatch:oe,status:ae,isManual:!1}})},[C,z,w]),X=S.useMemo(()=>{if(L.length===0)return;const W=Math.max(...L.map(K=>K.slot_id||0));if(W<=0)return;const ee=new Array(W).fill(-1);return L.forEach(K=>{K.slot_id&&K.slot_id>0&&(ee[K.slot_id-1]=K.loaded?.globalTrayId??-1)}),ee},[L]),R=C?.filaments&&C.filaments.length>0,Y=ht({mutationFn:W=>be.addToQueue(W),onSuccess:()=>{r.invalidateQueries({queryKey:["queue"]}),i("Added to print queue"),n()},onError:W=>{i(W.message||"Failed to add to queue","error")}}),J=W=>{if(W.preventDefault(),!a){i("Please select a printer","error");return}const ee={printer_id:a,archive_id:t,require_previous_success:f,auto_off_after:g,manual_start:l==="manual",ams_mapping:X};l==="scheduled"&&u&&(ee.scheduled_time=new Date(u).toISOString()),Y.mutate(ee)},G=()=>{const W=new Date;return W.setMinutes(W.getMinutes()+1),W.toISOString().slice(0,16)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsx(_t,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:W=>W.stopPropagation(),children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Schedule Print"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:J,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),s.jsx("p",{className:"text-white font-medium truncate",children:e})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),N?.length===0?s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(pa,{className:"w-4 h-4"}),"No printers configured"]}):s.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=>o(W.target.value?Number(W.target.value):null),required:!0,children:[s.jsx("option",{value:"",children:"Select printer..."}),N?.map(W=>s.jsx("option",{value:W.id,children:W.name},W.id))]})]}),a&&R&&s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>x(!v),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(qb,{className:"w-4 h-4",fill:L.some(W=>W.status==="mismatch")?"#f97316":L.some(W=>W.status==="type_only")?"#facc15":"#00ae42",stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),L.some(W=>W.status==="mismatch")?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):L.some(W=>W.status==="type_only")?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),v?s.jsx(Xc,{className:"w-4 h-4 ml-auto"}):s.jsx(Qi,{className:"w-4 h-4 ml-auto"})]}),v&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.jsxs("button",{type:"button",onClick:async()=>{if(a){E(!0);try{await be.refreshPrinterStatus(a),await new Promise(W=>setTimeout(W,500)),await r.refetchQueries({queryKey:["printer-status",a]})}finally{E(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:y,children:[s.jsx(Rr,{className:`w-3 h-3 ${y?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),L.map((W,ee)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${W.type} - ${Gc(W.color)}`,children:s.jsx(qb,{className:"w-3 h-3",fill:W.color,stroke:W.color})}),s.jsxs("span",{className:"text-white truncate",children:[W.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",W.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:W.loaded?.globalTrayId??"",onChange:K=>{const F=W.slot_id||0;if(F>0){const q=K.target.value;A(q===""?ne=>{const re={...ne};return delete re[F],re}:ne=>({...ne,[F]:parseInt(q,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${W.status==="match"?"border-bambu-green/50 text-bambu-green":W.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${W.isManual?"ring-1 ring-blue-400/50":""}`,title:W.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),z.map(K=>s.jsxs("option",{value:K.globalTrayId,className:"bg-bambu-dark text-white",children:[K.label,": ",K.type," (",K.colorName,")"]},K.globalTrayId))]}),W.status==="match"?s.jsx(Aa,{className:"w-3 h-3 text-bambu-green"}):W.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(yn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(yn,{className:"w-3 h-3 text-orange-400"})})]},ee))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("asap"),children:[s.jsx(tr,{className:"w-4 h-4"}),"ASAP"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("scheduled"),children:[s.jsx(qr,{className:"w-4 h-4"}),"Scheduled"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${l==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>c("manual"),children:[s.jsx(PR,{className:"w-4 h-4"}),"Queue Only"]})]})]}),l==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.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:u,onChange:W=>d(W.target.value),min:G(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:f,onChange:W=>p(W.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:g,onChange:W=>b(W.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(zl,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:l==="asap"?"Print will start as soon as the printer is idle.":l==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Ee,{type:"submit",className:"flex-1",disabled:Y.isPending||!a||N?.length===0,children:Y.isPending?"Adding...":"Add to Queue"})]})]})]})})})}function T9e({archiveIds:t,onClose:e}){S.useEffect(()=>{const a=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=lt({queryKey:["archive-comparison",t],queryFn:()=>be.compareArchives(t)});return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?s.jsxs("div",{className:"text-center py-12 text-red-400",children:[s.jsx(yn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"Failed to load comparison"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?s.jsx(C9e,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Ee,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function C9e({comparison:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]",children:"Setting"}),t.archives.map(e=>s.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[s.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),s.jsx("div",{className:`text-xs ${e.status==="completed"?"text-bambu-green":e.status==="failed"?"text-red-400":"text-bambu-gray"}`,children:e.status})]},e.id))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(yn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),s.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>s.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??s.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&s.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&s.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[s.jsx(yn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(Aa,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[s.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),s.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?s.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>s.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[s.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",s.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):s.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:s.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function k9e(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function j9e(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function P9e({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=S.useState(!1),[c,u]=S.useState(t.tags||""),[d,f]=S.useState(t.notes||""),[p,g]=S.useState(t.project_id),[b,v]=S.useState(!1);return s.jsx(_t,{children:s.jsxs(Mt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Xh,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:t.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx("span",{children:k9e(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),j9e(t.uploaded_at)]}),t.source_ip&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?s.jsx(Xc,{className:"w-5 h-5"}):s.jsx(Qi,{className:"w-5 h-5"})}),s.jsx(Ee,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:p||void 0}),disabled:i,children:i?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Os,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:a,children:a?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(ln,{className:"w-4 h-4 text-red-400"})})]})]}),b&&s.jsx(Un,{title:"Discard Upload",message:`Are you sure you want to discard "${t.filename}"? This cannot be undone.`,confirmText:"Discard",variant:"danger",onConfirm:()=>{r(t.id),v(!1)},onCancel:()=>v(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:"e.g., functional, prototype, gift",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:x=>f(x.target.value),placeholder:"Add notes about this print...",rows:2,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.jsxs("select",{value:p||"",onChange:x=>g(x.target.value?Number(x.target.value):null),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm",children:[s.jsx("option",{value:"",children:"No project"}),e.map(x=>s.jsx("option",{value:x.id,children:x.name},x.id))]})]})]})]})})}function R9e(){const t=an(),{showToast:e}=Wn(),[n,r]=S.useState(!1),[i,a]=S.useState(!1),[o,l]=S.useState(new Set),[c,u]=S.useState(new Set),{data:d,isLoading:f}=lt({queryKey:["pending-uploads"],queryFn:dp.list,refetchInterval:1e4}),{data:p}=lt({queryKey:["projects"],queryFn:()=>be.getProjects()}),g=ht({mutationFn:({id:y,data:E})=>dp.archive(y,E),onMutate:({id:y})=>{l(E=>new Set(E).add(y))},onSettled:(y,E,{id:w})=>{l(A=>{const N=new Set(A);return N.delete(w),N})},onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${y.print_name}`)},onError:y=>{e(y.message||"Failed to archive","error")}}),b=ht({mutationFn:y=>dp.discard(y),onMutate:y=>{u(E=>new Set(E).add(y))},onSettled:(y,E,w)=>{u(A=>{const N=new Set(A);return N.delete(w),N})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:y=>{e(y.message||"Failed to discard","error")}}),v=ht({mutationFn:dp.archiveAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${y.archived} files${y.failed>0?`, ${y.failed} failed`:""}`)},onError:y=>{e(y.message||"Failed to archive all","error")}}),x=ht({mutationFn:dp.discardAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${y.discarded} files`)},onError:y=>{e(y.message||"Failed to discard all","error")}});return f?s.jsx(_t,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(_t,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(Vr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(xi,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ee,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:v.isPending,children:v.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(Os,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:x.isPending,children:x.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(ln,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Mt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"These files were uploaded via the virtual printer. Review and archive them to add to your collection."}),s.jsx("div",{className:"space-y-3",children:d.map(y=>s.jsx(P9e,{upload:y,projects:p||[],onArchive:(E,w)=>g.mutate({id:E,data:w}),onDiscard:E=>b.mutate(E),isArchiving:o.has(y.id),isDiscarding:c.has(y.id)},y.id))})]})]}),n&&s.jsx(Un,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{v.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.jsx(Un,{title:"Discard All Uploads",message:`Are you sure you want to discard all ${d.length} pending uploads? This cannot be undone.`,confirmText:"Discard All",variant:"danger",onConfirm:()=>{x.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function s2(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ib(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Ih(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function D9e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system"}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const c=an(),{showToast:u}=Wn(),d=wW(),[f,p]=S.useState(!1),[g,b]=S.useState(!1),[v,x]=S.useState(!1),[y,E]=S.useState(!1),[w,A]=S.useState(!1),[N,C]=S.useState(!1),[T,D]=S.useState([]),[k,P]=S.useState(!1),[z,L]=S.useState(!1),[X,R]=S.useState(!1),[Y,J]=S.useState(!1),[G,W]=S.useState(!1),[ee,K]=S.useState(!1),[F,q]=S.useState(null),ne=S.useRef(null),re=S.useRef(null),se=ht({mutationFn:U=>be.uploadSource3mf(t.id,U),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(`Source 3MF attached: ${U.filename}`)},onError:U=>{u(U.message||"Failed to upload source 3MF","error")}}),de=ht({mutationFn:()=>be.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Source 3MF removed")},onError:U=>{u(U.message||"Failed to remove source 3MF","error")}}),pe=ht({mutationFn:U=>be.uploadF3d(t.id,U),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(`F3D attached: ${U.filename}`)},onError:U=>{u(U.message||"Failed to upload F3D","error")}}),Ce=ht({mutationFn:()=>be.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("F3D removed")},onError:U=>{u(U.message||"Failed to remove F3D","error")}}),oe=ht({mutationFn:()=>be.scanArchiveTimelapse(t.id),onSuccess:U=>{U.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${U.filename}`)):U.status==="exists"?u("Timelapse already attached"):U.status==="not_found"&&U.available_files&&U.available_files.length>0?(D(U.available_files),C(!0)):u(U.message||"No matching timelapse found","warning")},onError:U=>{u(U.message||"Failed to scan for timelapse","error")}}),ae=ht({mutationFn:U=>be.selectArchiveTimelapse(t.id,U),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(`Timelapse attached: ${U.filename}`),C(!1),D([])},onError:U=>{u(U.message||"Failed to attach timelapse","error")}}),ge=ht({mutationFn:()=>be.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u("Archive deleted")},onError:()=>{u("Failed to delete archive","error")}}),ue=ht({mutationFn:()=>be.toggleFavorite(t.id),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(U.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:Le}=lt({queryKey:["archive-folders",t.id],queryFn:()=>be.getLibraryFoldersByArchive(t.id)}),V=ht({mutationFn:U=>be.updateArchive(t.id,{project_id:U}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u("Project updated")},onError:()=>{u("Failed to update project","error")}}),$=U=>{U.preventDefault(),q({x:U.clientX,y:U.clientY})},B=[...Ih(t.filename)?[{label:"Print",icon:s.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>J(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const U=t.print_name||t.filename||"model",Q=`${window.location.origin}${be.getArchiveForSlicer(t.id,U)}`;kc(Q)}}]:[{label:"Slice",icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const U=t.print_name||t.filename||"model",Q=`${window.location.origin}${be.getArchiveForSlicer(t.id,U)}`;kc(Q)}}],{label:"View on MakerWorld",icon:s.jsx(pf,{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:s.jsx(ks,{className:"w-4 h-4"}),onClick:()=>p(!0)},{label:"View Timelapse",icon:s.jsx(_d,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(dW,{className:"w-4 h-4"}),onClick:()=>oe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||oe.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(nw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const U=document.createElement("a");U.href=be.getSource3mfDownloadUrl(t.id),U.download=`${t.print_name||t.filename}_source.3mf`,U.click()}else ne.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(xi,{className:"w-4 h-4"}),onClick:()=>ne.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(ln,{className:"w-4 h-4"}),onClick:()=>W(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(ks,{className:"w-4 h-4"}),onClick:()=>re.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const U=document.createElement("a");U.href=be.getF3dDownloadUrl(t.id),U.download=`${t.print_name||t.filename}.f3d`,U.click()}},{label:"Remove F3D",icon:s.jsx(ln,{className:"w-4 h-4"}),onClick:()=>K(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const U=document.createElement("a");U.href=be.getArchiveDownload(t.id),U.download=`${t.print_name||t.filename}.3mf`,U.click()}},{label:"Copy Download Link",icon:s.jsx($s,{className:"w-4 h-4"}),onClick:()=>{const U=`${window.location.origin}${be.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(U).then(()=>{u("Link copied to clipboard")}).catch(()=>{u("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(uW,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(zp,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(xf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ue.mutate()},{label:"Edit",icon:s.jsx(Jo,{className:"w-4 h-4"}),onClick:()=>E(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ma,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ma,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const U=[];if(t.project_id&&U.push({label:"Remove from Project",icon:s.jsx(zt,{className:"w-4 h-4"}),onClick:()=>V.mutate(null)}),!a)U.push({label:"Loading...",icon:s.jsx(ft,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Q=a.filter(Me=>Me.status==="active");Q.length===0?U.push({label:"No projects available",icon:s.jsx(ma,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Q.forEach(Me=>{U.push({label:Me.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Me.color||"#888"}}),onClick:()=>V.mutate(Me.id),disabled:t.project_id===Me.id})})}return U})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Qc,{className:"w-4 h-4"}):s.jsx(Zc,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(ln,{className:"w-4 h-4"}),onClick:()=>x(!0),danger:!0}];return s.jsxs(_t,{"data-archive-id":t.id,className:`relative flex flex-col group ${n?"ring-2 ring-bambu-green":""} ${i?"cursor-pointer":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,onContextMenu:$,onClick:i?()=>r(t.id):void 0,children:[i&&s.jsx("button",{className:"absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:U=>{U.stopPropagation(),r(t.id)},children:n?s.jsx(Qc,{className:"w-5 h-5 text-bambu-green"}):s.jsx(Zc,{className:"w-5 h-5 text-white"})}),s.jsxs("div",{className:"aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl",children:[t.thumbnail_path?s.jsx("img",{src:be.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(z0,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),s.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${d?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:U=>{U.stopPropagation();const Q=U.currentTarget.getBoundingClientRect();q({x:Q.left,y:Q.bottom+4})},title:"Right-click for more options",children:s.jsx(vd,{className:"w-5 h-5 text-white"})}),s.jsx("button",{className:"absolute top-2 right-2 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors",onClick:U=>{U.stopPropagation(),ue.mutate()},title:t.is_favorite?"Remove from favorites":"Add to favorites",children:s.jsx(xf,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"}`})}),(t.status==="failed"||t.status==="aborted")&&s.jsx("div",{className:"absolute top-2 left-12 px-2 py-1 rounded text-xs bg-red-500/80 text-white",children:t.status==="aborted"?"cancelled":"failed"}),t.duplicate_count>0&&s.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:[s.jsx($s,{className:"w-3 h-3"}),"duplicate"]}),t.source_3mf_path&&s.jsx("button",{className:"absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:U=>{U.stopPropagation();const Q=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Me=`${window.location.origin}${be.getSource3mfForSlicer(t.id,Q)}`;kc(Me)},title:"Open source 3MF in Bambu Studio (right-click for more options)",children:s.jsx(nw,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&s.jsx("button",{className:`absolute bottom-2 ${t.source_3mf_path?"left-12":"left-2"} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:U=>{U.stopPropagation(),window.location.href=be.getF3dDownloadUrl(t.id)},title:"Download Fusion 360 design file",children:s.jsx(ks,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&s.jsx("button",{className:"absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:U=>{U.stopPropagation(),A(!0)},title:"View timelapse",children:s.jsx(_d,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.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:U=>{U.stopPropagation(),L(!0)},title:`View ${t.photos.length} photo${t.photos.length>1?"s":""}`,children:[s.jsx(zp,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&s.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})]}),Le&&Le.length>0&&s.jsx(Ts,{to:`/files?folder=${Le[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:U=>U.stopPropagation(),title:`Open folder: ${Le[0].name}`,style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:s.jsx(Zo,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Mt,{className:"p-4 flex-1 flex flex-col",children:[s.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:e}),s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Ih(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Ih(t.filename)?"Sliced file - ready to print":"Source file only - no AMS mapping available",children:Ih(t.filename)?"GCODE":"SOURCE"}),t.project_name&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(U=>U.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(U=>U.id===t.project_id)?.color||"#6b7280"},title:`Project: ${t.project_name}`,children:t.project_name})]}),s.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)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${ib(t.print_time_seconds||0)}
- Actual: ${ib(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${ib(t.actual_time_seconds)}`:`Estimated: ${ib(t.print_time_seconds||0)}`,children:[s.jsx(tr,{className:"w-3 h-3"}),ib(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&s.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&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Cl,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Hs,{className:"w-3 h-3"}),t.total_layers&&s.jsxs("span",{children:[t.total_layers," layers"]}),t.total_layers&&t.layer_height&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:`${t.object_count} object${t.object_count>1?"s":""}`,children:[s.jsx(ks,{className:"w-3 h-3"}),t.object_count," object",t.object_count>1?"s":""]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((U,Q)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:U},title:U},Q))})]})]}),(t.tags||t.notes)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&s.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:s.jsx(fW,{className:"w-3 h-3"})}),t.tags?.split(",").map((U,Q)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:U.trim()},Q))]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[s.jsx("span",{children:Vp(t.created_at,l)}),s.jsx("span",{children:s2(t.file_size)})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[Ih(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>b(!0),children:[s.jsx(Qr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Reprint"})]}),s.jsx(Ee,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const U=t.print_name||t.filename||"model",Q=`${window.location.origin}${be.getArchiveForSlicer(t.id,U)}`;kc(Q)},title:"Open in Bambu Studio",children:s.jsx(Kr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Ee,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const U=t.print_name||t.filename||"model",Q=`${window.location.origin}${be.getArchiveForSlicer(t.id,U)}`;kc(Q)},title:"Open in Bambu Studio to slice",children:[s.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:"Slice"})]}),s.jsx(Ee,{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:s.jsx(pf,{className:`w-3 h-3 sm:w-4 sm:h-4 ${t.makerworld_url?"":"opacity-20"}`})}),s.jsx(Ee,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>p(!0),title:"3D Preview",children:s.jsx(ks,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Ee,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const U=document.createElement("a");U.href=be.getArchiveDownload(t.id),U.download=`${t.print_name||t.filename}.3mf`,U.click()},title:"Download",children:s.jsx(Yr,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>E(!0),title:"Edit",children:s.jsx(Jo,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>x(!0),title:"Delete",children:s.jsx(ln,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),y&&s.jsx(sJ,{archive:t,onClose:()=>E(!1)}),f&&s.jsx(iJ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>p(!1)}),g&&s.jsx(aJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1),onSuccess:()=>{}}),v&&s.jsx(Un,{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:()=>{ge.mutate(),x(!1)},onCancel:()=>x(!1)}),G&&s.jsx(Un,{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:()=>{de.mutate(),W(!1)},onCancel:()=>W(!1)}),ee&&s.jsx(Un,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{Ce.mutate(),K(!1)},onCancel:()=>K(!1)}),F&&s.jsx(oJ,{x:F.x,y:F.y,items:B,onClose:()=>q(null)}),w&&t.timelapse_path&&s.jsx(Wte,{src:be.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),A(!1)}}),N&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{C(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(U=>s.jsxs("button",{onClick:()=>ae.mutate(U.name),disabled:ae.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:[s.jsx(_d,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:U.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[s2(U.size),U.mtime&&` • ${Vp(U.mtime,l)}`]})]})]},U.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Ee,{variant:"secondary",onClick:()=>{C(!1),D([])},className:"w-full",children:"Cancel"})})]})}),k&&s.jsx(lJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),z&&t.photos&&t.photos.length>0&&s.jsx(cJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async U=>{try{await be.deleteArchivePhoto(t.id,U),c.invalidateQueries({queryKey:["archives"]}),u("Photo deleted")}catch{u("Failed to delete photo","error")}}}),X&&s.jsx(Gte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),Y&&s.jsx(eL,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>J(!1)}),s.jsx("input",{ref:ne,type:"file",accept:".3mf",className:"hidden",onChange:U=>{const Q=U.target.files?.[0];Q&&se.mutate(Q),U.target.value=""}}),s.jsx("input",{ref:re,type:"file",accept:".f3d",className:"hidden",onChange:U=>{const Q=U.target.files?.[0];Q&&pe.mutate(Q),U.target.value=""}})]})}function O9e({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o}){const l=an(),{showToast:c}=Wn(),[u,d]=S.useState(!1),[f,p]=S.useState(!1),[g,b]=S.useState(!1),[v,x]=S.useState(!1),[y,E]=S.useState(!1),[w,A]=S.useState(!1),[N,C]=S.useState(!1),[T,D]=S.useState([]),[k,P]=S.useState(!1),[z,L]=S.useState(!1),[X,R]=S.useState(!1),[Y,J]=S.useState(!1),[G,W]=S.useState(!1),[ee,K]=S.useState(null),F=S.useRef(null),q=S.useRef(null),ne=ht({mutationFn:Z=>be.uploadSource3mf(t.id,Z),onSuccess:Z=>{l.invalidateQueries({queryKey:["archives"]}),c(`Source 3MF attached: ${Z.filename}`)},onError:Z=>{c(Z.message||"Failed to upload source 3MF","error")}}),re=ht({mutationFn:()=>be.deleteSource3mf(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Source 3MF removed")},onError:Z=>{c(Z.message||"Failed to remove source 3MF","error")}}),se=ht({mutationFn:Z=>be.uploadF3d(t.id,Z),onSuccess:Z=>{l.invalidateQueries({queryKey:["archives"]}),c(`F3D attached: ${Z.filename}`)},onError:Z=>{c(Z.message||"Failed to upload F3D","error")}}),de=ht({mutationFn:()=>be.deleteF3d(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("F3D removed")},onError:Z=>{c(Z.message||"Failed to remove F3D","error")}}),pe=ht({mutationFn:()=>be.scanArchiveTimelapse(t.id),onSuccess:Z=>{Z.status==="attached"?(l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${Z.filename}`)):Z.status==="exists"?c("Timelapse already attached"):Z.status==="not_found"&&Z.available_files&&Z.available_files.length>0?(D(Z.available_files),C(!0)):c(Z.message||"No matching timelapse found","warning")},onError:Z=>{c(Z.message||"Failed to scan for timelapse","error")}}),Ce=ht({mutationFn:Z=>be.selectArchiveTimelapse(t.id,Z),onSuccess:Z=>{l.invalidateQueries({queryKey:["archives"]}),c(`Timelapse attached: ${Z.filename}`),C(!1),D([])},onError:Z=>{c(Z.message||"Failed to attach timelapse","error")}}),oe=ht({mutationFn:()=>be.deleteArchive(t.id),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),c("Archive deleted")},onError:()=>{c("Failed to delete archive","error")}}),ae=ht({mutationFn:()=>be.toggleFavorite(t.id),onSuccess:Z=>{l.invalidateQueries({queryKey:["archives"]}),c(Z.is_favorite?"Added to favorites":"Removed from favorites")}}),{data:ge}=lt({queryKey:["archive-folders",t.id],queryFn:()=>be.getLibraryFoldersByArchive(t.id)}),ue=ht({mutationFn:Z=>be.updateArchive(t.id,{project_id:Z}),onSuccess:()=>{l.invalidateQueries({queryKey:["archives"]}),l.invalidateQueries({queryKey:["projects"]}),c("Project updated")},onError:()=>{c("Failed to update project","error")}}),Le=Z=>{Z.preventDefault(),K({x:Z.clientX,y:Z.clientY})},$=[...Ih(t.filename)?[{label:"Print",icon:s.jsx(Qr,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:"Schedule",icon:s.jsx(qr,{className:"w-4 h-4"}),onClick:()=>x(!0)},{label:"Open in Bambu Studio",icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const Z=t.print_name||t.filename||"model",B=`${window.location.origin}${be.getArchiveForSlicer(t.id,Z)}`;kc(B)}}]:[{label:"Slice",icon:s.jsx(Kr,{className:"w-4 h-4"}),onClick:()=>{const Z=t.print_name||t.filename||"model",B=`${window.location.origin}${be.getArchiveForSlicer(t.id,Z)}`;kc(B)}}],{label:"View on MakerWorld",icon:s.jsx(pf,{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:s.jsx(ks,{className:"w-4 h-4"}),onClick:()=>E(!0)},{label:"View Timelapse",icon:s.jsx(_d,{className:"w-4 h-4"}),onClick:()=>A(!0),disabled:!t.timelapse_path},{label:"Scan for Timelapse",icon:s.jsx(dW,{className:"w-4 h-4"}),onClick:()=>pe.mutate(),disabled:!t.printer_id||!!t.timelapse_path||pe.isPending},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?"Download Source 3MF":"Upload Source 3MF",icon:s.jsx(nw,{className:"w-4 h-4"}),onClick:()=>{if(t.source_3mf_path){const Z=document.createElement("a");Z.href=be.getSource3mfDownloadUrl(t.id),Z.download=`${t.print_name||t.filename}_source.3mf`,Z.click()}else F.current?.click()}},...t.source_3mf_path?[{label:"Replace Source 3MF",icon:s.jsx(xi,{className:"w-4 h-4"}),onClick:()=>F.current?.click()},{label:"Remove Source 3MF",icon:s.jsx(ln,{className:"w-4 h-4"}),onClick:()=>J(!0),danger:!0}]:[],{label:t.f3d_path?"Replace F3D":"Upload F3D",icon:s.jsx(ks,{className:"w-4 h-4"}),onClick:()=>q.current?.click()},...t.f3d_path?[{label:"Download F3D",icon:s.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const Z=document.createElement("a");Z.href=be.getF3dDownloadUrl(t.id),Z.download=`${t.print_name||t.filename}.f3d`,Z.click()}},{label:"Remove F3D",icon:s.jsx(ln,{className:"w-4 h-4"}),onClick:()=>W(!0),danger:!0}]:[],{label:"",divider:!0,onClick:()=>{}},{label:"Download",icon:s.jsx(Yr,{className:"w-4 h-4"}),onClick:()=>{const Z=document.createElement("a");Z.href=be.getArchiveDownload(t.id),Z.download=`${t.print_name||t.filename}.3mf`,Z.click()}},{label:"Copy Download Link",icon:s.jsx($s,{className:"w-4 h-4"}),onClick:()=>{const Z=`${window.location.origin}${be.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(Z).then(()=>{c("Link copied to clipboard")}).catch(()=>{c("Failed to copy link","error")})}},{label:"QR Code",icon:s.jsx(uW,{className:"w-4 h-4"}),onClick:()=>P(!0)},{label:`View Photos${t.photos?.length?` (${t.photos.length})`:""}`,icon:s.jsx(zp,{className:"w-4 h-4"}),onClick:()=>L(!0),disabled:!t.photos?.length},{label:"Project Page",icon:s.jsx(Ua,{className:"w-4 h-4"}),onClick:()=>R(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?"Remove from Favorites":"Add to Favorites",icon:s.jsx(xf,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>ae.mutate()},{label:"Edit",icon:s.jsx(Jo,{className:"w-4 h-4"}),onClick:()=>d(!0)},...t.project_id&&t.project_name?[{label:`Go to Project: ${t.project_name}`,icon:s.jsx(ma,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:"Add to Project",icon:s.jsx(ma,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const Z=[];if(t.project_id&&Z.push({label:"Remove from Project",icon:s.jsx(zt,{className:"w-4 h-4"}),onClick:()=>ue.mutate(null)}),!a)Z.push({label:"Loading...",icon:s.jsx(ft,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const B=a.filter(U=>U.status==="active");B.length===0?Z.push({label:"No projects available",icon:s.jsx(ma,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):B.forEach(U=>{Z.push({label:U.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:U.color||"#888"}}),onClick:()=>ue.mutate(U.id),disabled:t.project_id===U.id})})}return Z})()},{label:n?"Deselect":"Select",icon:n?s.jsx(Qc,{className:"w-4 h-4"}):s.jsx(Zc,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:"Delete",icon:s.jsx(ln,{className:"w-4 h-4"}),onClick:()=>p(!0),danger:!0}];return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-archive-id":t.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?"bg-bambu-green/10":""}`,style:o?{outline:"4px solid #facc15",outlineOffset:"-4px"}:void 0,onContextMenu:Le,children:[s.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&s.jsx("button",{onClick:()=>r(t.id),children:n?s.jsx(Qc,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Zc,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:be.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:s.jsx(z0,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),s.jsxs("div",{className:"col-span-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&s.jsx("span",{title:"Has timelapse",children:s.jsx(_d,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),ge&&ge.length>0&&s.jsx(Ts,{to:`/files?folder=${ge[0].id}`,className:"flex-shrink-0",title:`Open folder: ${ge[0].name}`,onClick:Z=>Z.stopPropagation(),children:s.jsx(Zo,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((Z,B)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:Z},title:Z},B))})]})]}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray",children:Hp(t.created_at)}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:s2(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>{const Z=t.print_name||t.filename||"model",B=`${window.location.origin}${be.getArchiveForSlicer(t.id,Z)}`;kc(B)},title:"Open in Bambu Studio",children:s.jsx(Kr,{className:"w-4 h-4"})}),t.makerworld_url&&s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>window.open(t.makerworld_url,"_blank"),title:"MakerWorld",children:s.jsx(pf,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>{const Z=document.createElement("a");Z.href=be.getArchiveDownload(t.id),Z.download=`${t.print_name||t.filename}.3mf`,Z.click()},title:"Download",children:s.jsx(Yr,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>d(!0),title:"Edit",children:s.jsx(Jo,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>p(!0),title:"Delete",children:s.jsx(ln,{className:"w-4 h-4 text-red-400"})}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:Z=>{const B=Z.currentTarget.getBoundingClientRect();K({x:B.left,y:B.bottom+4})},title:"More options",children:s.jsx(vd,{className:"w-4 h-4"})})]})]}),u&&s.jsx(sJ,{archive:t,onClose:()=>d(!1)}),y&&s.jsx(iJ,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>E(!1)}),g&&s.jsx(aJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1),onSuccess:()=>{}}),f&&s.jsx(Un,{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:()=>{oe.mutate(),p(!1)},onCancel:()=>p(!1)}),Y&&s.jsx(Un,{title:"Remove Source 3MF",message:`Are you sure you want to remove the source 3MF file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{re.mutate(),J(!1)},onCancel:()=>J(!1)}),G&&s.jsx(Un,{title:"Remove F3D",message:`Are you sure you want to remove the Fusion 360 design file from "${t.print_name||t.filename}"?`,confirmText:"Remove",variant:"danger",onConfirm:()=>{de.mutate(),W(!1)},onCancel:()=>W(!1)}),ee&&s.jsx(oJ,{x:ee.x,y:ee.y,items:$,onClose:()=>K(null)}),w&&t.timelapse_path&&s.jsx(Wte,{src:be.getArchiveTimelapse(t.id),title:`${t.print_name||t.filename} - Timelapse`,downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>A(!1),onEdit:()=>{l.invalidateQueries({queryKey:["archives"]}),A(!1)}}),N&&T.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{C(!1),D([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:T.map(Z=>s.jsxs("button",{onClick:()=>Ce.mutate(Z.name),disabled:Ce.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:Z.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:s2(Z.size)}),Z.mtime&&s.jsx("span",{children:Hp(Z.mtime)})]})]},Z.name))})]})}),k&&s.jsx(lJ,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>P(!1)}),z&&t.photos&&s.jsx(cJ,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>L(!1),onDelete:async Z=>{try{await be.deleteArchivePhoto(t.id,Z),l.invalidateQueries({queryKey:["archives"]}),c("Photo deleted")}catch{c("Failed to delete photo","error")}}}),X&&s.jsx(Gte,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>R(!1)}),v&&s.jsx(eL,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>x(!1)}),s.jsx("input",{ref:F,type:"file",accept:".3mf",className:"hidden",onChange:Z=>{const B=Z.target.files?.[0];B&&ne.mutate(B),Z.target.value=""}}),s.jsx("input",{ref:q,type:"file",accept:".f3d",className:"hidden",onChange:Z=>{const B=Z.target.files?.[0];B&&se.mutate(B),Z.target.value=""}})]})}const L9e=[{id:"all",label:"All Archives",icon:s.jsx(Zo,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(tr,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(qr,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(qr,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(xf,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx(pa,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx($s,{className:"w-4 h-4"})}];function I9e(){const t=an(),{showToast:e}=Wn(),n=S.useRef(null),[r,i]=S.useState(""),[a,o]=S.useState(()=>{const ie=localStorage.getItem("archiveFilterPrinter");return ie?Number(ie):null}),[l,c]=S.useState(()=>localStorage.getItem("archiveFilterMaterial")),[u,d]=S.useState(()=>{const ie=localStorage.getItem("archiveFilterColors");return ie?new Set(JSON.parse(ie)):new Set}),[f,p]=S.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[g,b]=S.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[v,x]=S.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[y,E]=S.useState(()=>localStorage.getItem("archiveFilterTag")),[w,A]=S.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[N,C]=S.useState(!1),[T,D]=S.useState([]),[k,P]=S.useState(!1),[z,L]=S.useState(new Set),[X,R]=S.useState(!1),[Y,J]=S.useState(!1),[G,W]=S.useState(!1),[ee,K]=S.useState(!1),[F,q]=S.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[ne,re]=S.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[se,de]=S.useState(()=>localStorage.getItem("archiveCollection")||"all"),[pe,Ce]=S.useState(!1),[oe,ae]=S.useState(!1),[ge,ue]=S.useState(!1),[Le,V]=S.useState(null);S.useEffect(()=>{if(Le){const ie=setTimeout(()=>{const ve=document.querySelector(`[data-archive-id="${Le}"]`);ve&&ve.scrollIntoView({behavior:"smooth",block:"center"})},100),He=setTimeout(()=>V(null),5e3);return()=>{clearTimeout(ie),clearTimeout(He)}}},[Le]);const{data:$,isLoading:Z}=lt({queryKey:["archives",a],queryFn:()=>be.getArchives(a||void 0)}),{data:B}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:U}=lt({queryKey:["projects"],queryFn:()=>be.getProjects()}),{data:Q}=lt({queryKey:["settings"],queryFn:be.getSettings}),Me=Q?.time_format||"system",Te=ht({mutationFn:async ie=>(await Promise.all(ie.map(He=>be.deleteArchive(He))),ie.length),onSuccess:ie=>{t.invalidateQueries({queryKey:["archives"]}),L(new Set),e(`${ie} archive${ie!==1?"s":""} deleted`)},onError:()=>{e("Failed to delete archives","error")}});S.useEffect(()=>{a!==null?localStorage.setItem("archiveFilterPrinter",a.toString()):localStorage.removeItem("archiveFilterPrinter")},[a]),S.useEffect(()=>{l?localStorage.setItem("archiveFilterMaterial",l):localStorage.removeItem("archiveFilterMaterial")},[l]),S.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...u]))},[u]),S.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",f)},[f]),S.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",g.toString())},[g]),S.useEffect(()=>{localStorage.setItem("archiveHideFailed",v.toString())},[v]),S.useEffect(()=>{y?localStorage.setItem("archiveFilterTag",y):localStorage.removeItem("archiveFilterTag")},[y]),S.useEffect(()=>{localStorage.setItem("archiveFilterFileType",w)},[w]),S.useEffect(()=>{localStorage.setItem("archiveViewMode",F)},[F]),S.useEffect(()=>{localStorage.setItem("archiveSortBy",ne)},[ne]),S.useEffect(()=>{localStorage.setItem("archiveCollection",se)},[se]);const fe=new Map(B?.map(ie=>[ie.id,ie.name])||[]),H=[...new Set($?.flatMap(ie=>ie.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),I=[...new Set($?.flatMap(ie=>ie.filament_color?.split(",")||[]).filter(Boolean)||[])],ce=[...new Set($?.flatMap(ie=>ie.tags?.split(",").map(He=>He.trim())||[]).filter(Boolean)||[])].sort(),we=$?.filter(ie=>{const He=new Date,ve=fi(ie.created_at)||new Date(0);let Be=!0;switch(se){case"recent":Be=He.getTime()-ve.getTime()<1440*60*1e3;break;case"this-week":Be=He.getTime()-ve.getTime()<10080*60*1e3;break;case"this-month":Be=ve.getMonth()===He.getMonth()&&ve.getFullYear()===He.getFullYear();break;case"favorites":Be=ie.is_favorite===!0;break;case"failed":Be=ie.status==="failed"||ie.status==="aborted";break;case"duplicates":Be=ie.duplicate_count>0;break}const je=(ie.print_name||ie.filename).toLowerCase().includes(r.toLowerCase()),Ne=!l||ie.filament_type?.split(", ").includes(l),Xe=ie.filament_color?.split(",")||[],mt=u.size===0||(f==="or"?Xe.some(Cn=>u.has(Cn)):[...u].every(Cn=>Xe.includes(Cn))),At=se==="favorites"||!g||ie.is_favorite,Rt=se==="failed"||!v||ie.status!=="failed"&&ie.status!=="aborted",Xt=ie.tags?.split(",").map(Cn=>Cn.trim())||[],Lt=!y||Xt.includes(y),Sn=Ih(ie.filename);return Be&&je&&Ne&&mt&&At&&Rt&&Lt&&(w==="all"||w==="gcode"&&Sn||w==="source"&&!Sn)}).sort((ie,He)=>{switch(ne){case"date-desc":return(fi(He.created_at)?.getTime()||0)-(fi(ie.created_at)?.getTime()||0);case"date-asc":return(fi(ie.created_at)?.getTime()||0)-(fi(He.created_at)?.getTime()||0);case"name-asc":return(ie.print_name||ie.filename).localeCompare(He.print_name||He.filename);case"name-desc":return(He.print_name||He.filename).localeCompare(ie.print_name||ie.filename);case"size-desc":return He.file_size-ie.file_size;case"size-asc":return ie.file_size-He.file_size;default:return 0}}),Se=X||z.size>0,_e=ie=>{L(He=>{const ve=new Set(He);return ve.has(ie)?ve.delete(ie):ve.add(ie),ve})},st=()=>{we&&L(new Set(we.map(ie=>ie.id)))},Ve=()=>{L(new Set),R(!1)},it=ie=>{d(He=>{const ve=new Set(He);return ve.has(ie)?ve.delete(ie):ve.add(ie),ve})},ct=()=>{d(new Set)},Fe=()=>{i(""),o(null),c(null),b(!1),x(!1),E(null),A("all")},me=r||a||l||g||v||y||w!=="all",Ke=S.useCallback(ie=>{ie.preventDefault(),ie.dataTransfer.types.includes("Files")&&P(!0)},[]),qe=S.useCallback(ie=>{ie.preventDefault(),ie.currentTarget===ie.target&&P(!1)},[]),Qe=S.useCallback(ie=>{ie.preventDefault(),P(!1);const He=Array.from(ie.dataTransfer.files).filter(ve=>ve.name.endsWith(".3mf"));He.length>0?(D(He),C(!0)):ie.dataTransfer.files.length>0&&e("Only .3mf files are supported","warning")},[e]),ut=S.useCallback(ie=>{const He=ie.target;if(He.tagName==="INPUT"||He.tagName==="TEXTAREA"||He.isContentEditable){ie.key==="Escape"&&He.blur();return}switch(ie.key){case"/":ie.preventDefault(),n.current?.focus();break;case"u":case"U":!ie.metaKey&&!ie.ctrlKey&&(ie.preventDefault(),C(!0));break;case"Escape":Se&&Ve();break}},[Se]);return S.useEffect(()=>(document.addEventListener("keydown",ut),()=>document.removeEventListener("keydown",ut)),[ut]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:Ke,onDragLeave:qe,onDrop:Qe,children:[k&&s.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:s.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[s.jsx(xi,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:"Release to upload"})]})}),Se&&s.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:[s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:Ve,children:[s.jsx(zt,{className:"w-4 h-4"}),"Close"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("span",{className:"text-white font-medium",children:[z.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:st,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>W(!0),children:[s.jsx($p,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>K(!0),children:[s.jsx(ma,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>{const ie=Array.from(z);Promise.all(ie.map(He=>be.toggleFavorite(He))).then(()=>{t.invalidateQueries({queryKey:["archives"]}),e(`Toggled favorites for ${ie.length} archive${ie.length!==1?"s":""}`)}).catch(()=>{e("Failed to update favorites","error")})},children:[s.jsx(xf,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Ee,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>J(!0),children:[s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.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:se,onChange:ie=>de(ie.target.value),children:L9e.map(ie=>s.jsx("option",{value:ie.id,children:ie.label},ie.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[we?.length||0," of ",$?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Ee,{variant:"secondary",onClick:()=>Ce(!pe),disabled:oe,children:[oe?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(rw,{className:"w-4 h-4"}),"Export"]}),pe&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{Ce(!1),ae(!0);try{const{blob:ie,filename:He}=await be.exportArchives({format:"csv",printerId:a||void 0,status:se==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(ie),Be=document.createElement("a");Be.href=ve,Be.download=He,Be.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[s.jsx(Ua,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{Ce(!1),ae(!0);try{const{blob:ie,filename:He}=await be.exportArchives({format:"xlsx",printerId:a||void 0,status:se==="failed"?"failed":void 0,search:r||void 0}),ve=URL.createObjectURL(ie),Be=document.createElement("a");Be.href=ve,Be.download=He,Be.click(),URL.revokeObjectURL(ve),e("Export downloaded")}catch{e("Export failed","error")}finally{ae(!1)}},children:[s.jsx(rw,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),z.size>=2&&z.size<=5&&s.jsxs(Ee,{variant:"secondary",onClick:()=>ue(!0),children:[s.jsx(Ep,{className:"w-4 h-4"}),"Compare (",z.size,")"]}),!Se&&s.jsxs(Ee,{variant:"secondary",onClick:()=>R(!0),children:[s.jsx(Qc,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Ee,{onClick:()=>C(!0),children:[s.jsx(xi,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(_t,{className:"mb-6",children:s.jsxs(Mt,{className:"py-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[s.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[s.jsx(Eo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:n,type:"text",placeholder:"Search archives...",className:"w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:r,onChange:ie=>i(ie.target.value)})]}),s.jsxs("div",{className:"flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(y2,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:ie=>o(ie.target.value?Number(ie.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),B?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(Cl,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:l||"",onChange:ie=>c(ie.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),H.map(ie=>s.jsx("option",{value:ie,children:ie},ie))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(nw,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:w,onChange:ie=>A(ie.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>b(!g),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${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:[s.jsx(xf,{className:`w-4 h-4 ${g?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>x(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:v?"Show failed prints":"Hide failed prints",children:[s.jsx(pa,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),ce.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx($p,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:y||"",onChange:ie=>E(ie.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),ce.map(ie=>s.jsx("option",{value:ie,children:ie},ie))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(gle,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:ne,onChange:ie=>re(ie.target.value),children:[s.jsx("option",{value:"date-desc",children:"Newest first"}),s.jsx("option",{value:"date-asc",children:"Oldest first"}),s.jsx("option",{value:"name-asc",children:"Name A-Z"}),s.jsx("option",{value:"name-desc",children:"Name Z-A"}),s.jsx("option",{value:"size-desc",children:"Largest first"}),s.jsx("option",{value:"size-asc",children:"Smallest first"})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${F==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>q("grid"),title:"Grid view",children:s.jsx(S2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${F==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>q("list"),title:"List view",children:s.jsx(M2,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${F==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>q("calendar"),title:"Calendar view",children:s.jsx(Rle,{className:"w-4 h-4"})})]})]}),me&&s.jsxs(Ee,{variant:"ghost",size:"sm",onClick:Fe,className:"text-bambu-gray hover:text-white",children:[s.jsx(zt,{className:"w-4 h-4"}),"Reset"]})]}),I.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),u.size>1&&s.jsx("button",{onClick:()=>p(ie=>ie==="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()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:I.map(ie=>s.jsx("button",{onClick:()=>it(ie),className:`w-6 h-6 rounded-full border-2 transition-all ${u.has(ie)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ie},title:ie},ie))}),u.size>0&&s.jsxs("button",{onClick:ct,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(zt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(R9e,{}),Z?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading archives..."}):we?.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray",children:r?"No archives match your search":"No archives yet"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):F==="calendar"?s.jsx(_t,{className:"p-6",children:s.jsx(uBe,{archives:we||[],onArchiveClick:ie=>{i(""),q("grid"),V(ie.id)},highlightedArchiveId:Le})}):F==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:we?.map(ie=>s.jsx(D9e,{archive:ie,printerName:ie.printer_id?fe.get(ie.printer_id)||"Unknown":"No Printer",isSelected:z.has(ie.id),onSelect:_e,selectionMode:Se,projects:U,isHighlighted:ie.id===Le,timeFormat:Me},ie.id))}):F==="list"?s.jsx(_t,{children:s.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"col-span-1"}),s.jsx("div",{className:"col-span-4",children:"Name"}),s.jsx("div",{className:"col-span-2",children:"Printer"}),s.jsx("div",{className:"col-span-2",children:"Date"}),s.jsx("div",{className:"col-span-1",children:"Size"}),s.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),we?.map(ie=>s.jsx(O9e,{archive:ie,printerName:ie.printer_id?fe.get(ie.printer_id)||"Unknown":"No Printer",isSelected:z.has(ie.id),onSelect:_e,selectionMode:Se,projects:U,isHighlighted:ie.id===Le},ie.id))]})}):null,N&&s.jsx(tBe,{onClose:()=>{C(!1),D([])},initialFiles:T}),Y&&s.jsx(Un,{title:"Delete Archives",message:`Are you sure you want to delete ${z.size} archive${z.size>1?"s":""}? This action cannot be undone.`,confirmText:`Delete ${z.size}`,variant:"danger",onConfirm:()=>{Te.mutate(Array.from(z)),J(!1)},onCancel:()=>J(!1)}),G&&s.jsx(iBe,{selectedIds:Array.from(z),existingTags:ce,onClose:()=>W(!1)}),ee&&s.jsx(aBe,{selectedIds:Array.from(z),onClose:()=>K(!1)}),ge&&z.size>=2&&z.size<=5&&s.jsx(T9e,{archiveIds:Array.from(z),onClose:()=>{ue(!1),L(new Set),R(!1)}})]})}function F9e(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return S.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const WM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function zg(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function tL(t){return"nodeType"in t}function ps(t){var e,n;return t?zg(t)?t:tL(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function nL(t){const{Document:e}=ps(t);return t instanceof e}function Ny(t){return zg(t)?!1:t instanceof ps(t).HTMLElement}function qte(t){return t instanceof ps(t).SVGElement}function Bg(t){return t?zg(t)?t.document:tL(t)?nL(t)?t:Ny(t)||qte(t)?t.ownerDocument:document:document:document}const Fl=WM?S.useLayoutEffect:S.useEffect;function rL(t){const e=S.useRef(t);return Fl(()=>{e.current=t}),S.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function U9e(){const t=S.useRef(null),e=S.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=S.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function R0(t,e){e===void 0&&(e=[t]);const n=S.useRef(t);return Fl(()=>{n.current!==t&&(n.current=t)},e),n}function Ay(t,e){const n=S.useRef();return S.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function o2(t){const e=rL(t),n=S.useRef(null),r=S.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function hR(t){const e=S.useRef();return S.useEffect(()=>{e.current=t},[t]),e.current}let Yk={};function Ty(t,e){return S.useMemo(()=>{if(e)return e;const n=Yk[t]==null?0:Yk[t]+1;return Yk[t]=n,t+"-"+n},[t,e])}function Kte(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const Fp=Kte(1),D0=Kte(-1);function z9e(t){return"clientX"in t&&"clientY"in t}function iL(t){if(!t)return!1;const{KeyboardEvent:e}=ps(t.target);return e&&t instanceof e}function B9e(t){if(!t)return!1;const{TouchEvent:e}=ps(t.target);return e&&t instanceof e}function fR(t){if(B9e(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 z9e(t)?{x:t.clientX,y:t.clientY}:null}const pg=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[pg.Translate.toString(t),pg.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),tG="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function $9e(t){return t.matches(tG)?t:t.querySelector(tG)}const H9e={display:"none"};function V9e(t){let{id:e,value:n}=t;return Cr.createElement("div",{id:e,style:H9e},n)}function G9e(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const i={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 Cr.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function W9e(){const[t,e]=S.useState("");return{announce:S.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const Xte=S.createContext(null);function q9e(t){const e=S.useContext(Xte);S.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function K9e(){const[t]=S.useState(()=>new Set),e=S.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[S.useCallback(r=>{let{type:i,event:a}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const X9e={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.
- `},Y9e={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 Q9e(t){let{announcements:e=Y9e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=X9e}=t;const{announce:a,announcement:o}=W9e(),l=Ty("DndLiveRegion"),[c,u]=S.useState(!1);if(S.useEffect(()=>{u(!0)},[]),q9e(S.useMemo(()=>({onDragStart(f){let{active:p}=f;a(e.onDragStart({active:p}))},onDragMove(f){let{active:p,over:g}=f;e.onDragMove&&a(e.onDragMove({active:p,over:g}))},onDragOver(f){let{active:p,over:g}=f;a(e.onDragOver({active:p,over:g}))},onDragEnd(f){let{active:p,over:g}=f;a(e.onDragEnd({active:p,over:g}))},onDragCancel(f){let{active:p,over:g}=f;a(e.onDragCancel({active:p,over:g}))}}),[a,e])),!c)return null;const d=Cr.createElement(Cr.Fragment,null,Cr.createElement(V9e,{id:r,value:i.draggable}),Cr.createElement(G9e,{id:l,announcement:o}));return n?Pc.createPortal(d,n):d}var Ei;(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"})(Ei||(Ei={}));function l2(){}function c2(t,e){return S.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function Yte(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return S.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const tl=Object.freeze({x:0,y:0});function Qte(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Zte(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function Z9e(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function nG(t){let{left:e,top:n,height:r,width:i}=t;return[{x:e,y:n},{x:e+i,y:n},{x:e,y:n+r},{x:e+i,y:n+r}]}function Jte(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function rG(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 ene=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=rG(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=Qte(rG(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(Zte)},J9e=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=nG(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=nG(c),d=i.reduce((p,g,b)=>p+Qte(u[b],g),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(Zte)};function eGe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=o*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const tGe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=eGe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(Z9e)};function nGe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function tne(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:tl}function rGe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((o,l)=>({...o,top:o.top+t*l.y,bottom:o.bottom+t*l.y,left:o.left+t*l.x,right:o.right+t*l.x}),{...n})}}const iGe=rGe(1);function aGe(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 sGe(t,e,n){const r=aGe(e);if(!r)return t;const{scaleX:i,scaleY:a,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const oGe={ignoreTransform:!1};function $g(t,e){e===void 0&&(e=oGe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=ps(t).getComputedStyle(t);u&&(n=sGe(n,u,d))}const{top:r,left:i,width:a,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:l,right:c}}function iG(t){return $g(t,{ignoreTransform:!0})}function lGe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function cGe(t,e){return e===void 0&&(e=ps(t).getComputedStyle(t)),e.position==="fixed"}function uGe(t,e){e===void 0&&(e=ps(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function qM(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(nL(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Ny(i)||qte(i)||n.includes(i))return n;const a=ps(t).getComputedStyle(i);return i!==t&&uGe(i,a)&&n.push(i),cGe(i,a)?n:r(i.parentNode)}return t?r(t):n}function nne(t){const[e]=qM(t,1);return e??null}function Qk(t){return!WM||!t?null:zg(t)?t:tL(t)?nL(t)||t===Bg(t).scrollingElement?window:Ny(t)?t:null:null}function rne(t){return zg(t)?t.scrollX:t.scrollLeft}function ine(t){return zg(t)?t.scrollY:t.scrollTop}function mR(t){return{x:rne(t),y:ine(t)}}var Gi;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Gi||(Gi={}));function ane(t){return!WM||!t?!1:t===document.scrollingElement}function sne(t){const e={x:0,y:0},n=ane(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const dGe={x:.2,y:.2};function hGe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=dGe);const{isTop:u,isBottom:d,isLeft:f,isRight:p}=sne(t),g={x:0,y:0},b={x:0,y:0},v={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+v.height?(g.y=Gi.Backward,b.y=r*Math.abs((e.top+v.height-a)/v.height)):!d&&c>=e.bottom-v.height&&(g.y=Gi.Forward,b.y=r*Math.abs((e.bottom-v.height-c)/v.height)),!p&&l>=e.right-v.width?(g.x=Gi.Forward,b.x=r*Math.abs((e.right-v.width-l)/v.width)):!f&&o<=e.left+v.width&&(g.x=Gi.Backward,b.x=r*Math.abs((e.left+v.width-o)/v.width)),{direction:g,speed:b}}function fGe(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,height:o}}const{top:e,left:n,right:r,bottom:i}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:i,width:t.clientWidth,height:t.clientHeight}}function one(t){return t.reduce((e,n)=>Fp(e,mR(n)),tl)}function mGe(t){return t.reduce((e,n)=>e+rne(n),0)}function pGe(t){return t.reduce((e,n)=>e+ine(n),0)}function gGe(t,e){if(e===void 0&&(e=$g),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);nne(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const xGe=[["x",["left","right"],mGe],["y",["top","bottom"],pGe]];class aL{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 r=qM(n),i=one(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of xGe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ub{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var i;(i=this.target)==null||i.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function bGe(t){const{EventTarget:e}=ps(t);return t instanceof e?t:Bg(t)}function Zk(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var ho;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(ho||(ho={}));function aG(t){t.preventDefault()}function yGe(t){t.stopPropagation()}var Dn;(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"})(Dn||(Dn={}));const lne={start:[Dn.Space,Dn.Enter],cancel:[Dn.Esc],end:[Dn.Space,Dn.Enter,Dn.Tab]},vGe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Dn.Right:return{...n,x:n.x+25};case Dn.Left:return{...n,x:n.x-25};case Dn.Down:return{...n,y:n.y+25};case Dn.Up:return{...n,y:n.y-25}}};class KM{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 Ub(Bg(n)),this.windowListeners=new Ub(ps(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ho.Resize,this.handleCancel),this.windowListeners.add(ho.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ho.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&gGe(r),n(tl)}handleKeyDown(e){if(iL(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=lne,coordinateGetter:o=vGe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:tl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const p=D0(f,d),g={x:0,y:0},{scrollableAncestors:b}=r.current;for(const v of b){const x=e.code,{isTop:y,isRight:E,isLeft:w,isBottom:A,maxScroll:N,minScroll:C}=sne(v),T=fGe(v),D={x:Math.min(x===Dn.Right?T.right-T.width/2:T.right,Math.max(x===Dn.Right?T.left:T.left+T.width/2,f.x)),y:Math.min(x===Dn.Down?T.bottom-T.height/2:T.bottom,Math.max(x===Dn.Down?T.top:T.top+T.height/2,f.y))},k=x===Dn.Right&&!E||x===Dn.Left&&!w,P=x===Dn.Down&&!A||x===Dn.Up&&!y;if(k&&D.x!==f.x){const z=v.scrollLeft+p.x,L=x===Dn.Right&&z<=N.x||x===Dn.Left&&z>=C.x;if(L&&!p.y){v.scrollTo({left:z,behavior:l});return}L?g.x=v.scrollLeft-z:g.x=x===Dn.Right?v.scrollLeft-N.x:v.scrollLeft-C.x,g.x&&v.scrollBy({left:-g.x,behavior:l});break}else if(P&&D.y!==f.y){const z=v.scrollTop+p.y,L=x===Dn.Down&&z<=N.y||x===Dn.Up&&z>=C.y;if(L&&!p.x){v.scrollTo({top:z,behavior:l});return}L?g.y=v.scrollTop-z:g.y=x===Dn.Down?v.scrollTop-N.y:v.scrollTop-C.y,g.y&&v.scrollBy({top:-g.y,behavior:l});break}}this.handleMove(e,Fp(D0(f,this.referenceCoordinates),g))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(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()}}KM.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=lne,onActivation:i}=e,{active:a}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function sG(t){return!!(t&&"distance"in t)}function oG(t){return!!(t&&"delay"in t)}class sL{constructor(e,n,r){var i;r===void 0&&(r=bGe(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:o}=a;this.props=e,this.events=n,this.document=Bg(o),this.documentListeners=new Ub(this.document),this.listeners=new Ub(r),this.windowListeners=new Ub(ps(o)),this.initialCoordinates=(i=fR(a))!=null?i:tl,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:r}}}=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(ho.Resize,this.handleCancel),this.windowListeners.add(ho.DragStart,aG),this.windowListeners.add(ho.VisibilityChange,this.handleCancel),this.windowListeners.add(ho.ContextMenu,aG),this.documentListeners.add(ho.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(oG(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(sG(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:r,onPending:i}=this.props;i(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(ho.Click,yGe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ho.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=fR(e))!=null?n:tl,u=D0(i,c);if(!r&&l){if(sG(l)){if(l.tolerance!=null&&Zk(u,l.tolerance))return this.handleCancel();if(Zk(u,l.distance))return this.handleStart()}if(oG(l)&&Zk(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}e.cancelable&&e.preventDefault(),o(c)}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===Dn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const _Ge={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class XM extends sL{constructor(e){const{event:n}=e,r=Bg(n.target);super(e,_Ge,r)}}XM.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const wGe={move:{name:"mousemove"},end:{name:"mouseup"}};var pR;(function(t){t[t.RightClick=2]="RightClick"})(pR||(pR={}));class SGe extends sL{constructor(e){super(e,wGe,Bg(e.event.target))}}SGe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===pR.RightClick?!1:(r?.({event:n}),!0)}}];const Jk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class MGe extends sL{constructor(e){super(e,Jk)}static setup(){return window.addEventListener(Jk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Jk.move.name,e)};function e(){}}}MGe.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var zb;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(zb||(zb={}));var u2;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(u2||(u2={}));function EGe(t){let{acceleration:e,activator:n=zb.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=u2.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=t;const g=AGe({delta:f,disabled:!a}),[b,v]=U9e(),x=S.useRef({x:0,y:0}),y=S.useRef({x:0,y:0}),E=S.useMemo(()=>{switch(n){case zb.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case zb.DraggableRect:return i}},[n,i,c]),w=S.useRef(null),A=S.useCallback(()=>{const C=w.current;if(!C)return;const T=x.current.x*y.current.x,D=x.current.y*y.current.y;C.scrollBy(T,D)},[]),N=S.useMemo(()=>l===u2.TreeOrder?[...u].reverse():u,[l,u]);S.useEffect(()=>{if(!a||!u.length||!E){v();return}for(const C of N){if(r?.(C)===!1)continue;const T=u.indexOf(C),D=d[T];if(!D)continue;const{direction:k,speed:P}=hGe(C,D,E,e,p);for(const z of["x","y"])g[z][k[z]]||(P[z]=0,k[z]=0);if(P.x>0||P.y>0){v(),w.current=C,b(A,o),x.current=P,y.current=k;return}}x.current={x:0,y:0},y.current={x:0,y:0},v()},[e,A,r,v,a,o,JSON.stringify(E),JSON.stringify(g),b,u,N,d,JSON.stringify(p)])}const NGe={x:{[Gi.Backward]:!1,[Gi.Forward]:!1},y:{[Gi.Backward]:!1,[Gi.Forward]:!1}};function AGe(t){let{delta:e,disabled:n}=t;const r=hR(e);return Ay(i=>{if(n||!r||!i)return NGe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[Gi.Backward]:i.x[Gi.Backward]||a.x===-1,[Gi.Forward]:i.x[Gi.Forward]||a.x===1},y:{[Gi.Backward]:i.y[Gi.Backward]||a.y===-1,[Gi.Forward]:i.y[Gi.Forward]||a.y===1}}},[n,e,r])}function TGe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Ay(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function CGe(t,e){return S.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...a]},[]),[t,e])}var O0;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(O0||(O0={}));var gR;(function(t){t.Optimized="optimized"})(gR||(gR={}));const lG=new Map;function kGe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=S.useState(null),{frequency:l,measure:c,strategy:u}=i,d=S.useRef(t),f=x(),p=R0(f),g=S.useCallback(function(y){y===void 0&&(y=[]),!p.current&&o(E=>E===null?y:E.concat(y.filter(w=>!E.includes(w))))},[p]),b=S.useRef(null),v=Ay(y=>{if(f&&!n)return lG;if(!y||y===lG||d.current!==t||a!=null){const E=new Map;for(let w of t){if(!w)continue;if(a&&a.length>0&&!a.includes(w.id)&&w.rect.current){E.set(w.id,w.rect.current);continue}const A=w.node.current,N=A?new aL(c(A),A):null;w.rect.current=N,N&&E.set(w.id,N)}return E}return y},[t,a,n,f,c]);return S.useEffect(()=>{d.current=t},[t]),S.useEffect(()=>{f||g()},[n,f]),S.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),S.useEffect(()=>{f||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{g(),b.current=null},l))},[l,f,g,...r]),{droppableRects:v,measureDroppableContainers:g,measuringScheduled:a!=null};function x(){switch(u){case O0.Always:return!1;case O0.BeforeDragging:return n;default:return!n}}}function cne(t,e){return Ay(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function jGe(t,e){return cne(t,e)}function PGe(t){let{callback:e,disabled:n}=t;const r=rL(e),i=S.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return S.useEffect(()=>()=>i?.disconnect(),[i]),i}function YM(t){let{callback:e,disabled:n}=t;const r=rL(e),i=S.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return S.useEffect(()=>()=>i?.disconnect(),[i]),i}function RGe(t){return new aL($g(t),t)}function cG(t,e,n){e===void 0&&(e=RGe);const[r,i]=S.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=PGe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),l=YM({callback:a});return Fl(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function DGe(t){const e=cne(t);return tne(t,e)}const uG=[];function OGe(t){const e=S.useRef(t),n=Ay(r=>t?r&&r!==uG&&t&&e.current&&t.parentNode===e.current.parentNode?r:qM(t):uG,[t]);return S.useEffect(()=>{e.current=t},[t]),n}function LGe(t){const[e,n]=S.useState(null),r=S.useRef(t),i=S.useCallback(a=>{const o=Qk(a.target);o&&n(l=>l?(l.set(o,mR(o)),new Map(l)):null)},[]);return S.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=Qk(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,mR(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(a)};function o(l){l.forEach(c=>{const u=Qk(c);u?.removeEventListener("scroll",i)})}},[i,t]),S.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>Fp(a,o),tl):one(t):tl,[t,e])}function dG(t,e){e===void 0&&(e=[]);const n=S.useRef(null);return S.useEffect(()=>{n.current=null},e),S.useEffect(()=>{const r=t!==tl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?D0(t,n.current):tl}function IGe(t){S.useEffect(()=>{if(!WM)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n?.()}},t.map(e=>{let{sensor:n}=e;return n}))}function FGe(t,e){return S.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function une(t){return S.useMemo(()=>t?lGe(t):null,[t])}const hG=[];function UGe(t,e){e===void 0&&(e=$g);const[n]=t,r=une(n?ps(n):null),[i,a]=S.useState(hG);function o(){a(()=>t.length?t.map(c=>ane(c)?r:new aL(e(c),c)):hG)}const l=YM({callback:o});return Fl(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function zGe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Ny(e)?e:t}function BGe(t){let{measure:e}=t;const[n,r]=S.useState(null),i=S.useCallback(u=>{for(const{target:d}of u)if(Ny(d)){r(f=>{const p=e(d);return f?{...f,width:p.width,height:p.height}:p});break}},[e]),a=YM({callback:i}),o=S.useCallback(u=>{const d=zGe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=o2(o);return S.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const $Ge=[{sensor:XM,options:{}},{sensor:KM,options:{}}],HGe={current:{}},X1={draggable:{measure:iG},droppable:{measure:iG,strategy:O0.WhileDragging,frequency:gR.Optimized},dragOverlay:{measure:$g}};class Bb 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,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const VGe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Bb,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:l2},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:X1,measureDroppableContainers:l2,windowRect:null,measuringScheduled:!1},GGe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:l2,draggableNodes:new Map,over:null,measureDroppableContainers:l2},QM=S.createContext(GGe),dne=S.createContext(VGe);function WGe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Bb}}}function qGe(t,e){switch(e.type){case Ei.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Ei.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 Ei.DragEnd:case Ei.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ei.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new Bb(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Ei.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new Bb(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Ei.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new Bb(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function KGe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=S.useContext(QM),a=hR(r),o=hR(n?.id);return S.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!iL(a)||document.activeElement===a.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=$9e(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function XGe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function YGe(t){return S.useMemo(()=>({draggable:{...X1.draggable,...t?.draggable},droppable:{...X1.droppable,...t?.droppable},dragOverlay:{...X1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function QGe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=S.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Fl(()=>{if(!o&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=tne(d,r);if(o||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const p=nne(u);p&&p.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const hne=S.createContext({...tl,scaleX:1,scaleY:1});var od;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(od||(od={}));const fne=S.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=$Ge,collisionDetection:f=tGe,measuring:p,modifiers:g,...b}=e;const v=S.useReducer(qGe,void 0,WGe),[x,y]=v,[E,w]=K9e(),[A,N]=S.useState(od.Uninitialized),C=A===od.Initialized,{draggable:{active:T,nodes:D,translate:k},droppable:{containers:P}}=x,z=T!=null?D.get(T):null,L=S.useRef({initial:null,translated:null}),X=S.useMemo(()=>{var Be;return T!=null?{id:T,data:(Be=z?.data)!=null?Be:HGe,rect:L}:null},[T,z]),R=S.useRef(null),[Y,J]=S.useState(null),[G,W]=S.useState(null),ee=R0(b,Object.values(b)),K=Ty("DndDescribedBy",o),F=S.useMemo(()=>P.getEnabled(),[P]),q=YGe(p),{droppableRects:ne,measureDroppableContainers:re,measuringScheduled:se}=kGe(F,{dragging:C,dependencies:[k.x,k.y],config:q.droppable}),de=TGe(D,T),pe=S.useMemo(()=>G?fR(G):null,[G]),Ce=ve(),oe=jGe(de,q.draggable.measure);QGe({activeNode:T!=null?D.get(T):null,config:Ce.layoutShiftCompensation,initialRect:oe,measure:q.draggable.measure});const ae=cG(de,q.draggable.measure,oe),ge=cG(de?de.parentElement:null),ue=S.useRef({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Le=P.getNodeFor((n=ue.current.over)==null?void 0:n.id),V=BGe({measure:q.dragOverlay.measure}),$=(r=V.nodeRef.current)!=null?r:de,Z=C?(i=V.rect)!=null?i:ae:null,B=!!(V.nodeRef.current&&V.rect),U=DGe(B?null:ae),Q=une($?ps($):null),Me=OGe(C?Le??de:null),Te=UGe(Me),fe=XGe(g,{transform:{x:k.x-U.x,y:k.y-U.y,scaleX:1,scaleY:1},activatorEvent:G,active:X,activeNodeRect:ae,containerNodeRect:ge,draggingNodeRect:Z,over:ue.current.over,overlayNodeRect:V.rect,scrollableAncestors:Me,scrollableAncestorRects:Te,windowRect:Q}),H=pe?Fp(pe,k):null,I=LGe(Me),ce=dG(I),we=dG(I,[ae]),Se=Fp(fe,ce),_e=Z?iGe(Z,fe):null,st=X&&_e?f({active:X,collisionRect:_e,droppableRects:ne,droppableContainers:F,pointerCoordinates:H}):null,Ve=Jte(st,"id"),[it,ct]=S.useState(null),Fe=B?fe:Fp(fe,we),me=nGe(Fe,(a=it?.rect)!=null?a:null,ae),Ke=S.useRef(null),qe=S.useCallback((Be,je)=>{let{sensor:Ne,options:Xe}=je;if(R.current==null)return;const mt=D.get(R.current);if(!mt)return;const At=Be.nativeEvent,Rt=new Ne({active:R.current,activeNode:mt,event:At,options:Xe,context:ue,onAbort(Lt){if(!D.get(Lt))return;const{onDragAbort:$t}=ee.current,Cn={id:Lt};$t?.(Cn),E({type:"onDragAbort",event:Cn})},onPending(Lt,Sn,$t,Cn){if(!D.get(Lt))return;const{onDragPending:Hn}=ee.current,Jr={id:Lt,constraint:Sn,initialCoordinates:$t,offset:Cn};Hn?.(Jr),E({type:"onDragPending",event:Jr})},onStart(Lt){const Sn=R.current;if(Sn==null)return;const $t=D.get(Sn);if(!$t)return;const{onDragStart:Cn}=ee.current,nr={activatorEvent:At,active:{id:Sn,data:$t.data,rect:L}};Pc.unstable_batchedUpdates(()=>{Cn?.(nr),N(od.Initializing),y({type:Ei.DragStart,initialCoordinates:Lt,active:Sn}),E({type:"onDragStart",event:nr}),J(Ke.current),W(At)})},onMove(Lt){y({type:Ei.DragMove,coordinates:Lt})},onEnd:Xt(Ei.DragEnd),onCancel:Xt(Ei.DragCancel)});Ke.current=Rt;function Xt(Lt){return async function(){const{active:$t,collisions:Cn,over:nr,scrollAdjustedTranslate:Hn}=ue.current;let Jr=null;if($t&&Hn){const{cancelDrop:qn}=ee.current;Jr={activatorEvent:At,active:$t,collisions:Cn,delta:Hn,over:nr},Lt===Ei.DragEnd&&typeof qn=="function"&&await Promise.resolve(qn(Jr))&&(Lt=Ei.DragCancel)}R.current=null,Pc.unstable_batchedUpdates(()=>{y({type:Lt}),N(od.Uninitialized),ct(null),J(null),W(null),Ke.current=null;const qn=Lt===Ei.DragEnd?"onDragEnd":"onDragCancel";if(Jr){const yt=ee.current[qn];yt?.(Jr),E({type:qn,event:Jr})}})}}},[D]),Qe=S.useCallback((Be,je)=>(Ne,Xe)=>{const mt=Ne.nativeEvent,At=D.get(Xe);if(R.current!==null||!At||mt.dndKit||mt.defaultPrevented)return;const Rt={active:At};Be(Ne,je.options,Rt)===!0&&(mt.dndKit={capturedBy:je.sensor},R.current=Xe,qe(Ne,je))},[D,qe]),ut=CGe(d,Qe);IGe(d),Fl(()=>{ae&&A===od.Initializing&&N(od.Initialized)},[ae,A]),S.useEffect(()=>{const{onDragMove:Be}=ee.current,{active:je,activatorEvent:Ne,collisions:Xe,over:mt}=ue.current;if(!je||!Ne)return;const At={active:je,activatorEvent:Ne,collisions:Xe,delta:{x:Se.x,y:Se.y},over:mt};Pc.unstable_batchedUpdates(()=>{Be?.(At),E({type:"onDragMove",event:At})})},[Se.x,Se.y]),S.useEffect(()=>{const{active:Be,activatorEvent:je,collisions:Ne,droppableContainers:Xe,scrollAdjustedTranslate:mt}=ue.current;if(!Be||R.current==null||!je||!mt)return;const{onDragOver:At}=ee.current,Rt=Xe.get(Ve),Xt=Rt&&Rt.rect.current?{id:Rt.id,rect:Rt.rect.current,data:Rt.data,disabled:Rt.disabled}:null,Lt={active:Be,activatorEvent:je,collisions:Ne,delta:{x:mt.x,y:mt.y},over:Xt};Pc.unstable_batchedUpdates(()=>{ct(Xt),At?.(Lt),E({type:"onDragOver",event:Lt})})},[Ve]),Fl(()=>{ue.current={activatorEvent:G,active:X,activeNode:de,collisionRect:_e,collisions:st,droppableRects:ne,draggableNodes:D,draggingNode:$,draggingNodeRect:Z,droppableContainers:P,over:it,scrollableAncestors:Me,scrollAdjustedTranslate:Se},L.current={initial:Z,translated:_e}},[X,de,st,_e,D,$,Z,ne,P,it,Me,Se]),EGe({...Ce,delta:k,draggingRect:_e,pointerCoordinates:H,scrollableAncestors:Me,scrollableAncestorRects:Te});const ie=S.useMemo(()=>({active:X,activeNode:de,activeNodeRect:ae,activatorEvent:G,collisions:st,containerNodeRect:ge,dragOverlay:V,draggableNodes:D,droppableContainers:P,droppableRects:ne,over:it,measureDroppableContainers:re,scrollableAncestors:Me,scrollableAncestorRects:Te,measuringConfiguration:q,measuringScheduled:se,windowRect:Q}),[X,de,ae,G,st,ge,V,D,P,ne,it,re,Me,Te,q,se,Q]),He=S.useMemo(()=>({activatorEvent:G,activators:ut,active:X,activeNodeRect:ae,ariaDescribedById:{draggable:K},dispatch:y,draggableNodes:D,over:it,measureDroppableContainers:re}),[G,ut,X,ae,y,K,D,it,re]);return Cr.createElement(Xte.Provider,{value:w},Cr.createElement(QM.Provider,{value:He},Cr.createElement(dne.Provider,{value:ie},Cr.createElement(hne.Provider,{value:me},u)),Cr.createElement(KGe,{disabled:l?.restoreFocus===!1})),Cr.createElement(Q9e,{...l,hiddenTextDescribedById:K}));function ve(){const Be=Y?.autoScrollEnabled===!1,je=typeof c=="object"?c.enabled===!1:c===!1,Ne=C&&!Be&&!je;return typeof c=="object"?{...c,enabled:Ne}:{enabled:Ne}}}),ZGe=S.createContext(null),fG="button",JGe="Draggable";function eWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Ty(JGe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=S.useContext(QM),{role:g=fG,roleDescription:b="draggable",tabIndex:v=0}=i??{},x=c?.id===e,y=S.useContext(x?hne:ZGe),[E,w]=o2(),[A,N]=o2(),C=FGe(o,e),T=R0(n);Fl(()=>(f.set(e,{id:e,key:a,node:E,activatorNode:A,data:T}),()=>{const k=f.get(e);k&&k.key===a&&f.delete(e)}),[f,e]);const D=S.useMemo(()=>({role:g,tabIndex:v,"aria-disabled":r,"aria-pressed":x&&g===fG?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,g,v,x,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:D,isDragging:x,listeners:r?void 0:C,node:E,over:p,setNodeRef:w,setActivatorNodeRef:N,transform:y}}function tWe(){return S.useContext(dne)}const nWe="Droppable",rWe={timeout:25};function iWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Ty(nWe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=S.useContext(QM),d=S.useRef({disabled:n}),f=S.useRef(!1),p=S.useRef(null),g=S.useRef(null),{disabled:b,updateMeasurementsFor:v,timeout:x}={...rWe,...i},y=R0(v??r),E=S.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),g.current=null},x)},[x]),w=YM({callback:E,disabled:b||!o}),A=S.useCallback((D,k)=>{w&&(k&&(w.unobserve(k),f.current=!1),D&&w.observe(D))},[w]),[N,C]=o2(A),T=R0(e);return S.useEffect(()=>{!w||!N.current||(w.disconnect(),f.current=!1,w.observe(N.current))},[N,w]),S.useEffect(()=>(l({type:Ei.RegisterDroppable,element:{id:r,key:a,disabled:n,node:N,rect:p,data:T}}),()=>l({type:Ei.UnregisterDroppable,key:a,id:r})),[r]),S.useEffect(()=>{n!==d.current.disabled&&(l({type:Ei.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:p,isOver:c?.id===r,node:N,over:c,setNodeRef:C}}function ZM(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function aWe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function b1(t){return t!==null&&t>=0}function sWe(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 oWe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const oL=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=ZM(e,r,n),o=e[i],l=a[i];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},y1={scaleX:1,scaleY:1},lWe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:o}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...y1}:null}const c=cWe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...y1}:i<n&&i>=o?{x:0,y:l.height+c,...y1}:{x:0,y:0,...y1}};function cWe(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const mne="Sortable",pne=Cr.createContext({activeIndex:-1,containerId:mne,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:oL,disabled:{draggable:!1,droppable:!1}});function gne(t){let{children:e,id:n,items:r,strategy:i=oL,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=tWe(),f=Ty(mne,n),p=l.rect!==null,g=S.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),b=o!=null,v=o?g.indexOf(o.id):-1,x=u?g.indexOf(u.id):-1,y=S.useRef(g),E=!sWe(g,y.current),w=x!==-1&&v===-1||E,A=oWe(a);Fl(()=>{E&&b&&d(g)},[E,g,b,d]),S.useEffect(()=>{y.current=g},[g]);const N=S.useMemo(()=>({activeIndex:v,containerId:f,disabled:A,disableTransforms:w,items:g,overIndex:x,useDragOverlay:p,sortedRects:aWe(g,c),strategy:i}),[v,f,A.draggable,A.droppable,w,g,x,c,p,i]);return Cr.createElement(pne.Provider,{value:N},e)}const uWe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return ZM(n,r,i).indexOf(e)},dWe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===o?!1:n?!0:o!==i&&e===c},hWe={duration:200,easing:"ease"},xne="transform",fWe=pg.Transition.toString({property:xne,duration:0,easing:"linear"}),mWe={roleDescription:"sortable"};function pWe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=S.useState(null),l=S.useRef(n);return Fl(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=$g(r.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}n!==l.current&&(l.current=n)},[e,n,r,i]),S.useEffect(()=>{a&&o(null)},[a]),a}function bne(t){let{animateLayoutChanges:e=dWe,attributes:n,disabled:r,data:i,getNewIndex:a=uWe,id:o,strategy:l,resizeObserverConfig:c,transition:u=hWe}=t;const{items:d,containerId:f,activeIndex:p,disabled:g,disableTransforms:b,sortedRects:v,overIndex:x,useDragOverlay:y,strategy:E}=S.useContext(pne),w=gWe(r,g),A=d.indexOf(o),N=S.useMemo(()=>({sortable:{containerId:f,index:A,items:d},...i}),[f,i,A,d]),C=S.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:T,node:D,isOver:k,setNodeRef:P}=iWe({id:o,data:N,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:z,activatorEvent:L,activeNodeRect:X,attributes:R,setNodeRef:Y,listeners:J,isDragging:G,over:W,setActivatorNodeRef:ee,transform:K}=eWe({id:o,data:N,attributes:{...mWe,...n},disabled:w.draggable}),F=F9e(P,Y),q=!!z,ne=q&&!b&&b1(p)&&b1(x),re=!y&&G,se=re&&ne?K:null,pe=ne?se??(l??E)({rects:v,activeNodeRect:X,activeIndex:p,overIndex:x,index:A}):null,Ce=b1(p)&&b1(x)?a({id:o,items:d,activeIndex:p,overIndex:x}):A,oe=z?.id,ae=S.useRef({activeId:oe,items:d,newIndex:Ce,containerId:f}),ge=d!==ae.current.items,ue=e({active:z,containerId:f,isDragging:G,isSorting:q,id:o,index:A,items:d,newIndex:ae.current.newIndex,previousItems:ae.current.items,previousContainerId:ae.current.containerId,transition:u,wasDragging:ae.current.activeId!=null}),Le=pWe({disabled:!ue,index:A,node:D,rect:T});return S.useEffect(()=>{q&&ae.current.newIndex!==Ce&&(ae.current.newIndex=Ce),f!==ae.current.containerId&&(ae.current.containerId=f),d!==ae.current.items&&(ae.current.items=d)},[q,Ce,f,d]),S.useEffect(()=>{if(oe===ae.current.activeId)return;if(oe!=null&&ae.current.activeId==null){ae.current.activeId=oe;return}const $=setTimeout(()=>{ae.current.activeId=oe},50);return()=>clearTimeout($)},[oe]),{active:z,activeIndex:p,attributes:R,data:N,rect:T,index:A,newIndex:Ce,items:d,isOver:k,isSorting:q,isDragging:G,listeners:J,node:D,overIndex:x,over:W,setNodeRef:F,setActivatorNodeRef:ee,setDroppableNodeRef:P,setDraggableNodeRef:Y,transform:Le??pe,transition:V()};function V(){if(Le||ge&&ae.current.newIndex===A)return fWe;if(!(re&&!iL(L)||!u)&&(q||ue))return pg.Transition.toString({...u,property:xne})}}function gWe(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t?.draggable)!=null?n:e.draggable,droppable:(r=t?.droppable)!=null?r:e.droppable}}function d2(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 xWe=[Dn.Down,Dn.Right,Dn.Up,Dn.Left],yne=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(xWe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const p=i.get(f.id);if(p)switch(t.code){case Dn.Down:r.top<p.top&&c.push(f);break;case Dn.Up:r.top>p.top&&c.push(f);break;case Dn.Left:r.left>p.left&&c.push(f);break;case Dn.Right:r.left<p.left&&c.push(f);break}});const u=J9e({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Jte(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),p=a.get(d),g=p?i.get(p.id):null,b=p?.node.current;if(b&&g&&f&&p){const x=qM(b).some((C,T)=>l[T]!==C),y=vne(f,p),E=bWe(f,p),w=x||!y?{x:0,y:0}:{x:E?r.width-g.width:0,y:E?r.height-g.height:0},A={x:g.left,y:g.top};return w.x&&w.y?A:D0(A,w)}}}};function vne(t,e){return!d2(t)||!d2(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function bWe(t,e){return!d2(t)||!d2(e)||!vne(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function yWe({item:t,onClose:e}){const n=an(),{showToast:r}=Wn(),[i,a]=S.useState(t.printer_id),[o,l]=S.useState(t.plate_id),c=t.scheduled_time&&new Date(t.scheduled_time).getTime()>Date.now()+4320*60*60*1e3,[u,d]=S.useState(()=>t.manual_start?"manual":t.scheduled_time&&!c?"scheduled":"asap"),[f,p]=S.useState(()=>t.scheduled_time&&!c?new Date(t.scheduled_time).toISOString().slice(0,16):""),[g,b]=S.useState(t.require_previous_success),[v,x]=S.useState(t.auto_off_after),[y,E]=S.useState(!1),[w,A]=S.useState(!1),[N,C]=S.useState(!1),[T,D]=S.useState({bed_levelling:t.bed_levelling??!0,flow_cali:t.flow_cali??!1,vibration_cali:t.vibration_cali??!0,layer_inspect:t.layer_inspect??!1,timelapse:t.timelapse??!1,use_ams:t.use_ams??!0}),[k,P]=S.useState(()=>{if(t.ams_mapping&&Array.isArray(t.ams_mapping)){const oe={};return t.ams_mapping.forEach((ae,ge)=>{ae!==-1&&(oe[ge+1]=ae)}),oe}return{}}),{data:z}=lt({queryKey:["printers"],queryFn:()=>be.getPrinters()}),{data:L}=lt({queryKey:["archive-plates",t.archive_id],queryFn:()=>be.getArchivePlates(t.archive_id)});S.useEffect(()=>{L?.plates?.length===1&&!o&&l(L.plates[0].index)},[L,o]);const X=L?.is_multi_plate??!1,R=L?.plates??[],{data:Y}=lt({queryKey:["archive-filaments",t.archive_id,o],queryFn:()=>be.getArchiveFilamentRequirements(t.archive_id,o??void 0),enabled:o!==null||!X}),{data:J}=lt({queryKey:["printer-status",i],queryFn:()=>be.getPrinterStatus(i),enabled:i!==null}),[G]=S.useState(t.printer_id),[W]=S.useState(t.plate_id);S.useEffect(()=>{(i!==G||o!==W)&&P({})},[i,G,o,W]),S.useEffect(()=>{const oe=ae=>{ae.key==="Escape"&&e()};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[e]);const ee=oe=>oe?`#${oe.replace("#","").substring(0,6)}`:"#808080",K=(oe,ae,ge,ue)=>{const Le=String.fromCharCode(65+(oe>=128?oe-128:oe));return ge?`HT-${Le}`:`AMS-${Le} Slot ${ae+1}`},F=(oe,ae,ge)=>oe*4+ae,q=S.useMemo(()=>{const oe=[];if(J?.ams?.forEach(ae=>{const ge=ae.tray.length===1;ae.tray.forEach(ue=>{if(ue.tray_type){const Le=ee(ue.tray_color);oe.push({type:ue.tray_type,color:Le,colorName:Gc(Le),amsId:ae.id,trayId:ue.id,isHt:ge,isExternal:!1,label:K(ae.id,ue.id,ge),globalTrayId:F(ae.id,ue.id)})}})}),J?.vt_tray?.tray_type){const ae=ee(J.vt_tray.tray_color);oe.push({type:J.vt_tray.tray_type,color:ae,colorName:Gc(ae),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return oe},[J]),ne=S.useMemo(()=>{if(!Y?.filaments||Y.filaments.length===0)return[];const oe=ue=>ue?ue.replace("#","").toLowerCase().substring(0,6):"",ae=(ue,Le,V=40)=>{const $=oe(ue),Z=oe(Le);if(!$||!Z||$.length<6||Z.length<6)return!1;const B=parseInt($.substring(0,2),16),U=parseInt($.substring(2,4),16),Q=parseInt($.substring(4,6),16),Me=parseInt(Z.substring(0,2),16),Te=parseInt(Z.substring(2,4),16),fe=parseInt(Z.substring(4,6),16);return Math.abs(B-Me)<=V&&Math.abs(U-Te)<=V&&Math.abs(Q-fe)<=V},ge=new Set(Object.values(k));return Y.filaments.map(ue=>{const Le=ue.slot_id||0;if(Le>0&&k[Le]!==void 0){const fe=k[Le],H=q.find(I=>I.globalTrayId===fe);if(H){const I=H.type?.toUpperCase()===ue.type?.toUpperCase(),ce=oe(H.color)===oe(ue.color)||ae(H.color,ue.color);let we;return I&&ce?we="match":I?we="type_only":we="mismatch",{...ue,loaded:H,hasFilament:!0,typeMatch:I,colorMatch:ce,status:we,isManual:!0}}}const V=q.find(fe=>!ge.has(fe.globalTrayId)&&fe.type?.toUpperCase()===ue.type?.toUpperCase()&&oe(fe.color)===oe(ue.color)),$=!V&&q.find(fe=>!ge.has(fe.globalTrayId)&&fe.type?.toUpperCase()===ue.type?.toUpperCase()&&ae(fe.color,ue.color)),Z=!V&&!$&&q.find(fe=>!ge.has(fe.globalTrayId)&&fe.type?.toUpperCase()===ue.type?.toUpperCase()),B=V||$||Z||void 0;B&&ge.add(B.globalTrayId);const U=!!B,Q=U,Me=!!V||!!$;let Te;return V||$?Te="match":Z?Te="type_only":Te="mismatch",{...ue,loaded:B,hasFilament:U,typeMatch:Q,colorMatch:Me,status:Te,isManual:!1}})},[Y,q,k]),re=S.useMemo(()=>{if(ne.length===0)return;const oe=Math.max(...ne.map(ge=>ge.slot_id||0));if(oe<=0)return;const ae=new Array(oe).fill(-1);return ne.forEach(ge=>{ge.slot_id&&ge.slot_id>0&&(ae[ge.slot_id-1]=ge.loaded?.globalTrayId??-1)}),ae},[ne]),se=Y?.filaments&&Y.filaments.length>0,de=ht({mutationFn:oe=>be.updateQueueItem(t.id,oe),onSuccess:()=>{n.invalidateQueries({queryKey:["queue"]}),r("Queue item updated"),e()},onError:oe=>{r(oe.message||"Failed to update queue item","error")}}),pe=oe=>{oe.preventDefault();const ae={printer_id:i,require_previous_success:g,auto_off_after:v,manual_start:u==="manual",ams_mapping:re,plate_id:o,...T};u==="scheduled"&&f?ae.scheduled_time=new Date(f).toISOString():ae.scheduled_time=null,de.mutate(ae)},Ce=()=>{const oe=new Date;return oe.setMinutes(oe.getMinutes()+1),oe.toISOString().slice(0,16)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsx(_t,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:oe=>oe.stopPropagation(),children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Jo,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Edit Queue Item"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:pe,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Print Job"}),s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),z?.length===0?s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(pa,{className:"w-4 h-4"}),"No printers configured"]}):s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:`w-full px-3 py-2 bg-bambu-dark border rounded-lg text-white focus:border-bambu-green focus:outline-none ${i===null?"border-orange-400":"border-bambu-dark-tertiary"}`,value:i??"",onChange:oe=>a(oe.target.value?Number(oe.target.value):null),children:[s.jsx("option",{value:"",children:"-- Select a printer --"}),z?.map(oe=>s.jsx("option",{value:oe.id,children:oe.name},oe.id))]}),i===null&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx(pa,{className:"w-3 h-3"}),"Assign a printer to enable printing"]})]})]}),X&&R.length>1&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Hs,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("label",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!o&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(yn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:R.map(oe=>s.jsxs("button",{type:"button",onClick:()=>l(oe.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${o===oe.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"}`,children:[oe.has_thumbnail&&oe.thumbnail_url?s.jsx("img",{src:oe.thumbnail_url,alt:`Plate ${oe.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(Hs,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white font-medium truncate",children:oe.name||`Plate ${oe.index}`}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:oe.objects?.length>0?oe.objects.slice(0,3).join(", ")+(oe.objects.length>3?"...":""):`${oe.filaments.length} filament${oe.filaments.length!==1?"s":""}`})]}),o===oe.index&&s.jsx(Aa,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},oe.index))})]}),i!==null&&(X?o!==null:!0)&&se&&s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>E(!y),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx(qb,{className:"w-4 h-4",fill:ne.some(oe=>oe.status==="mismatch")?"#f97316":ne.some(oe=>oe.status==="type_only")?"#facc15":"#00ae42",stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),ne.some(oe=>oe.status==="mismatch")?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):ne.some(oe=>oe.status==="type_only")?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),y?s.jsx(Xc,{className:"w-4 h-4 ml-auto"}):s.jsx(Qi,{className:"w-4 h-4 ml-auto"})]}),y&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.jsxs("button",{type:"button",onClick:async()=>{if(i){C(!0);try{await be.refreshPrinterStatus(i),await new Promise(oe=>setTimeout(oe,500)),await n.refetchQueries({queryKey:["printer-status",i]})}finally{C(!1)}}},className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white",disabled:N,children:[s.jsx(Rr,{className:`w-3 h-3 ${N?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),ne.map((oe,ae)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${oe.type} - ${Gc(oe.color)}`,children:s.jsx(qb,{className:"w-3 h-3",fill:oe.color,stroke:oe.color})}),s.jsxs("span",{className:"text-white truncate",children:[oe.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",oe.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:oe.loaded?.globalTrayId??"",onChange:ge=>{const ue=oe.slot_id||0;if(ue>0){const Le=ge.target.value;P(Le===""?V=>{const $={...V};return delete $[ue],$}:V=>({...V,[ue]:parseInt(Le,10)}))}},className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${oe.status==="match"?"border-bambu-green/50 text-bambu-green":oe.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${oe.isManual?"ring-1 ring-blue-400/50":""}`,title:oe.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),q.map(ge=>s.jsxs("option",{value:ge.globalTrayId,className:"bg-bambu-dark text-white",children:[ge.label,": ",ge.type," (",ge.colorName,")"]},ge.globalTrayId))]}),oe.status==="match"?s.jsx(Aa,{className:"w-3 h-3 text-bambu-green"}):oe.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(yn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(yn,{className:"w-3 h-3 text-orange-400"})})]},ae))]})]}),s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>A(!w),className:"flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full",children:[s.jsx($0,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),w?s.jsx(Xc,{className:"w-4 h-4 ml-auto"}):s.jsx(Qi,{className:"w-4 h-4 ml-auto"})]}),w&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[{key:"bed_levelling",label:"Bed Levelling",desc:"Auto-level bed before print"},{key:"flow_cali",label:"Flow Calibration",desc:"Calibrate extrusion flow"},{key:"vibration_cali",label:"Vibration Calibration",desc:"Reduce ringing artifacts"},{key:"layer_inspect",label:"First Layer Inspection",desc:"AI inspection of first layer"},{key:"timelapse",label:"Timelapse",desc:"Record timelapse video"}].map(({key:oe,label:ae,desc:ge})=>s.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:ae}),s.jsx("p",{className:"text-xs text-bambu-gray",children:ge})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${T[oe]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>D(ue=>({...ue,[oe]:!ue[oe]})),children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${T[oe]?"translate-x-5":"translate-x-0.5"}`})})]},oe))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${u==="asap"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>d("asap"),children:[s.jsx(tr,{className:"w-4 h-4"}),"ASAP"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${u==="scheduled"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>d("scheduled"),children:[s.jsx(qr,{className:"w-4 h-4"}),"Scheduled"]}),s.jsxs("button",{type:"button",className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${u==="manual"?"bg-bambu-green border-bambu-green text-white":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,onClick:()=>d("manual"),children:[s.jsx(PR,{className:"w-4 h-4"}),"Queue Only"]})]})]}),u==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.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:f,onChange:oe=>p(oe.target.value),min:Ce(),required:!0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"requirePrevious",checked:g,onChange:oe=>b(oe.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"autoOffAfter",checked:v,onChange:oe=>x(oe.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(zl,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:u==="asap"?"Print will start as soon as the printer is idle.":u==="scheduled"?"Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.":"Print will be staged but won't start automatically. Use the Start button to release it to the queue."}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsx(Ee,{type:"submit",className:"flex-1",disabled:de.isPending||z?.length===0,children:de.isPending?"Saving...":"Save Changes"})]})]})]})})})}function _ne(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 vWe(t,e="system"){if(!t)return"ASAP";const n=fi(t);if(!n)return"ASAP";const r=new Date,i=n.getTime()-r.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`:Vp(t,e)}function _We({status:t}){const e={pending:{icon:tr,color:"text-yellow-400 bg-yellow-400/10 border-yellow-400/20",label:"Pending"},printing:{icon:Yc,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"Printing"},completed:{icon:pr,color:"text-green-400 bg-green-400/10 border-green-400/20",label:"Completed"},failed:{icon:Wi,color:"text-red-400 bg-red-400/10 border-red-400/20",label:"Failed"},skipped:{icon:sw,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Skipped"},cancelled:{icon:zt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:"Cancelled"}},{icon:n,color:r,label:i}=e[t];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r}`,children:[s.jsx(n,{className:"w-3.5 h-3.5"}),i]})}function ej({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system"}){const{attributes:u,listeners:d,setNodeRef:f,transform:p,transition:g,isDragging:b}=bne({id:t.id,disabled:t.status!=="pending"}),v={transform:pg.Transform.toString(p),transition:g},x=t.status==="printing",y=t.status==="pending",E=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:f,style:v,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${b?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${x?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[y?s.jsx("div",{...u,...d,className:"flex items-center justify-center w-10 h-10 md:w-8 md:h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation",children:s.jsx(Kb,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?s.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]}):s.jsx("div",{className:"w-8"}),s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?s.jsx("img",{src:be.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(Hs,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:t.archive_name||`Archive #${t.archive_id}`}),s.jsx(Ts,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:"View archive",children:s.jsx(Kr,{className:"w-3.5 h-3.5"})})]}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[s.jsxs("span",{className:`flex items-center gap-1.5 ${t.printer_id===null?"text-orange-400":""}`,children:[s.jsx(Qr,{className:"w-3.5 h-3.5"}),t.printer_id===null?"Unassigned":t.printer_name||`Printer #${t.printer_id}`]}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(hd,{className:"w-3.5 h-3.5"}),_ne(t.print_time_seconds)]}),y&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(tr,{className:"w-3.5 h-3.5"}),vWe(t.scheduled_time,c)]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&s.jsxs("span",{className:"text-xs px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1",children:[s.jsx(PR,{className:"w-3 h-3"}),"Staged"]}),t.require_previous_success&&s.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&&s.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:[s.jsx(zl,{className:"w-3 h-3"}),"Auto power off"]})]}),x&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Printing in progress..."})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx(pa,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(_We,{status:t.status}),s.jsxs("div",{className:"flex items-center gap-1",children:[x&&s.jsx(Ee,{variant:"ghost",size:"sm",onClick:a,title:"Stop Print",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Yle,{className:"w-4 h-4"})}),y&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Ee,{variant:"ghost",size:"sm",onClick:l,title:"Start Print",className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:s.jsx(Yc,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:n,title:"Edit",children:s.jsx(Jo,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:r,title:"Cancel",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(zt,{className:"w-4 h-4"})})]}),E&&s.jsxs(s.Fragment,{children:[s.jsx(Ee,{variant:"ghost",size:"sm",onClick:o,title:"Re-queue",className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:s.jsx(Rr,{className:"w-4 h-4"})}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:i,title:"Remove",children:s.jsx(ln,{className:"w-4 h-4"})})]})]})]})})}function wWe(){const t=an(),{showToast:e}=Wn(),[n,r]=S.useState(null),[i,a]=S.useState(""),[o,l]=S.useState(!1),[c,u]=S.useState(null),[d,f]=S.useState(null),[p,g]=S.useState(null),[b,v]=S.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[x,y]=S.useState(()=>{const ne=localStorage.getItem("queue.historySortAsc");return ne!==null?ne==="true":!1}),[E,w]=S.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[A,N]=S.useState(()=>{const ne=localStorage.getItem("queue.pendingSortAsc");return ne!==null?ne==="true":!0});S.useEffect(()=>{localStorage.setItem("queue.historySortBy",b)},[b]),S.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(x))},[x]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",E)},[E]),S.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(A))},[A]);const C=Yte(c2(XM,{activationConstraint:{distance:8}}),c2(KM,{coordinateGetter:yne})),{data:T}=lt({queryKey:["settings"],queryFn:be.getSettings}),D=T?.time_format||"system",{data:k,isLoading:P}=lt({queryKey:["queue",n,i],queryFn:()=>be.getQueue(n||void 0,i||void 0),refetchInterval:5e3}),{data:z}=lt({queryKey:["printers"],queryFn:()=>be.getPrinters()}),L=ht({mutationFn:ne=>be.cancelQueueItem(ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item cancelled")},onError:()=>e("Failed to cancel item","error")}),X=ht({mutationFn:ne=>be.removeFromQueue(ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Queue item removed")},onError:()=>e("Failed to remove item","error")}),R=ht({mutationFn:ne=>be.stopQueueItem(ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print stopped")},onError:()=>e("Failed to stop print","error")}),Y=ht({mutationFn:ne=>be.startQueueItem(ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]}),e("Print released to queue")},onError:()=>e("Failed to start print","error")}),J=ht({mutationFn:ne=>be.reorderQueue(ne),onSuccess:()=>{t.invalidateQueries({queryKey:["queue"]})},onError:()=>e("Failed to reorder queue","error")}),G=ht({mutationFn:async()=>{const ne=k?.filter(re=>["completed","failed","skipped","cancelled"].includes(re.status))||[];for(const re of ne)await be.removeFromQueue(re.id);return ne.length},onSuccess:ne=>{t.invalidateQueries({queryKey:["queue"]}),e(`Cleared ${ne} history item${ne!==1?"s":""}`)},onError:()=>e("Failed to clear history","error")}),W=S.useMemo(()=>{const ne=k?.filter(se=>se.status==="pending")||[],re=se=>{if(!se.scheduled_time)return 0;const de=new Date(se.scheduled_time).getTime(),pe=Date.now()+4320*60*60*1e3;return de>pe?0:de};return[...ne].sort((se,de)=>{let pe;return E==="name"?pe=(se.archive_name||"").localeCompare(de.archive_name||""):E==="printer"?pe=(se.printer_name||"").localeCompare(de.printer_name||""):E==="time"?pe=re(se)-re(de):pe=se.position-de.position,A?pe:-pe})},[k,E,A]),ee=k?.filter(ne=>ne.status==="printing")||[],K=S.useMemo(()=>[...k?.filter(re=>["completed","failed","skipped","cancelled"].includes(re.status))||[]].sort((re,se)=>{let de;return b==="name"?de=(re.archive_name||"").localeCompare(se.archive_name||""):b==="printer"?de=(re.printer_name||"").localeCompare(se.printer_name||""):de=new Date(se.completed_at||se.created_at).getTime()-new Date(re.completed_at||re.created_at).getTime(),x?-de:de}),[k,b,x]),F=S.useMemo(()=>W.reduce((ne,re)=>ne+(re.print_time_seconds||0),0),[W]),q=ne=>{const{active:re,over:se}=ne;if(!se||re.id===se.id)return;const de=W.findIndex(Ce=>Ce.id===re.id),pe=W.findIndex(Ce=>Ce.id===se.id);if(de!==-1&&pe!==-1){const oe=ZM(W,de,pe).map((ae,ge)=>({id:ae.id,position:ge+1}));J.mutate(oe)}};return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsx("div",{className:"flex items-center justify-between mb-8",children:s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx(cW,{className:"w-7 h-7 text-bambu-green"}),"Print Queue"]}),s.jsx("p",{className:"text-bambu-gray mt-1",children:"Schedule and manage your print jobs"})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[s.jsx(_t,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:s.jsx(Yc,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ee.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Printing"})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:s.jsx(tr,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:W.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Queued"})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:s.jsx(hd,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:_ne(F)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Total Queue Time"})]})]})})}),s.jsx(_t,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:s.jsx(pr,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:K.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"History"})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.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===-1?"unassigned":n||"",onChange:ne=>{const re=ne.target.value;r(re==="unassigned"?-1:re===""?null:Number(re))},children:[s.jsx("option",{value:"",children:"All Printers"}),s.jsx("option",{value:"unassigned",children:"Unassigned"}),z?.map(ne=>s.jsx("option",{value:ne.id,children:ne.name},ne.id))]}),s.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:i,onChange:ne=>a(ne.target.value),children:[s.jsx("option",{value:"",children:"All Status"}),s.jsx("option",{value:"pending",children:"Pending"}),s.jsx("option",{value:"printing",children:"Printing"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"failed",children:"Failed"}),s.jsx("option",{value:"skipped",children:"Skipped"}),s.jsx("option",{value:"cancelled",children:"Cancelled"})]}),s.jsx("div",{className:"flex-1"}),K.length>0&&s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>l(!0),children:[s.jsx(ln,{className:"w-4 h-4"}),"Clear History"]})]}),P?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading..."}):k?.length===0?s.jsxs(_t,{className:"p-12 text-center border-dashed",children:[s.jsx(qr,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),s.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:"No prints scheduled"}),s.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.'})]}):s.jsxs("div",{className:"space-y-8",children:[ee.length>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),"Currently Printing"]}),s.jsx("div",{className:"space-y-3",children:ee.map(ne=>s.jsx(ej,{item:ne,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>g({type:"stop",item:ne}),onRequeue:()=>{},onStart:()=>{},timeFormat:D},ne.id))})]}),W.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(tr,{className:"w-5 h-5 text-yellow-400"}),"Queued",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",W.length," item",W.length!==1?"s":"",")"]}),s.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)"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:E,onChange:ne=>w(ne.target.value),children:[s.jsx("option",{value:"position",children:"Sort by Position"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"}),s.jsx("option",{value:"time",children:"Sort by Schedule"})]}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>N(!A),title:A?"Ascending":"Descending",className:"px-2",children:A?s.jsx(Up,{className:"w-4 h-4"}):s.jsx(Wb,{className:"w-4 h-4"})})]})]}),s.jsx(fne,{sensors:C,collisionDetection:ene,onDragEnd:q,children:s.jsx(gne,{items:W.map(ne=>ne.id),strategy:lWe,children:s.jsx("div",{className:"space-y-3",children:W.map((ne,re)=>s.jsx(ej,{item:ne,position:re+1,onEdit:()=>u(ne),onCancel:()=>g({type:"cancel",item:ne}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>Y.mutate(ne.id),timeFormat:D},ne.id))})})})]}),K.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(pr,{className:"w-5 h-5 text-bambu-gray"}),"History",s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",K.length," item",K.length!==1?"s":"",")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:b,onChange:ne=>v(ne.target.value),children:[s.jsx("option",{value:"date",children:"Sort by Date"}),s.jsx("option",{value:"name",children:"Sort by Name"}),s.jsx("option",{value:"printer",children:"Sort by Printer"})]}),s.jsx(Ee,{variant:"ghost",size:"sm",onClick:()=>y(!x),title:x?"Ascending (oldest first)":"Descending (newest first)",className:"px-2",children:x?s.jsx(Up,{className:"w-4 h-4"}):s.jsx(Wb,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:K.slice(0,20).map((ne,re)=>s.jsx(ej,{item:ne,position:re+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>g({type:"remove",item:ne}),onStop:()=>{},onRequeue:()=>f(ne),onStart:()=>{},timeFormat:D},ne.id))})]})]}),c&&s.jsx(yWe,{item:c,onClose:()=>u(null)}),d&&s.jsx(eL,{archiveId:d.archive_id,archiveName:d.archive_name||`Archive #${d.archive_id}`,onClose:()=>f(null)}),p&&s.jsx(Un,{title:p.type==="cancel"?"Cancel Scheduled Print":p.type==="stop"?"Stop Print":"Remove from History",message:p.type==="cancel"?`Are you sure you want to cancel "${p.item.archive_name||"this print"}"?`:p.type==="stop"?`Are you sure you want to stop the current print "${p.item.archive_name||"this print"}"? This will cancel the print job on the printer.`:`Are you sure you want to remove "${p.item.archive_name||"this item"}" from the queue history?`,confirmText:p.type==="cancel"?"Cancel Print":p.type==="stop"?"Stop Print":"Remove",variant:"danger",onConfirm:()=>{p.type==="cancel"?L.mutate(p.item.id):p.type==="stop"?R.mutate(p.item.id):X.mutate(p.item.id),g(null)},onCancel:()=>g(null)}),o&&s.jsx(Un,{title:"Clear History",message:`Are you sure you want to remove all ${K.length} item${K.length!==1?"s":""} from the history?`,confirmText:"Clear History",variant:"danger",onConfirm:()=>{G.mutate(),l(!1)},onCancel:()=>l(!1)})]})}function SWe({printDates:t,months:e=3}){const n=S.useRef(null),[r,i]=S.useState(0);S.useEffect(()=>{const E=n.current;if(!E)return;const w=new ResizeObserver(A=>{const N=A[0]?.contentRect.width||0;i(N)});return w.observe(E),()=>w.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=S.useMemo(()=>{const E={};t.forEach(z=>{const L=z.split("T")[0];E[L]=(E[L]||0)+1});const w=new Date,A=new Date(w);A.setMonth(A.getMonth()-e),A.setDate(A.getDate()-A.getDay());const N=[],C=[];let T=[],D=-1;const k=new Date(A);let P=0;for(;k<=w;)k.getDay()===0&&T.length>0&&(N.push(T),T=[],P++),k.getMonth()!==D&&(C.push({month:k.toLocaleDateString("en-US",{month:"short"}),weekIndex:P}),D=k.getMonth()),T.push(new Date(k)),k.setDate(k.getDate()+1);return T.length>0&&N.push(T),{weeks:N,monthLabels:C,printCounts:E}},[t,e]),c=Math.max(1,...Object.values(l)),u=E=>{if(E===0)return"bg-bambu-dark";const w=E/c;return w<=.25?"bg-bambu-green/30":w<=.5?"bg-bambu-green/50":w<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,p=32,g=2,b=r-p-16,v=f>0?Math.floor((b-(f-1)*g)/f):12,x=Math.max(8,Math.min(20,v)),y=x<=10?10:12;return s.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&s.jsxs("div",{children:[s.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:E,weekIndex:w},A)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:y,marginLeft:A===0?0:`${(w-(o[A-1]?.weekIndex||0))*(x+g)-24}px`},children:E},A))}),s.jsxs("div",{className:"flex",style:{gap:g},children:[s.jsx("div",{className:"flex flex-col",style:{gap:g,marginRight:4,width:p},children:d.map((E,w)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:x,fontSize:y,visibility:w%2===1?"visible":"hidden"},children:E},E))}),a.map((E,w)=>s.jsx("div",{className:"flex flex-col",style:{gap:g},children:[0,1,2,3,4,5,6].map(A=>{const N=E.find(k=>k.getDay()===A);if(!N)return s.jsx("div",{style:{width:x,height:x}},A);const C=N.toISOString().split("T")[0],T=l[C]||0,D=C===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(T)} ${D?"ring-1 ring-white":""}`,style:{width:x,height:x},title:`${N.toLocaleDateString()}: ${T} print${T!==1?"s":""}`},A)})},w))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:y},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:g},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:x,height:x}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:x,height:x}})]}),s.jsx("span",{children:"More"})]})]})})}const v1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function MWe(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 EWe({archives:t,currency:e="$"}){const[n,r]=S.useState("30d"),i=S.useMemo(()=>{const p=MWe(n);return t.filter(g=>(fi(g.completed_at||g.created_at)||new Date(0))>=p)},[t,n]),a=S.useMemo(()=>{const p=new Map;return i.forEach(g=>{const b=fi(g.completed_at||g.created_at)||new Date,v=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,x=p.get(v)||{date:v,filament:0,cost:0,prints:0};x.filament+=g.filament_used_grams||0,x.cost+=g.cost||0,x.prints+=1,p.set(v,x)}),Array.from(p.values()).sort((g,b)=>g.date.localeCompare(b.date)).map(g=>({...g,dateLabel:new Date(g.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=S.useMemo(()=>{if(n==="7d"||n==="30d")return a;const p=new Map;return i.forEach(g=>{const b=fi(g.completed_at||g.created_at)||new Date,v=new Date(b);v.setDate(b.getDate()-b.getDay());const x=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`,y=p.get(x)||{week:x,filament:0,cost:0,prints:0};y.filament+=g.filament_used_grams||0,y.cost+=g.cost||0,y.prints+=1,p.set(x,y)}),Array.from(p.values()).sort((g,b)=>g.week.localeCompare(b.week)).map(g=>({date:g.week,dateLabel:`Week of ${new Date(g.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...g}))},[i,a,n]),l=S.useMemo(()=>{const p=new Map;return i.forEach(g=>{const v=(g.filament_type||"Unknown").split(", ");v.forEach(x=>{const y=(g.filament_used_grams||0)/v.length;p.set(x,(p.get(x)||0)+y)})}),Array.from(p.entries()).map(([g,b])=>({name:g,value:Math.round(b)})).sort((g,b)=>b.value-g.value)},[i]),c=S.useMemo(()=>{const p=new Date,g=[];for(let b=5;b>=0;b--){const v=new Date(p.getFullYear(),p.getMonth()-b,1),x=new Date(p.getFullYear(),p.getMonth()-b+1,0),y=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),E=t.filter(w=>{const A=fi(w.completed_at||w.created_at)||new Date(0);return A>=v&&A<=x});g.push({month:y,filament:Math.round(E.reduce((w,A)=>w+(A.filament_used_grams||0),0)),cost:E.reduce((w,A)=>w+(A.cost||0),0),prints:E.length})}return g},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((p,g)=>p+(g.filament_used_grams||0),0),f=i.reduce((p,g)=>p+(g.cost||0),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(p=>s.jsx("button",{onClick:()=>r(p),className:`px-3 py-1 text-sm rounded-md transition-colors ${n===p?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:p==="all"?"All":p.replace("d","D")},p))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i.length," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.length>0?(d/i.length).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,i.length>0?(f/i.length).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(j1,{width:"100%",height:250,children:s.jsxs(RCe,{data:u,children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),s.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),s.jsx(Jw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(tS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(nS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),s.jsx(R1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:p=>[`${p.toFixed(0)}g`,"Filament"]}),s.jsx(_Q,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):s.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(j1,{width:160,height:160,children:s.jsxs(jCe,{children:[s.jsx(GY,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((p,g)=>s.jsx(py,{fill:v1[g%v1.length]},`cell-${g}`))}),s.jsx(R1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:p=>[`${p}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((p,g)=>{const b=l.reduce((x,y)=>x+y.value,0),v=b>0?(p.value/b*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:v1[g%v1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:p.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},p.name)})})]}):s.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),s.jsx(j1,{width:"100%",height:200,children:s.jsxs(yCe,{data:c,children:[s.jsx(Jw,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(tS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(nS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:p=>`${p}g`}),s.jsx(R1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(p,g)=>[g==="filament"?`${p}g`:g==="cost"?`${e}${p.toFixed(2)}`:p,g==="filament"?"Filament":g==="cost"?"Cost":"Prints"]}),s.jsx(uD,{}),s.jsx(QY,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function NWe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:p}=bne({id:t}),g={transform:pg.Transform.toString(d),transition:f,opacity:p?.5:1};return r?null:s.jsxs("div",{ref:u,style:{...g,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"ring-2 ring-bambu-green shadow-lg":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{...l,...c,className:"cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Drag to reorder",children:s.jsx(Kb,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),s.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:o,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:`Size: ${i===1?"1/4":i===2?"1/2":"Full"} - Click to cycle`,children:i===4?s.jsx(Fue,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(kue,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),s.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:s.jsx(x2,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),s.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function AWe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const A={};return t.forEach(N=>{A[N.id]=N.defaultSize||4}),A},[l,c]=S.useState(()=>{const A=localStorage.getItem(e);if(A)try{const N=JSON.parse(A);return N.sizes||(N.sizes=o()),N}catch{}return{order:t.map(N=>N.id),hidden:t.filter(N=>N.defaultVisible===!1).map(N=>N.id),sizes:o()}}),[u,d]=S.useState(!1);S.useEffect(()=>{const A=()=>d(N=>!N);return window.addEventListener("toggle-hidden-panel",A),()=>window.removeEventListener("toggle-hidden-panel",A)},[]),S.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),S.useEffect(()=>{const N=t.map(C=>C.id).filter(C=>!l.order.includes(C));N.length>0&&c(C=>({...C,order:[...C.order,...N]}))},[t,l.order]);const f=Yte(c2(XM,{activationConstraint:{distance:8}}),c2(KM,{coordinateGetter:yne})),p=A=>{const{active:N,over:C}=A;C&&N.id!==C.id&&c(T=>{const D=T.order.indexOf(N.id),k=T.order.indexOf(C.id);return{...T,order:ZM(T.order,D,k)}})},g=A=>{c(N=>({...N,hidden:N.hidden.includes(A)?N.hidden.filter(C=>C!==A):[...N.hidden,A]}))},b=A=>{c(N=>{const C=N.sizes[A]||4,T=C===1?2:C===2?4:1;return{...N,sizes:{...N.sizes,[A]:T}}})},v=()=>{const A={order:t.map(N=>N.id),hidden:t.filter(N=>N.defaultVisible===!1).map(N=>N.id),sizes:o()};c(A),i?.()},x=l.order.map(A=>t.find(N=>N.id===A)).filter(Boolean),y=x.filter(A=>!l.hidden.includes(A.id)),E=x.filter(A=>l.hidden.includes(A.id)),w=a?.({hiddenCount:E.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:v});return s.jsxs("div",{className:"space-y-4",children:[w,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:v,children:[s.jsx(If,{className:"w-4 h-4"}),"Reset Layout"]}),E.length>0&&s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(mf,{className:"w-4 h-4"}),E.length," Hidden"]})]}),u&&E.length>0&&s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:E.map(A=>s.jsxs("button",{onClick:()=>g(A.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:[s.jsx(mf,{className:"w-3 h-3"}),A.title]},A.id))})]}),s.jsx(fne,{sensors:f,collisionDetection:ene,onDragEnd:p,children:s.jsx(gne,{items:y.map(A=>A.id),strategy:oL,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:y.map(A=>s.jsx(NWe,{id:A.id,title:A.title,component:A.component,isHidden:l.hidden.includes(A.id),size:l.sizes[A.id]||2,onToggleVisibility:()=>g(A.id),onToggleSize:()=>b(A.id)},A.id))})})}),y.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Ee,{className:"mt-4",onClick:v,children:"Reset Layout"})]})]})}function TWe({stats:t,currency:e}){return s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(Cl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Total Prints"}),s.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:s.jsx(tr,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Print Time"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:s.jsx(Cl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:s.jsx(_j,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:s.jsx(bf,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Used"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:s.jsx(_j,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Energy Cost"}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function CWe({stats:t,printerMap:e,size:n=1}){const r=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,i=n===1?112:n===2?128:144,a=i/2-8,o=a*2*Math.PI;return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:i,height:i},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:i/2,cy:i/2,r:a,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${r/100*o} ${o}`})]}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r,"%"]})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(pr,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Successful:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Wi,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Failed:"}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.failed_prints||0})]})]}),n>=2&&t?.prints_by_printer&&Object.keys(t.prints_by_printer).length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:"Prints by Printer"}),s.jsx("div",{className:`grid gap-x-6 gap-y-1 ${n===4?"grid-cols-3":"grid-cols-2"}`,style:{width:"fit-content"},children:Object.entries(t.prints_by_printer).map(([l,c])=>s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(l)||`Printer ${l}`}),s.jsx("span",{className:"text-white font-medium",children:c})]},l))})]})]})]})}function kWe({stats:t,printerMap:e,size:n=1}){const r=t?.average_time_accuracy;if(r==null)return s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No time accuracy data yet"})});const a=(Math.min(150,Math.max(50,r))-50)/100*100,l=(b=>b>=95&&b<=105?"#00ae42":b>105?"#3b82f6":"#f97316")(r),c=r-100,u=n===1?112:n===2?128:144,d=u/2-8,f=d*2*Math.PI,p=n===1?3:n===2?6:999,g=t?.time_accuracy_by_printer?Object.entries(t.time_accuracy_by_printer).slice(0,p):[];return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:u,height:u},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:u/2,cy:u/2,r:d,fill:"none",stroke:l,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${a/100*f} ${f}`})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[r.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${c>=0?"text-blue-400":"text-orange-400"}`,children:[c>=0?"+":"",c.toFixed(0),"%"]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx(mW,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:"100% = perfect estimate"})]}),g.length>0&&s.jsx("div",{className:`mt-2 ${n===4?"grid grid-cols-3 gap-x-6 gap-y-1":n===2?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,style:{width:"fit-content"},children:g.map(([b,v])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(b)||`Printer ${b}`}),s.jsxs("span",{className:`font-medium ${v>=95&&v<=105?"text-bambu-green":v>105?"text-blue-400":"text-orange-400"}`,children:[v.toFixed(0),"%"]})]},b))})]})]})}function jWe({stats:t,size:e=1}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No filament data available"});const n=Object.entries(t.prints_by_filament_type).sort(([,o],[,l])=>l-o),r=e===1?5:e===2?8:999,i=n.slice(0,r),a=n.length>r;return e===4&&i.length>4?s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white truncate max-w-[120px]",children:o}),s.jsx("span",{className:"text-bambu-gray",children:l})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)})}):s.jsxs("div",{className:"space-y-3",children:[i.map(([o,l])=>{const c=Math.round(l/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white",children:o}),s.jsxs("span",{className:"text-bambu-gray",children:[l," prints"]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${c}%`}})})]},o)}),a&&s.jsxs("p",{className:"text-xs text-bambu-gray text-center pt-1",children:["+",n.length-r," more types"]})]})}function PWe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(SWe,{printDates:t,months:n})}function RWe({stats:t,printerMap:e}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No printer data available"}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([n,r])=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:s.jsx(Qr,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(n)||`Printer ${n}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[r," prints"]})]})]},n))})}function DWe({archives:t,currency:e}){return!t||t.length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data available"}):s.jsx(EWe,{archives:t,currency:e})}function OWe({size:t=1}){const{data:e,isLoading:n}=lt({queryKey:["failureAnalysis"],queryFn:()=>be.getFailureAnalysis({days:30})});if(n)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!e||e.total_prints===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:"No print data in the last 30 days"});const r=t===1?5:t===2?8:999,i=Object.entries(e.failures_by_reason).sort(([,l],[,c])=>c-l),a=i.slice(0,r),o=i.length>r;return s.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[s.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yn,{className:`w-5 h-5 ${e.failure_rate>20?"text-red-400":e.failure_rate>10?"text-yellow-400":"text-bambu-green"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[e.failure_rate.toFixed(1),"%"]})]})}),s.jsxs("div",{className:"text-sm text-bambu-gray mt-1",children:[e.failed_prints," / ",e.total_prints," prints failed"]}),e.trend&&e.trend.length>=2&&s.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(gW,{className:`w-4 h-4 ${e.trend[e.trend.length-1].failure_rate<e.trend[e.trend.length-2].failure_rate?"text-bambu-green":"text-red-400"}`}),s.jsxs("span",{className:"text-bambu-gray",children:["Last week: ",e.trend[e.trend.length-1].failure_rate.toFixed(1),"%"]})]})})]}),a.length>0&&s.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?"Failure Reasons":"Top Failure Reasons"}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:a.map(([l,c])=>s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:l||"Unknown"}),s.jsx("span",{className:"text-bambu-gray ml-2",children:c})]},l))}),o&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["+",i.length-r," more reasons"]})]})]})}function LWe(){const{showToast:t}=Wn(),[e,n]=S.useState(!1),[r,i]=S.useState(!1),[a,o]=S.useState(0),[l,c]=S.useState(0);S.useEffect(()=>{const w=()=>{try{const N=localStorage.getItem("bambusy-dashboard-layout");if(N){const C=JSON.parse(N);c(C.hidden?.length||0)}}catch{c(0)}};w(),window.addEventListener("storage",w);const A=setInterval(w,500);return()=>{window.removeEventListener("storage",w),clearInterval(A)}},[a]);const{data:u,isLoading:d}=lt({queryKey:["archiveStats"],queryFn:be.getArchiveStats}),{data:f}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:p}=lt({queryKey:["archives"],queryFn:()=>be.getArchives(void 0,void 0,1e3,0)}),{data:g}=lt({queryKey:["settings"],queryFn:be.getSettings}),b=async w=>{i(!1),n(!0);try{const{blob:A,filename:N}=await be.exportStats({format:w,days:90}),C=URL.createObjectURL(A),T=document.createElement("a");T.href=C,T.download=N,T.click(),URL.revokeObjectURL(C),t("Export downloaded")}catch{t("Export failed","error")}finally{n(!1)}},v=g?.currency||"$",x=new Map(f?.map(w=>[String(w.id),w.name])||[]),y=p?.map(w=>w.created_at)||[];if(d)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"Loading statistics..."})});const E=[{id:"quick-stats",title:"Quick Stats",component:s.jsx(TWe,{stats:u,currency:v}),defaultSize:2},{id:"success-rate",title:"Success Rate",component:w=>s.jsx(CWe,{stats:u,printerMap:x,size:w}),defaultSize:1},{id:"time-accuracy",title:"Time Accuracy",component:w=>s.jsx(kWe,{stats:u,printerMap:x,size:w}),defaultSize:1},{id:"filament-types",title:"Filament Types",component:w=>s.jsx(jWe,{stats:u,size:w}),defaultSize:1},{id:"failure-analysis",title:"Failure Analysis (30 days)",component:w=>s.jsx(OWe,{size:w}),defaultSize:1},{id:"print-activity",title:"Print Activity",component:w=>s.jsx(PWe,{printDates:y,size:w}),defaultSize:2},{id:"prints-by-printer",title:"Prints by Printer",component:s.jsx(RWe,{stats:u,printerMap:x}),defaultSize:2},{id:"filament-trends",title:"Filament Usage Trends",component:s.jsx(DWe,{archives:p||[],currency:v}),defaultSize:4}];return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Dashboard"}),s.jsx("p",{className:"text-bambu-gray",children:"Drag widgets to rearrange. Click the eye icon to hide."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&s.jsxs(Ee,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(mf,{className:"w-4 h-4"}),l," Hidden"]}),s.jsxs(Ee,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),o(w=>w+1),t("Layout reset")},children:[s.jsx(If,{className:"w-4 h-4"}),"Reset Layout"]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Ee,{variant:"secondary",onClick:()=>i(!r),disabled:e,children:[e?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(rw,{className:"w-4 h-4"}),"Export Stats"]}),r&&s.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20",children:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:()=>b("csv"),children:[s.jsx(Ua,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:()=>b("xlsx"),children:[s.jsx(rw,{className:"w-4 h-4"}),"Export as Excel"]})]})]})]})]}),s.jsx(AWe,{widgets:E,storageKey:"bambusy-dashboard-layout",hideControls:!0},a)]})}function IWe({plug:t,onEdit:e}){const n=an(),{showToast:r}=Wn(),[i,a]=S.useState(!1),[o,l]=S.useState(!1),[c,u]=S.useState(!1),[d,f]=S.useState(!1),{data:p,isLoading:g}=lt({queryKey:["smart-plug-status",t.id],queryFn:()=>be.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:b}=lt({queryKey:["printers"],queryFn:be.getPrinters}),v=b?.find(D=>D.id===t.printer_id),x=ht({mutationFn:D=>be.controlSmartPlug(t.id,D),onMutate:async D=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const k=n.getQueryData(["smart-plug-status",t.id]),P=D==="on"?"ON":D==="off"||p?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],z=>({...z,state:P})),{previousStatus:k}},onError:(D,k,P)=>{P?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],P.previousStatus),r(`Failed to turn ${k} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),y=ht({mutationFn:D=>be.updateSmartPlug(t.id,D),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]})}}),E=ht({mutationFn:()=>be.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]})}}),w=p?.state==="ON",A=p?.reachable??!1,N=x.isPending,T=(()=>{if(t.plug_type!=="tasmota"||!t.ip_address)return null;const D=t.ip_address;return t.username&&t.password?`http://${encodeURIComponent(t.username)}:${encodeURIComponent(t.password)}@${D}/`:`http://${D}/`})();return s.jsxs(s.Fragment,{children:[s.jsx(_t,{className:"relative",children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${A?w?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="homeassistant"?s.jsx(w2,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(Ls,{className:`w-5 h-5 ${A?w?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t.plug_type==="homeassistant"?t.ha_entity_id:t.ip_address})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[g?s.jsx(ft,{className:"w-4 h-4 text-bambu-gray animate-spin"}):A?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Np,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:w?"text-bambu-green":"text-bambu-gray",children:p?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-red-400",children:[s.jsx(H0,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),T&&s.jsxs("a",{href:T,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors",title:"Open plug admin page",children:[s.jsx(Kr,{className:"w-3 h-3"}),"Admin"]})]})]}),v&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:v.name})]}),(t.power_alert_enabled||t.schedule_enabled)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.power_alert_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full",children:[s.jsx(Kh,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&s.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full",children:[s.jsx(qr,{className:"w-3 h-3"}),t.schedule_on_time&&t.schedule_off_time?`${t.schedule_on_time} - ${t.schedule_off_time}`:t.schedule_on_time?`On ${t.schedule_on_time}`:`Off ${t.schedule_off_time}`]})]}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Ee,{size:"sm",variant:w?"primary":"secondary",disabled:!A||N,onClick:()=>l(!0),className:"flex-1",children:[N?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(zl,{className:"w-4 h-4"}),"On"]}),s.jsxs(Ee,{size:"sm",variant:w?"secondary":"primary",disabled:!A||N,onClick:()=>u(!0),className:"flex-1",children:[N?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(E2,{className:"w-4 h-4"}),"Off"]})]}),s.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Pd,{className:"w-4 h-4"}),"Automation Settings"]}),s.jsx("span",{children:d?"-":"+"})]}),d&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(S2,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:D=>y.mutate({show_in_switchbar:D.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:D=>y.mutate({enabled:D.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:D=>y.mutate({auto_on:D.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:D=>y.mutate({auto_off:D.target.checked}),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>y.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:[s.jsx(tr,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>y.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:[s.jsx(N2,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:D=>y.mutate({off_delay_minutes:parseInt(D.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"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:D=>y.mutate({off_temp_threshold:parseInt(D.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(OR,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(ln,{className:"w-4 h-4"})})]})]})]})}),i&&s.jsx(Un,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{E.mutate(),a(!1)},onCancel:()=>a(!1)}),o&&s.jsx(Un,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{x.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&s.jsx(Un,{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:()=>{x.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function FWe({plug:t,onClose:e}){const n=an(),r=!!t,[i,a]=S.useState(t?.plug_type||"tasmota"),[o,l]=S.useState(t?.name||""),[c,u]=S.useState(t?.ip_address||""),[d,f]=S.useState(t?.username||""),[p,g]=S.useState(t?.password||""),[b,v]=S.useState(t?.ha_entity_id||""),[x,y]=S.useState(t?.printer_id||null),[E,w]=S.useState(null),[A,N]=S.useState(null),[C,T]=S.useState(t?.power_alert_enabled||!1),[D,k]=S.useState(t?.power_alert_high?.toString()||""),[P,z]=S.useState(t?.power_alert_low?.toString()||""),[L,X]=S.useState(t?.schedule_enabled||!1),[R,Y]=S.useState(t?.schedule_on_time||""),[J,G]=S.useState(t?.schedule_off_time||""),[W,ee]=S.useState(t?.show_in_switchbar||!1),[K,F]=S.useState(!1),[q,ne]=S.useState({scanned:0,total:0}),[re,se]=S.useState([]),de=S.useRef(null),{data:pe}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:Ce}=lt({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs}),{data:oe}=lt({queryKey:["settings"],queryFn:be.getSettings}),ae=!!(oe?.ha_enabled&&oe?.ha_url&&oe?.ha_token),{data:ge,isLoading:ue}=lt({queryKey:["ha-entities"],queryFn:be.getHAEntities,enabled:i==="homeassistant"&&ae,retry:!1,staleTime:0});S.useEffect(()=>{const fe=H=>{H.key==="Escape"&&e()};return window.addEventListener("keydown",fe),()=>{window.removeEventListener("keydown",fe),de.current&&clearInterval(de.current)}},[e]);const Le=async()=>{F(!0),se([]),ne({scanned:0,total:0}),N(null);try{await be.startTasmotaScan();const fe=async()=>{try{const H=await be.getTasmotaScanStatus();ne({scanned:H.scanned,total:H.total});const I=await be.getDiscoveredTasmotaDevices();se(I),H.running||(F(!1),de.current&&(clearInterval(de.current),de.current=null))}catch(H){console.error("Polling error:",H)}};await fe(),de.current=setInterval(fe,500)}catch(fe){F(!1);const H=fe instanceof Error?fe.message:typeof fe=="string"?fe:JSON.stringify(fe);N(H||"Failed to start scan")}},V=async()=>{try{await be.stopTasmotaScan()}catch{}F(!1),de.current&&(clearInterval(de.current),de.current=null)},$=fe=>{u(fe.ip_address),l(fe.name),w(null)},Z=ht({mutationFn:()=>be.testSmartPlugConnection(c,d||null,p||null),onSuccess:fe=>{w(fe),N(null),!o&&fe.device_name&&l(fe.device_name)},onError:fe=>{w(null),N(fe.message)}}),B=ht({mutationFn:fe=>be.createSmartPlug(fe),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:fe=>{N(fe.message)}}),U=ht({mutationFn:fe=>be.updateSmartPlug(t.id,fe),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),e()},onError:fe=>{N(fe.message)}}),Q=pe?.filter(fe=>!Ce?.some(I=>I.printer_id===fe.id&&I.id!==t?.id)),Me=fe=>{if(fe.preventDefault(),N(null),!o.trim()){N("Name is required");return}if(i==="tasmota"&&!c.trim()){N("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!b){N("Entity is required for Home Assistant plugs");return}const H={name:o.trim(),plug_type:i,ip_address:i==="tasmota"?c.trim():null,ha_entity_id:i==="homeassistant"?b:null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&p.trim()||null,printer_id:x,power_alert_enabled:C,power_alert_high:D?parseFloat(D):null,power_alert_low:P?parseFloat(P):null,schedule_enabled:L,schedule_on_time:R||null,schedule_off_time:J||null,show_in_switchbar:W};r?U.mutate(H):B.mutate(H)},Te=B.isPending||U.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:fe=>fe.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Me,className:"p-6 space-y-4 overflow-y-auto",children:[A&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:A}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("tasmota"),w(null),N(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="tasmota"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(Ls,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("homeassistant"),w(null),N(null)},className:`flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg font-medium transition-colors ${i==="homeassistant"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary"}`,children:[s.jsx(w2,{className:"w-4 h-4"}),"Home Assistant"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[K?s.jsxs(Ee,{type:"button",variant:"secondary",onClick:V,className:"w-full",children:[s.jsx(zt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Ee,{type:"button",variant:"primary",onClick:Le,className:"w-full",children:[s.jsx(Eo,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),K&&q.total>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[s.jsx("span",{children:"Scanning network..."}),s.jsxs("span",{children:[q.scanned," / ",q.total]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${q.scanned/q.total*100}%`}})})]}),re.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",re.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:re.map(fe=>s.jsxs("button",{type:"button",onClick:()=>$(fe),className:"w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ls,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:fe.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:fe.ip_address})]})]}),fe.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${fe.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(zl,{className:"w-3 h-3"}),fe.state]})]},fe.ip_address))})]}),!K&&re.length===0&&q.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&s.jsxs("div",{className:"space-y-3",children:[!ae&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:["Home Assistant is not configured. Set it up in"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),s.jsx("select",{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 opacity-50",children:s.jsx("option",{children:"Choose an entity..."})})]})]}),ae&&s.jsxs(s.Fragment,{children:[ue&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(ft,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),ge&&ge.length===0&&s.jsx("div",{className:"p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400",children:"No switch/light entities found in Home Assistant"}),ge&&ge.length>0&&(()=>{const fe=Ce?.filter(I=>I.ha_entity_id&&I.id!==t?.id).map(I=>I.ha_entity_id)||[],H=ge.filter(I=>!fe.includes(I.entity_id));return s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("select",{value:b,onChange:I=>{v(I.target.value);const ce=ge?.find(we=>we.entity_id===I.target.value);ce&&!o&&l(ce.friendly_name)},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:[s.jsx("option",{value:"",children:"Choose an entity..."}),H.map(I=>s.jsxs("option",{value:I.entity_id,children:[I.friendly_name," (",I.entity_id,") - ",I.state]},I.entity_id))]}),fe.length>0&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[fe.length," entity(s) already configured"]})]})})(),b&&ge&&s.jsxs("div",{className:"p-3 bg-bambu-green/20 border border-bambu-green/50 rounded-lg text-sm text-bambu-green flex items-center gap-2",children:[s.jsx(pr,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Entity selected"}),s.jsxs("p",{className:"text-xs opacity-80",children:[ge.find(fe=>fe.entity_id===b)?.friendly_name," - ",ge.find(fe=>fe.entity_id===b)?.state]})]})]})]})]}),i==="tasmota"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:c,onChange:fe=>{u(fe.target.value),w(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"}),s.jsxs(Ee,{type:"button",variant:"secondary",onClick:()=>Z.mutate(),disabled:!c.trim()||Z.isPending,children:[Z.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Np,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&E&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${E.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:E.success?s.jsxs(s.Fragment,{children:[s.jsx(pr,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Connected!"}),s.jsxs("p",{className:"text-sm opacity-80",children:[E.device_name&&`Device: ${E.device_name} - `,"State: ",E.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(H0,{className:"w-5 h-5"}),s.jsx("span",{children:"Connection failed"})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:fe=>l(fe.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"})]}),i==="tasmota"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),s.jsx("input",{type:"text",value:d,onChange:fe=>f(fe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:p,onChange:fe=>g(fe.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"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:x??"",onChange:fe=>y(fe.target.value?Number(fe.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:[s.jsx("option",{value:"",children:"No printer (manual control only)"}),Q?.map(fe=>s.jsx("option",{value:fe.id,children:fe.name},fe.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Kh,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:C,onChange:fe=>T(fe.target.checked),className:"sr-only peer"}),s.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"})]})]}),C&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),s.jsx("input",{type:"number",value:D,onChange:fe=>k(fe.target.value),placeholder:"e.g. 200",min:"0",max:"5000",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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),s.jsx("input",{type:"number",value:P,onChange:fe=>z(fe.target.value),placeholder:"e.g. 10",min:"0",max:"5000",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"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Get notified when power consumption crosses these thresholds. Leave empty to disable that direction."})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tr,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:L,onChange:fe=>X(fe.target.checked),className:"sr-only peer"}),s.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"})]})]}),L&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),s.jsx("input",{type:"time",value:R,onChange:fe=>Y(fe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),s.jsx("input",{type:"time",value:J,onChange:fe=>G(fe.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"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Automatically turn the plug on/off at these times daily. Leave empty to skip that action."})]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(S2,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:W,onChange:fe=>ee(fe.target.checked),className:"sr-only peer"}),s.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"})]})]})}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{type:"submit",disabled:Te,className:"flex-1",children:[Te?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Rs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function $n({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return s.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:n,onClick:r,className:`relative inline-flex w-11 h-7 md:w-9 md: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:s.jsx("span",{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${t?"translate-x-4":"translate-x-0"}`})})}const UWe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function zWe({provider:t,onEdit:e}){const n=an(),[r,i]=S.useState(!1),[a,o]=S.useState(!1),[l,c]=S.useState(null),{data:u}=lt({queryKey:["printers"],queryFn:be.getPrinters}),d=u?.find(v=>v.id===t.printer_id),f=ht({mutationFn:v=>be.updateNotificationProvider(t.id,v),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=ht({mutationFn:()=>be.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),g=ht({mutationFn:()=>be.testNotificationProvider(t.id),onSuccess:v=>{c(v),n.invalidateQueries({queryKey:["notification-providers"]})},onError:v=>{c({success:!1,message:v.message})}}),b=v=>v||"";return s.jsxs(s.Fragment,{children:[s.jsx(_t,{className:"relative",children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:s.jsx(Kh,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:UWe[t.provider_type]||t.provider_type})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&s.jsxs("span",{className:"text-xs text-bambu-green hidden sm:inline",children:["Last: ",Hp(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(fi(t.last_error_at)?.getTime()||0)>(fi(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-red-400",title:t.last_error,children:"Error"}),s.jsx($n,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded",children:"Start"}),t.on_print_complete&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&s.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&s.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&s.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded",children:"Low Filament"}),t.on_maintenance_due&&s.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded",children:"Maintenance"}),t.on_ams_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded",children:"AMS Humidity"}),t.on_ams_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded",children:"AMS Temp"}),t.on_ams_ht_humidity_high&&s.jsx("span",{className:"px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded",children:"AMS-HT Humidity"}),t.on_ams_ht_temperature_high&&s.jsx("span",{className:"px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded",children:"AMS-HT Temp"}),t.quiet_hours_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[s.jsx(aw,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[s.jsx(qr,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Ee,{size:"sm",variant:"secondary",disabled:g.isPending,onClick:()=>{c(null),g.mutate()},className:"w-full",children:[g.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(LR,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&s.jsxs("div",{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${l.success?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[l.success?s.jsx(pr,{className:"w-4 h-4"}):s.jsx(Wi,{className:"w-4 h-4"}),s.jsx("span",{children:l.message})]}),s.jsxs("button",{onClick:()=>o(!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:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Pd,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(Xc,{className:"w-4 h-4"}):s.jsx(Qi,{className:"w-4 h-4"})]}),a&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),s.jsx($n,{checked:t.enabled,onChange:v=>f.mutate({enabled:v})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Started"}),s.jsx($n,{checked:t.on_print_start,onChange:v=>f.mutate({on_print_start:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx($n,{checked:t.on_print_complete,onChange:v=>f.mutate({on_print_complete:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx($n,{checked:t.on_print_failed,onChange:v=>f.mutate({on_print_failed:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx($n,{checked:t.on_print_stopped,onChange:v=>f.mutate({on_print_stopped:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),s.jsx($n,{checked:t.on_print_progress,onChange:v=>f.mutate({on_print_progress:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),s.jsx($n,{checked:t.on_printer_offline,onChange:v=>f.mutate({on_printer_offline:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx($n,{checked:t.on_printer_error,onChange:v=>f.mutate({on_printer_error:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx($n,{checked:t.on_filament_low,onChange:v=>f.mutate({on_filament_low:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),s.jsx($n,{checked:t.on_maintenance_due??!1,onChange:v=>f.mutate({on_maintenance_due:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_humidity_high??!1,onChange:v=>f.mutate({on_ams_humidity_high:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_temperature_high??!1,onChange:v=>f.mutate({on_ams_temperature_high:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_ht_humidity_high??!1,onChange:v=>f.mutate({on_ams_ht_humidity_high:v})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),s.jsx($n,{checked:t.on_ams_ht_temperature_high??!1,onChange:v=>f.mutate({on_ams_ht_temperature_high:v})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(aw,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx($n,{checked:t.quiet_hours_enabled,onChange:v=>f.mutate({quiet_hours_enabled:v})})]}),t.quiet_hours_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tr,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[b(t.quiet_hours_start)||"22:00"," - ",b(t.quiet_hours_end)||"07:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx($n,{checked:t.daily_digest_enabled,onChange:v=>f.mutate({daily_digest_enabled:v})})]}),t.daily_digest_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tr,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",b(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(OR,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(ln,{className:"w-4 h-4"})})]})]})]})}),r&&s.jsx(Un,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{p.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const mG=[{value:"email",label:"Email",description:"SMTP email notifications"},{value:"telegram",label:"Telegram",description:"Notifications via Telegram bot"},{value:"discord",label:"Discord",description:"Send to Discord channel via webhook"},{value:"ntfy",label:"ntfy",description:"Free, self-hostable push notifications"},{value:"pushover",label:"Pushover",description:"Simple, reliable push notifications"},{value:"callmebot",label:"CallMeBot/WhatsApp",description:"Free WhatsApp notifications via CallMeBot"},{value:"webhook",label:"Webhook",description:"Generic HTTP POST to any URL"}];function BWe({provider:t,onClose:e}){const n=an(),r=!!t,[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.provider_type||"email"),[c,u]=S.useState(t?.printer_id||null),[d,f]=S.useState(t?.quiet_hours_enabled||!1),[p,g]=S.useState(t?.quiet_hours_start||"22:00"),[b,v]=S.useState(t?.quiet_hours_end||"07:00"),[x,y]=S.useState(t?.daily_digest_enabled||!1),[E,w]=S.useState(t?.daily_digest_time||"08:00"),[A,N]=S.useState(t?.on_print_start??!1),[C,T]=S.useState(t?.on_print_complete??!0),[D,k]=S.useState(t?.on_print_failed??!0),[P,z]=S.useState(t?.on_print_stopped??!0),[L,X]=S.useState(t?.on_print_progress??!1),[R,Y]=S.useState(t?.on_printer_offline??!1),[J,G]=S.useState(t?.on_printer_error??!1),[W,ee]=S.useState(t?.on_filament_low??!1),[K,F]=S.useState(t?.on_maintenance_due??!1),[q,ne]=S.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([B,U])=>[B,String(U)])):{}),[re,se]=S.useState(null),[de,pe]=S.useState(null),{data:Ce}=lt({queryKey:["printers"],queryFn:be.getPrinters});S.useEffect(()=>{const B=U=>{U.key==="Escape"&&e()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[e]);const oe=ht({mutationFn:()=>be.testNotificationConfig({provider_type:o,config:q}),onSuccess:B=>{se(B),pe(null)},onError:B=>{se({success:!1,message:B.message})}}),ae=ht({mutationFn:B=>be.createNotificationProvider(B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{pe(B.message)}}),ge=ht({mutationFn:B=>be.updateNotificationProvider(t.id,B),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:B=>{pe(B.message)}}),ue=B=>{if(B.preventDefault(),pe(null),!i.trim()){pe("Name is required");return}const U=$(o);for(const Me of U)if(!q[Me.key]?.trim()){pe(`${Me.label} is required`);return}const Q={name:i.trim(),provider_type:o,config:q,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?b:null,daily_digest_enabled:x,daily_digest_time:x?E:null,on_print_start:A,on_print_complete:C,on_print_failed:D,on_print_stopped:P,on_print_progress:L,on_printer_offline:R,on_printer_error:J,on_filament_low:W,on_maintenance_due:K};r?ge.mutate(Q):ae.mutate(Q)},Le=ae.isPending||ge.isPending,V=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-bambuddy",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}];case"discord":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://discord.com/api/webhooks/...",type:"text",required:!0}];case"webhook":return[{key:"webhook_url",label:"Webhook URL",placeholder:"https://example.com/webhook",type:"text",required:!0},{key:"auth_header",label:"Authorization",placeholder:"Bearer token (optional)",type:"password",required:!1},{key:"field_title",label:"Title Field Name",placeholder:"title",type:"text",required:!1},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1}];default:return[]}},$=B=>V(B).filter(U=>U.required),Z=V(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto",onClick:B=>B.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ue,className:"p-6 space-y-4",children:[de&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:de}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:B=>{l(B.target.value),ne({}),se(null)},disabled:r,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:mG.map(B=>s.jsx("option",{value:B.value,children:B.label},B.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:mG.find(B=>B.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),Z.map(B=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[B.label," ",B.required&&"*"]}),B.type==="select"&&B.options?s.jsx("select",{value:q[B.key]||B.options[0]?.value||"",onChange:U=>{ne({...q,[B.key]:U.target.value}),se(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(U=>s.jsx("option",{value:U.value,children:U.label},U.value))}):s.jsx("input",{type:B.type,value:q[B.key]||"",onChange:U=>{ne({...q,[B.key]:U.target.value}),se(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))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Ee,{type:"button",variant:"secondary",onClick:()=>{se(null),oe.mutate()},disabled:oe.isPending||!q[$(o)[0]?.key],className:"flex-1",children:[oe.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(LR,{className:"w-4 h-4"}),"Test Configuration"]})}),re&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${re.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:re.success?s.jsxs(s.Fragment,{children:[s.jsx(pr,{className:"w-5 h-5"}),s.jsx("span",{children:re.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(Wi,{className:"w-5 h-5"}),s.jsx("span",{children:re.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.jsxs("select",{value:c??"",onChange:B=>u(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:[s.jsx("option",{value:"",children:"All printers"}),Ce?.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx($n,{checked:d,onChange:f})]}),d&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),s.jsx("input",{type:"time",value:p,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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.jsx("input",{type:"time",value:b,onChange:B=>v(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"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),s.jsx($n,{checked:x,onChange:y})]}),x&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),s.jsx("input",{type:"time",value:E,onChange:B=>w(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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Start"}),s.jsx($n,{checked:A,onChange:N})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx($n,{checked:C,onChange:T})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx($n,{checked:D,onChange:k})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx($n,{checked:P,onChange:z})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx($n,{checked:L,onChange:X})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx($n,{checked:R,onChange:Y})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx($n,{checked:J,onChange:G})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx($n,{checked:W,onChange:ee})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx($n,{checked:K,onChange:F})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{type:"submit",disabled:Le,className:"flex-1",children:[Le?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Rs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function $We({template:t,onClose:e}){const n=an(),r=S.useRef(null),[i,a]=S.useState(t.title_template),[o,l]=S.useState(t.body_template),[c,u]=S.useState(null),[d,f]=S.useState(!0),{data:p}=lt({queryKey:["template-variables"],queryFn:be.getTemplateVariables}),g=p?.find(N=>N.event_type===t.event_type),{data:b,isLoading:v}=lt({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>be.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});S.useEffect(()=>{const N=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const x=ht({mutationFn:N=>be.updateNotificationTemplate(t.id,N),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:N=>{u(N.message)}}),y=ht({mutationFn:()=>be.resetNotificationTemplate(t.id),onSuccess:N=>{a(N.title_template),l(N.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:N=>{u(N.message)}}),E=N=>{if(N.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}x.mutate({title_template:i,body_template:o})},w=N=>{const C=r.current;if(!C)return;const T=C.selectionStart,D=C.selectionEnd,k=o,P=k.substring(0,T),z=k.substring(D),L=P+`{${N}}`+z;l(L),setTimeout(()=>{C.focus();const X=T+N.length+2;C.setSelectionRange(X,X)},0)},A=i!==t.title_template||o!==t.body_template;return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:E,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:N=>a(N.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green",placeholder:"Notification title..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),s.jsx("textarea",{ref:r,value:o,onChange:N=>l(N.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),g&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:g.variables.map(N=>s.jsxs("button",{type:"button",onClick:()=>w(N),className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(dr,{className:"w-3 h-3"}),N]},N))}),s.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(mf,{className:"w-4 h-4"}),"Live Preview"]}),s.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&s.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:v?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):b?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),s.jsx("div",{className:"text-white font-medium",children:b.title})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),s.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:b.body})]})]}):s.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[s.jsxs(Ee,{type:"button",variant:"ghost",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-orange-400 hover:text-orange-300",children:[y.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(If,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Ee,{onClick:E,disabled:x.isPending||!A,children:[x.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Rs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const HWe={print_start:"Print Started",print_complete:"Print Complete",print_failed:"Print Failed",print_stopped:"Print Stopped",print_progress:"Progress",printer_offline:"Printer Offline",printer_error:"Printer Error",filament_low:"Low Filament",maintenance_due:"Maintenance Due",test:"Test"},VWe={print_start:"text-blue-400",print_complete:"text-bambu-green",print_failed:"text-red-400",print_stopped:"text-orange-400",print_progress:"text-yellow-400",printer_offline:"text-gray-400",printer_error:"text-rose-400",filament_low:"text-cyan-400",maintenance_due:"text-purple-400",test:"text-bambu-gray"};function GWe({onClose:t}){const e=an(),{showToast:n}=Wn(),[r,i]=S.useState(7),[a,o]=S.useState(null),[l,c]=S.useState(!1),{data:u}=lt({queryKey:["settings"],queryFn:be.getSettings}),d=u?.time_format||"system",{data:f,isLoading:p,refetch:g,isRefetching:b}=lt({queryKey:["notification-logs",r,l],queryFn:()=>be.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:v}=lt({queryKey:["notification-log-stats",r],queryFn:()=>be.getNotificationLogStats(r)}),x=ht({mutationFn:()=>be.clearNotificationLogs(30),onSuccess:E=>{n(E.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:E=>{n(`Failed to clear logs: ${E.message}`,"error")}}),y=E=>{const w=fi(E);if(!w)return"";const N=new Date().getTime()-w.getTime();return N<6e4?"Just now":N<36e5?`${Math.floor(N/6e4)}m ago`:N<864e5?`${Math.floor(N/36e5)}h ago`:w.toLocaleDateString()+" "+Che(w,d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(iw,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),v&&s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:s.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[s.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",s.jsx("span",{className:"text-white font-medium",children:v.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(pr,{className:"w-4 h-4"}),v.success_count," sent"]}),v.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Wi,{className:"w-4 h-4"}),v.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.jsxs("select",{value:r,onChange:E=>i(Number(E.target.value)),className:"px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:l,onChange:E=>c(E.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),"Show failed only"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>g(),disabled:b,children:[b?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Rr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>x.mutate(),disabled:x.isPending,className:"text-red-400 hover:text-red-300",children:[x.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(ln,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(E=>s.jsx(WWe,{log:E,isExpanded:a===E.id,onToggle:()=>o(a===E.id?null:E.id),formatDate:y,formatFullDate:w=>Vp(w,d)},E.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(iw,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function WWe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return s.jsxs("div",{className:`border rounded-lg overflow-hidden transition-colors ${t.success?"border-bambu-dark-tertiary bg-bambu-dark/30":"border-red-500/30 bg-red-500/5"}`,children:[s.jsxs("button",{className:"w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors",onClick:n,children:[t.success?s.jsx(pr,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(Wi,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${VWe[t.event_type]||"text-bambu-gray"}`,children:HWe[t.event_type]||t.event_type}),s.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),s.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?s.jsx(Xc,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Qi,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&s.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),s.jsx("p",{className:"text-sm text-white",children:t.title})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),s.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),s.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[s.jsxs("span",{children:["Provider: ",t.provider_type]}),s.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}const _1=[{id:"settings",labelKey:"backup.categories.settings",defaultLabel:"App Settings",icon:s.jsx($0,{className:"w-4 h-4"}),default:!0,description:"Language, theme, update preferences"},{id:"notifications",labelKey:"backup.categories.notifications",defaultLabel:"Notification Providers",icon:s.jsx(Kh,{className:"w-4 h-4"}),default:!0,description:"ntfy, Pushover, Discord, etc."},{id:"templates",labelKey:"backup.categories.templates",defaultLabel:"Notification Templates",icon:s.jsx(Ua,{className:"w-4 h-4"}),default:!0,description:"Custom message templates"},{id:"smart_plugs",labelKey:"backup.categories.smartPlugs",defaultLabel:"Smart Plugs",icon:s.jsx(Ls,{className:"w-4 h-4"}),default:!0,description:"Tasmota plug configurations"},{id:"external_links",labelKey:"backup.categories.externalLinks",defaultLabel:"External Links",icon:s.jsx(B0,{className:"w-4 h-4"}),default:!0,description:"Sidebar links to external services"},{id:"printers",labelKey:"backup.categories.printers",defaultLabel:"Printers",icon:s.jsx(Qr,{className:"w-4 h-4"}),default:!1,description:"Printer info (access codes excluded)"},{id:"filaments",labelKey:"backup.categories.filaments",defaultLabel:"Filament Inventory",icon:s.jsx(RR,{className:"w-4 h-4"}),default:!1,description:"Filament types and costs"},{id:"maintenance",labelKey:"backup.categories.maintenance",defaultLabel:"Maintenance Types",icon:s.jsx(Rd,{className:"w-4 h-4"}),default:!1,description:"Custom maintenance schedules"},{id:"archives",labelKey:"backup.categories.archives",defaultLabel:"Print Archives",icon:s.jsx(Os,{className:"w-4 h-4"}),default:!1,description:"All print data + files (3MF, thumbnails, photos)"},{id:"projects",labelKey:"backup.categories.projects",defaultLabel:"Projects",icon:s.jsx(ma,{className:"w-4 h-4"}),default:!1,description:"Projects, BOM items, and attachments"},{id:"pending_uploads",labelKey:"backup.categories.pendingUploads",defaultLabel:"Pending Uploads",icon:s.jsx(xi,{className:"w-4 h-4"}),default:!1,description:"Virtual printer uploads awaiting review"},{id:"api_keys",labelKey:"backup.categories.apiKeys",defaultLabel:"API Keys",icon:s.jsx(Uh,{className:"w-4 h-4"}),default:!1,description:"Webhook API keys (new keys generated on import)"}];function qWe({onClose:t,onExport:e}){const{t:n}=xg(),[r,i]=S.useState(()=>{const b={};return _1.forEach(v=>{b[v.id]=v.default}),b}),[a,o]=S.useState(!1),[l,c]=S.useState(!1);S.useEffect(()=>{const b=v=>{v.key==="Escape"&&t()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t]);const u=b=>{i(v=>({...v,[b]:!v[b]}))},d=()=>{const b={};_1.forEach(v=>{b[v.id]=!0}),i(b)},f=()=>{const b={};_1.forEach(v=>{b[v.id]=!1}),i(b)},p=Object.values(r).filter(Boolean).length,g=async()=>{c(!0);try{await e({...r,access_codes:a&&r.printers})}finally{c(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:l?void 0:t,children:s.jsx(_t,{className:"w-full max-w-lg",onClick:b=>b.stopPropagation(),children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:s.jsx(Yr,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("backup.exportTitle",{defaultValue:"Export Backup"})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.selectCategories",{defaultValue:"Select data to include"})})]})]}),s.jsx("button",{onClick:t,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex gap-2 px-4 pt-4",children:[s.jsx("button",{onClick:d,disabled:l,className:"text-sm text-bambu-green hover:text-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectAll",{defaultValue:"Select All"})}),s.jsx("span",{className:"text-bambu-gray",children:"|"}),s.jsx("button",{onClick:f,disabled:l,className:"text-sm text-bambu-gray hover:text-white disabled:opacity-50 disabled:cursor-not-allowed",children:n("common.selectNone",{defaultValue:"Select None"})})]}),s.jsx("div",{className:`p-4 space-y-2 max-h-[400px] overflow-y-auto ${l?"opacity-50 pointer-events-none":""}`,children:_1.map(b=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-colors ${r[b.id]?"bg-bambu-green/10 border border-bambu-green/30":"bg-bambu-dark hover:bg-bambu-dark-tertiary border border-transparent"}`,children:[s.jsx("input",{type:"checkbox",checked:r[b.id],onChange:()=>u(b.id),disabled:l,className:"w-4 h-4 rounded border-bambu-gray bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0"}),s.jsx("div",{className:`${r[b.id]?"text-bambu-green":"text-bambu-gray"}`,children:b.icon}),s.jsxs("div",{className:"flex-1",children:[s.jsx("div",{className:"text-white text-sm font-medium",children:n(b.labelKey,{defaultValue:b.defaultLabel})}),s.jsx("div",{className:"text-xs text-bambu-gray",children:b.description})]})]},b.id))}),r.archives&&s.jsx("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Os,{className:"w-4 h-4 text-yellow-500 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200 dark:text-yellow-200 text-yellow-700",children:[s.jsx("span",{className:"font-medium",children:"ZIP file will be created."}),s.jsx("span",{className:"text-yellow-600 dark:text-yellow-200/70",children:" Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file."})]})]})}),r.printers&&s.jsxs("div",{className:"mx-4 mb-2 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Uh,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:"Include Access Codes"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"For transferring to another machine"})]})]}),s.jsx($n,{checked:a,onChange:o})]}),a&&s.jsx("div",{className:"mt-2 p-2 rounded bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[s.jsx(yn,{className:"w-3 h-3 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("span",{className:"text-orange-700 dark:text-orange-200",children:"Access codes will be included in plain text. Keep this backup file secure!"})]})})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("backup.selectedCount",{count:p,defaultValue:`${p} categories selected`})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ee,{variant:"secondary",onClick:t,disabled:l,children:n("common.cancel",{defaultValue:"Cancel"})}),s.jsx(Ee,{onClick:g,disabled:p===0||l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50 disabled:cursor-not-allowed min-w-[100px]",children:l?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),n("backup.exporting",{defaultValue:"Exporting..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(Yr,{className:"w-4 h-4 mr-2"}),n("backup.export",{defaultValue:"Export"})]})})]})]})]})})})}const pG={settings:"Settings",notification_providers:"Notification Providers",notification_templates:"Notification Templates",smart_plugs:"Smart Plugs",printers:"Printers",filaments:"Filaments",maintenance_types:"Maintenance Types",archives:"Archives",projects:"Projects",pending_uploads:"Pending Uploads",external_links:"External Links",api_keys:"API Keys"};function KWe({onClose:t,onRestore:e,onSuccess:n}){const[r,i]=S.useState("options"),[a,o]=S.useState(!1),[l,c]=S.useState(null),[u,d]=S.useState(null),[f,p]=S.useState(new Set),g=S.useRef(null);S.useEffect(()=>{const A=N=>{N.key==="Escape"&&r!=="restoring"&&(r==="result"&&u?.success&&n(),t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,n,r,u]);const b=A=>{const N=A.target.files?.[0];N&&c(N)},v=async()=>{if(l){i("restoring");try{const A=await e(l,a);d(A),i("result")}catch{d({success:!1,message:"Failed to restore backup. Please check the file format."}),i("result")}}},x=()=>{u?.success&&n(),t()},y=A=>{p(N=>{const C=new Set(N);return C.has(A)?C.delete(A):C.add(A),C})},E=u?.restored?Object.values(u.restored).reduce((A,N)=>A+N,0)+(u.files_restored||0):0,w=u?.total_skipped||0;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onMouseDown:A=>{A.target===A.currentTarget&&r!=="restoring"&&t()},children:s.jsx(_t,{className:"w-full max-w-lg",children:s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-full ${r==="result"&&u?.success?"bg-bambu-green/20 text-bambu-green":r==="result"&&!u?.success?"bg-red-500/20 text-red-500":"bg-blue-500/20 text-blue-500"}`,children:r==="result"&&u?.success?s.jsx(pr,{className:"w-5 h-5"}):r==="result"&&!u?.success?s.jsx(yn,{className:"w-5 h-5"}):s.jsx(xi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:[r==="options"&&"Restore Backup",r==="restoring"&&"Restoring...",r==="result"&&(u?.success?"Restore Complete":"Restore Failed")]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[r==="options"&&"Import settings from a backup file",r==="restoring"&&"Please wait while your data is being restored",r==="result"&&u?.message]})]})]}),r!=="restoring"&&s.jsx("button",{onClick:x,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),r==="options"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("input",{ref:g,type:"file",accept:".json,.zip",className:"hidden",onChange:b}),s.jsx("button",{type:"button",onClick:()=>g.current?.click(),className:`w-full p-4 border-2 border-dashed rounded-lg transition-colors ${l?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:l?s.jsxs("div",{className:"flex items-center justify-center gap-2 text-bambu-green",children:[s.jsx(pr,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:l.name})]}):s.jsxs("div",{className:"flex flex-col items-center gap-2 text-bambu-gray",children:[s.jsx(xi,{className:"w-8 h-8"}),s.jsx("span",{children:"Click to select backup file (.json or .zip)"})]})})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(yn,{className:"w-4 h-4 text-blue-500 dark:text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-blue-700 dark:text-blue-200",children:[s.jsx("p",{className:"font-medium mb-1",children:"How duplicate handling works:"}),s.jsxs("ul",{className:"text-blue-600 dark:text-blue-200/80 space-y-1 text-xs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"Printers"})," - matched by serial number"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Smart Plugs"})," - matched by IP address"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Notification Providers"})," - matched by name"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Filaments"})," - matched by name + type + brand"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Archives"})," - matched by content hash (always skipped)"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Pending Uploads"})," - matched by filename"]}),s.jsxs("li",{children:[s.jsx("strong",{children:"Settings & Templates"})," - always overwritten"]})]})]})]})}),s.jsx("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-white font-medium flex items-center gap-2",children:[a?s.jsx(Rr,{className:"w-4 h-4 text-orange-400"}):s.jsx(sw,{className:"w-4 h-4 text-bambu-gray"}),a?"Replace existing data":"Keep existing data"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a?"Overwrite items that already exist with backup data":"Only restore items that don't already exist"})]}),s.jsx($n,{checked:a,onChange:o})]})}),a&&s.jsx("div",{className:"p-3 rounded-lg bg-orange-500/10 border border-orange-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(yn,{className:"w-4 h-4 text-orange-500 dark:text-orange-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-orange-700 dark:text-orange-200",children:[s.jsx("span",{className:"font-medium",children:"Caution:"})," Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security."]})]})})]}),s.jsxs("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),s.jsxs(Ee,{type:"button",onClick:v,disabled:!l,className:"bg-bambu-green hover:bg-bambu-green-dark disabled:opacity-50",children:[s.jsx(xi,{className:"w-4 h-4 mr-2"}),"Restore"]})]})]}),r==="restoring"&&s.jsxs("div",{className:"p-8 flex flex-col items-center gap-4",children:[s.jsx(ft,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-bambu-gray",children:"Processing backup file..."})]}),r==="result"&&u&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 space-y-4 max-h-[400px] overflow-y-auto",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-green/10 border border-bambu-green/30",children:[s.jsx("div",{className:"text-2xl font-bold text-bambu-green",children:E}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Restored"})]}),s.jsxs("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:[s.jsx("div",{className:"text-2xl font-bold text-yellow-500",children:w}),s.jsx("div",{className:"text-sm text-bambu-gray",children:"Items Skipped"})]})]}),u.restored&&Object.entries(u.restored).some(([,A])=>A>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(pr,{className:"w-4 h-4 text-bambu-green"}),"Restored"]}),s.jsxs("div",{className:"space-y-1",children:[Object.entries(u.restored).filter(([,A])=>A>0).map(([A,N])=>s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:pG[A]||A}),s.jsx("span",{className:"text-bambu-green font-medium",children:N})]},A)),(u.files_restored||0)>0&&s.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded bg-bambu-dark",children:[s.jsx("span",{className:"text-white",children:"Files (3MF, thumbnails, etc.)"}),s.jsx("span",{className:"text-bambu-green font-medium",children:u.files_restored})]})]})]}),u.skipped&&Object.entries(u.skipped).some(([,A])=>A>0)&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(sw,{className:"w-4 h-4 text-yellow-500"}),"Skipped (already exist)"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(u.skipped).filter(([,A])=>A>0).map(([A,N])=>{const C=u.skipped_details?.[A]||[],T=f.has(A);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>C.length>0&&y(A),className:`w-full flex items-center justify-between text-sm p-2 rounded bg-bambu-dark ${C.length>0?"hover:bg-bambu-dark-tertiary cursor-pointer":""}`,children:[s.jsxs("span",{className:"text-white flex items-center gap-2",children:[pG[A]||A,C.length>0&&(T?s.jsx(Xc,{className:"w-3 h-3"}):s.jsx(Qi,{className:"w-3 h-3"}))]}),s.jsx("span",{className:"text-yellow-500 font-medium",children:N})]}),T&&C.length>0&&s.jsxs("div",{className:"mt-1 ml-4 p-2 rounded bg-bambu-dark-tertiary text-xs text-bambu-gray space-y-1",children:[C.slice(0,10).map((D,k)=>s.jsx("div",{children:D},k)),C.length>10&&s.jsxs("div",{className:"text-bambu-gray/60",children:["...and ",C.length-10," more"]})]})]},A)})})]}),u.new_api_keys&&u.new_api_keys.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(yn,{className:"w-4 h-4 text-orange-500"}),"New API Keys Generated"]}),s.jsxs("div",{className:"p-3 rounded bg-orange-500/10 border border-orange-500/30",children:[s.jsx("p",{className:"text-xs text-orange-200 mb-2",children:"These keys are only shown once. Copy them now!"}),s.jsx("div",{className:"space-y-2",children:u.new_api_keys.map((A,N)=>s.jsxs("div",{className:"p-2 rounded bg-bambu-dark",children:[s.jsx("div",{className:"text-sm text-white font-medium mb-1",children:A.name}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"text-xs text-bambu-green bg-bambu-dark-tertiary px-2 py-1 rounded font-mono flex-1 break-all",children:A.key}),s.jsx("button",{onClick:()=>navigator.clipboard.writeText(A.key),className:"text-xs text-bambu-gray hover:text-white px-2 py-1 rounded bg-bambu-dark-tertiary",children:"Copy"})]})]},N))})]})]}),E===0&&w===0&&s.jsx("div",{className:"p-4 text-center text-bambu-gray",children:"No data was found to restore in the backup file."})]}),s.jsx("div",{className:"flex items-center justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Ee,{onClick:x,children:"Close"})})]})]})})})}async function XWe(){const t=await fetch("/api/v1/settings/spoolman");if(!t.ok)throw new Error("Failed to load Spoolman settings");return t.json()}async function YWe(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 QWe(){const t=an(),[e,n]=S.useState(!1),[r,i]=S.useState(""),[a,o]=S.useState("auto"),[l,c]=S.useState(!1),[u,d]=S.useState("all"),[f,p]=S.useState(!1),[g,b]=S.useState(!1),{data:v,isLoading:x}=lt({queryKey:["spoolman-settings"],queryFn:XWe}),{data:y,isLoading:E,refetch:w}=lt({queryKey:["spoolman-status"],queryFn:be.getSpoolmanStatus,refetchInterval:3e4}),{data:A}=lt({queryKey:["printers"],queryFn:be.getPrinters});S.useEffect(()=>{v&&(n(v.spoolman_enabled==="true"),i(v.spoolman_url||""),o(v.spoolman_sync_mode||"auto"),p(!0))},[v]),S.useEffect(()=>{if(!f||!v)return;if(v.spoolman_enabled==="true"!==e||(v.spoolman_url||"")!==r||(v.spoolman_sync_mode||"auto")!==a){const Y=setTimeout(()=>{N.mutate()},500);return()=>clearTimeout(Y)}},[e,r,a,f]);const N=ht({mutationFn:()=>YWe({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),C=ht({mutationFn:be.connectSpoolman,onSuccess:()=>{w()}}),T=ht({mutationFn:be.disconnectSpoolman,onSuccess:()=>{w()}}),D=ht({mutationFn:be.syncAllPrintersAms,onSuccess:R=>{R.success}}),k=ht({mutationFn:R=>be.syncPrinterAms(R),onSuccess:R=>{R.success}}),P=()=>{u==="all"?D.mutate():k.mutate(u)},z=D.isPending||k.isPending,L=u==="all"?D.data:k.data,X=u==="all"?D.isSuccess:k.isSuccess;return x?s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Bp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Mt,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Bp,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),N.isPending&&s.jsx(ft,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(Aa,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(jd,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.jsx("p",{className:"text-blue-300/80",children:'To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:R=>n(R.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:R=>i(R.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,onChange:R=>o(R.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:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.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&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),E?s.jsx(ft,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(Aa,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(zt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:y?.connected?s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>T.mutate(),disabled:T.isPending,children:[T.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(pue,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Ee,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(El,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&s.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}),y?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("select",{value:u,onChange:R=>d(R.target.value==="all"?"all":Number(R.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:[s.jsx("option",{value:"all",children:"All Printers"}),A?.map(R=>s.jsx("option",{value:R.id,children:R.name},R.id))]}),s.jsx(Qi,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:P,disabled:z,children:[z?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Rr,{className:"w-4 h-4"}),"Sync"]})]})]}),X&&L&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${L.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:L.success?`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} successfully`:`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} with ${L.errors.length} error${L.errors.length!==1?"s":""}`}),L.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(yn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[L.skipped_count," spool",L.skipped_count!==1?"s":""," skipped"]})]}),L.skipped_count>5&&s.jsx("button",{onClick:()=>b(!g),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:g?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(g?L.skipped:L.skipped.slice(0,5)).map((R,Y)=>s.jsxs("li",{className:"flex items-center gap-2",children:[R.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${R.color}`}}),s.jsx("span",{children:R.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",R.reason]})]},Y)),!g&&L.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",L.skipped_count-5," more"]})]})]}),L.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:L.errors.map((R,Y)=>s.jsx("li",{children:R},Y))})]})]})]})]})]})}function ZWe({link:t,onClose:e}){const n=an(),{mode:r}=wg(),i=!!t,a=S.useRef(null),[o,l]=S.useState(t?.name||""),[c,u]=S.useState(t?.url||""),[d,f]=S.useState(t?.icon||"link"),[p,g]=S.useState(!!t?.custom_icon),[b,v]=S.useState(t?.custom_icon?be.getExternalLinkIconUrl(t.id):null),[x,y]=S.useState(null),[E,w]=S.useState(null);S.useEffect(()=>{const z=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[e]);const A=ht({mutationFn:async z=>{const L=await be.createExternalLink(z);return x?await be.uploadExternalLinkIcon(L.id,x):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:z=>{w(z.message)}}),N=ht({mutationFn:async z=>{let L=await be.updateExternalLink(t.id,z);return x?L=await be.uploadExternalLinkIcon(t.id,x):!p&&t?.custom_icon&&(L=await be.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:z=>{w(z.message)}}),C=z=>{const L=z.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){w("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){w("Image file must be less than 1MB");return}y(L),g(!0);const R=new FileReader;R.onload=Y=>{v(Y.target?.result)},R.readAsDataURL(L)}},T=()=>{y(null),v(null),g(!1),a.current&&(a.current.value="")},D=z=>{if(z.preventDefault(),w(null),!o.trim()){w("Name is required");return}if(!c.trim()){w("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){w("URL must start with http:// or https://");return}const L={name:o.trim(),url:c.trim(),icon:d};i?N.mutate(L):A.mutate(L)},k=A.isPending||N.isPending,P=A2(d);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:z=>z.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:p&&b?s.jsx("img",{src:b,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(P,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:D,className:"p-6 space-y-4",children:[E&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:E}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:z=>l(z.target.value),placeholder:"My Link",maxLength:50,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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),s.jsx("input",{type:"text",value:c,onChange:z=>u(z.target.value),placeholder:"https://example.com",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"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),p&&b?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("img",{src:b,alt:"Custom icon",className:`w-8 h-8 rounded border border-bambu-dark-tertiary ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}),s.jsx("button",{type:"button",onClick:T,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(ln,{className:"w-4 h-4"})})]}):s.jsxs(Ee,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(xi,{className:"w-4 h-4"}),"Upload"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!p&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(Mhe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{type:"submit",disabled:k,className:"flex-1",children:[k?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Rs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function JWe(){const t=an(),[e,n]=S.useState(!1),[r,i]=S.useState(null),[a,o]=S.useState(null),[l,c]=S.useState(null),{data:u,isLoading:d}=lt({queryKey:["external-links"],queryFn:be.getExternalLinks}),f=ht({mutationFn:E=>be.deleteExternalLink(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=ht({mutationFn:E=>be.reorderExternalLinks(E),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),g=(E,w)=>{c(w),E.dataTransfer.effectAllowed="move"},b=E=>{E.preventDefault(),E.dataTransfer.dropEffect="move"},v=(E,w)=>{if(E.preventDefault(),l===null||l===w||!u)return;const A=u.map(D=>D.id),N=A.indexOf(l),C=A.indexOf(w);if(N===-1||C===-1)return;const T=[...A];T.splice(N,1),T.splice(C,0,l),p.mutate(T),c(null)},x=E=>{o(E)},y=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(El,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Ee,{size:"sm",onClick:()=>n(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Mt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(E=>{const w=A2(E.icon);return s.jsxs("div",{draggable:!0,onDragStart:A=>g(A,E.id),onDragOver:b,onDrop:A=>v(A,E.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===E.id?"opacity-50":""}`,children:[s.jsx(Kb,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(w,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:E.name}),s.jsx(Kr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:E.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.jsx("button",{onClick:()=>i(E),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:s.jsx(Jo,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>x(E),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:s.jsx(ln,{className:"w-4 h-4"})})]})]},E.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(El,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No external links configured"}),s.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&s.jsx(ZWe,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Un,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:y,onCancel:()=>o(null)})]})}function eqe(){const t=an(),{showToast:e}=Wn(),[n,r]=S.useState(!1),[i,a]=S.useState(""),[o,l]=S.useState("immediate"),[c,u]=S.useState("3DPrinter-X1-Carbon"),[d,f]=S.useState(!1),[p,g]=S.useState(null),{data:b,isLoading:v}=lt({queryKey:["virtual-printer-settings"],queryFn:E1.getSettings,refetchInterval:1e4}),{data:x}=lt({queryKey:["virtual-printer-models"],queryFn:E1.getModels});S.useEffect(()=>{if(b){r(b.enabled);let D=b.mode==="queue"?"review":b.mode;D!=="immediate"&&D!=="review"&&D!=="print_queue"&&(D="immediate"),l(D),u(b.model)}},[b]);const y=ht({mutationFn:D=>E1.updateSettings(D),onSuccess:()=>{t.invalidateQueries({queryKey:["virtual-printer-settings"]}),e("Virtual printer settings updated"),g(null)},onError:D=>{if(e(D.message||"Failed to update settings","error"),b){r(b.enabled);const k=b.mode==="queue"?"review":b.mode;l(k==="print_queue"||k==="review"?k:"immediate"),u(b.model)}g(null)}}),E=()=>{const D=!n;if(D&&!i&&!b?.access_code_set){e("Please set an access code first","error");return}r(D),g("toggle"),y.mutate({enabled:D,access_code:i||void 0,mode:o})},w=()=>{if(!i){e("Access code cannot be empty","error");return}if(i.length!==8){e("Access code must be exactly 8 characters","error");return}g("accessCode"),y.mutate({access_code:i}),a("")},A=D=>{l(D),g("mode"),y.mutate({mode:D})},N=D=>{u(D),g("model"),y.mutate({model:D})};if(v)return s.jsx(_t,{children:s.jsx(Mt,{className:"py-8 flex justify-center",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const C=b?.status,T=C?.running||!1;return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qr,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Virtual Printer"})]}),C&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${T?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${T?"bg-green-400 animate-pulse":"bg-gray-500"}`}),T?"Running":"Stopped"]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-medium",children:"Enable Virtual Printer"}),s.jsx("div",{className:"text-sm text-bambu-gray",children:T?'Visible as "Bambuddy" in slicer discovery':"Not visible to slicers"})]}),s.jsx("button",{onClick:E,disabled:p==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${n?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${p==="toggle"?"opacity-50":""}`,children:s.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${n?"translate-x-6":""}`})})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Printer Model"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:"Select which printer model to emulate."}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:c,onChange:D=>N(D.target.value),disabled:p==="model",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white appearance-none cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed pr-10",children:x?.models&&Object.entries(x.models).sort(([,D],[,k])=>D.localeCompare(k)).map(([D,k])=>s.jsx("option",{value:D,children:k},D))}),s.jsx(Qi,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),n&&T&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(jd,{className:"w-3 h-3 inline mr-1"}),"Changing the model will restart the virtual printer"]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Access Code"}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:b?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(Aa,{className:"w-4 h-4"}),"Access code is set"]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(yn,{className:"w-4 h-4"}),"No access code set - required to enable"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:d?"text":"password",value:i,onChange:D=>a(D.target.value),placeholder:b?.access_code_set?"Enter new code to change":"Enter 8-char code",maxLength:8,className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray pr-10 font-mono"}),s.jsx("button",{onClick:()=>f(!d),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:d?s.jsx(x2,{className:"w-4 h-4"}):s.jsx(mf,{className:"w-4 h-4"})})]}),s.jsx(Ee,{onClick:w,disabled:!i||p==="accessCode",variant:"primary",children:p==="accessCode"?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):"Save"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["Must be exactly 8 characters. Used by slicers to authenticate.",i&&s.jsxs("span",{className:i.length===8?"text-green-400":"text-yellow-400",children:[" ","(",i.length,"/8)"]})]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:"Mode"}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("button",{onClick:()=>A("immediate"),disabled:p==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="immediate"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Archive"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive files immediately"})]}),s.jsxs("button",{onClick:()=>A("review"),disabled:p==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="review"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Review"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Review and tag before archiving"})]}),s.jsxs("button",{onClick:()=>A("print_queue"),disabled:p==="mode",className:`p-3 rounded-lg border text-left transition-colors ${o==="print_queue"?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[s.jsx("div",{className:"text-white font-medium",children:"Queue"}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Archive and add to print queue"})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(_t,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(yn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:"Setup Required"}),s.jsx("p",{className:"text-bambu-gray mb-3",children:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings."}),s.jsxs("a",{href:"https://wiki.bambuddy.cool/features/virtual-printer/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-4 py-2 bg-yellow-500/20 border border-yellow-500/50 rounded-md text-yellow-400 hover:bg-yellow-500/30 transition-colors",children:[s.jsx(Kr,{className:"w-4 h-4"}),"Read the setup guide before enabling"]})]})]})})}),s.jsx(_t,{children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(jd,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsx("strong",{className:"text-white",children:"How it works:"})}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:"Complete the setup guide for your platform"}),s.jsx("li",{children:"Enable the virtual printer and set an access code"}),s.jsx("li",{children:'In Bambu Studio or OrcaSlicer, go to "Add Printer"'}),s.jsx("li",{children:'The "Bambuddy" printer should appear in the discovery list'}),s.jsx("li",{children:"Connect using the access code you set"}),s.jsx("li",{children:'When you "print" to Bambuddy, the 3MF file is archived instead'})]})]})]})})}),C&&T&&s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:"Status Details"})}),s.jsx(Mt,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Printer Name"}),s.jsx("div",{className:"text-white",children:C.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Model"}),s.jsx("div",{className:"text-white",children:C.model_name||C.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Serial Number"}),s.jsx("div",{className:"text-white font-mono",children:C.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Mode"}),s.jsx("div",{className:"text-white capitalize",children:C.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:"Pending Files"}),s.jsx("div",{className:"text-white",children:C.pending_files})]})]})})]})]})]})}const tqe={get:"bg-blue-500/20 text-blue-400 border-blue-500/30",post:"bg-green-500/20 text-green-400 border-green-500/30",put:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",patch:"bg-orange-500/20 text-orange-400 border-orange-500/30",delete:"bg-red-500/20 text-red-400 border-red-500/30"};function nqe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function xb(t,e,n=0){if(n>5)return"...";if(e.$ref)return xb(t,nqe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=xb(t,i,n+1);typeof a=="object"&&a!==null&&Object.assign(r,a)}return r}if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;switch(e.type){case"string":return e.enum?e.enum[0]:"string";case"integer":case"number":return 0;case"boolean":return!1;case"array":return e.items?[xb(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=xb(t,a,n+1);return r}return{};default:return null}}function rqe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=S.useState(!1),[l,c]=S.useState({}),[u,d]=S.useState(""),[f,p]=S.useState(null),[g,b]=S.useState(!1),[v,x]=S.useState(!1);S.useEffect(()=>{if(a&&n.parameters){const D={};for(const k of n.parameters)k.schema?.default!==void 0&&(D[k.name]=String(k.schema.default));c(k=>({...D,...k}))}},[a,n.parameters]),S.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const D=n.requestBody.content["application/json"].schema,k=xb(r,D);d(JSON.stringify(k,null,2))}},[a,n.requestBody,r,u]);const E=(()=>{const D=[];for(const k of n.parameters||[])if(k.in==="path"||k.required){const P=l[k.name];(P===void 0||P==="")&&D.push(k.name)}return D})(),w=async()=>{if(E.length>0){p({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${E.join(", ")}`,duration:0});return}b(!0),p(null);try{let D=t;const k=new URLSearchParams;for(const K of n.parameters||[]){const F=l[K.name];F!==void 0&&F!==""&&(K.in==="path"?D=D.replace(`{${K.name}}`,encodeURIComponent(F)):K.in==="query"&&k.append(K.name,F))}const P=k.toString(),z=`${D}${P?`?${P}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const X={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&u&&(X.body=u);const R=performance.now(),Y=await fetch(z,X),J=Math.round(performance.now()-R),G={};Y.headers.forEach((K,F)=>{G[F]=K});let W;Y.headers.get("content-type")?.includes("application/json")?W=await Y.json():W=await Y.text(),p({status:Y.status,statusText:Y.statusText,headers:G,body:W,duration:J})}catch(D){p({status:0,statusText:"Network Error",headers:{},body:D instanceof Error?D.message:"Unknown error",duration:0})}finally{b(!1)}},A=async()=>{if(f){const D=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(D),x(!0),setTimeout(()=>x(!1),2e3)}catch{const k=document.createElement("textarea");k.value=D,k.style.position="fixed",k.style.left="-999999px",document.body.appendChild(k),k.select(),document.execCommand("copy"),document.body.removeChild(k),x(!0),setTimeout(()=>x(!1),2e3)}}},N=(n.parameters||[]).filter(D=>D.in==="path"),C=(n.parameters||[]).filter(D=>D.in==="query"),T=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(Qi,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(Bs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${tqe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),s.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&s.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&s.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),N.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),s.jsx("div",{className:"space-y-2",children:N.map(D=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[D.name]||"",onChange:k=>c(P=>({...P,[D.name]:k.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),C.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:C.map(D=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[D.name,D.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),D.schema?.enum?s.jsxs("select",{value:l[D.name]||"",onChange:k=>c(P=>({...P,[D.name]:k.target.value})),className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"",children:"-- Select --"}),D.schema.enum.map(k=>s.jsx("option",{value:k,children:k},k))]}):s.jsx("input",{type:"text",value:l[D.name]||"",onChange:k=>c(P=>({...P,[D.name]:k.target.value})),placeholder:D.description||D.schema?.type||"value",className:"flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none"})]},D.name))})]}),T&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange:D=>d(D.target.value),rows:8,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y",placeholder:"JSON request body..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ee,{onClick:w,disabled:g,children:[g?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Yc,{className:"w-4 h-4"}),"Execute"]}),E.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx(pa,{className:"w-3 h-3"}),"Fill in: ",E.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:A,children:v?s.jsx(pr,{className:"w-3 h-3 text-green-400"}):s.jsx($s,{className:"w-3 h-3"})})]}),s.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function iqe({apiKey:t=""}){const[e,n]=S.useState(null),[r,i]=S.useState(!0),[a,o]=S.useState(null),[l,c]=S.useState(new Set),[u,d]=S.useState("");if(S.useEffect(()=>{async function x(){try{const y=await fetch("/openapi.json");if(!y.ok)throw new Error("Failed to fetch OpenAPI schema");const E=await y.json();n(E)}catch(y){o(y instanceof Error?y.message:"Unknown error")}finally{i(!1)}}x()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(_t,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx(pa,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[x,y]of Object.entries(e.paths))for(const[E,w]of Object.entries(y)){if(E==="parameters")continue;const A=w.tags||["Other"];for(const N of A)f[N]||(f[N]=[]),f[N].push({path:x,method:E,spec:w})}const p=Object.entries(f).map(([x,y])=>{if(!u)return{tag:x,endpoints:y};const E=y.filter(({path:w,method:A,spec:N})=>{const C=u.toLowerCase();return w.toLowerCase().includes(C)||A.toLowerCase().includes(C)||(N.summary?.toLowerCase()||"").includes(C)||(N.description?.toLowerCase()||"").includes(C)});return{tag:x,endpoints:E}}).filter(({endpoints:x})=>x.length>0).sort((x,y)=>x.tag.localeCompare(y.tag)),g=x=>{c(y=>{const E=new Set(y);return E.has(x)?E.delete(x):E.add(x),E})},b=()=>{c(new Set(p.map(x=>x.tag)))},v=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.jsx("input",{type:"text",value:u,onChange:x=>d(x.target.value),placeholder:"Search endpoints...",className:"w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ee,{variant:"secondary",size:"sm",onClick:b,children:"Expand All"}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:v,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(Kr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((x,y)=>x+y.endpoints.length,0)," endpoints in ",p.length," categories"]}),s.jsx("div",{className:"space-y-3",children:p.map(({tag:x,endpoints:y})=>s.jsxs(_t,{children:[s.jsx("button",{onClick:()=>g(x),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left",children:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(x)?s.jsx(Qi,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Bs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:x.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:y.length})]})}),l.has(x)&&s.jsx(Mt,{className:"pt-0 space-y-2",children:y.map(({path:E,method:w,spec:A})=>s.jsx(rqe,{path:E,method:w,spec:A,schema:e,apiKey:t},`${w}-${E}`))})]},x))})]})}function aqe(){const t=an(),{t:e,i18n:n}=xg(),{showToast:r,showPersistentToast:i,dismissToast:a}=Wn(),{mode:o,darkStyle:l,darkBackground:c,darkAccent:u,lightStyle:d,lightBackground:f,lightAccent:p,setDarkStyle:g,setDarkBackground:b,setDarkAccent:v,setLightStyle:x,setLightBackground:y,setLightAccent:E}=wg(),[w,A]=S.useState(null),[N,C]=S.useState(!1),[T,D]=S.useState(null),[k,P]=S.useState(!1),[z,L]=S.useState(null),[X,R]=S.useState(null),[Y,J]=S.useState(!1),[G,W]=S.useState(SW()),[ee,K]=S.useState("general"),[F,q]=S.useState(!1),[ne,re]=S.useState(""),[se,de]=S.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[pe,Ce]=S.useState(null),[oe,ae]=S.useState(null),[ge,ue]=S.useState(""),[Le,V]=S.useState(!1),[$,Z]=S.useState(!1),[B,U]=S.useState(null),[Q,Me]=S.useState(!1),[Te,fe]=S.useState(!1),[H,I]=S.useState(!1),[ce,we]=S.useState(!1),[Se,_e]=S.useState(null),[st,Ve]=S.useState(!1),it=xe=>{W(xe),Ahe(xe)},ct=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Fe,isLoading:me}=lt({queryKey:["settings"],queryFn:be.getSettings}),{data:Ke,isLoading:qe}=lt({queryKey:["smart-plugs"],queryFn:be.getSmartPlugs}),{data:Qe,isLoading:ut}=lt({queryKey:["smart-plugs-energy",Ke?.map(xe=>xe.id)],queryFn:async()=>{if(!Ke||Ke.length===0)return null;const xe=await Promise.all(Ke.filter(Je=>Je.enabled).map(async Je=>{try{const xt=await be.getSmartPlugStatus(Je.id);return{plug:Je,status:xt}}catch{return{plug:Je,status:null}}}));let le=0,Ae=0,Oe=0,Ie=0,Re=0;for(const{status:Je}of xe)Je?.reachable&&Je.energy&&(Re++,Je.energy.power!=null&&(le+=Je.energy.power),Je.energy.today!=null&&(Ae+=Je.energy.today),Je.energy.yesterday!=null&&(Oe+=Je.energy.yesterday),Je.energy.total!=null&&(Ie+=Je.energy.total));return{totalPower:le,totalToday:Ae,totalYesterday:Oe,totalLifetime:Ie,reachableCount:Re,totalPlugs:Ke.filter(Je=>Je.enabled).length}},enabled:ee==="plugs"&&!!Ke&&Ke.length>0,refetchInterval:ee==="plugs"?1e4:!1}),{data:ie,isLoading:He}=lt({queryKey:["notification-providers"],queryFn:be.getNotificationProviders}),{data:ve,isLoading:Be}=lt({queryKey:["api-keys"],queryFn:be.getAPIKeys}),je=ht({mutationFn:xe=>be.createAPIKey(xe),onSuccess:xe=>{Ce(xe.key||null),q(!1),re(""),t.invalidateQueries({queryKey:["api-keys"]}),r("API key created")},onError:xe=>{r(`Failed to create API key: ${xe.message}`,"error")}}),Ne=ht({mutationFn:xe=>be.deleteAPIKey(xe),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),r("API key deleted")},onError:xe=>{r(`Failed to delete API key: ${xe.message}`,"error")}}),{data:Xe}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:mt,isLoading:At}=lt({queryKey:["notification-templates"],queryFn:be.getNotificationTemplates}),{data:Rt}=lt({queryKey:["virtual-printer-settings"],queryFn:E1.getSettings,refetchInterval:1e4}),Xt=Rt?.status?.running??!1,{data:Lt}=lt({queryKey:["ffmpeg-status"],queryFn:be.checkFfmpeg}),{data:Sn}=lt({queryKey:["version"],queryFn:be.getVersion}),{data:$t,refetch:Cn,isRefetching:nr}=lt({queryKey:["updateCheck"],queryFn:be.checkForUpdates,staleTime:300*1e3}),{data:Hn,refetch:Jr}=lt({queryKey:["updateStatus"],queryFn:be.getUpdateStatus,refetchInterval:xe=>{const le=xe.state.data;return le?.status==="downloading"||le?.status==="installing"?1e3:!1}}),{data:qn}=lt({queryKey:["mqtt-status"],queryFn:be.getMQTTStatus,refetchInterval:ee==="network"?5e3:!1}),yt=ht({mutationFn:be.applyUpdate,onSuccess:xe=>{xe.is_docker?r(xe.message,"error"):Jr()}}),[Ft,qt]=S.useState(null),gt=ht({mutationFn:be.testAllNotificationProviders,onSuccess:xe=>{qt(xe),t.invalidateQueries({queryKey:["notification-providers"]}),xe.failed===0?r(`All ${xe.tested} providers tested successfully!`,"success"):r(`${xe.success}/${xe.tested} providers succeeded`,xe.failed>0?"error":"success")},onError:xe=>{r(`Failed to test providers: ${xe.message}`,"error")}}),en=ht({mutationFn:async xe=>{if(!Ke)return{success:0,failed:0};const le=Ke.filter(Oe=>Oe.enabled),Ae=await Promise.all(le.map(async Oe=>{try{return await be.controlSmartPlug(Oe.id,xe),{success:!0}}catch{return{success:!1}}}));return{success:Ae.filter(Oe=>Oe.success).length,failed:Ae.filter(Oe=>!Oe.success).length}},onSuccess:(xe,le)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),xe.failed===0?r(`All ${xe.success} plugs turned ${le}`,"success"):r(`${xe.success} plugs turned ${le}, ${xe.failed} failed`,"error")},onError:xe=>{r(`Failed: ${xe.message}`,"error")}}),ye=S.useRef(null),$e=S.useRef(!1),Ye=S.useRef(!0);S.useEffect(()=>{Fe&&!w&&(A(Fe),setTimeout(()=>{Ye.current=!1},100))},[Fe,w]);const nt=ht({mutationFn:be.updateSettings,onSuccess:xe=>{t.setQueryData(["settings"],xe),A(xe),t.invalidateQueries({queryKey:["archiveStats"]}),r("Settings saved","success")},onError:xe=>{r(`Failed to save: ${xe.message}`,"error")},onSettled:()=>{$e.current=!1}});S.useEffect(()=>{if(!(Ye.current||!w||!Fe||!(Fe.auto_archive!==w.auto_archive||Fe.save_thumbnails!==w.save_thumbnails||Fe.capture_finish_photo!==w.capture_finish_photo||Fe.default_filament_cost!==w.default_filament_cost||Fe.currency!==w.currency||Fe.energy_cost_per_kwh!==w.energy_cost_per_kwh||Fe.energy_tracking_mode!==w.energy_tracking_mode||Fe.check_updates!==w.check_updates||Fe.notification_language!==w.notification_language||Fe.telemetry_enabled!==w.telemetry_enabled||Fe.ams_humidity_good!==w.ams_humidity_good||Fe.ams_humidity_fair!==w.ams_humidity_fair||Fe.ams_temp_good!==w.ams_temp_good||Fe.ams_temp_fair!==w.ams_temp_fair||Fe.ams_history_retention_days!==w.ams_history_retention_days||Fe.date_format!==w.date_format||Fe.time_format!==w.time_format||Fe.default_printer_id!==w.default_printer_id||Fe.ftp_retry_enabled!==w.ftp_retry_enabled||Fe.ftp_retry_count!==w.ftp_retry_count||Fe.ftp_retry_delay!==w.ftp_retry_delay||Fe.ftp_timeout!==w.ftp_timeout||Fe.mqtt_enabled!==w.mqtt_enabled||Fe.mqtt_broker!==w.mqtt_broker||Fe.mqtt_port!==w.mqtt_port||Fe.mqtt_username!==w.mqtt_username||Fe.mqtt_password!==w.mqtt_password||Fe.mqtt_topic_prefix!==w.mqtt_topic_prefix||Fe.mqtt_use_tls!==w.mqtt_use_tls||Fe.ha_enabled!==w.ha_enabled||Fe.ha_url!==w.ha_url||Fe.ha_token!==w.ha_token||(Fe.library_archive_mode??"ask")!==(w.library_archive_mode??"ask")||Number(Fe.library_disk_warning_gb??5)!==Number(w.library_disk_warning_gb??5)))&&!$e.current)return ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{if($e.current)return;$e.current=!0;const le={auto_archive:w.auto_archive,save_thumbnails:w.save_thumbnails,capture_finish_photo:w.capture_finish_photo,default_filament_cost:w.default_filament_cost,currency:w.currency,energy_cost_per_kwh:w.energy_cost_per_kwh,energy_tracking_mode:w.energy_tracking_mode,check_updates:w.check_updates,notification_language:w.notification_language,telemetry_enabled:w.telemetry_enabled,ams_humidity_good:w.ams_humidity_good,ams_humidity_fair:w.ams_humidity_fair,ams_temp_good:w.ams_temp_good,ams_temp_fair:w.ams_temp_fair,ams_history_retention_days:w.ams_history_retention_days,date_format:w.date_format,time_format:w.time_format,default_printer_id:w.default_printer_id,ftp_retry_enabled:w.ftp_retry_enabled,ftp_retry_count:w.ftp_retry_count,ftp_retry_delay:w.ftp_retry_delay,ftp_timeout:w.ftp_timeout,mqtt_enabled:w.mqtt_enabled,mqtt_broker:w.mqtt_broker,mqtt_port:w.mqtt_port,mqtt_username:w.mqtt_username,mqtt_password:w.mqtt_password,mqtt_topic_prefix:w.mqtt_topic_prefix,mqtt_use_tls:w.mqtt_use_tls,ha_enabled:w.ha_enabled,ha_url:w.ha_url,ha_token:w.ha_token,library_archive_mode:w.library_archive_mode,library_disk_warning_gb:w.library_disk_warning_gb};nt.mutate(le)},500),()=>{ye.current&&clearTimeout(ye.current)}},[w,Fe,nt]);const ke=S.useCallback((xe,le)=>{A(Ae=>Ae?{...Ae,[xe]:le}:null)},[]);return me||!w?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Settings"}),s.jsx("p",{className:"text-bambu-gray",children:"Configure Bambuddy"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>K("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${ee==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:"General"}),s.jsxs("button",{onClick:()=>K("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ls,{className:"w-4 h-4"}),"Smart Plugs",Ke&&Ke.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ke.length})]}),s.jsxs("button",{onClick:()=>K("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Kh,{className:"w-4 h-4"}),"Notifications",ie&&ie.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ie.length})]}),s.jsxs("button",{onClick:()=>K("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(fce,{className:"w-4 h-4"}),"Filament"]}),s.jsxs("button",{onClick:()=>K("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Np,{className:"w-4 h-4"}),"Network",s.jsx("span",{className:`w-2 h-2 rounded-full ${qn?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>K("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Uh,{className:"w-4 h-4"}),"API Keys",ve&&ve.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:ve.length})]}),s.jsxs("button",{onClick:()=>K("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ee==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Qr,{className:"w-4 h-4"}),"Virtual Printer",s.jsx("span",{className:`w-2 h-2 rounded-full ${Xt?"bg-green-400":"bg-gray-500"}`})]})]}),ee==="general"&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.general")})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(pf,{className:"w-4 h-4 inline mr-1"}),e("settings.language")]}),s.jsx("select",{value:n.language,onChange:xe=>n.changeLanguage(xe.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:vU.map(xe=>s.jsxs("option",{value:xe.code,children:[xe.nativeName," (",xe.name,")"]},xe.code))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("settings.defaultView")}),s.jsx("select",{value:G,onChange:xe=>it(xe.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:Yb.map(xe=>s.jsx("option",{value:xe.to,children:e(xe.labelKey)},xe.id))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:e("settings.defaultViewDescription")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),s.jsxs("select",{value:w.date_format||"system",onChange:xe=>ke("date_format",xe.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:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),s.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),s.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("select",{value:w.time_format||"system",onChange:xe=>ke("time_format",xe.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:[s.jsx("option",{value:"system",children:"System Default"}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("select",{value:w.default_printer_id??"",onChange:xe=>ke("default_printer_id",xe.target.value?Number(xe.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:[s.jsx("option",{value:"",children:"No default (ask each time)"}),Xe?.map(xe=>s.jsx("option",{value:xe.id,children:xe.name},xe.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Sidebar order"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:ct,children:[s.jsx(If,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(RR,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Mt,{className:"space-y-6",children:[s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${o==="dark"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",o==="dark"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:c,onChange:xe=>{b(xe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"}),s.jsx("option",{value:"oled",children:"OLED Black"}),s.jsx("option",{value:"slate",children:"Slate Blue"}),s.jsx("option",{value:"forest",children:"Forest Green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:u,onChange:xe=>{v(xe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:l,onChange:xe=>{g(xe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsxs("div",{className:`space-y-3 p-4 rounded-lg border ${o==="light"?"border-bambu-green bg-bambu-green/5":"border-bambu-dark-tertiary"}`,children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",o==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:f,onChange:xe=>{y(xe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:p,onChange:xe=>{E(xe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:d,onChange:xe=>{x(xe.target.value),r("Settings saved","success")},className:"w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Archive Settings"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Auto-archive prints"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.auto_archive,onChange:xe=>ke("auto_archive",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Save thumbnails"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.save_thumbnails,onChange:xe=>ke("save_thumbnails",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Capture finish photo"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.capture_finish_photo,onChange:xe=>ke("capture_finish_photo",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),w.capture_finish_photo&&Lt&&!Lt.installed&&s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(yn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),s.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Cost Tracking"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:w.default_filament_cost,onChange:xe=>ke("default_filament_cost",parseFloat(xe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),s.jsxs("select",{value:w.currency,onChange:xe=>ke("currency",xe.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:[s.jsx("option",{value:"USD",children:"USD ($)"}),s.jsx("option",{value:"EUR",children:"EUR (€)"}),s.jsx("option",{value:"GBP",children:"GBP (£)"}),s.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),s.jsx("option",{value:"JPY",children:"JPY (¥)"}),s.jsx("option",{value:"CNY",children:"CNY (¥)"}),s.jsx("option",{value:"CAD",children:"CAD ($)"}),s.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:w.energy_cost_per_kwh,onChange:xe=>ke("energy_cost_per_kwh",parseFloat(xe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),s.jsxs("select",{value:w.energy_tracking_mode||"total",onChange:xe=>ke("energy_tracking_mode",xe.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:[s.jsx("option",{value:"print",children:"Prints Only"}),s.jsx("option",{value:"total",children:"Total Consumption"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:w.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ua,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),s.jsxs("select",{value:w.library_archive_mode??"ask",onChange:xe=>ke("library_archive_mode",xe.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:[s.jsx("option",{value:"always",children:"Always create archive entry"}),s.jsx("option",{value:"never",children:"Never create archive entry"}),s.jsx("option",{value:"ask",children:"Ask each time"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:w.library_disk_warning_gb??5,onChange:xe=>ke("library_disk_warning_gb",parseFloat(xe.target.value)||5),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[s.jsx(JWe,{}),s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Check for updates"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.check_updates,onChange:xe=>ke("check_updates",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white",children:e("settings.telemetry")}),s.jsxs("button",{onClick:()=>I(!0),className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-bambu-dark rounded-full text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsx(jd,{className:"w-3 h-3"}),e("settings.telemetryLearnMore")]})]}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e("settings.telemetryDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.telemetry_enabled,onChange:xe=>ke("telemetry_enabled",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Current version"}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",Sn?.version||"..."]})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>Cn(),disabled:nr,children:[nr?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Rr,{className:"w-4 h-4"}),"Check now"]})]}),$t?.update_available?s.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",$t.latest_version]}),$t.release_name&&$t.release_name!==$t.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:$t.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[$t.release_notes&&s.jsx("button",{onClick:()=>we(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),$t.release_url&&s.jsx("a",{href:$t.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:"View release on GitHub",children:s.jsx(Kr,{className:"w-4 h-4"})})]})]}),Hn?.status==="downloading"||Hn?.status==="installing"?s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:Hn.message})]}),s.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Hn.progress}%`}})})]}):Hn?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:Hn.message}):Hn?.status==="error"?s.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:Hn.error||Hn.message}):$t?.is_docker?s.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),s.jsx("code",{className:"block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono",children:"docker compose pull && docker compose up -d"})]}):s.jsxs(Ee,{className:"mt-3",onClick:()=>yt.mutate(),disabled:yt.isPending,children:[yt.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Yr,{className:"w-4 h-4"}),"Install Update"]})]}):$t?.error?s.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: ",$t.error]}):$t&&!$t.update_available?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Data Management"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Backup Data"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export settings, providers, printers, and more"})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>Me(!0),children:[s.jsx(Yr,{className:"w-4 h-4"}),"Export"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Restore Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Import settings from a backup file with duplicate handling options"})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>fe(!0),children:[s.jsx(xi,{className:"w-4 h-4"}),"Restore"]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Clear Notification Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Delete notification logs older than 30 days"})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>V(!0),children:[s.jsx(ln,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Reset UI Preferences"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected."})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>Z(!0),children:[s.jsx(ln,{className:"w-4 h-4"}),"Reset"]})]})]})]})]})]}),ee==="network"&&w&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Rr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable retry"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.ftp_retry_enabled??!0,onChange:xe=>ke("ftp_retry_enabled",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),w.ftp_retry_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"10",value:w.ftp_retry_count??3,onChange:xe=>ke("ftp_retry_count",Math.min(10,Math.max(1,parseInt(xe.target.value)||3))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"times"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"30",value:w.ftp_retry_delay??2,onChange:xe=>ke("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(xe.target.value)||2))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"10",max:"120",value:w.ftp_timeout??30,onChange:xe=>ke("ftp_timeout",Math.min(120,Math.max(10,parseInt(xe.target.value)||30))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Socket timeout for slow connections. Increase for A1/A1 Mini printers with weak WiFi (10-120)"})]})]})]}),s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(w2,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),w.ha_enabled&&Se&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Se.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Se.success?"text-green-400":"text-red-400"}`,children:Se.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, and input_boolean entities."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Home Assistant"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Control smart plugs via Home Assistant"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.ha_enabled??!1,onChange:xe=>ke("ha_enabled",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),w.ha_enabled&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),s.jsx("input",{type:"text",value:w.ha_url??"",onChange:xe=>ke("ha_url",xe.target.value),placeholder:"http://192.168.1.100:8123",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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Long-Lived Access Token"}),s.jsx("input",{type:"password",value:w.ha_token??"",onChange:xe=>ke("ha_token",xe.target.value),placeholder:"eyJ0eXAiOiJKV1QiLC...",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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Create a token in HA: Profile → Long-Lived Access Tokens → Create Token"})]}),w.ha_url&&w.ha_token&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Ee,{variant:"secondary",size:"sm",disabled:st,onClick:async()=>{Ve(!0),_e(null);try{const xe=await be.testHAConnection(w.ha_url,w.ha_token);_e(xe)}catch(xe){_e({success:!1,message:null,error:xe instanceof Error?xe.message:"Unknown error"})}finally{Ve(!1)}},children:[st?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Np,{className:"w-4 h-4"}),"Test Connection"]})})]})]})]})]}),s.jsx("div",{className:"flex-1 lg:max-w-xl space-y-4",children:s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Np,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),qn?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${qn.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${qn.connected?"text-green-400":"text-red-400"}`,children:qn.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable MQTT"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.mqtt_enabled??!1,onChange:xe=>ke("mqtt_enabled",xe.target.checked),className:"sr-only peer"}),s.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"})]})]}),w.mqtt_enabled&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),s.jsx("input",{type:"text",value:w.mqtt_broker??"",onChange:xe=>ke("mqtt_broker",xe.target.value),placeholder:"mqtt.example.com or 192.168.1.100",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"})]}),s.jsxs("div",{className:"flex items-end gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),s.jsx("input",{type:"number",min:"1",max:"65535",value:w.mqtt_port??1883,onChange:xe=>ke("mqtt_port",Math.min(65535,Math.max(1,parseInt(xe.target.value)||1883))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:w.mqtt_use_tls??!1,onChange:xe=>{const le=xe.target.checked;ke("mqtt_use_tls",le);const Ae=w.mqtt_port??1883;le&&Ae===1883?ke("mqtt_port",8883):!le&&Ae===8883&&ke("mqtt_port",1883)},className:"sr-only peer"}),s.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"})]}),s.jsx("span",{className:"text-white text-sm",children:"Use TLS"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),s.jsx("input",{type:"text",value:w.mqtt_username??"",onChange:xe=>ke("mqtt_username",xe.target.value),placeholder:"Leave empty for anonymous",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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),s.jsx("input",{type:"password",value:w.mqtt_password??"",onChange:xe=>ke("mqtt_password",xe.target.value),placeholder:"Leave empty for anonymous",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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),s.jsx("input",{type:"text",value:w.mqtt_topic_prefix??"bambuddy",onChange:xe=>ke("mqtt_topic_prefix",xe.target.value),placeholder:"bambuddy",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"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",w.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),qn&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${qn.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:qn.connected?s.jsxs(s.Fragment,{children:["Connected to ",s.jsxs("span",{className:"text-white",children:[qn.broker,":",qn.port]})]}):"Not connected"})]})})]})]})]})})]}),Se&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[Se.success?s.jsx(pr,{className:"w-8 h-8 text-green-400"}):s.jsx(Wi,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:Se.success?"Connection Successful":"Connection Failed"})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:Se.success?Se.message||"Successfully connected to Home Assistant.":Se.error||"Failed to connect to Home Assistant."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Ee,{variant:"primary",onClick:()=>_e(null),children:"OK"})})]})}),ee==="plugs"&&s.jsxs("div",{className:"max-w-4xl",children:[s.jsxs("div",{className:"flex items-start justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Ke&&Ke.filter(xe=>xe.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("on"),disabled:en.isPending,title:"Turn all plugs on",children:[en.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(zl,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Ee,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>U("off"),disabled:en.isPending,title:"Turn all plugs off",children:[en.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(E2,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Ee,{className:"whitespace-nowrap",onClick:()=>{D(null),C(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Ke&&Ke.length>0&&s.jsxs(_t,{className:"mb-6",children:[s.jsx(Vr,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(bf,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",ut&&s.jsx(ft,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Mt,{children:Qe?s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(bf,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Qe.totalPower.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[Qe.reachableCount,"/",Qe.totalPlugs," plugs online"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(qr,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Qe.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Qe.totalToday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(xW,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Qe.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Qe.totalYesterday*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(_j,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[Qe.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),w&&w.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(Qe.totalLifetime*w.energy_cost_per_kwh).toFixed(2)," ",w.currency]})]})]}):ut?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),qe?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ke&&Ke.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Ke.map(xe=>s.jsx(IWe,{plug:xe,onEdit:le=>{D(le),C(!0)}},xe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ls,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No smart plugs configured"}),s.jsx("p",{className:"text-sm mb-4",children:"Add a Tasmota-based smart plug to track energy usage and automate power control."}),s.jsxs(Ee,{onClick:()=>{D(null),C(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Your First Smart Plug"]})]})})})]}),ee==="notifications"&&s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Kh,{className:"w-5 h-5 text-bambu-green"}),"Providers"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>J(!0),children:[s.jsx(iw,{className:"w-4 h-4"}),"Log"]}),ie&&ie.length>0&&s.jsxs(Ee,{size:"sm",variant:"secondary",onClick:()=>{qt(null),gt.mutate()},disabled:gt.isPending,children:[gt.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(LR,{className:"w-4 h-4"}),"Test All"]}),s.jsxs(Ee,{size:"sm",onClick:()=>{L(null),P(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(_t,{className:"mb-4",children:s.jsx(Mt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm font-medium",children:e("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:e("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:w.notification_language||"en",onChange:xe=>ke("notification_language",xe.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:vU.map(xe=>s.jsx("option",{value:xe.code,children:xe.nativeName},xe.code))})]})})}),Ft&&s.jsx(_t,{className:"mb-4",children:s.jsxs(Mt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium text-white",children:"Test Results"}),s.jsx("button",{onClick:()=>qt(null),className:"text-bambu-gray hover:text-white text-xs",children:"Dismiss"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(pr,{className:"w-4 h-4"}),Ft.success," passed"]}),Ft.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Wi,{className:"w-4 h-4"}),Ft.failed," failed"]})]}),Ft.results.filter(xe=>!xe.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Ft.results.filter(xe=>!xe.success).map(xe=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[xe.provider_name,":"]})," ",xe.message]},xe.provider_id))})]})}),He?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):ie&&ie.length>0?s.jsx("div",{className:"space-y-3",children:ie.map(xe=>s.jsx(zWe,{provider:xe,onEdit:le=>{L(le),P(!0)}},xe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Kh,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:"No providers configured"}),s.jsx("p",{className:"text-xs mb-3",children:"Add a provider to receive alerts."}),s.jsxs(Ee,{size:"sm",onClick:()=>{L(null),P(!0)},children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Provider"]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(Ua,{className:"w-5 h-5 text-bambu-green"}),"Message Templates"]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Customize notification messages for each event."}),At?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):mt&&mt.length>0?s.jsx("div",{className:"space-y-2",children:mt.map(xe=>s.jsx(_t,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>R(xe),children:s.jsx(Mt,{className:"py-2.5 px-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium text-sm truncate",children:xe.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:xe.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:le=>{le.stopPropagation(),R(xe)},children:s.jsx(OR,{className:"w-4 h-4 text-bambu-gray"})})]})})},xe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ua,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:"No templates available. Restart the backend to seed default templates."})]})})})]})]}),ee==="apikeys"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Uh,{className:"w-5 h-5 text-bambu-green"}),"API Keys"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Create API keys for external integrations and webhooks."})]}),s.jsxs(Ee,{size:"sm",onClick:()=>q(!0),className:"flex-shrink-0",children:[s.jsx(dr,{className:"w-4 h-4"}),"Create Key"]})]}),pe&&s.jsx(_t,{className:"mb-6 border-bambu-green",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(pr,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"API Key Created Successfully"}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Copy this key now - it won't be shown again!"}),s.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[s.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:pe}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(pe);else{const xe=document.createElement("textarea");xe.value=pe,xe.style.position="fixed",xe.style.left="-999999px",document.body.appendChild(xe),xe.select(),document.execCommand("copy"),document.body.removeChild(xe)}r("Key copied to clipboard")}catch{r("Failed to copy key","error")}},children:s.jsx($s,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>{ue(pe),r("Key added to API Browser")},children:"Use in API Browser"}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>Ce(null),children:"Dismiss"})]})]})]})})}),F&&s.jsxs(_t,{className:"mb-6",children:[s.jsx(Vr,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Create New API Key"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Key Name"}),s.jsx("input",{type:"text",value:ne,onChange:xe=>re(xe.target.value),placeholder:"e.g., Home Assistant, OctoPrint",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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Permissions"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:se.can_read_status,onChange:xe=>de(le=>({...le,can_read_status:xe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Read Status"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"View printer status and queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:se.can_queue,onChange:xe=>de(le=>({...le,can_queue:xe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Manage Queue"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Add and remove items from print queue"})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:se.can_control_printer,onChange:xe=>de(le=>({...le,can_control_printer:xe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:"Control Printer"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pause, resume, and stop prints"})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(Ee,{onClick:()=>je.mutate({name:ne||"Unnamed Key",...se}),disabled:je.isPending,children:[je.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(dr,{className:"w-4 h-4"}),"Create Key"]}),s.jsx(Ee,{variant:"secondary",onClick:()=>q(!1),children:"Cancel"})]})]})]}),Be?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ve&&ve.length>0?s.jsx("div",{className:"space-y-3",children:ve.map(xe=>s.jsx(_t,{children:s.jsx(Mt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Uh,{className:`w-5 h-5 ${xe.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:xe.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[xe.key_prefix,"••••••••",xe.last_used&&` · Last used: ${Hp(xe.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[xe.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:"Read"}),xe.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:"Queue"}),xe.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:"Control"})]}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:()=>ae(xe.id),children:s.jsx(ln,{className:"w-4 h-4 text-red-400"})})]})]})})},xe.id))}):s.jsx(_t,{children:s.jsx(Mt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Uh,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No API keys"}),s.jsx("p",{className:"text-sm mb-4",children:"Create an API key to integrate with external services."}),s.jsxs(Ee,{onClick:()=>q(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"Create Your First Key"]})]})})}),s.jsxs(_t,{className:"mt-6",children:[s.jsx(Vr,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:"Webhook Endpoints"})}),s.jsxs(Mt,{className:"space-y-3 text-sm",children:[s.jsxs("p",{className:"text-bambu-gray",children:["Use your API key in the ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header."]}),s.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),s.jsx("span",{className:"text-bambu-gray",children:" - Get all printer status"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),s.jsx("span",{className:"text-bambu-gray",children:" - Get specific printer status"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-green-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),s.jsx("span",{className:"text-bambu-gray",children:" - Add to print queue"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),s.jsx("span",{className:"text-bambu-gray",children:" - Pause print"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),s.jsx("span",{className:"text-bambu-gray",children:" - Resume print"})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-red-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),s.jsx("span",{className:"text-bambu-gray",children:" - Stop print"})]})]})]})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(pf,{className:"w-5 h-5 text-bambu-green"}),"API Browser"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Explore and test all available API endpoints."})]}),s.jsx(_t,{className:"mb-4",children:s.jsxs(Mt,{className:"py-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"API Key for Testing"}),s.jsx("input",{type:"text",value:ge,onChange:xe=>ue(xe.target.value),placeholder:"Paste your API key here to test authenticated endpoints...",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:["This key will be sent as ",s.jsx("code",{className:"text-bambu-green",children:"X-API-Key"})," header with requests."]})]})}),s.jsx(iqe,{apiKey:ge})]})]}),ee==="virtual-printer"&&s.jsx(eqe,{}),ee==="filament"&&w&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsxs(_t,{children:[s.jsx(Vr,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"AMS Display Thresholds"})}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configure color thresholds for AMS humidity and temperature indicators."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(jR,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:"Humidity"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (green) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_good??40,onChange:xe=>ke("ams_humidity_good",parseInt(xe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:w.ams_humidity_fair??60,onChange:xe=>ke("ams_humidity_fair",parseInt(xe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (bad)"})]}),s.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(N2,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:"Temperature"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Good (blue) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_good??28,onChange:xe=>ke("ams_temp_good",parseFloat(xe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Fair (orange) ≤"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:w.ams_temp_fair??35,onChange:xe=>ke("ams_temp_fair",parseFloat(xe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Above fair threshold shows as red (hot)"})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Bp,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:"History Retention"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Keep sensor history for"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:w.ams_history_retention_days??30,onChange:xe=>ke("ams_history_retention_days",parseInt(xe.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"days"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Older humidity and temperature data will be automatically deleted"})]})]})]})}),s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsx(QWe,{})})]}),oe!==null&&s.jsx(Un,{title:"Delete API Key",message:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",confirmText:"Delete Key",variant:"danger",onConfirm:()=>{Ne.mutate(oe),ae(null)},onCancel:()=>ae(null)}),N&&s.jsx(FWe,{plug:T,onClose:()=>{C(!1),D(null)}}),k&&s.jsx(BWe,{provider:z,onClose:()=>{P(!1),L(null)}}),X&&s.jsx($We,{template:X,onClose:()=>R(null)}),Y&&s.jsx(GWe,{onClose:()=>J(!1)}),Le&&s.jsx(Un,{title:"Clear Notification Logs",message:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",confirmText:"Clear Logs",variant:"warning",onConfirm:async()=>{V(!1);try{const xe=await be.clearNotificationLogs(30);r(xe.message,"success")}catch{r("Failed to clear logs","error")}},onCancel:()=>V(!1)}),$&&s.jsx(Un,{title:"Reset UI Preferences",message:"This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.",confirmText:"Reset Preferences",variant:"default",onConfirm:()=>{Z(!1),localStorage.clear(),r("UI preferences reset. Refreshing...","success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>Z(!1)}),B&&s.jsx(Un,{title:`Turn All Plugs ${B==="on"?"On":"Off"}`,message:`This will turn ${B==="on"?"ON":"OFF"} all ${Ke?.filter(xe=>xe.enabled).length||0} enabled smart plugs. ${B==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${B==="on"?"On":"Off"}`,variant:B==="off"?"danger":"warning",onConfirm:()=>{const xe=B;U(null),en.mutate(xe)},onCancel:()=>U(null)}),Q&&s.jsx(qWe,{onClose:()=>Me(!1),onExport:async xe=>{Me(!1);const le="backup-progress",Ae=xe.archives;Ae&&i(le,e("backup.preparing",{defaultValue:"Preparing backup..."}),"loading");try{const{blob:Oe,filename:Ie}=await be.exportBackup(xe);Ae&&a(le);const Re=URL.createObjectURL(Oe),Je=document.createElement("a");Je.href=Re,Je.download=Ie,Je.click(),URL.revokeObjectURL(Re),r(e("backup.downloaded",{defaultValue:"Backup downloaded"}),"success")}catch{Ae&&a(le),r(e("backup.failed",{defaultValue:"Failed to create backup"}),"error")}}}),Te&&s.jsx(KWe,{onClose:()=>fe(!1),onRestore:async(xe,le)=>await be.importBackup(xe,le),onSuccess:()=>{A(null),Ye.current=!0,t.resetQueries({queryKey:["settings"]}),t.invalidateQueries({queryKey:["notification-providers"]}),t.invalidateQueries({queryKey:["notification-templates"]}),t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["external-links"]}),t.invalidateQueries({queryKey:["printers"]}),t.invalidateQueries({queryKey:["filaments"]}),t.invalidateQueries({queryKey:["maintenance-types"]}),t.invalidateQueries({queryKey:["api-keys"]})}}),H&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>I(!1),children:s.jsxs(_t,{className:"w-full max-w-lg",onClick:xe=>xe.stopPropagation(),children:[s.jsxs(Vr,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Sde,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("settings.telemetryInfoTitle")})]}),s.jsx("button",{onClick:()=>I(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs(Mt,{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray text-sm",children:e("settings.telemetryInfoIntro")}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(pr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(pr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(pr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(pr,{className:"w-4 h-4 text-bambu-green mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoItem4")})]})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-white font-medium",children:e("settings.telemetryInfoNotCollected")}),s.jsxs("ul",{className:"space-y-2 text-sm",children:[s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Wi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem1")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Wi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem2")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Wi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem3")})]}),s.jsxs("li",{className:"flex items-start gap-2 text-bambu-gray",children:[s.jsx(Wi,{className:"w-4 h-4 text-red-400 mt-0.5 shrink-0"}),s.jsx("span",{children:e("settings.telemetryInfoNotItem4")})]})]})]}),s.jsx("p",{className:"text-bambu-gray text-xs border-t border-bambu-dark-tertiary pt-4",children:e("settings.telemetryInfoFooter")}),s.jsx(Ee,{onClick:()=>I(!1),className:"w-full",children:e("common.close")})]})]})}),ce&&$t?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>we(!1),children:s.jsxs(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:xe=>xe.stopPropagation(),children:[s.jsxs(Vr,{className:"flex flex-row items-center justify-between shrink-0",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Release Notes - v",$t.latest_version]}),$t.release_name&&$t.release_name!==$t.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray",children:$t.release_name})]}),s.jsx("button",{onClick:()=>we(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx(Mt,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:$t.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[$t.release_url&&s.jsx("a",{href:$t.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Ee,{variant:"secondary",className:"w-full",children:[s.jsx(Kr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Ee,{onClick:()=>we(!1),className:"flex-1",children:"Close"})]})]})})]})}const wne=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},sqe=t=>t.startsWith("HH")?"HF":"S",oqe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},xR=t=>{const e=["High Flow_","High Flow ","Standard_","Standard ","HF_","HF ","S_","S "];for(const r of e)if(t.startsWith(r))return t.slice(r.length);const n=t.indexOf("_");return n>0?t.slice(n+1):t};function tj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=sqe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?s.jsx(Qc,{className:"w-4 h-4 text-bambu-green"}):s.jsx(Zc,{className:"w-4 h-4"})}),s.jsxs("button",{onClick:u,className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?"ring-1 ring-bambu-green":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:wne(t.k_value)}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&s.jsx("span",{title:"Has note",children:s.jsx(fW,{className:"w-3 h-3 text-yellow-500"})}),s.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&s.jsxs("div",{className:"text-xs mt-0.5 truncate text-yellow-500/70",title:o,children:["Note: ",o.length>50?o.substring(0,50)+"...":o]})]}),!r&&n&&s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:s.jsx($s,{className:"w-4 h-4"})})]})}function nj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u}){const{showToast:d}=Wn(),[f,p]=S.useState(t?.name||""),[g,b]=S.useState(t?.k_value?wne(t.k_value):"0.020"),[v,x]=S.useState(t?.filament_id||""),[y,E]=S.useState(t?.nozzle_id?oqe(t.nozzle_id):"HH00"),[w,A]=S.useState(t?.nozzle_diameter||n),[N,C]=S.useState(t?[t.extruder_id]:i?[0,1]:[0]),[T,D]=S.useState(!1),[k,P]=S.useState({current:0,total:0}),[z,L]=S.useState(a),X=Cr.useMemo(()=>{const K=new Map;for(const F of r)if(F.filament_id&&!K.has(F.filament_id)){const q=xR(F.name||"");K.set(F.filament_id,{id:F.filament_id,name:q||F.filament_id})}return Array.from(K.values()).sort((F,q)=>F.name.localeCompare(q.name))},[r]),R=ht({mutationFn:K=>(console.log("[KProfile] Calling API..."),be.setKProfile(e,K)),onSuccess:K=>{if(console.log("[KProfile] Save success:",K),d("K-profile saved"),u&&z!==a){let F;z===""&&o?F=o:t&&t.slot_id>0?F=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:F=`name_${f}_${v}`,u(F,z)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:K=>{console.error("[KProfile] Save error:",K),d(K.message,"error"),D(!1)}}),Y=ht({mutationFn:K=>(console.log("[KProfile] Deleting profile..."),be.deleteKProfile(e,K)),onSuccess:K=>{console.log("[KProfile] Delete success:",K),d("K-profile deleted"),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:K=>{console.error("[KProfile] Delete error:",K),d(K.message,"error"),D(!1)}}),[J,G]=S.useState(!1),W=()=>{t&&Y.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})},ee=async K=>{if(K.preventDefault(),i&&!t&&N.length===0){d("Please select at least one extruder","error");return}const F=parseFloat(g).toFixed(6),q=`${y}-${w}`;if(t||N.length===1){const re={name:f,k_value:F,filament_id:v,nozzle_id:q,nozzle_diameter:w,extruder_id:t?t.extruder_id:N[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",re),R.mutate(re);return}D(!0),P({current:1,total:N.length});const ne=N.map(re=>({name:f,k_value:F,filament_id:v,nozzle_id:q,nozzle_diameter:w,extruder_id:re,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ne.length} profiles in batch:`,ne);try{if(await be.setKProfilesBatch(e,ne),d(`K-profile saved to ${N.length} extruders`),u&&z){const re=`name_${f}_${v}`;u(re,z)}}catch(re){console.error("[KProfile] Failed to save batch:",re),d("Failed to save K-profiles","error"),D(!1),P({current:0,total:0});return}P({current:N.length,total:N.length}),setTimeout(()=>{D(!1),P({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(_t,{className:"w-full max-w-md relative",children:[T&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:k.total>1?`Saving to extruder ${k.current}/${k.total}...`:"Syncing with printer..."}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:"Please wait"})]}),s.jsxs(Mt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t?"Edit K-Profile":"Add K-Profile"}),s.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:T,children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:ee,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Profile Name"}),s.jsx("input",{type:"text",value:f,onChange:K=>p(K.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"K-Value"}),s.jsx("input",{type:"text",inputMode:"decimal",value:g,onChange:K=>{const F=K.target.value;(F===""||/^\d*\.?\d*$/.test(F))&&b(F)},onBlur:K=>{const F=parseFloat(K.target.value);isNaN(F)||b((Math.trunc(F*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}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Filament"}),s.jsxs("select",{value:v,onChange:K=>{const F=K.target.value;if(x(F),!t&&F&&!f){const q=X.find(ne=>ne.id===F);q&&p(`${y==="HH00"?"HF":"S"} ${q.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:[s.jsx("option",{value:"",children:"Select filament..."}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:X.find(K=>K.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&X.map(K=>s.jsx("option",{value:K.id,children:K.name},K.id))]}),!t&&X.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"No filaments found. Create a K-profile in Bambu Studio first."})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Flow Type"}),s.jsxs("select",{value:y,onChange:K=>{const F=K.target.value;if(E(F),!t&&v&&!f){const q=X.find(ne=>ne.id===v);q&&p(`${F==="HS00"?"HF":"S"} ${q.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:[s.jsx("option",{value:"HH00",children:"High Flow"}),s.jsx("option",{value:"HS00",children:"Standard"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle Size"}),s.jsxs("select",{value:w,onChange:K=>A(K.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:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t?"Extruder":"Extruders"}),t?s.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"}):s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:N.includes(1),onChange:K=>{K.target.checked?C([...N,1]):C(N.filter(F=>F!==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"}),s.jsx("span",{className:"text-white",children:"Left"})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:N.includes(0),onChange:K=>{K.target.checked?C([...N,0]):C(N.filter(F=>F!==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"}),s.jsx("span",{className:"text-white",children:"Right"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes (stored locally)"}),s.jsx("textarea",{value:z,onChange:K=>L(K.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Notes are saved in Bambuddy, not on the printer"})]}),s.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&s.jsx(Ee,{type:"button",variant:"secondary",onClick:()=>G(!0),disabled:Y.isPending||T,className:"text-red-500 hover:bg-red-500/10",children:Y.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(ln,{className:"w-4 h-4"})}),s.jsx(Ee,{type:"button",variant:"secondary",onClick:l,disabled:T,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{type:"submit",disabled:R.isPending||T,className:"flex-1",children:[R.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(v2,{className:"w-4 h-4"}),"Save"]})]})]})]})]}),J&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(_t,{className:"w-full max-w-sm",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(ln,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profile"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsxs("span",{className:"text-white font-medium",children:['"',t?.name,'"']})," from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ee,{variant:"secondary",onClick:()=>G(!1),className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{onClick:()=>{G(!1),W()},disabled:Y.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[Y.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}const w1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function lqe(){const{showToast:t}=Wn(),[e,n]=S.useState(null),[r,i]=S.useState(()=>localStorage.getItem(w1.NOZZLE_DIAMETER)||"0.4"),[a,o]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(null),[f,p]=S.useState(""),[g,b]=S.useState("all"),[v,x]=S.useState("all"),[y,E]=S.useState(()=>localStorage.getItem(w1.SORT_OPTION)||"name"),[w,A]=S.useState(!1),[N,C]=S.useState(new Set),[T,D]=S.useState(!1),[k,P]=S.useState(!1),z=S.useCallback(B=>`${B.slot_id}_${B.extruder_id}`,[]);S.useEffect(()=>{localStorage.setItem(w1.NOZZLE_DIAMETER,r)},[r]),S.useEffect(()=>{localStorage.setItem(w1.SORT_OPTION,y)},[y]);const{data:L,isLoading:X}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:R,isLoading:Y,isFetching:J,error:G,refetch:W}=lt({queryKey:["kprofiles",e,r],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",e,"nozzle",r);const B=await be.getKProfiles(e,r);return console.log("[KProfiles] Received profiles:",B?.profiles?.length||0,"profiles"),B},enabled:!!e,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:ee}=lt({queryKey:["kprofiles",e,"0.4"],queryFn:()=>be.getKProfiles(e,"0.4"),enabled:!!e,staleTime:6e4}),{data:K,refetch:F}=lt({queryKey:["kprofile-notes",e],queryFn:()=>be.getKProfileNotes(e),enabled:!!e,staleTime:3e4}),q=G?.message?.includes("not connected");S.useEffect(()=>{if(!e&&L&&L.length>0){const B=L.find(U=>U.is_active);B&&n(B.id)}},[e,L]),S.useEffect(()=>{if(e){const B=setTimeout(()=>{W()},150);return()=>clearTimeout(B)}},[e,r]);const ne=L?.filter(B=>B.is_active)||[],re=Cr.useMemo(()=>R?.profiles?R.profiles.filter(U=>{const Q=f.toLowerCase(),Me=!Q||U.name.toLowerCase().includes(Q)||U.filament_id.toLowerCase().includes(Q),Te=g==="all"||g==="left"&&U.extruder_id===1||g==="right"&&U.extruder_id===0,fe=v==="all"||v==="hf"&&U.nozzle_id.startsWith("HH")||v==="s"&&U.nozzle_id.startsWith("HS");return Me&&Te&&fe}).sort((U,Q)=>{switch(y){case"k_value":return parseFloat(U.k_value)-parseFloat(Q.k_value);case"filament":return xR(U.name).localeCompare(xR(Q.name));case"name":default:return U.name.localeCompare(Q.name)}}):[],[R?.profiles,f,g,v,y]),se=L?.find(B=>B.id===e),de=se?.nozzle_count===2;S.useEffect(()=>{const B=U=>{U.target instanceof HTMLInputElement||U.target instanceof HTMLTextAreaElement||U.target instanceof HTMLSelectElement||a||l||u||(U.key==="r"||U.key==="R"?(U.preventDefault(),W()):U.key==="n"||U.key==="N"?(U.preventDefault(),c(!0)):U.key==="Escape"&&w&&(U.preventDefault(),A(!1),C(new Set)))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[a,l,u,w,W]);const pe=S.useCallback(()=>{if(!R?.profiles||R.profiles.length===0){t("No profiles to export","error");return}const B={version:1,exported_at:new Date().toISOString(),printer:se?.name||"Unknown",nozzle_diameter:r,profiles:R.profiles.map(Te=>({name:Te.name,k_value:Te.k_value,filament_id:Te.filament_id,nozzle_id:Te.nozzle_id,nozzle_diameter:Te.nozzle_diameter,extruder_id:Te.extruder_id}))},U=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),Q=URL.createObjectURL(U),Me=document.createElement("a");Me.href=Q,Me.download=`kprofiles_${se?.name||"printer"}_${r}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),URL.revokeObjectURL(Q),t(`Exported ${R.profiles.length} profiles`)},[R?.profiles,se,r,t]),Ce=S.useCallback(()=>{const B=document.createElement("input");B.type="file",B.accept=".json",B.onchange=async U=>{const Q=U.target.files?.[0];if(Q)try{const Me=await Q.text(),Te=JSON.parse(Me);if(!Te.profiles||!Array.isArray(Te.profiles)){t("Invalid file format","error");return}let fe=0;for(const H of Te.profiles)if(!(!H.name||!H.k_value||!H.filament_id))try{await be.setKProfile(e,{name:H.name,k_value:parseFloat(H.k_value).toFixed(6),filament_id:H.filament_id,nozzle_id:H.nozzle_id||`HH00-${r}`,nozzle_diameter:H.nozzle_diameter||r,extruder_id:H.extruder_id??0,slot_id:0}),fe++,await new Promise(I=>setTimeout(I,500))}catch(I){console.error("Failed to import profile:",H.name,I)}t(`Imported ${fe} of ${Te.profiles.length} profiles`),W()}catch(Me){console.error("Import error:",Me),t("Failed to parse import file","error")}},B.click()},[e,r,t,W]),oe=S.useCallback(B=>{C(U=>{const Q=new Set(U);return Q.has(B)?Q.delete(B):Q.add(B),Q})},[]),ae=S.useCallback(()=>{C(new Set(re.map(B=>z(B))))},[re,z]),ge=S.useCallback(()=>{N.size!==0&&D(!0)},[N.size]),ue=S.useCallback(async()=>{const B=re.filter(Q=>N.has(z(Q)));P(!0);let U=0;for(const Q of B)try{await be.deleteKProfile(e,{slot_id:Q.slot_id,extruder_id:Q.extruder_id,nozzle_id:Q.nozzle_id,nozzle_diameter:Q.nozzle_diameter,filament_id:Q.filament_id,setting_id:Q.setting_id}),U++,await new Promise(Me=>setTimeout(Me,300))}catch(Me){console.error("Failed to delete profile:",Q.name,Me)}t(`Deleted ${U} profiles`),P(!1),D(!1),A(!1),C(new Set),W()},[e,N,re,t,W,z]),Le=S.useCallback(B=>{const U=[];return B.setting_id&&U.push(B.setting_id),U.push(`slot_${B.slot_id}_${B.filament_id}_${B.extruder_id}`),U.push(`name_${B.name}_${B.filament_id}`),U},[]),V=S.useCallback(async(B,U)=>{if(e)try{await be.setKProfileNote(e,B,U),F()}catch(Q){console.error("Failed to save note:",Q),t("Failed to save note","error")}},[e,F,t]),$=S.useCallback(B=>{if(!K?.notes)return{note:"",key:null};const U=Le(B);for(const Q of U)if(K.notes[Q])return{note:K.notes[Q],key:Q};return{note:"",key:null}},[K,Le]),Z=S.useCallback(B=>$(B).note,[$]);return X?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!L||L.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(pa,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Printers Configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add a printer in Settings to manage K-profiles"})]})}):ne.length===0?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Qr,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Active Printers"}),s.jsx("p",{className:"text-bambu-gray",children:"Enable a printer connection to view its K-profiles"})]})}):s.jsxs(s.Fragment,{children:[J&&!Y&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(ft,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:"Loading K-Profiles..."})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1 min-w-48",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer"}),s.jsx("select",{value:e||"",onChange:B=>n(parseInt(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",children:ne.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Nozzle"}),s.jsxs("select",{value:r,onChange:B=>i(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",children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Ee,{variant:"secondary",onClick:()=>W(),disabled:J,children:[s.jsx(Rr,{className:`w-4 h-4 ${J?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Ee,{onClick:()=>c(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Profile"]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-48 relative",children:[s.jsx(Eo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:f,onChange:B=>p(B.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"})]}),de&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:g,onChange:B=>b(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:"All Extruders"}),s.jsx("option",{value:"left",children:"Left Only"}),s.jsx("option",{value:"right",children:"Right Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:v,onChange:B=>x(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",children:[s.jsx("option",{value:"all",children:"All Flow"}),s.jsx("option",{value:"hf",children:"HF Only"}),s.jsx("option",{value:"s",children:"S Only"})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:y,onChange:B=>E(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",children:[s.jsx("option",{value:"name",children:"Sort: Name"}),s.jsx("option",{value:"k_value",children:"Sort: K-Value"}),s.jsx("option",{value:"filament",children:"Sort: Filament"})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(Ee,{variant:"secondary",onClick:pe,disabled:!R?.profiles?.length,title:"Export profiles to JSON",children:[s.jsx(Yr,{className:"w-4 h-4"}),"Export"]}),s.jsxs(Ee,{variant:"secondary",onClick:Ce,title:"Import profiles from JSON",children:[s.jsx(xi,{className:"w-4 h-4"}),"Import"]}),s.jsx("div",{className:"flex-1"}),w?s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{variant:"secondary",onClick:ae,title:"Select all visible profiles",children:[s.jsx(Qc,{className:"w-4 h-4"}),"Select All"]}),s.jsxs(Ee,{variant:"secondary",onClick:ge,disabled:N.size===0,className:"text-red-500 hover:bg-red-500/10",title:`Delete ${N.size} selected profiles`,children:[s.jsx(ln,{className:"w-4 h-4"}),"Delete (",N.size,")"]}),s.jsxs(Ee,{variant:"secondary",onClick:()=>{A(!1),C(new Set)},children:[s.jsx(zt,{className:"w-4 h-4"}),"Cancel"]})]}):s.jsxs(Ee,{variant:"secondary",onClick:()=>A(!0),disabled:!re.length,title:"Enter selection mode for bulk delete",children:[s.jsx(Qc,{className:"w-4 h-4"}),"Select"]})]}),Y?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):q?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(H0,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Printer Offline"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:"The selected printer is not connected. Power it on to view K-profiles."}),s.jsxs(Ee,{variant:"secondary",onClick:()=>W(),children:[s.jsx(Rr,{className:"w-4 h-4"}),"Retry"]})]})}):re.length>0?de?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Left Extruder"}),s.jsx("div",{className:"space-y-1",children:re.filter(B=>B.extruder_id===1).map(B=>s.jsx(tj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:w,isSelected:N.has(z(B)),onToggleSelect:()=>oe(z(B)),note:Z(B)},z(B)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:"Right Extruder"}),s.jsx("div",{className:"space-y-1",children:re.filter(B=>B.extruder_id===0).map(B=>s.jsx(tj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:w,isSelected:N.has(z(B)),onToggleSelect:()=>oe(z(B)),note:Z(B)},z(B)))})]})]}):s.jsx("div",{className:"space-y-1",children:re.map(B=>s.jsx(tj,{profile:B,onEdit:()=>o(B),onCopy:()=>d(B),selectionMode:w,isSelected:N.has(z(B)),onToggleSelect:()=>oe(z(B)),note:Z(B)},z(B)))}):f||g!=="all"||v!=="all"?s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(Eo,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No Matching Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"No profiles match your search criteria"})]})}):s.jsx(_t,{children:s.jsxs(Mt,{className:"py-12 text-center",children:[s.jsx(v2,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No K-Profiles"}),s.jsxs("p",{className:"text-bambu-gray mb-4",children:["No pressure advance profiles found for ",r,"mm nozzle"]}),s.jsxs(Ee,{onClick:()=>c(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"Create First Profile"]})]})}),a&&e&&(()=>{const{note:B,key:U}=$(a);return s.jsx(nj,{profile:a,printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:de,initialNote:B,initialNoteKey:U,onSaveNote:V,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),o(null),W()},onSave:()=>{o(null),W()}})})(),l&&e&&s.jsx(nj,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:V,onClose:()=>{c(!1),W()},onSave:()=>{c(!1),W()}}),u&&e&&s.jsx(nj,{printerId:e,nozzleDiameter:r,existingProfiles:ee?.profiles||R?.profiles,isDualNozzle:de,onSaveNote:V,profile:{...u,slot_id:0,name:`${u.name} (Copy)`},onClose:()=>{d(null),W()},onSave:()=>{d(null),W()}}),T&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-sm",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(ln,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Profiles"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This cannot be undone"})]})]}),s.jsxs("p",{className:"text-bambu-gray mb-6",children:["Are you sure you want to delete ",s.jsx("span",{className:"text-white font-medium",children:N.size})," selected profiles from the printer?"]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Ee,{variant:"secondary",onClick:()=>D(!1),disabled:k,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{onClick:ue,disabled:k,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[k?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]})]})})})]})}function lL(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function L0(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function cqe(t){const e=fi(t);if(!e)return"";const r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4),a=Math.floor(r/36e5),o=Math.floor(r/864e5);return i<1?"Just now":i<60?`${i}m ago`:a<24?`${a}h ago`:o<7?`${o}d ago`:e.toLocaleDateString()}function uqe({onSuccess:t}){const{showToast:e}=Wn(),[n,r]=S.useState("email"),[i,a]=S.useState(""),[o,l]=S.useState(""),[c,u]=S.useState(""),[d,f]=S.useState(""),[p,g]=S.useState("global"),b=ht({mutationFn:()=>be.cloudLogin(i,o,p),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):w.needs_verification?(e("Verification code sent to your email"),r("code")):e(w.message,"error")},onError:w=>e(w.message,"error")}),v=ht({mutationFn:()=>be.cloudVerify(i,c),onSuccess:w=>{w.success?(e("Logged in successfully"),t()):e(w.message,"error")},onError:w=>e(w.message,"error")}),x=ht({mutationFn:()=>be.cloudSetToken(d),onSuccess:()=>{e("Token set successfully"),t()},onError:w=>e(w.message,"error")}),y=w=>{w.preventDefault(),n==="email"?b.mutate():n==="code"?v.mutate():n==="token"&&x.mutate()},E=b.isPending||v.isPending||x.isPending;return s.jsx(_t,{className:"max-w-md mx-auto",children:s.jsxs(Mt,{children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:s.jsx(g2,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Connect to Bambu Cloud"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Sync your slicer presets across devices"})]}),s.jsxs("form",{onSubmit:y,className:"space-y-4",children:[n==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Email"}),s.jsx("input",{type:"email",value:i,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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:o,onChange:w=>l(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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Region"}),s.jsxs("select",{value:p,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:[s.jsx("option",{value:"global",children:"Global"}),s.jsx("option",{value:"china",children:"China"})]})]})]}),n==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Verification Code"}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Check your email (",i,") for a 6-digit code"]}),s.jsx("input",{type:"text",value:c,onChange:w=>u(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"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Access Token"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Paste your Bambu Lab access token (from Bambu Studio)"}),s.jsx("textarea",{value:d,onChange:w=>f(w.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none",placeholder:"eyJ...",rows:4,required:!0})]}),s.jsxs("div",{className:"flex gap-2",children:[n==="code"&&s.jsx(Ee,{type:"button",variant:"secondary",onClick:()=>r("email"),className:"flex-1",children:"Back"}),s.jsxs(Ee,{type:"submit",disabled:E,className:"flex-1",children:[E?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(zU,{className:"w-4 h-4"}),n==="email"?"Login":n==="code"?"Verify":"Set Token"]})]}),n==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Uh,{className:"w-4 h-4"}),"Use access token instead"]})}),n==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>r("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(zU,{className:"w-4 h-4"}),"Login with email instead"]})})]})]})})}function cp({label:t,value:e,options:n,onChange:r}){const[i,a]=S.useState(!1),o=n.find(l=>l.value===e);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),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:[s.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),s.jsx("span",{children:o?.label||"All"}),s.jsx(Qi,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.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(l=>s.jsxs("button",{onClick:()=>{r(l.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===l.value?"text-bambu-green":"text-white"}`,children:[s.jsx("span",{children:l.label}),l.count!==void 0&&s.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function dqe(){const[t,e]=S.useState(!1);S.useEffect(()=>{const r=()=>{e(window.scrollY>300)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]);const n=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?s.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:s.jsx(Up,{className:"w-5 h-5"})}):null}function rj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o}){const l=lL(t.name),c=L0(t.setting_id);return s.jsxs("div",{className:"flex items-center gap-2 group",children:[s.jsx("button",{onClick:e,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?"bg-blue-500/20 border border-blue-500/50":o?"bg-bambu-dark/50 opacity-40 cursor-not-allowed":"bg-bambu-dark hover:bg-bambu-dark-tertiary"} ${r&&!o?"cursor-pointer":""}`,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&s.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&c&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:"My preset (editable)"}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),l.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.filamentType}),l.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.layerHeight}),l.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:l.printer})]})}),s.jsx("button",{onClick:u=>{u.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:"Duplicate",children:s.jsx($s,{className:"w-4 h-4"})})]})}function bR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(a=>n+" "+a).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+bR(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+bR(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function hqe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i}){const{showToast:a}=Wn(),o=an(),[l,c]=S.useState(!1),{data:u,isLoading:d}=lt({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>be.getCloudSettingDetail(t.setting_id)}),f=ht({mutationFn:()=>be.deleteCloudSetting(t.setting_id),onSuccess:()=>{a("Preset deleted"),o.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:b=>a(b.message,"error")}),p=L0(t.setting_id),g=lL(t.name,u?.setting?.inherits);return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),p&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:"Editable"})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsxs("span",{className:"capitalize",children:[t.type," preset"]}),g.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:g.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx("pre",{className:"text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full",children:bR(u)}):s.jsx("div",{className:"text-center py-16 text-bambu-gray",children:"Failed to load preset details"})}),l?s.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[s.jsx(yn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:"Delete this preset?"})]}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-4",children:['This will permanently delete "',t.name,'" from Bambu Cloud. This cannot be undone.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ee,{variant:"secondary",onClick:()=>c(!1),disabled:f.isPending,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{variant:"danger",onClick:()=>f.mutate(),disabled:f.isPending,className:"flex-1",children:[f.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]})]}):s.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ee,{variant:"secondary",onClick:e,className:"flex-1",children:"Close"}),s.jsxs(Ee,{variant:"secondary",onClick:r,children:[s.jsx($s,{className:"w-4 h-4"}),"Duplicate"]}),p&&s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{variant:"secondary",onClick:i,disabled:d||!u,children:[s.jsx(Jo,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Ee,{variant:"danger",onClick:()=>c(!0),children:s.jsx(ln,{className:"w-4 h-4"})})]})]})})]})})})}function Sne(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Mne(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function fqe({onClose:t,onApply:e}){const{showToast:n}=Wn(),[r,i]=S.useState(Sne),[a,o]=S.useState("all"),[l,c]=S.useState(null),[u,d]=S.useState(""),[f,p]=S.useState(""),[g,b]=S.useState("{}"),[v,x]=S.useState(null),[y,E]=S.useState(null),w=a==="all"?r:r.filter(L=>L.type===a),A=L=>{i(L),Mne(L)},N=L=>{const X=r.filter(R=>R.id!==L);A(X),E(null),n("Template deleted")},C=L=>{c(L.id),d(L.name),p(L.description),b(JSON.stringify(L.settings,null,2)),x(null)},T=()=>{if(!(!l||!u.trim()))try{const L=JSON.parse(g),X=r.map(R=>R.id===l?{...R,name:u.trim(),description:f.trim(),settings:L}:R);A(X),c(null),n("Template updated")}catch(L){x(L.message)}},D=()=>{c(null),d(""),p(""),b("{}"),x(null)},k=L=>{const X=r.map(R=>R.id===L?{...R,showInModal:!R.showInModal}:R);A(X)},P={filament:{label:"Filament",icon:kR,color:"text-amber-400"},print:{label:"Process",icon:Pd,color:"text-blue-400"},printer:{label:"Printer",icon:Qr,color:"text-purple-400"}},z=y?r.find(L=>L.id===y):null;return S.useEffect(()=>{const L=X=>{X.key==="Escape"&&(y?E(null):l?D():t())};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[y,l,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[z&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(_t,{className:"w-full max-w-md",children:s.jsxs(Mt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:s.jsx(yn,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Delete Template"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"This action cannot be undone"})]})]}),s.jsxs("p",{className:"text-white mb-6",children:['Are you sure you want to delete "',s.jsx("span",{className:"font-medium",children:z.name}),'"?']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ee,{variant:"secondary",onClick:()=>E(null),className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{onClick:()=>N(y),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]})]})})}),s.jsx(_t,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Xb,{className:"w-5 h-5 text-amber-400"}),"Quick Templates"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Type:"}),["all","filament","print","printer"].map(L=>s.jsx("button",{onClick:()=>o(L),className:`px-3 py-1 text-sm rounded-lg transition-colors ${a===L?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:L==="all"?"All":P[L].label},L))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:w.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(Xb,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:"No templates yet"}),s.jsx("p",{className:"text-sm mt-1",children:"Create templates from the preset editor"})]}):s.jsx("div",{className:"space-y-2",children:w.map(L=>{const X=P[L.type],R=X.icon;return l===L.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:u,onChange:Y=>d(Y.target.value),placeholder:"Template name",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:f,onChange:Y=>p(Y.target.value),placeholder:"Description",className:"px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:"Settings (JSON)"}),s.jsx("textarea",{value:g,onChange:Y=>{b(Y.target.value),x(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ee,{size:"sm",onClick:T,disabled:!u.trim(),children:[s.jsx(Rs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:D,children:"Cancel"})]})]},L.id):s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors",children:[s.jsx(R,{className:`w-5 h-5 ${X.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:L.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:L.description})]}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:[Object.keys(L.settings).length," fields"]}),s.jsx("button",{onClick:()=>k(L.id),className:`p-1 transition-colors ${L.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:L.showInModal?"Shown in modals":"Hidden in modals",children:L.showInModal?s.jsx(mf,{className:"w-4 h-4"}):s.jsx(x2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(L),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:"Apply"}),s.jsx("button",{onClick:()=>C(L),className:"p-1 text-bambu-gray hover:text-white",title:"Edit",children:s.jsx(Jo,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E(L.id),className:"p-1 text-bambu-gray hover:text-red-400",title:"Delete",children:s.jsx(ln,{className:"w-4 h-4"})})]},L.id)})})})]})})]})}function Ene({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i}){const[a,o]=S.useState("changes"),[l,c]=S.useState(""),u=S.useMemo(()=>{const g=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const v of g){if(v==="inherits"||v==="version")continue;const x=e[v],y=n[v],E=v in e,w=v in n;let A;!E&&w?A="added":E&&!w?A="removed":JSON.stringify(x)!==JSON.stringify(y)?A="changed":A="same",b.push({key:v,left:x,right:y,status:A})}return b.sort((v,x)=>{const y={changed:0,added:1,removed:2,same:3};return y[v.status]!==y[x.status]?y[v.status]-y[x.status]:v.key.localeCompare(x.key)})},[e,n]),d=S.useMemo(()=>{let g=[...u];if(a==="changes"&&(g=g.filter(b=>b.status!=="same")),l){const b=l.toLowerCase();g=g.filter(v=>v.key.toLowerCase().includes(b)||String(v.left).toLowerCase().includes(b)||String(v.right).toLowerCase().includes(b))}return g},[u,a,l]),f=S.useMemo(()=>({added:u.filter(g=>g.status==="added").length,removed:u.filter(g=>g.status==="removed").length,changed:u.filter(g=>g.status==="changed").length,same:u.filter(g=>g.status==="same").length}),[u]),p=g=>{if(g===void 0)return"—";if(g===null)return"null";if(Array.isArray(g))return g.length===0?"[]":g.length===1?String(g[0]):g.join(", ");if(typeof g=="object")return JSON.stringify(g);const b=String(g);if(b.includes("\\n")||b.length>100){const v=b.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return S.useEffect(()=>{const g=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(_t,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Mt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ep,{className:"w-5 h-5 text-blue-400"}),"Compare Presets"]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(zt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Left:"}),s.jsx("p",{className:"text-white font-medium truncate",children:r})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Right:"}),s.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(dr,{className:"w-3.5 h-3.5"}),f.added," added"]}),s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Mj,{className:"w-3.5 h-3.5"}),f.removed," removed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(vj,{className:"w-3.5 h-3.5"}),f.changed," changed"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(gA,{className:"w-3.5 h-3.5"}),f.same," same"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Eo,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:l,onChange:g=>c(g.target.value),placeholder:"Search fields...",className:"pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48"})]}),f.same>0&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>o("changes"),className:`px-3 py-1.5 text-sm transition-colors ${a==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"Changes"}),s.jsx("button",{onClick:()=>o("all"),className:`px-3 py-1.5 text-sm transition-colors ${a==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:"All"})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:d.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(gA,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a==="changes"?"No differences found":"No fields match the search"})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:"Field"}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:d.map(g=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[g.status],v={added:s.jsx(dr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(Mj,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(vj,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(gA,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[g.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[v,s.jsx("span",{className:"text-sm text-white font-mono",children:g.key})]})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${g.status==="removed"?"text-red-300":g.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(g.left)})}),s.jsx("td",{className:"p-3",children:s.jsx("span",{className:`text-sm font-mono break-all ${g.status==="added"?"text-green-300":g.status==="changed"?"text-white":"text-bambu-gray"}`,children:p(g.right)})})]},g.key)})})]})})]})})})}function mqe({onClose:t,initialData:e,allPresets:n}){const{showToast:r}=Wn(),i=an(),a=!!e?.setting_id,[o,l]=S.useState("common"),[c,u]=S.useState(e?.type||"filament"),[d,f]=S.useState(e?.name?a?e.name:`${e.name} (Copy)`:""),[p,g]=S.useState(e?.base_id||""),[b,v]=S.useState(""),[x,y]=S.useState(e?.setting||{inherits:""}),[E,w]=S.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[A,N]=S.useState(null),[C,T]=S.useState(""),[D,k]=S.useState(!1),[P,z]=S.useState(""),[L,X]=S.useState(!1),[R,Y]=S.useState(Sne),[J,G]=S.useState(!1),[W,ee]=S.useState(""),[K,F]=S.useState(""),[q,ne]=S.useState(!0),[re,se]=S.useState(null),[de,pe]=S.useState(!1),Ce=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[c]||[],[n,c]),oe=S.useMemo(()=>Ce.filter(me=>L0(me.setting_id)),[Ce]),{data:ae}=lt({queryKey:["cloudFields",c],queryFn:()=>be.getCloudFields(c==="print"?"process":c),staleTime:1e3*60*60}),{data:ge}=lt({queryKey:["allPresetDetails",c,oe.map(me=>me.setting_id).join(",")],queryFn:async()=>{const me={};for(let qe=0;qe<oe.length;qe+=5){const Qe=oe.slice(qe,qe+5);(await Promise.all(Qe.map(async ie=>{try{const He=await be.getCloudSettingDetail(ie.setting_id);return{id:ie.setting_id,detail:He}}catch{return null}}))).forEach(ie=>{ie&&(me[ie.id]=ie.detail)})}return me},enabled:oe.length>0,staleTime:1e3*60*10}),{data:ue,isLoading:Le}=lt({queryKey:["cloudSettingDetail",p],queryFn:()=>be.getCloudSettingDetail(p),enabled:!!p});S.useEffect(()=>{o!=="json"&&w(JSON.stringify(x,null,2))},[x,o]);const V=S.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[c]||[]).filter(Ke=>!L0(Ke.setting_id)).sort((Ke,qe)=>Ke.name.localeCompare(qe.name)),[n,c]);S.useEffect(()=>{if(!p)return;const me=V.find(Ke=>Ke.setting_id===p);me&&(v(me.name),a||(y({inherits:me.name}),w(JSON.stringify({inherits:me.name},null,2))))},[p,V,a]);const $=S.useMemo(()=>{const me=ae?.fields||[],Ke=new Set(me.map(ie=>ie.key)),qe=new Set,Qe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);ge&&Object.values(ge).forEach(ie=>{ie?.setting&&Object.keys(ie.setting).forEach(He=>{!Ke.has(He)&&!Qe.has(He)&&qe.add(He)})}),Object.keys(x).forEach(ie=>{!Ke.has(ie)&&!Qe.has(ie)&&qe.add(ie)});const ut=Array.from(qe).sort().map(ie=>({key:ie,label:ie.replace(/_/g," ").replace(/\b\w/g,He=>He.toUpperCase()),type:"text",category:"discovered",description:"Discovered from presets"}));return[...me,...ut]},[ae,ge,x]),Z=$.filter(me=>me.label.toLowerCase().includes(C.toLowerCase())||me.key.toLowerCase().includes(C.toLowerCase())),B=()=>{if(P.trim()){const me=P.trim().toLowerCase().replace(/\s+/g,"_");U(me,""),z(""),X(!1),r(`Field "${me}" added`)}},U=(me,Ke)=>{y(qe=>{const Qe={...qe};return Ke===""||Ke===void 0?delete Qe[me]:Qe[me]=Ke,Qe})},Q=me=>{y(Ke=>({...Ke,...me.settings})),se(me.name),r("Template applied")},Me=()=>{if(!W.trim())return;const me={...x};if(delete me.inherits,Object.keys(me).length===0){r("No overrides to save","error");return}const Ke={id:Date.now().toString(),name:W.trim(),description:K.trim()||"Custom template",type:c,settings:me,showInModal:q},qe=[...R,Ke];Y(qe),Mne(qe),G(!1),ee(""),F(""),ne(!0),r("Template saved")},Te=S.useMemo(()=>R.filter(me=>me.type===c&&me.showInModal),[c,R]),fe=me=>{w(me);try{const Ke=JSON.parse(me);y(Ke),N(null)}catch(Ke){N(Ke.message)}},H=me=>{me.preventDefault(),k(!1);const Ke=me.dataTransfer.files[0];if(Ke&&Ke.name.endsWith(".json")){const qe=new FileReader;qe.onload=Qe=>{try{const ut=Qe.target?.result,ie=JSON.parse(ut),He=ie.setting||ie;y(ve=>({...ve,...He})),w(JSON.stringify({...x,...He},null,2)),r("File imported successfully")}catch{r("Invalid JSON file","error")}},qe.readAsText(Ke)}},I=ht({mutationFn:()=>{const me={...x},Ke=c==="filament"?"filament_settings_id":c==="print"?"print_settings_id":"printer_settings_id";me[Ke]=`"${d}"`;const qe={type:c,name:d,base_id:p,setting:me};return be.createCloudSetting(qe)},onSuccess:async()=>{r("Preset created successfully"),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:me=>r(me.message,"error")}),ce=ht({mutationFn:()=>{if(!e?.setting_id)throw new Error("No setting ID for update");return be.updateCloudSetting(e.setting_id,{name:d,setting:x})},onSuccess:async()=>{r("Preset updated successfully"),i.removeQueries({queryKey:["cloudSettingDetail"]}),await i.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:me=>r(me.message,"error")}),we=a?ce:I,Se=ue?.setting?.inherits,_e=Se?V.find(me=>me.name===Se):void 0,{data:st}=lt({queryKey:["cloudSettingDetail",_e?.setting_id],queryFn:()=>be.getCloudSettingDetail(_e.setting_id),enabled:!!_e?.setting_id}),Ve=S.useMemo(()=>{const me=st?.setting||{},Ke=ue?.setting||{},qe=p&&ge?.[p]?.setting?ge[p].setting:{};return{...me,...Ke,...qe}},[p,ue,st,ge]),it=me=>{if(me==null)return"";if(Array.isArray(me)){const Ke=[...new Set(me.map(qe=>String(qe)))];return Ke.length===1?Ke[0]:me.join(", ")}return String(me)},ct=me=>{const Ke=x[me.key],qe=Ve[me.key],Qe=it(qe),ut=Le?"Loading...":Qe||"",ie="w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none";if(me.type==="boolean"){const He=Ke==="1"||Ke===void 0&&qe==="1";return s.jsx("button",{type:"button",onClick:()=>U(me.key,Ke==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${He?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${He?"translate-x-3.5":"translate-x-0.5"}`})})}return me.type==="select"?s.jsxs("select",{value:Ke||"",onChange:He=>U(me.key,He.target.value),className:ie,children:[s.jsx("option",{value:"",children:ut}),me.options?.map(He=>s.jsx("option",{value:He.value,children:He.label},He.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:me.type==="number"?"number":"text",value:Ke!==void 0?String(Ke):"",onChange:He=>U(me.key,He.target.value),step:me.step,min:me.min,max:me.max,placeholder:ut,className:ie}),me.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:me.unit})]})},Fe=S.useMemo(()=>ue?.setting?ue.setting:{},[ue]);return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:me=>{me.preventDefault(),k(!0)},onDragLeave:()=>k(!1),onDrop:H,children:[de&&p&&s.jsx(Ene,{onClose:()=>pe(!1),leftPreset:Fe,rightPreset:x,leftLabel:`Base: ${b||p}`,rightLabel:`Current: ${d||"New Preset"}`}),s.jsx(_t,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Mt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:a?"Edit Preset":e?"Duplicate Preset":"Create New Preset"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize settings for your new preset"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[p&&s.jsxs("button",{onClick:()=>pe(!0),className:"flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Compare with base preset",children:[s.jsx(Ep,{className:"w-4 h-4"}),"Compare"]}),s.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(zt,{className:"w-5 h-5"})})]})]}),D&&s.jsx("div",{className:"absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(xi,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:"Drop JSON file to import"})]})}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Type"}),s.jsxs("select",{value:c,onChange:me=>{u(me.target.value),g("")},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:[s.jsx("option",{value:"filament",children:"Filament"}),s.jsx("option",{value:"print",children:"Process"}),s.jsx("option",{value:"printer",children:"Printer"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Base Preset"}),s.jsxs("select",{value:p,onChange:me=>g(me.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:[s.jsx("option",{value:"",children:"Select base preset..."}),V.map(me=>s.jsx("option",{value:me.setting_id,children:me.name},me.setting_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Preset Name"}),s.jsx("input",{type:"text",value:d,onChange:me=>f(me.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"})]})]}),b&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(Aa,{className:"w-3 h-3 text-bambu-green"}),"Inherits from: ",s.jsx("span",{className:"text-white",children:b}),Le&&s.jsx(ft,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>l("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(BU,{className:"w-4 h-4"}),"Common"]}),s.jsxs("button",{onClick:()=>l("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(M2,{className:"w-4 h-4"}),"All Fields"]}),s.jsxs("button",{onClick:()=>l("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${o==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[s.jsx(sW,{className:"w-4 h-4"}),"JSON",A&&s.jsx(pa,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const me={name:d,type:c,base_id:p,setting:x},Ke=new Blob([JSON.stringify(me,null,2)],{type:"application/json"}),qe=URL.createObjectURL(Ke),Qe=document.createElement("a");Qe.href=qe,Qe.download=`${d||"preset"}.json`,document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),URL.revokeObjectURL(qe),r("Preset exported")},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Export current settings to JSON file",children:[s.jsx(Yr,{className:"w-4 h-4"}),"Export"]}),s.jsxs("button",{onClick:()=>document.getElementById("file-import")?.click(),className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:"Import settings from JSON file",children:[s.jsx(xi,{className:"w-4 h-4"}),"Import"]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:me=>{const Ke=me.target.files?.[0];if(Ke){const qe=new FileReader;qe.onload=Qe=>{try{const ut=JSON.parse(Qe.target?.result),ie=ut.setting||ut;y(He=>({...He,...ie})),r("File imported")}catch{r("Invalid JSON","error")}},qe.readAsText(Ke)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[o==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(Xb,{className:"w-4 h-4 text-amber-400"}),"Quick Templates"]}),Object.keys(x).filter(me=>me!=="inherits").length>0&&s.jsxs("button",{onClick:()=>G(!J),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(Rs,{className:"w-3 h-3"}),"Save as template"]})]}),J&&s.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[s.jsx("input",{type:"text",value:W,onChange:me=>ee(me.target.value),placeholder:"Template name",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx("input",{type:"text",value:K,onChange:me=>F(me.target.value),placeholder:"Description (optional)",className:"px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ee,{size:"sm",onClick:Me,disabled:!W.trim(),children:[s.jsx(Rs,{className:"w-3 h-3"}),"Save"]}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:()=>G(!1),children:"Cancel"})]}),s.jsxs("button",{onClick:()=>ne(!q),className:`flex items-center gap-1.5 text-xs transition-colors ${q?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[q?s.jsx(mf,{className:"w-3.5 h-3.5"}):s.jsx(x2,{className:"w-3.5 h-3.5"}),q?"Show in modals":"Hidden in modals"]})]})]}),re&&s.jsxs("div",{className:"mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2",children:[s.jsx(Aa,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:["Template applied: ",s.jsx("span",{className:"font-medium",children:re})]}),s.jsx("button",{onClick:()=>se(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(zt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[Te.map(me=>s.jsxs("button",{onClick:()=>Q(me),className:"p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:me.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me.description})]},me.id)),Te.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:"No templates selected. Use the Templates button to enable templates for quick access."})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:"Manage templates via the Templates button on the main page"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Common Settings"}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:$.slice(0,10).map(me=>s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:me.label}),s.jsx("div",{className:"w-48",children:ct(me)})]},me.key))})]}),Object.keys(x).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:"Current Overrides"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(x).filter(([me])=>me!=="inherits").map(([me,Ke])=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded",children:[me,": ",String(Ke).slice(0,20),s.jsx("button",{onClick:()=>U(me,void 0),className:"hover:text-white",children:s.jsx(zt,{className:"w-3 h-3"})})]},me))})]})]}),o==="fields"&&s.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"Available Fields"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:ge?`${$.length} fields`:"Loading..."})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(Eo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:C,onChange:me=>T(me.target.value),placeholder:"Search fields...",className:"w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[Z.filter(me=>!(me.key in x)).map(me=>{const Ke=Ve[me.key],qe=it(Ke);return s.jsxs("div",{onClick:()=>{y(Qe=>({...Qe,[me.key]:qe||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white truncate",children:me.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:me.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[qe&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:qe,children:[qe.slice(0,20),qe.length>20?"...":""]}),s.jsx("div",{className:"w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors",children:s.jsx(dr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},me.key)}),Z.filter(me=>!(me.key in x)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:C?"No matching fields":"All fields added"})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:L?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:P,onChange:me=>z(me.target.value),onKeyDown:me=>me.key==="Enter"&&B(),placeholder:"custom_field_name",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none",autoFocus:!0}),s.jsx(Ee,{size:"sm",onClick:B,disabled:!P.trim(),children:s.jsx(dr,{className:"w-4 h-4"})}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:()=>{X(!1),z("")},children:s.jsx(zt,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>X(!0),className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(dr,{className:"w-4 h-4"}),"Add custom field"]})})]}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"Your Overrides"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Object.keys(x).filter(me=>me!=="inherits").length," fields"]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(x).filter(([me])=>me!=="inherits").map(([me,Ke])=>{const qe=$.find(Qe=>Qe.key===me);return s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:qe?.label||me}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:me})]}),s.jsx("button",{onClick:()=>U(me,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(zt,{className:"w-4 h-4"})})]}),qe?ct(qe):s.jsx("input",{type:"text",value:String(Ke),onChange:Qe=>U(me,Qe.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},me)}),Object.keys(x).filter(me=>me!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(BU,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:"No overrides yet"}),s.jsx("p",{className:"text-xs mt-1",children:"Click fields on the left to add them"})]})]}),Object.keys(x).filter(me=>me!=="inherits").length>0&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsxs("button",{onClick:()=>{G(!0),l("common")},className:"w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors",children:[s.jsx(Rs,{className:"w-4 h-4"}),"Save as template"]})})]})]}),o==="json"&&s.jsxs("div",{className:"space-y-2",children:[A&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx(pa,{className:"w-4 h-4"}),A]}),s.jsx("textarea",{value:E,onChange:me=>fe(me.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${A?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Tip: Drag & drop a .json file anywhere on this modal to import settings"})]})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[s.jsx(Ee,{variant:"secondary",onClick:t,className:"flex-1",children:"Cancel"}),s.jsxs(Ee,{onClick:()=>we.mutate(),disabled:we.isPending||!d.trim()||!a&&!p||!!A,className:"flex-1",children:[we.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):a?s.jsx(Rs,{className:"w-4 h-4"}):s.jsx(dr,{className:"w-4 h-4"}),a?"Save":e?"Duplicate":"Create"]})]})]})})]})}function pqe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i}){const[a,o]=S.useState(""),[l,c]=S.useState("all"),[u,d]=S.useState("all"),[f,p]=S.useState("all"),[g,b]=S.useState("all"),[v,x]=S.useState("all"),[y,E]=S.useState("all"),[w,A]=S.useState(null),[N,C]=S.useState(!1),[T,D]=S.useState(!1),[k,P]=S.useState(null),[z,L]=S.useState(null),[X,R]=S.useState(null),[Y,J]=S.useState(!1),[G,W]=S.useState([null,null]),[ee,K]=S.useState(!1),[F,q]=S.useState(null),ne=an(),re=S.useMemo(()=>[...t.filament.map(Z=>({...Z,type:"filament"})),...t.printer.map(Z=>({...Z,type:"printer"})),...t.process.map(Z=>({...Z,type:"process"}))].map(Z=>({...Z,meta:lL(Z.name)})),[t]),se=S.useMemo(()=>{const $=new Set,Z=new Set,B=new Set;return re.forEach(U=>{U.meta.nozzle&&$.add(U.meta.nozzle),U.meta.filamentType&&Z.add(U.meta.filamentType),U.meta.layerHeight&&B.add(U.meta.layerHeight)}),{printers:i.map(U=>({id:U.id.toString(),name:U.name})),nozzles:Array.from($).sort((U,Q)=>parseFloat(U)-parseFloat(Q)),filaments:Array.from(Z).sort(),layerHeights:Array.from(B).sort((U,Q)=>parseFloat(U)-parseFloat(Q))}},[re,i]),de=S.useMemo(()=>f==="all"?null:i.find(Z=>Z.id.toString()===f)?.model||null,[f,i]),pe=S.useMemo(()=>re.filter($=>l==="all"||$.type===l).filter($=>{if(u==="all")return!0;const Z=L0($.setting_id);return u==="custom"?Z:!Z}).filter($=>{if(f==="all"||!de)return!0;const Z=$.meta.printer?.toLowerCase()||"",B=de.toLowerCase();return Z.includes(B)||B.includes(Z)}).filter($=>g==="all"||$.meta.nozzle===g).filter($=>v==="all"||$.meta.filamentType===v).filter($=>y==="all"||$.meta.layerHeight===y).filter($=>a===""||$.name.toLowerCase().includes(a.toLowerCase())).sort(($,Z)=>$.name.localeCompare(Z.name)),[re,l,u,f,de,g,v,y,a]),Ce=$=>{if(Y){const Z=G[0]?.setting_id===$.setting_id,B=G[1]?.setting_id===$.setting_id;if(Z)W([G[1],null]);else if(B)W([G[0],null]);else if(!G[0])W([$,null]);else if(G[1]){if(G[0].type!==$.type)return;W([G[0],$])}else{if(G[0].type!==$.type)return;W([G[0],$])}}else A($)},oe=$=>{if(G[0]?.setting_id===$.setting_id)return 0;if(G[1]?.setting_id===$.setting_id)return 1},ae=async $=>{try{const Z=await be.getCloudSettingDetail($.setting_id),B=$.type==="process"?"print":$.type;P({type:B,name:$.name,base_id:Z.base_id||"GFSA00",setting:Z.setting||{}}),A(null)}catch(Z){console.error("Failed to fetch preset details for duplication:",Z)}},ge=async $=>{try{ne.removeQueries({queryKey:["cloudSettingDetail",$.setting_id]});const Z=await be.getCloudSettingDetail($.setting_id),B=$.type==="process"?"print":$.type;L({type:B,name:$.name,base_id:Z.base_id||"GFSA00",setting:Z.setting||{},setting_id:$.setting_id}),A(null)}catch(Z){console.error("Failed to fetch preset details for editing:",Z)}},ue=()=>{c("all"),d("all"),p("all"),b("all"),x("all"),E("all"),o("")},Le=l!=="all"||u!=="all"||f!=="all"||g!=="all"||v!=="all"||y!=="all"||a!=="",V=t.filament.length+t.printer.length+t.process.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-4 mb-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(Eo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:a,onChange:$=>o($.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"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ee,{variant:Y?"primary":"secondary",onClick:()=>{Y?(J(!1),W([null,null])):J(!0)},children:[s.jsx(Ep,{className:"w-4 h-4"}),Y?"Cancel":"Compare"]}),s.jsxs(Ee,{variant:"secondary",onClick:()=>D(!0),children:[s.jsx(Xb,{className:"w-4 h-4"}),"Templates"]}),s.jsxs(Ee,{variant:"secondary",onClick:n,disabled:r,children:[s.jsx(Rr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),"Refresh"]}),s.jsxs(Ee,{onClick:()=>C(!0),children:[s.jsx(dr,{className:"w-4 h-4"}),"New Preset"]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(y2,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(cp,{label:"Type",value:l,options:[{value:"all",label:"All",count:V},{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:$=>c($)}),s.jsx(cp,{label:"Owner",value:u,options:[{value:"all",label:"All"},{value:"custom",label:"My Presets"},{value:"builtin",label:"Built-in"}],onChange:$=>d($)}),se.printers.length>0&&s.jsx(cp,{label:"Printer",value:f,options:[{value:"all",label:"All"},...se.printers.map($=>({value:$.id,label:$.name}))],onChange:p}),se.nozzles.length>0&&s.jsx(cp,{label:"Nozzle",value:g,options:[{value:"all",label:"All"},...se.nozzles.map($=>({value:$,label:$}))],onChange:b}),se.filaments.length>0&&(l==="all"||l==="filament")&&s.jsx(cp,{label:"Filament",value:v,options:[{value:"all",label:"All"},...se.filaments.map($=>({value:$,label:$}))],onChange:x}),se.layerHeights.length>0&&(l==="all"||l==="process")&&s.jsx(cp,{label:"Layer",value:y,options:[{value:"all",label:"All"},...se.layerHeights.map($=>({value:$,label:$}))],onChange:E}),Le&&s.jsx("button",{onClick:ue,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:"Clear filters"})]})]}),Y&&s.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(Ep,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:"Compare Mode"}),s.jsx("span",{className:"text-bambu-gray",children:G[0]?`Select another ${G[0].type} preset`:"Click two presets of the same type to compare"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[0]?G[0].name:"1. Select first"}),s.jsx(vj,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${G[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:G[1]?G[1].name:"2. Select second"})]}),G[0]&&G[1]&&s.jsxs(Ee,{size:"sm",onClick:async()=>{try{const[$,Z]=await Promise.all([be.getCloudSettingDetail(G[0].setting_id),be.getCloudSettingDetail(G[1].setting_id)]);q([$.setting||{},Z.setting||{}]),K(!0)}catch{}},children:[s.jsx(Ep,{className:"w-4 h-4"}),"Compare Now"]})]})]})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),"Last synced: ",cqe(e.toISOString())]}),s.jsxs("span",{children:["Showing ",pe.length," of ",V," presets"]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),s.jsx("span",{children:"= My preset (editable)"})]})]}),pe.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(Hs,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:"No presets found"}),Le&&s.jsx("button",{onClick:ue,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:"Clear filters"})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(kR,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Filament"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",pe.filter($=>$.type==="filament").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[pe.filter($=>$.type==="filament").map($=>s.jsx(rj,{setting:$,onClick:()=>Ce($),onDuplicate:()=>ae($),compareMode:Y,isCompareSelected:oe($)!==void 0,compareIndex:oe($),compareDisabled:Y&&!!G[0]&&G[0].type!==$.type},$.setting_id)),pe.filter($=>$.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No filament presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Pd,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Process"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",pe.filter($=>$.type==="process").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[pe.filter($=>$.type==="process").map($=>s.jsx(rj,{setting:$,onClick:()=>Ce($),onDuplicate:()=>ae($),compareMode:Y,isCompareSelected:oe($)!==void 0,compareIndex:oe($),compareDisabled:Y&&!!G[0]&&G[0].type!==$.type},$.setting_id)),pe.filter($=>$.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No process presets"})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Qr,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:"Printer"}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",pe.filter($=>$.type==="printer").length,")"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[pe.filter($=>$.type==="printer").map($=>s.jsx(rj,{setting:$,onClick:()=>Ce($),onDuplicate:()=>ae($),compareMode:Y,isCompareSelected:oe($)!==void 0,compareIndex:oe($),compareDisabled:Y&&!!G[0]&&G[0].type!==$.type},$.setting_id)),pe.filter($=>$.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:"No printer presets"})]})]})]}),w&&s.jsx(hqe,{setting:w,onClose:()=>A(null),onDeleted:()=>A(null),onDuplicate:()=>ae(w),onEdit:()=>ge(w)}),(N||k||z||X)&&s.jsx(mqe,{onClose:()=>{C(!1),P(null),L(null),R(null)},initialData:z||k||(X?{type:X.type,name:"",base_id:"",setting:X.setting}:void 0),allPresets:t}),T&&s.jsx(fqe,{onClose:()=>D(!1),onApply:$=>{R({type:$.type,setting:$.settings}),D(!1)}}),ee&&F&&G[0]&&G[1]&&s.jsx(Ene,{onClose:()=>{K(!1),q(null)},leftPreset:F[0],rightPreset:F[1],leftLabel:G[0].name,rightLabel:G[1].name})]})}function gqe(){const t=an(),{showToast:e}=Wn(),[n,r]=S.useState("cloud"),[i,a]=S.useState(),{data:o,isLoading:l}=lt({queryKey:["cloudStatus"],queryFn:be.getCloudStatus}),{data:c=[]}=lt({queryKey:["printers"],queryFn:be.getPrinters}),{data:u,isLoading:d,refetch:f,dataUpdatedAt:p}=lt({queryKey:["cloudSettings"],queryFn:()=>be.getCloudSettings(),enabled:!!o?.is_authenticated,retry:!1,staleTime:1e3*60*5});S.useEffect(()=>{p&&a(new Date(p))},[p]);const g=ht({mutationFn:be.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:["cloudStatus"]}),t.removeQueries({queryKey:["cloudSettings"]}),e("Logged out")}}),b=()=>{t.invalidateQueries({queryKey:["cloudStatus"]})};return l?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-6 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Profiles"}),s.jsx("p",{className:"text-bambu-gray",children:"Manage your slicer presets and pressure advance calibrations"})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[s.jsxs("button",{onClick:()=>r("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:[s.jsx(g2,{className:"w-4 h-4"}),"Cloud Profiles"]}),s.jsxs("button",{onClick:()=>r("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:[s.jsx(v2,{className:"w-4 h-4"}),"K-Profiles"]})]}),n==="cloud"&&s.jsxs(s.Fragment,{children:[o?.is_authenticated&&s.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:["Connected as ",s.jsx("span",{className:"text-white",children:o.email})]})]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>g.mutate(),disabled:g.isPending,children:[s.jsx(Mue,{className:"w-4 h-4"}),"Logout"]})]}),o?.is_authenticated?d?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):u?s.jsx(pqe,{settings:u,lastSyncTime:i,onRefresh:()=>f(),isRefreshing:d,printers:c}):s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:"Failed to load profiles"}),s.jsx(Ee,{onClick:()=>f(),children:"Retry"})]}):s.jsx(uqe,{onSuccess:b})]}),n==="kprofiles"&&s.jsx(lqe,{}),s.jsx(dqe,{})]})}const bb={Droplet:kR,Flame:Dce,Ruler:hde,Sparkles:Xb,Square:Zc,Cable:jle,Wrench:Rd,Calendar:qr,Timer:hd,Cog:oce,Fan:oW,Zap:bf,Wind:yW,Thermometer:N2,Layers:Hs,Box:ks,Target:mW,RefreshCw:Rr,Settings:$0,Filter:y2,CircleDot:Kle};function $b(t){return t&&bb[t]||Rd}function up(t,e){if(e==="days")return t<1?"Today":t===1?"1 day":t<7?`${Math.round(t)} days`:t<180?`${Math.round(t/7)} weeks`:`${Math.round(t/30)} months`;{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const n=t/24;if(n<7)return`${n<2?n.toFixed(1):Math.round(n)}d`;const r=n/7;return r<12?`${r<2?r.toFixed(1):Math.round(r)}w`:`${Math.round(r/4)}mo`}}function ij(t,e){return e==="days"?t===1?"1 day":t===7?"1 week":t===14?"2 weeks":t===30?"1 month":t===60?"2 months":t===90?"3 months":t===180?"6 months":t===365?"1 year":`${t} days`:`${t}h`}function xqe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),o=n.includes("A1")&&!a,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":a||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":a||o||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":a||o?"https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube":l?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":u?"https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer":c?"https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer":"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube";case"Replace HEPA Filter":case"HEPA Filter":case"Replace Carbon Filter":case"Carbon Filter":return d?"https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte":"https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter";case"Lubricate Left Nozzle Rail":case"Left Nozzle Rail":return d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":null;default:return null}}function bqe({item:t,onPerform:e,onToggle:n}){const r=$b(t.maintenance_type_icon),i=t.interval_type||"hours",o=(()=>{if(i==="days"){const f=t.days_since_maintenance??0;return Math.max(0,Math.min(100,f/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),l=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",c=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",u=()=>t.enabled?t.is_due?"bg-red-500/5 border-red-500/20":t.is_warning?"bg-amber-500/5 border-amber-500/20":"bg-bambu-dark-secondary border-bambu-dark-tertiary":"bg-bambu-dark-secondary/50",d=()=>{if(!t.enabled)return"Disabled";if(i==="days"){const f=t.days_until_due??0;return t.is_due?`Overdue by ${up(Math.abs(f),"days")}`:t.is_warning?`Due in ${up(f,"days")}`:`${up(f,"days")} left`}else return t.is_due?`Overdue by ${up(Math.abs(t.hours_until_due),"hours")}`:t.is_warning?`Due in ${up(t.hours_until_due,"hours")}`:`${up(t.hours_until_due,"hours")} left`};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${u()}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:`relative p-2.5 rounded-lg ${t.is_due?"bg-red-500/20":t.is_warning?"bg-amber-500/20":t.enabled?"bg-bambu-dark":"bg-bambu-dark/50"}`,children:[s.jsx(r,{className:`w-5 h-5 ${l()}`}),t.enabled&&(t.is_due||t.is_warning)&&s.jsx("span",{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${t.is_due?"bg-red-500":"bg-amber-500"} animate-pulse`})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),i==="days"&&s.jsx("span",{title:"Time-based interval",children:s.jsx(qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const f=t.maintenance_type_wiki_url||xqe(t.maintenance_type_name,t.printer_model);return f?s.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:"View documentation",onClick:p=>p.stopPropagation(),children:s.jsx(Kr,{className:"w-3.5 h-3.5"})}):null})()]}),s.jsx("div",{className:"mt-2 mb-1.5",children:s.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${c()}`,style:{width:`${o}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${l()}`,children:[t.is_due&&s.jsx(yn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(tr,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(Aa,{className:"w-3 h-3"}),d()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx($n,{checked:t.enabled,onChange:f=>n(t.id,f)}),s.jsxs(Ee,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled,className:"!px-3",children:[s.jsx(If,{className:"w-3.5 h-3.5"}),"Reset"]})]})]})})}function yqe({overview:t,onPerform:e,onToggle:n,onSetHours:r}){const[i,a]=S.useState(!0),[o,l]=S.useState(!1),[c,u]=S.useState(t.total_print_hours.toFixed(1)),d=[...t.maintenance_items].sort((g,b)=>g.is_due&&!b.is_due?-1:!g.is_due&&b.is_due?1:g.is_warning&&!b.is_warning?-1:!g.is_warning&&b.is_warning?1:g.maintenance_type_id-b.maintenance_type_id),f=d.find(g=>g.enabled&&(g.is_due||g.is_warning)),p=()=>{const g=parseFloat(c);!isNaN(g)&&g>=0&&(r(t.printer_id,g),l(!1))};return s.jsxs(_t,{className:"overflow-hidden",children:[s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&s.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.5",children:[s.jsx(yn,{className:"w-3 h-3"}),t.due_count," overdue"]}),t.warning_count>0&&s.jsxs("span",{className:"px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5",children:[s.jsx(tr,{className:"w-3 h-3"}),t.warning_count," due soon"]}),t.due_count===0&&t.warning_count===0&&s.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.5",children:[s.jsx(Aa,{className:"w-3 h-3"}),"All good"]})]})]}),s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors",children:[i?s.jsx(Xc,{className:"w-4 h-4"}):s.jsx(Qi,{className:"w-4 h-4"}),i?"Collapse":"Expand"]})]}),s.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:s.jsx(hd,{className:"w-4 h-4 text-bambu-gray"})}),o?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:c,onChange:g=>u(g.target.value),onKeyDown:g=>{g.key==="Enter"&&p(),g.key==="Escape"&&l(!1)},className:"w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm",min:"0",step:"1",autoFocus:!0}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"hours"}),s.jsx(Ee,{size:"sm",onClick:p,children:"Save"}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:()=>l(!1),children:"Cancel"})]}):s.jsxs("button",{onClick:()=>{u(Math.round(t.total_print_hours).toString()),l(!0)},className:"group",children:[s.jsxs("div",{className:"text-sm font-medium text-white group-hover:text-bambu-green transition-colors flex items-center gap-1",children:[Math.round(t.total_print_hours)," hours",s.jsx(gf,{className:"w-3 h-3 text-bambu-gray group-hover:text-bambu-green"})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Total print time"})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),f&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const g=$b(f.maintenance_type_icon);return s.jsx(g,{className:`w-4 h-4 ${f.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${f.is_due?"text-red-400":"text-amber-400"}`,children:f.maintenance_type_name}),s.jsx("div",{className:`text-xs ${f.is_due?"text-red-400/70":"text-amber-400/70"}`,children:f.is_due?"Overdue":"Due soon"})]})]})]})]}),i&&s.jsx(Mt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:d.map(g=>s.jsx(bqe,{item:g,onPerform:e,onToggle:n},g.id))})})]})}function vqe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l}){const[c,u]=S.useState(null),[d,f]=S.useState(""),[p,g]=S.useState("hours"),[b,v]=S.useState(!1),[x,y]=S.useState(""),[E,w]=S.useState("100"),[A,N]=S.useState("hours"),[C,T]=S.useState("Wrench"),[D,k]=S.useState(""),[P,z]=S.useState(new Set),[L,X]=S.useState(null),R=S.useMemo(()=>t?t.map(B=>({id:B.printer_id,name:B.printer_name})):[],[t]),Y=B=>t?t.filter(U=>U.maintenance_items.some(Q=>Q.maintenance_type_id===B)).map(U=>({printerId:U.printer_id,printerName:U.printer_name,itemId:U.maintenance_items.find(Q=>Q.maintenance_type_id===B)?.id})):[],J=B=>{if(!t)return[];const U=new Set(Y(B).map(Q=>Q.printerId));return R.filter(Q=>!U.has(Q.id))},[G,W]=S.useState(null),[ee,K]=S.useState(""),[F,q]=S.useState(""),[ne,re]=S.useState("hours"),[se,de]=S.useState("Wrench"),[pe,Ce]=S.useState(""),oe=B=>{W(B),K(B.name),q(B.default_interval_hours.toString()),re(B.interval_type||"hours"),de(B.icon||"Wrench"),Ce(B.wiki_url||"")},ae=()=>{G&&ee.trim()&&parseFloat(F)>0&&(i(G.id,{name:ee.trim(),default_interval_hours:parseFloat(F),interval_type:ne,icon:se,wiki_url:pe.trim()||null}),W(null))},ge=(B,U,Q)=>{const Me=parseFloat(d);if(!isNaN(Me)&&Me>0){const Te=Math.abs(Me-U)<.01?null:Me;n(B,{custom_interval_hours:Te,custom_interval_type:p!==Q?p:null})}u(null)},ue=B=>{B.preventDefault(),x.trim()&&parseFloat(E)>0&&P.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(E),interval_type:A,icon:C,wiki_url:D.trim()||null},Array.from(P)),y(""),w("100"),N("hours"),k(""),z(new Set),v(!1))},Le=B=>{z(U=>{const Q=new Set(U);return Q.has(B)?Q.delete(B):Q.add(B),Q})},V=t?.map(B=>({printerId:B.printer_id,printerName:B.printer_name,items:B.maintenance_items.sort((U,Q)=>U.maintenance_type_id-Q.maintenance_type_id)})).sort((B,U)=>B.printerName.localeCompare(U.printerName))||[],$=e.filter(B=>B.is_system),Z=e.filter(B=>!B.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Maintenance Types"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"System types and your custom maintenance tasks"})]}),s.jsxs(Ee,{onClick:()=>v(!b),children:[s.jsx(dr,{className:"w-4 h-4"}),"Add Custom Type"]})]}),b&&s.jsx(_t,{className:"mb-6",children:s.jsx(Mt,{className:"py-4",children:s.jsxs("form",{onSubmit:ue,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Name"}),s.jsx("input",{type:"text",value:x,onChange:B=>y(B.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",placeholder:"e.g., Replace HEPA Filter",autoFocus:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Interval Type"}),s.jsxs("select",{value:A,onChange:B=>{N(B.target.value),B.target.value==="days"?w("30"):w("100")},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:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-bambu-gray mb-1.5",children:["Interval (",A==="days"?"days":"hours",")"]}),s.jsx("input",{type:"number",value:E,onChange:B=>w(B.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",min:"1"})]})]}),s.jsx("div",{className:"mt-4 flex items-end justify-between",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Icon"}),s.jsx("div",{className:"flex gap-1",children:Object.keys(bb).map(B=>{const U=bb[B];return s.jsx("button",{type:"button",onClick:()=>T(B),className:`p-2 rounded-lg transition-colors ${C===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(U,{className:"w-4 h-4"})},B)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Documentation Link (optional)"}),s.jsx("input",{type:"url",value:D,onChange:B=>k(B.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",placeholder:"https://wiki.bambulab.com/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:"Assign to Printers"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:R.map(B=>s.jsx("button",{type:"button",onClick:()=>Le(B.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${P.has(B.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:B.name},B.id))}),P.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:"Select at least one printer"})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:()=>{v(!1),z(new Set)},children:"Cancel"}),s.jsx(Ee,{type:"submit",disabled:!x.trim()||P.size===0,children:"Add Type"})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[$.map(B=>{const U=$b(B.icon),Q=B.interval_type||"hours";return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:s.jsx(U,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-white truncate",children:B.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Q==="days"?s.jsx(qr,{className:"w-3 h-3"}):s.jsx(hd,{className:"w-3 h-3"}),ij(B.default_interval_hours,Q)]})]})]})},B.id)}),Z.map(B=>{const U=$b(B.icon),Q=B.interval_type||"hours";if(G?.id===B.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:ee,onChange:I=>K(I.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",placeholder:"Name",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:ne,onChange:I=>re(I.target.value),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",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:F,onChange:I=>q(I.target.value),className:"w-24 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",min:"1"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(bb).map(I=>{const ce=bb[I];return s.jsx("button",{type:"button",onClick:()=>de(I),className:`p-1.5 rounded transition-colors ${se===I?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(ce,{className:"w-3.5 h-3.5"})},I)})}),s.jsx("input",{type:"url",value:pe,onChange:I=>Ce(I.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",placeholder:"Documentation link (optional)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Ee,{size:"sm",onClick:ae,disabled:!ee.trim(),children:"Save"}),s.jsx(Ee,{size:"sm",variant:"secondary",onClick:()=>W(null),children:"Cancel"})]})]})},B.id);const Te=Y(B.id),fe=J(B.id),H=L===B.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(U,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:B.name}),s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:"Custom"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Q==="days"?s.jsx(qr,{className:"w-3 h-3"}):s.jsx(hd,{className:"w-3 h-3"}),ij(B.default_interval_hours,Q)]})]}),s.jsxs("button",{onClick:()=>X(H?null:B.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${Te.length>0?"border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20":"border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20"}`,title:`${Te.length} printer(s) assigned - click to manage`,children:[s.jsx(Qr,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:Te.length}),s.jsx(Qi,{className:`w-3 h-3 transition-transform ${H?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>oe(B),className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",children:s.jsx(gf,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(`Delete "${B.name}"?`)&&a(B.id)},className:"p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(ln,{className:"w-4 h-4"})})]}),H&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Assigned to printers:"}),Te.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:"No printers assigned"}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:Te.map(I=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[I.printerName,s.jsx("button",{onClick:()=>I.itemId&&l(I.itemId),className:"hover:text-red-400 ml-1",title:"Remove from this printer",children:"×"})]},I.printerId))}),fe.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:"Add:"}),fe.map(I=>s.jsxs("button",{onClick:()=>o(I.id,B.id),className:"px-2 py-1 bg-bambu-dark hover:bg-bambu-green/20 rounded text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:["+ ",I.name]},I.id))]})]})]},B.id)})]})]}),V.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Interval Overrides"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"Customize intervals for specific printers"})]}),s.jsx("div",{className:"space-y-4",children:V.map(B=>s.jsx(_t,{children:s.jsxs(Mt,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:B.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:B.items.map(U=>{const Q=$b(U.maintenance_type_icon),Me=e.find(ce=>ce.id===U.maintenance_type_id),Te=Me?.default_interval_hours||U.interval_hours,fe=Me?.interval_type||"hours",H=U.interval_type||"hours",I=c===U.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(Q,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:U.maintenance_type_name}),I?s.jsxs("div",{className:"flex items-center gap-1",children:[p==="days"?s.jsx(qr,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(hd,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:p,onChange:ce=>g(ce.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[s.jsx("option",{value:"hours",children:"Print Hours"}),s.jsx("option",{value:"days",children:"Calendar Days"})]}),s.jsx("input",{type:"number",value:d,onChange:ce=>f(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&ge(U.id,Te,fe),ce.key==="Escape"&&u(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),s.jsx(Ee,{size:"sm",onClick:()=>ge(U.id,Te,fe),children:"OK"})]}):s.jsxs("button",{onClick:()=>{u(U.id),f(U.interval_hours.toString()),g(H)},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 flex items-center gap-1",children:[H==="days"?s.jsx(qr,{className:"w-3 h-3"}):s.jsx(hd,{className:"w-3 h-3"}),ij(U.interval_hours,H),s.jsx(gf,{className:"w-3 h-3 text-bambu-gray"})]})]},U.id)})})]})},B.printerId))})]}),V.length===0&&s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-12",children:[s.jsx(tr,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-bambu-gray",children:"No printers configured"}),s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:"Add printers to configure maintenance intervals"})]})})]})}function _qe(){const t=an(),{showToast:e}=Wn(),[n,r]=S.useState("status"),{data:i,isLoading:a}=lt({queryKey:["maintenanceOverview"],queryFn:be.getMaintenanceOverview}),{data:o}=lt({queryKey:["maintenanceTypes"],queryFn:be.getMaintenanceTypes}),l=ht({mutationFn:({id:w,notes:A})=>be.performMaintenance(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Maintenance marked as complete")},onError:w=>{e(w.message,"error")}}),c=ht({mutationFn:({id:w,data:A})=>be.updateMaintenanceItem(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:w=>{e(w.message,"error")}}),u=ht({mutationFn:({id:w,data:A})=>be.updateMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type updated")},onError:w=>{e(w.message,"error")}}),d=ht({mutationFn:be.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type deleted")},onError:w=>{e(w.message,"error")}}),f=ht({mutationFn:({printerId:w,hours:A})=>be.setPrinterHours(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),t.invalidateQueries({queryKey:["maintenanceSummary"]}),e("Print hours updated")},onError:w=>{e(w.message,"error")}}),p=ht({mutationFn:({printerId:w,typeId:A})=>be.assignMaintenanceType(w,A),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer assigned")},onError:w=>{e(w.message,"error")}}),g=ht({mutationFn:be.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Printer removed")},onError:w=>{e(w.message,"error")}}),b=w=>{l.mutate({id:w})},v=(w,A)=>{c.mutate({id:w,data:{enabled:A}})},x=(w,A)=>{f.mutate({printerId:w,hours:A})};if(a)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});const y=i?.reduce((w,A)=>w+A.due_count,0)||0,E=i?.reduce((w,A)=>w+A.warning_count,0)||0;return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Maintenance"}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:n==="status"?s.jsxs(s.Fragment,{children:[y>0&&s.jsxs("span",{className:"text-red-400",children:[y," task",y!==1?"s":""," overdue"]}),y>0&&E>0&&" · ",E>0&&s.jsxs("span",{className:"text-amber-400",children:[E," due soon"]}),y===0&&E===0&&s.jsx("span",{className:"text-bambu-green",children:"All maintenance up to date"})]}):"Configure maintenance types and intervals"})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>r("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"}),s.jsx("button",{onClick:()=>r("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"?s.jsx("div",{className:"space-y-6",children:i&&i.length>0?[...i].sort((w,A)=>{const N=w.due_count*10+w.warning_count,C=A.due_count*10+A.warning_count;return N!==C?C-N:w.printer_name.localeCompare(A.printer_name)}).map(w=>s.jsx(yqe,{overview:w,onPerform:b,onToggle:v,onSetHours:x},w.printer_id)):s.jsx(_t,{children:s.jsxs(Mt,{className:"text-center py-16",children:[s.jsx(Rd,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:"No printers configured"}),s.jsx("p",{className:"text-bambu-gray",children:"Add printers to start tracking maintenance"})]})})}):s.jsx(vqe,{overview:i,types:o||[],onUpdateInterval:(w,A)=>c.mutate({id:w,data:A}),onAddType:async(w,A)=>{const N=await be.createMaintenanceType(w);for(const C of A)await be.assignMaintenanceType(C,N.id);t.invalidateQueries({queryKey:["maintenanceTypes"]}),t.invalidateQueries({queryKey:["maintenanceOverview"]}),e("Maintenance type added")},onUpdateType:(w,A)=>u.mutate({id:w,data:A}),onDeleteType:w=>d.mutate(w),onAssignType:(w,A)=>p.mutate({printerId:w,typeId:A}),onRemoveItem:w=>g.mutate(w)})]})}const gG=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Nne({project:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=S.useState(t?.name||""),[o,l]=S.useState(t?.description||""),[c,u]=S.useState(t?.color||gG[0]),[d,f]=S.useState(t?.target_count?.toString()||""),[p,g]=S.useState(t?.target_parts_count?.toString()||""),[b,v]=S.useState(t?.status||"active"),[x,y]=S.useState(t?.tags||""),[E,w]=S.useState(t?.due_date?.split("T")[0]||""),[A,N]=S.useState(t?.priority||"normal"),C=T=>{T.preventDefault(),n({name:i.trim(),description:o.trim()||void 0,color:c,target_count:d?parseInt(d,10):void 0,target_parts_count:p?parseInt(p,10):void 0,tags:x.trim()||void 0,due_date:E||void 0,priority:A,...t&&{status:b}})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:t?"Edit Project":"New Project"})}),s.jsxs("form",{onSubmit:C,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Name"}),s.jsx("input",{type:"text",value:i,onChange:T=>a(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Voron 2.4 Build",required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Description"}),s.jsx("textarea",{value:o,onChange:T=>l(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none",placeholder:"Optional description...",rows:2})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Color"}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:gG.map(T=>s.jsx("button",{type:"button",onClick:()=>u(T),className:`w-8 h-8 rounded-full transition-transform ${c===T?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:T}},T))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Plates"}),s.jsx("input",{type:"number",value:d,onChange:T=>f(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 25",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of print jobs"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Target Parts"}),s.jsx("input",{type:"number",value:p,onChange:T=>g(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., 150",min:"1"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Total objects needed"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Tags (comma-separated)"}),s.jsx("input",{type:"text",value:x,onChange:T=>y(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., voron, functional, gift"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Due Date"}),s.jsx("input",{type:"date",value:E,onChange:T=>w(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Priority"}),s.jsxs("select",{value:A,onChange:T=>N(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"normal",children:"Normal"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Status"}),s.jsxs("select",{value:b,onChange:T=>v(T.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"active",children:"Active"}),s.jsx("option",{value:"completed",children:"Completed"}),s.jsx("option",{value:"archived",children:"Archived"})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Ee,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):t?"Save":"Create"})]})]})]})})}function wqe({project:t,onClick:e,onEdit:n,onDelete:r}){const i=t.target_count?Math.round(t.archive_count/t.target_count*100):0,a=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,o=t.status==="completed",l=t.status==="archived",[c,u]=S.useState(!1),f=o?{icon:p2,color:"text-bambu-green",bg:"bg-bambu-green/10"}:l?{icon:Os,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:tr,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:ma,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return s.jsxs("div",{className:"group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden",onClick:e,children:[s.jsx("div",{className:"absolute top-0 left-0 w-1.5 h-full",style:{backgroundColor:t.color||"#6b7280",boxShadow:`0 0 12px ${t.color||"#6b7280"}40`}}),s.jsxs("div",{className:"p-5 pl-6",children:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg ${f.bg} flex-shrink-0`,children:s.jsx(f.icon,{className:`w-5 h-5 ${f.color}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${a>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," parts"]}):t.target_count?s.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${i>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," plates"]}):t.completed_count>0?s.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray",children:[t.completed_count," parts"]}):null,o&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:"Done"}),l&&s.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:"Archived"})]}),t.description&&s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1 line-clamp-1",children:t.description}),t.archives&&t.archives.length>0&&(()=>{const p=t.archives.map(x=>x.filament_type).filter(Boolean).flatMap(x=>x.split(",").map(y=>y.trim())).filter(Boolean),g=[...new Set(p)],b=t.archives.map(x=>x.filament_color).filter(Boolean).flatMap(x=>x.split(",").map(y=>y.trim())).filter(x=>x.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(x)),v=[...new Set(b)];return g.length===0&&v.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[g.slice(0,3).map(x=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:x},x)),v.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[v.slice(0,5).map(x=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:x.startsWith("#")?x:`#${x}`},title:x},x)),v.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",v.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:p=>p.stopPropagation(),children:[s.jsx("button",{className:"p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100",onClick:()=>u(!c),children:s.jsx(vd,{className:"w-4 h-4"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!1)}),s.jsxs("div",{className:"absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{n(),u(!1)},children:[s.jsx(gf,{className:"w-4 h-4"}),"Edit"]}),s.jsxs("button",{className:"w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(),u(!1)},children:[s.jsx(ln,{className:"w-4 h-4"}),"Delete"]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?s.jsxs("div",{className:"space-y-3",children:[t.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Plates"}),s.jsxs("span",{className:i>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(i,100)}%`,background:i>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${i>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:"Parts"}),s.jsxs("span",{className:a>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.jsx("div",{className:"h-full transition-all duration-500 ease-out rounded-full relative",style:{width:`${Math.min(a,100)}%`,background:a>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${a>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," failed"]})]}):t.completed_count>0||t.failed_count>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(Os,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," completed"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(yn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.failed_count," failed"]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(tr,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," in queue"]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:"No prints yet"})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(p=>s.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:p.print_name||"Unknown",children:[p.thumbnail_path?s.jsx("img",{src:be.getArchiveThumbnail(p.id),alt:p.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(Cl,{className:"w-6 h-6"})}),p.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(yn,{className:"w-4 h-4 text-white"})})]},p.id))}),t.archive_count>4&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:["+",t.archive_count-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[s.jsxs("div",{className:"flex items-center gap-1.5",title:"Print jobs (plates)",children:[s.jsx(Hs,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," plates"]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:"Parts printed",children:[s.jsx(Cl,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," parts"]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:"Failed parts",children:[s.jsx(yn,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:"In queue",children:[s.jsx(Sj,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(Bs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function Sqe(){const t=vg(),e=an(),{showToast:n}=Wn(),[r,i]=S.useState(!1),[a,o]=S.useState(),[l,c]=S.useState("active"),[u,d]=S.useState(null),{data:f,isLoading:p}=lt({queryKey:["projects",l==="all"?void 0:l],queryFn:()=>be.getProjects(l==="all"?void 0:l)}),g=ht({mutationFn:C=>be.createProject(C),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),n("Project created","success")},onError:C=>{n(C.message,"error")}}),b=ht({mutationFn:({id:C,data:T})=>be.updateProject(C,T),onSuccess:()=>{e.invalidateQueries({queryKey:["projects"]}),i(!1),o(void 0),n("Project updated","success")},onError:C=>{n(C.message,"error")}}),v=ht({mutationFn:C=>be.deleteProject(C),onSuccess:()=>{d(null),n("Project deleted","success"),setTimeout(()=>window.location.reload(),100)},onError:C=>{d(null),n(C.message,"error")}}),x=C=>{a?b.mutate({id:a.id,data:C}):g.mutate(C)},y=C=>{o(C),i(!0)},E=C=>{t(`/projects/${C.id}`)},w=C=>{d(C)},A=()=>{u!==null&&v.mutate(u)},N=f?.reduce((C,T)=>(C[T.status]=(C[T.status]||0)+1,C.all=(C.all||0)+1,C),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(ma,{className:"w-6 h-6 text-bambu-green"})}),"Projects"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and track your 3D printing projects"})]}),s.jsxs(Ee,{onClick:()=>i(!0),className:"sm:w-auto w-full",children:[s.jsx(dr,{className:"w-4 h-4 mr-2"}),"New Project"]})]}),s.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:"Active",icon:tr},{key:"completed",label:"Completed",icon:p2},{key:"archived",label:"Archived",icon:Os},{key:"all",label:"All",icon:ma}].map(({key:C,label:T,icon:D})=>s.jsxs("button",{onClick:()=>c(C),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===C?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx(D,{className:"w-4 h-4"}),s.jsx("span",{children:T}),N[C]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${l===C?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:N[C]})]},C))}),p?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading projects..."})]})}):f?.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(ma,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:l==="all"?"No projects yet":`No ${l} projects`}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:l==="all"?"Create your first project to start organizing related prints, tracking progress, and managing your builds.":`You don't have any ${l} projects. Projects will appear here when their status changes.`}),l==="all"&&s.jsxs(Ee,{onClick:()=>i(!0),children:[s.jsx(dr,{className:"w-4 h-4 mr-2"}),"Create Your First Project"]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:f?.map(C=>s.jsx(wqe,{project:C,onClick:()=>E(C),onEdit:()=>y(C),onDelete:()=>w(C.id)},C.id))}),u!==null&&s.jsx(Un,{title:"Delete Project",message:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",confirmText:"Delete Project",variant:"danger",onConfirm:A,onCancel:()=>d(null)}),r&&s.jsx(Nne,{project:a,onClose:()=>{i(!1),o(void 0)},onSave:x,isLoading:g.isPending||b.isPending})]})}function Mqe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function Eqe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function Nqe({status:t}){const e={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},n=e[t]||e.active;return s.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${n}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}function xG({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(_t,{children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",title:i,children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function Aqe({archives:t}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Cl,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No prints in this project yet"})]}):s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3",children:t.map(e=>s.jsxs(Ts,{to:`/archives?search=${encodeURIComponent(e.print_name||"")}`,className:"group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors",children:[e.thumbnail_path?s.jsx("img",{src:be.getArchiveThumbnail(e.id),alt:e.print_name||"Print",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(Cl,{className:"w-8 h-8"})}),e.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(Wi,{className:"w-8 h-8 text-white"})}),e.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(pr,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx("p",{className:"text-xs text-white truncate",children:e.print_name||"Unknown"})})]},e.id))})}function Tqe({priority:t}){const e={low:{color:"bg-gray-500/20 text-gray-400",label:"Low"},normal:{color:"bg-blue-500/20 text-blue-400",label:"Normal"},high:{color:"bg-orange-500/20 text-orange-400",label:"High"},urgent:{color:"bg-red-500/20 text-red-400",label:"Urgent"}},{color:n,label:r}=e[t]||e.normal;return s.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${n}`,children:[t==="urgent"&&s.jsx(yn,{className:"w-3 h-3"}),r]})}function Cqe(t){return t?Hp(t,{year:"numeric",month:"short",day:"numeric"}):""}function aj(t){if(!t)return null;const e=fi(t);if(!e)return null;const n=new Date,r=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return r<0?{color:"text-red-400",label:"Overdue"}:r===0?{color:"text-orange-400",label:"Due today"}:r<=3?{color:"text-yellow-400",label:`${r} days left`}:{color:"text-bambu-gray",label:`${r} days left`}}function kqe(){const{id:t}=_R(),e=vg(),n=an(),{showToast:r}=Wn(),[i,a]=S.useState(!1),[o,l]=S.useState(!1),[c,u]=S.useState(""),d=parseInt(t||"0",10),{data:f,isLoading:p,error:g}=lt({queryKey:["project",d],queryFn:()=>be.getProject(d),enabled:d>0}),{data:b,isLoading:v}=lt({queryKey:["project-archives",d],queryFn:()=>be.getProjectArchives(d),enabled:d>0}),{data:x,isLoading:y}=lt({queryKey:["project-bom",d],queryFn:()=>be.getProjectBOM(d),enabled:d>0}),{data:E,isLoading:w}=lt({queryKey:["project-timeline",d],queryFn:()=>be.getProjectTimeline(d,20),enabled:d>0}),{data:A}=lt({queryKey:["settings"],queryFn:be.getSettings}),{data:N}=lt({queryKey:["project-folders",d],queryFn:()=>be.getLibraryFoldersByProject(d),enabled:d>0}),C=A?.currency||"$",T=A?.time_format||"system",D=ht({mutationFn:Q=>be.updateProject(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project",d]}),n.invalidateQueries({queryKey:["projects"]}),a(!1),l(!1),r("Project updated","success")},onError:Q=>{r(Q.message,"error")}}),k=()=>{u(f?.notes||""),l(!0)},P=()=>{D.mutate({notes:c})},z=()=>{l(!1),u("")},[L,X]=S.useState(""),[R,Y]=S.useState(1),[J,G]=S.useState(""),[W,ee]=S.useState(""),[K,F]=S.useState(""),[q,ne]=S.useState(!1),[re,se]=S.useState(!1),[de,pe]=S.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),Ce=ht({mutationFn:Q=>be.createBOMItem(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),X(""),Y(1),G(""),ee(""),F(""),ne(!1),r("Part added","success")},onError:Q=>r(Q.message,"error")}),oe=ht({mutationFn:({itemId:Q,data:Me})=>be.updateBOMItem(d,Q,Me),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]})},onError:Q=>r(Q.message,"error")}),ae=ht({mutationFn:Q=>be.deleteBOMItem(d,Q),onSuccess:()=>{n.invalidateQueries({queryKey:["project-bom",d]}),n.invalidateQueries({queryKey:["project",d]}),r("Part removed","success")},onError:Q=>r(Q.message,"error")}),ge=Q=>{Q.preventDefault(),L.trim()&&Ce.mutate({name:L.trim(),quantity_needed:R,unit_price:J?parseFloat(J):void 0,sourcing_url:W.trim()||void 0,remarks:K.trim()||void 0})},ue=Q=>{const Me=Q.is_complete?0:Q.quantity_needed;oe.mutate({itemId:Q.id,data:{quantity_acquired:Me}})},Le=(Q,Me)=>{pe({isOpen:!0,title:"Delete Part",message:`Are you sure you want to delete "${Me}"?`,onConfirm:()=>{pe(Te=>({...Te,isOpen:!1})),ae.mutate(Q)}})},V=ht({mutationFn:()=>be.createTemplateFromProject(d),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r("Template created","success")},onError:Q=>r(Q.message,"error")}),$=Q=>Vp(Q,T,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(p)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(g||!f)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:g?`Error: ${g.message}`:"Project not found"}),s.jsx(Ee,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:"Back to Projects"})]});const Z=f.stats,B=Z?.progress_percent??0,U=Z?.parts_progress_percent??0;return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Ts,{to:"/projects",className:"hover:text-white transition-colors",children:"Projects"}),s.jsx(Bs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:f.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(fle,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:f.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:f.name}),f.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:f.description})]})]}),s.jsx(Nqe,{status:f.status})]}),s.jsxs(Ee,{onClick:()=>a(!0),children:[s.jsx(gf,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),(f.target_count||f.target_parts_count)&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4 space-y-4",children:[f.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Plates Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[Z?.total_archives||0," / ",f.target_count," print jobs"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(B,100)}%`,backgroundColor:B>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[B.toFixed(0),"% complete"]}),Z?.remaining_prints!=null&&Z.remaining_prints>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Z.remaining_prints," remaining"]})]})]}),f.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Parts Progress"}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[Z?.completed_prints||0," / ",f.target_parts_count," parts"]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(U,100)}%`,backgroundColor:U>=100?"#22c55e":f.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[U.toFixed(0),"% complete"]}),Z?.remaining_parts!=null&&Z.remaining_parts>0&&s.jsxs("span",{className:"text-xs text-bambu-gray/70",children:[Z.remaining_parts," remaining"]})]})]})]})}),Z&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(_t,{children:s.jsx(Mt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(Cl,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Print Jobs"}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[Z.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:"total"})]}),Z.failed_prints>0&&s.jsxs("p",{className:"text-sm text-red-400",children:[Z.failed_prints," failed"]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[Z.completed_prints," parts printed"]})]})]})})}),s.jsx(xG,{icon:tr,label:"Print Time",value:Mqe(Z.total_print_time_hours),color:"text-yellow-400"}),s.jsx(xG,{icon:Qr,label:"Filament Used",value:Eqe(Z.total_filament_grams),color:"text-purple-400"})]}),Z&&(Z.estimated_cost>0||f.budget)&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:"Cost Tracking"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Filament Cost"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[C,Z.estimated_cost.toFixed(2)]})]}),Z.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Energy"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[Z.total_energy_kwh.toFixed(2)," kWh",Z.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",C,Z.total_energy_cost.toFixed(2),")"]})]})]}),f.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Budget"}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[C,f.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:"Remaining"}),s.jsxs("p",{className:`text-lg font-semibold ${f.budget-Z.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[C,(f.budget-Z.estimated_cost).toFixed(2)]})]})]})]})]})}),f.children&&f.children.length>0&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(zce,{className:"w-5 h-5"}),"Sub-projects (",f.children.length,")"]}),s.jsx("div",{className:"space-y-2",children:f.children.map(Q=>s.jsxs(Ts,{to:`/projects/${Q.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Q.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:Q.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${Q.status==="completed"?"bg-bambu-green/20 text-bambu-green":Q.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:Q.status})]}),Q.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[Q.progress_percent.toFixed(0),"%"]})]},Q.id))})]})}),f.parent_id&&f.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Hs,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Part of:"}),s.jsx(Ts,{to:`/projects/${f.parent_id}`,className:"text-bambu-green hover:underline",children:f.parent_name})]}),(f.tags||f.due_date||f.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[f.priority&&f.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:"Priority:"}),s.jsx(Tqe,{priority:f.priority})]}),f.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:Cqe(f.due_date)}),aj(f.due_date)&&s.jsxs("span",{className:`text-xs ${aj(f.due_date).color}`,children:["(",aj(f.due_date).label,")"]})]}),f.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($p,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:f.tags.split(",").map((Q,Me)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:Q.trim()},Me))})]})]}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ua,{className:"w-5 h-5"}),"Notes"]}),o?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:z,disabled:D.isPending,children:[s.jsx(zt,{className:"w-4 h-4 mr-1"}),"Cancel"]}),s.jsxs(Ee,{size:"sm",onClick:P,disabled:D.isPending,children:[D.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(Rs,{className:"w-4 h-4 mr-1"}),"Save"]})]}):s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:k,children:[s.jsx(gf,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),o?s.jsx(dR,{content:c,onChange:u,placeholder:"Add notes about this project..."}):f.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:f.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No notes yet. Click Edit to add notes."})]})}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Zo,{className:"w-5 h-5"}),"Files"]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(Ts,{to:"/files",className:"text-bambu-green hover:underline",children:"Link folders from the File Manager"})," ","to this project for quick access."]}),N&&N.length>0?s.jsx("div",{className:"space-y-2",children:N.map(Q=>s.jsxs(Ts,{to:`/files?folder=${Q.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Zo,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:Q.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[Q.file_count," file",Q.file_count!==1?"s":""]})]})]}),s.jsx(Bs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},Q.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No folders linked. Go to File Manager and link a folder to this project."})]})}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(hW,{className:"w-5 h-5"}),"Bill of Materials",Z&&Z.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Z.bom_completed_items,"/",Z.bom_total_items," acquired)"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[x&&x.some(Q=>Q.is_complete)&&s.jsx("button",{onClick:()=>se(!re),className:`text-xs px-2 py-1 rounded transition-colors ${re?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:re?"Show all":"Hide done"}),!q&&s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>ne(!0),children:[s.jsx(dr,{className:"w-4 h-4 mr-1"}),"Add Part"]})]})]}),q&&s.jsxs("form",{onSubmit:ge,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:L,onChange:Q=>X(Q.target.value),className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Part name (e.g., M3x8 screws)",autoFocus:!0}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:R,onChange:Q=>Y(parseInt(Q.target.value)||1),className:"w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green",min:"1",placeholder:"Qty"}),s.jsx("input",{type:"number",step:"0.01",value:J,onChange:Q=>G(Q.target.value),className:"flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:`Price (${C})`})]})]}),s.jsx("input",{type:"url",value:W,onChange:Q=>ee(Q.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Sourcing URL (optional)"}),s.jsx("input",{type:"text",value:K,onChange:Q=>F(Q.target.value),className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"Remarks (optional)"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",size:"sm",onClick:()=>ne(!1),children:"Cancel"}),s.jsx(Ee,{type:"submit",size:"sm",disabled:!L.trim()||Ce.isPending,children:Ce.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):"Add Part"})]})]}),y?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})}):x&&x.length>0?s.jsxs("div",{className:"space-y-2",children:[x.filter(Q=>!re||!Q.is_complete).map(Q=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${Q.is_complete?"bg-bambu-green/10":"bg-bambu-dark"}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>ue(Q),disabled:oe.isPending,className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${Q.is_complete?"bg-bambu-green border-bambu-green text-white":"border-bambu-gray hover:border-bambu-green"}`,children:Q.is_complete&&s.jsx(pr,{className:"w-3 h-3"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("p",{className:`text-sm font-medium ${Q.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[Q.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",Q.quantity_needed]})]}),Q.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[C,(Q.unit_price*Q.quantity_needed).toFixed(2)]})]}),s.jsx("button",{onClick:()=>Le(Q.id,Q.name),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0",title:"Delete",children:s.jsx(ln,{className:"w-4 h-4"})})]}),Q.sourcing_url&&s.jsxs("a",{href:Q.sourcing_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors",onClick:Me=>Me.stopPropagation(),children:[s.jsx(Kr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(Q.sourcing_url).hostname.replace("www.","")}catch{return Q.sourcing_url}})()})]}),Q.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:Q.remarks})]})]})},Q.id)),x.some(Q=>Q.unit_price!==null)&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:"Total cost:"}),s.jsxs("span",{className:"text-white font-medium",children:[C,x.reduce((Q,Me)=>Q+(Me.unit_price||0)*Me.quantity_needed,0).toFixed(2)]})]})]}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."})]})}),s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(iw,{className:"w-5 h-5"}),"Activity Timeline"]})}),w?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})}):E&&E.length>0?s.jsx("div",{className:"space-y-3",children:E.slice(0,10).map((Q,Me)=>s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${Q.event_type==="print_completed"?"bg-bambu-green/20 text-bambu-green":Q.event_type==="print_failed"?"bg-red-500/20 text-red-400":Q.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Q.event_type==="print_completed"&&s.jsx(pr,{className:"w-4 h-4"}),Q.event_type==="print_failed"&&s.jsx(Wi,{className:"w-4 h-4"}),Q.event_type==="print_started"&&s.jsx(Qr,{className:"w-4 h-4"}),Q.event_type==="queued"&&s.jsx(Sj,{className:"w-4 h-4"}),Q.event_type==="project_created"&&s.jsx(dr,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:Q.title}),Q.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:Q.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:$(Q.timestamp)})]})]},Me))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:"No activity yet."})]})}),!f.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>V.mutate(),disabled:V.isPending,children:[V.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx($s,{className:"w-4 h-4 mr-2"}),"Save as Template"]})}),Z&&(Z.queued_prints>0||Z.in_progress_prints>0)&&s.jsx(_t,{children:s.jsxs(Mt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Sj,{className:"w-5 h-5"}),"Queue"]}),s.jsx(Ts,{to:`/queue?project=${d}`,className:"text-sm text-bambu-green hover:underline",children:"View all"})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[Z.in_progress_prints>0&&s.jsxs("span",{className:"text-yellow-400",children:[Z.in_progress_prints," printing"]}),Z.queued_prints>0&&s.jsxs("span",{className:"text-bambu-gray",children:[Z.queued_prints," queued"]})]})]})}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-4",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Cl,{className:"w-5 h-5"}),"Prints (",b?.length||0,")"]})}),v?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(Aqe,{archives:b||[]})]}),i&&s.jsx(Nne,{project:{...f,archive_count:Z?.total_archives||0,total_items:Z?.total_items||0,completed_count:Z?.completed_prints||0,failed_count:Z?.failed_prints||0,queue_count:Z?.queued_prints||0,progress_percent:Z?.progress_percent||null,archives:[]},onClose:()=>a(!1),onSave:Q=>D.mutate(Q),isLoading:D.isPending}),de.isOpen&&s.jsx(Un,{title:de.title,message:de.message,confirmText:"Delete",variant:"danger",onConfirm:de.onConfirm,onCancel:()=>pe(Q=>({...Q,isOpen:!1}))})]})}function bp(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function jqe(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 Pqe({parentId:t,onClose:e,onSave:n,isLoading:r}){const[i,a]=S.useState(""),o=l=>{l.preventDefault(),n({name:i.trim(),parent_id:t})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"New Folder"})}),s.jsxs("form",{onSubmit:o,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:"Folder Name"}),s.jsx("input",{type:"text",value:i,onChange:l=>a(l.target.value),className:"w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green",placeholder:"e.g., Functional Parts",autoFocus:!0,required:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Ee,{type:"submit",disabled:!i.trim()||r,children:r?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):"Create"})]})]})]})})}function Rqe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a}){const[o,l]=S.useState(null),c=(d,f=0)=>{const p=[];for(const g of d)p.push({id:g.id,name:g.name,depth:f}),g.children.length>0&&p.push(...c(g.children,f+1));return p},u=[{id:null,name:"Root (No Folder)",depth:0},...c(t)];return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Move ",e.length," File(s)"]})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:u.map(d=>s.jsxs("button",{onClick:()=>l(d.id),disabled:d.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===d.id?"bg-bambu-green/20 text-bambu-green":d.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+d.depth*16}px`},children:[s.jsx(Zo,{className:"w-4 h-4"}),d.name,d.id===n&&s.jsx("span",{className:"text-xs text-bambu-gray ml-auto",children:"(current)"})]},d.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Ee,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(Ee,{onClick:()=>i(o),disabled:a,children:a?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):"Move"})]})]})]})})}function Dqe({folder:t,onClose:e,onLink:n,isLoading:r}){const[i,a]=S.useState("project"),[o,l]=S.useState(t.project_id||t.archive_id||null);S.useState(()=>{t.archive_id&&a("archive")});const{data:c}=lt({queryKey:["projects"],queryFn:()=>be.getProjects()}),{data:u}=lt({queryKey:["archives-for-link"],queryFn:()=>be.getArchives(void 0,void 0,100)}),d=()=>{n(i==="project"?{project_id:o,archive_id:0}:{project_id:0,archive_id:o})},f=()=>{n({project_id:0,archive_id:0})},p=t.project_id||t.archive_id;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(El,{className:"w-5 h-5 text-bambu-green"}),"Link Folder"]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:['Link "',s.jsx("span",{className:"text-white",children:t.name}),'" to a project or archive for quick access.']}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>{a("project"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(iW,{className:"w-4 h-4"}),"Project"]}),s.jsxs("button",{onClick:()=>{a("archive"),l(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${i==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(Os,{className:"w-4 h-4"}),"Archive"]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:i==="project"?c&&c.length>0?c.map(g=>s.jsxs("button",{onClick:()=>l(g.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===g.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:g.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:g.name})]},g.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No projects found"}):u&&u.length>0?u.map(g=>s.jsxs("button",{onClick:()=>l(g.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${o===g.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[s.jsx(Xh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:g.print_name||g.filename})]},g.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:"No archives found"})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[p&&s.jsxs(Ee,{variant:"danger",onClick:f,disabled:r,children:[s.jsx(IR,{className:"w-4 h-4 mr-2"}),"Unlink"]}),s.jsxs("div",{className:`flex gap-2 ${p?"":"ml-auto"}`,children:[s.jsx(Ee,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Ee,{onClick:d,disabled:!o||r,children:r?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):"Link"})]})]})]})})}function Oqe({folderId:t,onClose:e,onUploadComplete:n}){const[r,i]=S.useState([]),[a,o]=S.useState(!1),[l,c]=S.useState(!1),u=S.useRef(null),d=N=>{N.preventDefault(),o(!0)},f=N=>{N.preventDefault(),o(!1)},p=N=>{N.preventDefault(),o(!1);const C=Array.from(N.dataTransfer.files);b(C)},g=N=>{N.target.files&&b(Array.from(N.target.files))},b=N=>{const C=N.map(T=>({file:T,status:"pending"}));i(T=>[...T,...C])},v=N=>{i(C=>C.filter((T,D)=>D!==N))},x=async()=>{if(r.length!==0){c(!0);for(let N=0;N<r.length;N++)if(r[N].status==="pending"){i(C=>C.map((T,D)=>D===N?{...T,status:"uploading"}:T));try{await be.uploadLibraryFile(r[N].file,t),i(C=>C.map((T,D)=>D===N?{...T,status:"success"}:T))}catch(C){i(T=>T.map((D,k)=>k===N?{...D,status:"error",error:C instanceof Error?C.message:"Upload failed"}:D))}}c(!1),n(),e()}},y=r.filter(N=>N.status==="pending").length,E=r.filter(N=>N.status==="success").length,w=r.filter(N=>N.status==="error").length,A=r.length>0&&y===0&&!l;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Upload Files"}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(zt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:d,onDragLeave:f,onDrop:p,onClick:()=>u.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${a?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[s.jsx(xi,{className:`w-10 h-10 mx-auto mb-3 ${a?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("p",{className:"text-white font-medium",children:a?"Drop files here":"Drag & drop files here"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:"or click to browse"})]}),s.jsx("input",{ref:u,type:"file",multiple:!0,className:"hidden",onChange:g}),r.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:r.map((N,C)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[s.jsx(b2,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:N.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(N.file.size/1024/1024).toFixed(2)," MB"]})]}),N.status==="pending"&&s.jsx("button",{onClick:()=>v(C),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(zt,{className:"w-4 h-4 text-bambu-gray"})}),N.status==="uploading"&&s.jsx(ft,{className:"w-4 h-4 text-bambu-green animate-spin"}),N.status==="success"&&s.jsx(pr,{className:"w-4 h-4 text-green-500"}),N.status==="error"&&s.jsx("span",{title:N.error,children:s.jsx(Wi,{className:"w-4 h-4 text-red-500"})})]},C))}),A&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:["Upload complete: ",E," succeeded",w>0&&s.jsxs("span",{className:"text-red-400",children:[", ",w," failed"]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Ee,{variant:"secondary",onClick:e,children:A?"Close":"Cancel"}),!A&&s.jsx(Ee,{onClick:x,disabled:y===0||l,children:l?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"Uploading..."]}):s.jsxs(s.Fragment,{children:[s.jsx(xi,{className:"w-4 h-4 mr-2"}),"Upload ",y>0?`(${y})`:""]})})]})]})})}function Ane({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,depth:a=0}){const[o,l]=S.useState(!0),[c,u]=S.useState(!1),d=t.children.length>0,f=t.project_id||t.archive_id;return s.jsxs("div",{children:[s.jsxs("div",{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${e===t.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${8+a*12}px`},onClick:()=>n(t.id),children:[d?s.jsx("button",{onClick:p=>{p.stopPropagation(),l(!o)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Bs,{className:`w-3.5 h-3.5 transition-transform ${o?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(Zo,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:"text-sm truncate flex-1",children:t.name}),f&&s.jsxs("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors",title:`${t.project_name?`Project: ${t.project_name}`:`Archive: ${t.archive_name}`} (click to change)`,children:[s.jsx(El,{className:"w-3 h-3"}),t.project_name?s.jsx(iW,{className:"w-3 h-3"}):s.jsx(Os,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.file_count}),!f&&s.jsx("button",{onClick:p=>{p.stopPropagation(),i(t)},className:"p-1 rounded hover:bg-bambu-dark-tertiary",title:"Link to project or archive",children:s.jsx(El,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.jsx("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:p=>p.stopPropagation(),children:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>u(!c),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(vd,{className:"w-3.5 h-3.5 text-bambu-gray"})}),c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>u(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]",children:[s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t),u(!1)},children:[s.jsx(El,{className:"w-3.5 h-3.5"}),f?"Change Link...":"Link to..."]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),u(!1)},children:[s.jsx(ln,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]})})]}),d&&o&&s.jsx("div",{children:t.children.map(p=>s.jsx(Ane,{folder:p,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,depth:a+1},p.id))})]})}function Tne(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function Lqe({file:t,isSelected:e,onSelect:n,onDelete:r,onDownload:i,onAddToQueue:a}){const[o,l]=S.useState(!1);return s.jsxs("div",{className:`group relative bg-bambu-card rounded-lg border transition-all cursor-pointer overflow-hidden ${e?"border-bambu-green ring-1 ring-bambu-green":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,onClick:()=>n(t.id),children:[s.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?s.jsx("img",{src:be.getLibraryFileThumbnailUrl(t.id),alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(Xh,{className:"w-12 h-12 text-bambu-gray/30"}),t.duplicate_count>0&&s.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1 bg-amber-500/90 text-white text-xs px-1.5 py-0.5 rounded",children:[s.jsx($s,{className:"w-3 h-3"}),t.duplicate_count]}),s.jsx("div",{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type==="3mf"?"bg-bambu-green/90 text-white":t.file_type==="gcode"?"bg-blue-500/90 text-white":t.file_type==="stl"?"bg-purple-500/90 text-white":"bg-bambu-gray/90 text-white"}`,children:t.file_type.toUpperCase()})]}),s.jsxs("div",{className:"p-3",children:[s.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[s.jsx("span",{children:bp(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),jqe(t.print_time_seconds)]})]}),t.print_count>0&&s.jsxs("div",{className:"mt-1 text-xs text-bambu-green",children:["Printed ",t.print_count,"x"]})]}),s.jsxs("div",{className:"absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",onClick:c=>c.stopPropagation(),children:[s.jsx("button",{onClick:()=>l(!o),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(vd,{className:"w-4 h-4 text-bambu-gray"})}),o&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>l(!1)}),s.jsxs("div",{className:"absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]",children:[a&&Tne(t.filename)&&s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-bambu-green hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{a(t.id),l(!1)},children:[s.jsx(Qr,{className:"w-3.5 h-3.5"}),"Add to Queue"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-white hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{i(t.id),l(!1)},children:[s.jsx(Yr,{className:"w-3.5 h-3.5"}),"Download"]}),s.jsxs("button",{className:"w-full px-3 py-1.5 text-left text-sm text-red-400 hover:bg-bambu-dark flex items-center gap-2",onClick:()=>{r(t.id),l(!1)},children:[s.jsx(ln,{className:"w-3.5 h-3.5"}),"Delete"]})]})]})]}),s.jsx("div",{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${e?"bg-bambu-green border-bambu-green":"border-white/30 bg-black/30 opacity-0 group-hover:opacity-100"}`,children:e&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function Iqe(){const t=an(),{showToast:e}=Wn(),[n]=foe(),r=n.get("folder"),i=r?parseInt(r,10):null,[a,o]=S.useState(i),[l,c]=S.useState([]),[u,d]=S.useState(!1),[f,p]=S.useState(!1),[g,b]=S.useState(!1),[v,x]=S.useState(null),[y,E]=S.useState(null),[w,A]=S.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[N,C]=S.useState(""),[T,D]=S.useState("all"),[k,P]=S.useState("date"),[z,L]=S.useState("desc");S.useEffect(()=>{const U=n.get("folder"),Q=U?parseInt(U,10):null;Q!==a&&o(Q)},[n,a]);const{data:X}=lt({queryKey:["settings"],queryFn:()=>be.getSettings()}),{data:R,isLoading:Y}=lt({queryKey:["library-folders"],queryFn:()=>be.getLibraryFolders()}),{data:J,isLoading:G}=lt({queryKey:["library-files",a],queryFn:()=>be.getLibraryFiles(a,a===null)}),{data:W}=lt({queryKey:["library-stats"],queryFn:()=>be.getLibraryStats()}),ee=S.useMemo(()=>{if(!J)return[];const U=new Set(J.map(Q=>Q.file_type));return Array.from(U).sort()},[J]),K=S.useMemo(()=>{if(!J)return[];let U=[...J];if(N.trim()){const Q=N.toLowerCase();U=U.filter(Me=>Me.filename.toLowerCase().includes(Q)||Me.print_name&&Me.print_name.toLowerCase().includes(Q))}return T!=="all"&&(U=U.filter(Q=>Q.file_type===T)),U.sort((Q,Me)=>{let Te=0;switch(k){case"name":Te=(Q.print_name||Q.filename).localeCompare(Me.print_name||Me.filename);break;case"date":Te=new Date(Q.created_at).getTime()-new Date(Me.created_at).getTime();break;case"size":Te=Q.file_size-Me.file_size;break;case"type":Te=Q.file_type.localeCompare(Me.file_type);break;case"prints":Te=Q.print_count-Me.print_count;break}return z==="asc"?Te:-Te}),U},[J,N,T,k,z]),F=S.useMemo(()=>{if(!W||!X)return!1;const U=(X.library_disk_warning_gb||5)*1024*1024*1024;return W.disk_free_bytes<U},[W,X]),q=ht({mutationFn:U=>be.createLibraryFolder(U),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),d(!1),e("Folder created","success")},onError:U=>e(U.message,"error")}),ne=ht({mutationFn:U=>be.deleteLibraryFolder(U),onSuccess:()=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-stats"]}),a===y?.id&&o(null),E(null),e("Folder deleted","success")},onError:U=>{E(null),e(U.message,"error")}}),re=ht({mutationFn:U=>be.deleteLibraryFile(U),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),c(U=>U.filter(Q=>Q!==y?.id)),E(null),e("File deleted","success")},onError:U=>{E(null),e(U.message,"error")}}),se=ht({mutationFn:({fileIds:U,folderId:Q})=>be.moveLibraryFiles(U,Q),onSuccess:()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),c([]),p(!1),e("Files moved","success")},onError:U=>e(U.message,"error")}),de=ht({mutationFn:({id:U,data:Q})=>be.updateLibraryFolder(U,Q),onSuccess:(U,Q)=>{t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["project-folders"]}),t.invalidateQueries({queryKey:["archive-folders"]}),x(null);const Me=Q.data.project_id===0&&Q.data.archive_id===0;e(Me?"Folder unlinked":"Folder linked","success")},onError:U=>e(U.message,"error")}),pe=ht({mutationFn:U=>be.addLibraryFilesToQueue(U),onSuccess:U=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["queue"]}),t.invalidateQueries({queryKey:["archives"]}),c([]),U.added.length>0&&U.errors.length===0?e(`Added ${U.added.length} file${U.added.length>1?"s":""} to queue`,"success"):U.added.length>0&&U.errors.length>0?e(`Added ${U.added.length} file${U.added.length>1?"s":""}, ${U.errors.length} failed`,"success"):e(`Failed to add files: ${U.errors[0]?.error||"Unknown error"}`,"error")},onError:U=>e(U.message,"error")}),Ce=S.useCallback(U=>{const Q=U.toLowerCase();return Q.endsWith(".gcode")||Q.includes(".gcode.")},[]),oe=S.useMemo(()=>J?J.filter(U=>l.includes(U.id)&&Ce(U.filename)):[],[J,l,Ce]),ae=S.useCallback(U=>{c(Q=>Q.includes(U)?Q.filter(Me=>Me!==U):[...Q,U])},[]),ge=S.useCallback(()=>{K.length>0&&c(K.map(U=>U.id))},[K]),ue=S.useCallback(()=>{c([])},[]),Le=()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]})},V=U=>{window.open(be.getLibraryFileDownloadUrl(U),"_blank")},$=()=>{y&&(y.type==="file"?re.mutate(y.id):y.type==="folder"?ne.mutate(y.id):y.type==="bulk"&&be.bulkDeleteLibrary(l,[]).then(()=>{t.invalidateQueries({queryKey:["library-files"]}),t.invalidateQueries({queryKey:["library-folders"]}),t.invalidateQueries({queryKey:["library-stats"]}),e(`Deleted ${l.length} files`,"success"),c([]),E(null)}).catch(U=>{e(U.message,"error"),E(null)}))},Z=U=>{A(U),localStorage.setItem("library-view-mode",U)},B=Y||G;return s.jsxs("div",{className:"p-4 md:p-8 h-[calc(100vh-64px)] flex flex-col",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(Zo,{className:"w-6 h-6 text-bambu-green"})}),"File Manager"]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:"Organize and manage your print files"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[s.jsx("button",{onClick:()=>Z("grid"),className:`p-1.5 rounded transition-colors ${w==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"Grid view",children:s.jsx(S2,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Z("list"),className:`p-1.5 rounded transition-colors ${w==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:"List view",children:s.jsx(M2,{className:"w-4 h-4"})})]}),s.jsxs(Ee,{variant:"secondary",onClick:()=>d(!0),children:[s.jsx(Fce,{className:"w-4 h-4 mr-2"}),"New Folder"]}),s.jsxs(Ee,{onClick:()=>b(!0),children:[s.jsx(xi,{className:"w-4 h-4 mr-2"}),"Upload"]})]})]}),F&&W&&X&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(yn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-500 font-medium",children:"Low disk space warning"}),s.jsxs("p",{className:"text-xs text-amber-500/80",children:["Only ",bp(W.disk_free_bytes)," free of ",bp(W.disk_total_bytes)," total. Threshold is set to ",X.library_disk_warning_gb," GB in settings."]})]})]}),W&&s.jsxs("div",{className:"flex items-center gap-6 mb-6 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(b2,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-bambu-gray",children:"Files:"}),s.jsx("span",{className:"text-white font-medium",children:W.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Zo,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Folders:"}),s.jsx("span",{className:"text-white font-medium",children:W.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(_2,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-bambu-gray",children:"Size:"}),s.jsx("span",{className:"text-white font-medium",children:bp(W.total_size_bytes)})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm ml-auto",children:[s.jsx("span",{className:"text-bambu-gray",children:"Free:"}),s.jsx("span",{className:`font-medium ${F?"text-amber-500":"text-white"}`,children:bp(W.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex gap-6 min-h-0",children:[s.jsxs("div",{className:"w-64 flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex flex-col",children:[s.jsx("div",{className:"p-3 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-sm font-medium text-white",children:"Folders"})}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[s.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${a===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>o(null),children:[s.jsx(Xh,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"All Files"})]}),R?.map(U=>s.jsx(Ane,{folder:U,selectedFolderId:a,onSelect:o,onDelete:Q=>E({type:"folder",id:Q}),onLink:x},U.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[J&&J.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"relative flex-1 max-w-xs",children:[s.jsx(Eo,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search files...",value:N,onChange:U=>C(U.target.value),className:"w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(y2,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("select",{value:T,onChange:U=>D(U.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"all",children:"All types"}),ee.map(U=>s.jsx("option",{value:U,children:U.toUpperCase()},U))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:k,onChange:U=>P(U.target.value),className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green",children:[s.jsx("option",{value:"date",children:"Date"}),s.jsx("option",{value:"name",children:"Name"}),s.jsx("option",{value:"size",children:"Size"}),s.jsx("option",{value:"type",children:"Type"}),s.jsx("option",{value:"prints",children:"Prints"})]}),s.jsx("button",{onClick:()=>L(U=>U==="asc"?"desc":"asc"),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:z==="asc"?"Ascending":"Descending",children:z==="asc"?s.jsx(ble,{className:"w-4 h-4 text-white"}):s.jsx(ule,{className:"w-4 h-4 text-white"})})]}),(N||T!=="all")&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[K.length," of ",J.length," files"]})]}),K.length>0&&s.jsxs("div",{className:"flex items-center gap-2 mb-4 p-2 bg-bambu-card rounded-lg border border-bambu-dark-tertiary",children:[l.length===K.length&&l.length>0?s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:ue,children:[s.jsx(Zc,{className:"w-4 h-4 mr-1"}),"Deselect All"]}):s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:ge,children:[s.jsx(Qc,{className:"w-4 h-4 mr-1"}),"Select All"]}),l.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-bambu-gray ml-2",children:[l.length," selected"]}),s.jsx("div",{className:"flex-1"}),oe.length>0&&s.jsxs(Ee,{variant:"primary",size:"sm",onClick:()=>pe.mutate(oe.map(U=>U.id)),disabled:pe.isPending,children:[s.jsx(Qr,{className:"w-4 h-4 mr-1"}),pe.isPending?"Adding...":`Add to Queue${oe.length<l.length?` (${oe.length})`:""}`]}),s.jsxs(Ee,{variant:"secondary",size:"sm",onClick:()=>p(!0),children:[s.jsx(Wue,{className:"w-4 h-4 mr-1"}),"Move"]}),s.jsxs(Ee,{variant:"danger",size:"sm",onClick:()=>{l.length===1?E({type:"file",id:l[0]}):E({type:"bulk",id:0,count:l.length})},children:[s.jsx(ln,{className:"w-4 h-4 mr-1"}),"Delete"]}),s.jsx(Ee,{variant:"secondary",size:"sm",onClick:ue,children:"Clear"})]})]}),B?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Loading files..."})]})}):J?.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Xh,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:a!==null?"Folder is empty":"No files yet"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:a!==null?"Upload files or move files into this folder to get started.":"Upload files to start organizing your print-related files."}),s.jsxs(Ee,{onClick:()=>b(!0),children:[s.jsx(dr,{className:"w-4 h-4 mr-2"}),"Upload Files"]})]}):K.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Eo,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No matching files"}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:"No files match your current search or filter criteria."}),s.jsx(Ee,{variant:"secondary",onClick:()=>{C(""),D("all")},children:"Clear filters"})]}):w==="grid"?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4",children:K.map(U=>s.jsx(Lqe,{file:U,isSelected:l.includes(U.id),onSelect:ae,onDelete:Q=>E({type:"file",id:Q}),onDownload:V,onAddToQueue:Q=>pe.mutate([Q])},U.id))})}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[s.jsxs("div",{className:"grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"w-6"}),s.jsx("div",{children:"Name"}),s.jsx("div",{children:"Type"}),s.jsx("div",{children:"Size"}),s.jsx("div",{children:"Prints"}),s.jsx("div",{})]}),K.map(U=>s.jsxs("div",{className:`grid grid-cols-[auto_1fr_100px_100px_100px_80px] gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${l.includes(U.id)?"bg-bambu-green/10":""}`,onClick:()=>ae(U.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${l.includes(U.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:l.includes(U.id)&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative group/thumb",children:[s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:U.thumbnail_path?s.jsx("img",{src:be.getLibraryFileThumbnailUrl(U.id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(Xh,{className:"w-5 h-5 text-bambu-gray/50"})})}),U.thumbnail_path&&s.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:s.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:s.jsx("img",{src:be.getLibraryFileThumbnailUrl(U.id),alt:U.filename,className:"w-full h-full object-contain"})})})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm text-white truncate",children:U.print_name||U.filename}),U.duplicate_count>0&&s.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-400",children:[s.jsx($s,{className:"w-3 h-3"}),U.duplicate_count," duplicate(s)"]})]})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${U.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":U.file_type==="gcode"?"bg-blue-500/20 text-blue-400":U.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:U.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:bp(U.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:U.print_count>0?`${U.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:Q=>Q.stopPropagation(),children:[Tne(U.filename)&&s.jsx("button",{onClick:()=>pe.mutate([U.id]),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green transition-colors",title:"Add to Queue",disabled:pe.isPending,children:s.jsx(Qr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>V(U.id),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Download",children:s.jsx(Yr,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>E({type:"file",id:U.id}),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete",children:s.jsx(ln,{className:"w-4 h-4"})})]})]},U.id))]})})]})]}),u&&s.jsx(Pqe,{parentId:a,onClose:()=>d(!1),onSave:U=>q.mutate(U),isLoading:q.isPending}),f&&R&&s.jsx(Rqe,{folders:R,selectedFiles:l,currentFolderId:a,onClose:()=>p(!1),onMove:U=>se.mutate({fileIds:l,folderId:U}),isLoading:se.isPending}),g&&s.jsx(Oqe,{folderId:a,onClose:()=>b(!1),onUploadComplete:Le}),v&&s.jsx(Dqe,{folder:v,onClose:()=>x(null),onLink:U=>de.mutate({id:v.id,data:U}),isLoading:de.isPending}),y&&s.jsx(Un,{title:y.type==="folder"?"Delete Folder":y.type==="bulk"?`Delete ${y.count} Files`:"Delete File",message:y.type==="folder"?"Are you sure you want to delete this folder? All files inside will also be deleted.":y.type==="bulk"?`Are you sure you want to delete ${y.count} selected files? This action cannot be undone.`:"Are you sure you want to delete this file?",confirmText:"Delete",variant:"danger",onConfirm:$,onCancel:()=>E(null)})]})}const sj=5,Fqe=2e3,Uqe=3e4,zqe=5e3;function Bqe(){const{printerId:t}=_R(),e=parseInt(t||"0",10),[n,r]=S.useState("stream"),[i,a]=S.useState(!1),[o,l]=S.useState(!0),[c,u]=S.useState(Date.now()),[d,f]=S.useState(!1),[p,g]=S.useState(!1),[b,v]=S.useState(0),[x,y]=S.useState(!1),[E,w]=S.useState(0),A=S.useRef(null),N=S.useRef(null),C=S.useRef(null),T=S.useRef(null),D=S.useRef(null),{data:k}=lt({queryKey:["printer",e],queryFn:()=>be.getPrinter(e),enabled:e>0});S.useEffect(()=>(k&&(document.title=`${k.name} - Camera`),()=>{document.title="Bambuddy"}),[k]);const P=S.useRef(!1);S.useEffect(()=>{const K=`/api/v1/printers/${e}/camera/stop`;P.current=!1;const F=()=>{e>0&&!P.current&&(P.current=!0,navigator.sendBeacon(K))},q=()=>{F()};window.addEventListener("beforeunload",q);const ne=A.current;return()=>{window.removeEventListener("beforeunload",q),ne&&(ne.src=""),F()}},[e]),S.useEffect(()=>{if(o&&!d){const F=setTimeout(()=>{l(!1)},n==="stream"?3e3:2e4);return()=>clearTimeout(F)}},[n,o,c,d]),S.useEffect(()=>{const K=()=>{const F=!!document.fullscreenElement;g(F),n==="stream"&&!d&&(A.current&&(A.current.src=""),setTimeout(()=>{l(!0),u(Date.now())},200))};return document.addEventListener("fullscreenchange",K),()=>document.removeEventListener("fullscreenchange",K)},[n,d]),S.useEffect(()=>{let K;const F=()=>{clearTimeout(K),K=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",F),()=>{clearTimeout(K),window.removeEventListener("resize",F)}},[]),S.useEffect(()=>()=>{C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),D.current&&clearInterval(D.current)},[]);const z=S.useCallback(()=>{if(b>=sj){y(!1),a(!0);return}const K=Math.min(Fqe*Math.pow(2,b),Uqe);y(!0),w(Math.ceil(K/1e3)),T.current=setInterval(()=>{w(F=>F<=1?(T.current&&clearInterval(T.current),0):F-1)},1e3),C.current=setTimeout(()=>{v(F=>F+1),y(!1),l(!0),a(!1),A.current&&(A.current.src=""),u(Date.now())},K)},[b]);S.useEffect(()=>{if(n!=="stream"||o||x||d){D.current&&(clearInterval(D.current),D.current=null);return}return D.current=setInterval(async()=>{try{const K=await fetch(`/api/v1/printers/${e}/camera/status`);if(K.ok){const F=await K.json();(F.stalled||!F.active&&!i)&&(console.log(`Stream issue detected: stalled=${F.stalled}, active=${F.active}, reconnecting...`),D.current&&(clearInterval(D.current),D.current=null),l(!1),z())}}catch{}},zqe),()=>{D.current&&(clearInterval(D.current),D.current=null)}},[n,o,i,x,d,e,z]);const L=()=>{l(!1),n==="stream"&&b<sj?z():a(!0)},X=()=>{if(l(!1),a(!1),v(0),y(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),A.current&&!localStorage.getItem("cameraWindowState")){const K=A.current,F=K.naturalWidth,q=K.naturalHeight;if(F>0&&q>0){const se=window.outerWidth-window.innerWidth,de=window.outerHeight-window.innerHeight,pe=F+16+se,Ce=q+45+16+de;try{window.resizeTo(pe,Ce)}catch{}}}},R=()=>{e>0&&fetch(`/api/v1/printers/${e}/camera/stop`).catch(()=>{})},Y=K=>{n===K||d||(f(!0),l(!0),a(!1),v(0),y(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),A.current&&(A.current.src=""),n==="stream"&&R(),setTimeout(()=>{r(K),u(Date.now()),f(!1)},100))},J=()=>{d||(f(!0),l(!0),a(!1),v(0),y(!1),C.current&&clearTimeout(C.current),T.current&&clearInterval(T.current),A.current&&(A.current.src=""),n==="stream"&&R(),setTimeout(()=>{u(Date.now()),f(!1)},100))},G=()=>{N.current&&(document.fullscreenElement?document.exitFullscreen():N.current.requestFullscreen())},W=d?"":n==="stream"?`/api/v1/printers/${e}/camera/stream?fps=10&t=${c}`:`/api/v1/printers/${e}/camera/snapshot?t=${c}`,ee=o||d||x;return e?s.jsxs("div",{ref:N,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(zp,{className:"w-4 h-4"}),k?.name||`Printer ${e}`]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[s.jsx("button",{onClick:()=>Y("stream"),disabled:ee,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"}),s.jsx("button",{onClick:()=>Y("snapshot"),disabled:ee,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"})]}),s.jsx("button",{onClick:J,disabled:ee,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:n==="stream"?"Restart stream":"Refresh snapshot",children:s.jsx(Rr,{className:`w-4 h-4 text-bambu-gray ${ee?"animate-spin":""}`})}),s.jsx("button",{onClick:G,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:p?"Exit fullscreen":"Fullscreen",children:p?s.jsx(zue,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Pue,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2",children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(o||d)&&!x&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Rr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n==="stream"?"Connecting to camera...":"Capturing snapshot..."})]})}),x&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(H0,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Connection lost"}),s.jsxs("p",{className:"text-sm text-bambu-gray mb-3",children:["Reconnecting in ",E,"s... (attempt ",b+1,"/",sj,")"]}),s.jsx("button",{onClick:J,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:"Reconnect now"})]})}),i&&!x&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(yn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:"Camera unavailable"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:"Make sure the printer is powered on and connected."}),s.jsx("button",{onClick:J,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:"Retry"})]})}),s.jsx("img",{ref:A,src:W,alt:"Camera stream",className:"max-w-full max-h-full object-contain",onError:W?L:void 0,onLoad:W?X:void 0},c)]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:"Invalid printer ID"})})}function $qe(){const{id:t}=_R(),{mode:e}=wg(),{data:n,isLoading:r,error:i}=lt({queryKey:["external-link",t],queryFn:()=>be.getExternalLink(Number(t)),enabled:!!t});return r?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i||!n?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[s.jsx(yn,{className:"w-12 h-12"}),s.jsx("p",{children:"Link not found"})]}):s.jsx("iframe",{src:n.url,className:"h-full w-full border-0",style:{colorScheme:e},title:n.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}function Hqe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Hr({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return s.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function bG({percent:t,color:e="bg-bambu-green"}){return s.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Zu({title:t,icon:e,children:n}){return s.jsxs(_t,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(e,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function Vqe(){const{t}=xg(),e=an(),[n,r]=S.useState(null),[i,a]=S.useState(!1),[o,l]=S.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=lt({queryKey:["systemInfo"],queryFn:be.getSystemInfo,refetchInterval:3e4}),{data:p}=lt({queryKey:["debugLogging"],queryFn:A1.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:g}=lt({queryKey:["settings"],queryFn:be.getSettings}),{data:b}=lt({queryKey:["library-stats"],queryFn:be.getLibraryStats}),v=g?.time_format||"system",x=async()=>{l(!0);try{const A=await A1.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],A)}catch(A){console.error("Failed to toggle debug logging:",A)}finally{l(!1)}},y=async()=>{r(null),a(!0);try{await A1.downloadSupportBundle()}catch(A){r(A instanceof Error?A.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return s.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const E=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",w=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),s.jsxs("button",{onClick:()=>d(),disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[s.jsx(Rr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(Zu,{title:t("system.application","Application"),icon:Nh,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Hr,{icon:Nh,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(Hr,{icon:tr,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(Hr,{icon:Nh,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(Zu,{title:t("support.title","Support & Troubleshooting"),icon:tue,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(aW,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),s.jsxs("button",{onClick:x,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${p?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&s.jsx(ft,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:s.jsx(Yr,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),s.jsxs("button",{onClick:y,disabled:i||!p?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:p?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&s.jsx(ft,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!p?.enabled&&s.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-bambu-gray",children:[s.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),s.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),s.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),s.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),s.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),s.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),s.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),s.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),s.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),s.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),s.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),s.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),s.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),s.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),s.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","IP addresses in logs are replaced with [IP] and email addresses with [EMAIL].")})]})]})}),s.jsxs(Zu,{title:t("system.database","Database"),icon:Bp,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(Hr,{icon:Os,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(Hr,{icon:p2,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(Hr,{icon:Wi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(Hr,{icon:ft,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Hr,{icon:Qr,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(Hr,{icon:RR,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(Hr,{icon:ma,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(Hr,{icon:Ls,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(Hr,{icon:tr,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(Hr,{icon:Os,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(Zu,{title:t("system.connectedPrinters","Connected Printers"),icon:Qr,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(A=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),s.jsx("span",{className:"font-medium text-white",children:A.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:A.model}),s.jsx("span",{className:`px-2 py-0.5 rounded ${A.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":A.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:A.state})]})]},A.id))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(Zu,{title:t("system.storage","Storage"),icon:_2,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),s.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),s.jsx(bG,{percent:c.storage.disk_percent_used,color:E}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(Hr,{icon:Os,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(Hr,{icon:Bp,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),b&&s.jsx(Hr,{icon:Zo,label:t("system.fileManagerStorage","File Manager"),value:Hqe(b.total_size_bytes),subValue:`${b.total_files} files, ${b.total_folders} folders`})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(Zu,{title:t("system.memory","Memory"),icon:Due,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),s.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),s.jsx(bG,{percent:c.memory.percent_used,color:w}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(Zu,{title:t("system.cpu","CPU"),icon:$v,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Hr,{icon:$v,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(Hr,{icon:$v,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(Zu,{title:t("system.systemDetails","System Details"),icon:Nh,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(Hr,{icon:Nh,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(Hr,{icon:$v,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(Hr,{icon:Nh,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(Hr,{icon:tr,label:t("system.bootTime","Boot Time"),value:Vp(c.system.boot_time,v)})]})})]})}function Gqe(){const t=S.useRef(null),e=S.useRef(null),n=an(),[r,i]=S.useState(!1),a=S.useRef(new Set),o=S.useRef(null),l=S.useRef(new Map),c=S.useRef(null),u=S.useRef([]),d=S.useRef(!1),f=S.useRef(()=>{}),p=S.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const E=()=>{const w=u.current.shift();w?requestAnimationFrame(()=>{f.current(w),u.current.length>0?setTimeout(E,16):d.current=!1}):d.current=!1};E()},[]),g=S.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const w=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,A=new WebSocket(w);let N=null;A.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),N=window.setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send(JSON.stringify({type:"ping"}))},3e4)},A.onmessage=C=>{try{const T=JSON.parse(C.data);T.type==="printer_status"&&T.printer_id!==void 0&&T.data?f.current(T):(u.current.push(T),p())}catch{}},A.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),N&&(clearInterval(N),N=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{g()},3e3)},A.onerror=C=>{console.error("[WebSocket] Error",C),A.close()},t.current=A},[p]),b=S.useCallback((E,w)=>{const A=l.current.get(E)||{};l.current.set(E,{...A,...w}),c.current||(c.current=window.setTimeout(()=>{const N=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{N.forEach((C,T)=>{n.setQueryData(["printerStatus",T],D=>{const k={...D,...C};return k.wifi_signal==null&&D?.wifi_signal!=null&&(k.wifi_signal=D.wifi_signal),k})})})},100))},[n]),v=S.useCallback(E=>{a.current.add(E),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const w=Array.from(a.current);a.current.clear(),o.current=null;let A=0;w.forEach(N=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[N]})})},A),A+=500})},3e3)},[n]),x=S.useCallback(E=>{switch(E.type){case"printer_status":E.printer_id!==void 0&&E.data&&b(E.printer_id,E.data);break;case"print_start":E.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",E.printer_id]});break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break}},[n,v,b]);S.useEffect(()=>{f.current=x},[x]),S.useEffect(()=>(g(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[g]);const y=S.useCallback(E=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(E))},[]);return{isConnected:r,sendMessage:y}}const Wqe=new $oe({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function qqe({children:t}){return Gqe(),s.jsx(s.Fragment,{children:t})}function Kqe(){return s.jsx(vhe,{children:s.jsx(Phe,{children:s.jsx(Hoe,{client:Wqe,children:s.jsx(coe,{children:s.jsxs(Use,{children:[s.jsx(Da,{path:"/camera/:printerId",element:s.jsx(Bqe,{})}),s.jsxs(Da,{element:s.jsx(qqe,{children:s.jsx(The,{})}),children:[s.jsx(Da,{index:!0,element:s.jsx(oke,{})}),s.jsx(Da,{path:"archives",element:s.jsx(I9e,{})}),s.jsx(Da,{path:"queue",element:s.jsx(wWe,{})}),s.jsx(Da,{path:"stats",element:s.jsx(LWe,{})}),s.jsx(Da,{path:"profiles",element:s.jsx(gqe,{})}),s.jsx(Da,{path:"maintenance",element:s.jsx(_qe,{})}),s.jsx(Da,{path:"projects",element:s.jsx(Sqe,{})}),s.jsx(Da,{path:"projects/:id",element:s.jsx(kqe,{})}),s.jsx(Da,{path:"files",element:s.jsx(Iqe,{})}),s.jsx(Da,{path:"settings",element:s.jsx(aqe,{})}),s.jsx(Da,{path:"system",element:s.jsx(Vqe,{})}),s.jsx(Da,{path:"external/:id",element:s.jsx($qe,{})})]})]})})})})})}Hie.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:s.jsx(Kqe,{})}));
|